Friday, November 27, 2009

MS Fonts in Google Documents on Ubuntu

A major reason why I love google documents is that I can access all the files from any computer regardless of the operating system. In principle this works great for me but unfortunately changing the text font (e.g. to Courier New) doesn't work on ubuntu. Although I still hope there is something goggle can do, the intermediate solution is using the 'Installer for Microsoft TrueType core fonts':

sudo apt-get install ttf-mscorefonts-installer

P.S. Don't forget to restart you browser afterwards.

Labels: , , ,

Friday, September 18, 2009

MATLAB/Octave Utils: submat, grouped

Totally forgot to share these two MATLAB/Octave functions I wrote some time ago:
submat: accessing a sub-matrix of an unknown multi-dimensional matrix
grouped: creating record like data structures from arrays grouped by an index cell

Actually, I still wonder if or why this functionality is not part of the core library or even the 'language syntax '? Anyhow, I couldn't find it so I wrote the two functions myself. (please tell me if you know about a predefined equivalent or a better solution)


1. submat ( submat.m )

In Matlab everything is a (potential) N-dimensional matrix of elements such as doubles, cells or structs. Sub-indexing is easy, unless you try to program in a generic way, e.g. with high-order functions. The problem is that traditional sub-indexing requires you to know the element type (cell or not) and dimensions of the matrix. So I came up with a function submat, which basically does sub-indexing in the highest dimension of an unknown type:

A = [ 1, 2, 3; 4, 5, 6 ];
submat(A,2:3) % same as A(:,2:3)
-> [ 2, 3; 5, 6 ]

B = { 'Hello', 'submat'; 'Goodbye', '(:)' };
submat(B',1) % same as B'{:,1}
-> { 'Hello', 'submat' }



2. grouped ( grouped.m )

The other thing I missed was a simple way to group data arrays to structs. Of course this can easily be done within a for loop, but using the group function eliminates the code repetition. Also, it can be be used in two ways:

First, it allows to simply group equal indices together.

grouped( [ 1, 2, 1, 3, 1, 2, 3] )
-> { [ 1, 3, 5 ], [ 2, 6 ], [ 4, 7 ] }

So far nothing special, but its main purpose is to create a custom struct array.

%artists = { 'Beatles', 'Bob Dylan' };
%records

record_artist_ids = [1, 1, 2, 2, 1];
% or the result of group(record_artist_ids)
record_artist_ids = { [1, 2, 5], [3, 4] };
title = { 'White Album', 'Rubber Soul', 'Blood on the Tracks', 'Blonde on Blonde', 'Revolver' };
year = [ 1968, 1965, 1975, 1966, 1966 ];

artist_records = grouped ( record_artist_ids, 'title', title, 'year', year)

-> artist_records(1).title = { 'White Album', 'Rubber Soul', 'Revolver' }
artist_records(1).year = [ 1968, 1965, 1966 ]
artist_records(2).title = { 'White Album', 'Rubber Soul', 'Revolver' }
artist_records(2).year = [ 1975, 1966 ]

Labels: ,

Thursday, September 17, 2009

New Project: Team-Tactics

So what is it about? Well, it's meant to be a playground for exploring intuitive and efficient ways to control/direct virtual entities - or simply a turn based football (soccer) game.

As some might know, my current research is about interaction metaphors for 3D scenes using novel input modalities (multi-touch, motion-sensors, video, ...). Thereby, a special focus lies on concurrent user interaction with both shared and networked devices. Although I might not be able to share much information about this before scientifically published, I believe the evaluation platform should be open right from the beginning. And why shouldn't it be something fun. A tactical football game will fit:

  • the rules are not too complicated to understand and implement

  • the big team size and typical player proximities are ideal for cooperative/competitive interaction

  • easy to realize in both 2D/3D as well as in various levels of abstraction

  • my Ph.D. supervisor is crazy about that football (!FC Barcelona!)


The gameplay will most likely consist of two repeating phases: First, the tactics are defined/adjusted by altering the players' next actions. Afterwards, all the movements are simulated concurrently. Hopefully, this 'genre' (half real-time tactics?) facilitates the strategic/tactical emphasis.

Except for this choice, everything else is still open. The idea is to prototype a lot and to find the most fun and intuitive concepts. (Clearly, the target audience includes casual gamers.)
I guess this is also the place to mention that help is always welcome: if you want to contribute design/interaction ideas, code, graphics, music/sounds or anything else - please let me know.

OK, that's it for now. If you're interested, please follow the dedicated blog at teamtacticsproject.blogspot.com - I intend to write a regular development diary and promise to write at least one post tomorrow.

Labels: , , ,

Saturday, April 12, 2008

Shell History Meme

Reading YC's post about the meme happening at the Fedora Planet, I also gave it a try:

history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head

113 cd
88 ls
53 hg
38 ant
28 fsc
23 ln
17 ssh
13 java
10 ../../../bin/java
9 scala

In words:
I am guy who likes to be at many places [cd] and to know the surroundings [ls] - I try to keep record of everything [hg]. Further, I don't want to bother with annoying repetitive tasks: things should be done automatically [ant] and fast [fsc]. Mental links [ln] help me not to get lost while my mind is far away [ssh]. Finally, you know I used to program in Java [java,../../../bin/java] but nothing can stop the rise of Scala [scala]. ;-)

Labels: , ,

Saturday, February 02, 2008

A *new* Scala Bundle for Textmate

No doubt, the upcoming Scala Module will make Netbeans the No.1 Scala IDE. I use the current pre-release version on my linux box at work without any difficulties. Unfortunately, I have encountered problems running the recommended daily development builds of Netbeans on my private macbook pro. I hoped that I could at least use my favorite editor for MacOS X, Textmate, but the bundle shipped with Scala 2.6.1 still seems to be a dummy/placeholder. Well, instead of falling into a deep depression, I invested half a day to create a new bundle myself.

For those interested, please find the download below:

- The Scala Bundle
- An Example Project (with some sources ripped from scala-lang.org)

The main goal was to have simple syntax highlighting, which actually looks quite good using the 'Cobalt Theme'. (I'm not 100% sure that value:Type is always displayed correctly, but it seemed to work with the samples.)

Further, there is a template for an Ant-Script which includes a compile, run & deploy task. These can be executed as bundle commands (menu or shortcuts), if the file is called 'build.xml'. Customization should be easy with a few properties at the top of the file.

Finally, there are a few snippets to write new code quickly. E.g. typing

trait ->| Adder ->| def ->| add ->| Int ->| 2 ->| left ->| Int ->| right ->| Int

results in
/**
* Adder
*/
trait Adder
{
def add ( left : Int, right : Int ) : Int
}
without pressing two keys at the same time (no SHIFT)!

But of course you can sketch your own (and share them with me =) ) !

Labels: ,

Thursday, October 18, 2007

Streams for Incremental and Tail-Recoursive Computing

Programming in Scala is a lot of fun for me, but I really love Streams. Their laziness allows really nice implementations of incremental algorithms and tail-recursive functions. the best thing is they can be used efficiently under different requirements: no matter if you are interested in each intermediate result or only the final one, you'll only need one implementations. =)

I hope the following example computing the factorial(s) using Streams explains it well:

Labels:

Wednesday, October 17, 2007

Building Scala from the Sources

As I noticed that the actual Scala sources include a great enhancement for all RandomAccessSeq.Mutables, such as Array or ArrayBuffer: Now, the methods drop, take, slice and reverse return a RandomAccessSeq.MutableProjection, which allows cool things to be done in O(1), e.g. Array(1,2,3) reverse(0) = 10.

Unable to hold mysself back waiting, I decided try the latest version. All I had to do was to follow these instruction: Building Scala 2 from the sources. Et viola, one can already taste some of the features/fixes scheduled for Scala 2.6.1. =)

Labels: