Sites
Projects
Written by Michael Zoech - 2010-07-13 08:00 - Comments - Tags: google, javascript
Sadly, the hype about Google Wave has come and gone. Although i like the idea that users can add new functionality to a wave by writing robots or gadget, nobody seems to use Google Wave.A few months ago i created a small poll gadget, something similar to doodle or quappo. Since Google Wave is now open for the public, i thought i share this one. This was just a proof of concept and there is much to do. Maybe someone else want to step up and make something cool out of it.

Users can add new options through the text field at the top and change their vote by clicking on the cells in their line. You can find the gadget xml here.
Written by Michael Zoech - 2009-04-27 23:30 - Comments - Tags: maik
Couldn't resist any longer. You may follow me now on Twitter.
See you in the cloud. Yay! :)
Written by Michael Zoech - 2009-04-27 23:00 - Comments - Tags: csharp, slimdx, cuda
I'm currently evaluating the possibilities to use DirectX 10 and CUDA from C# for a realtime visualization project. The official CUDA sdk contains many samples written in Cpp, but i couldn't find one sample in the whole web written in C#. So i ported one of the CUDA sdk samples using SlimDX for DirectX 10 and CUDA.NET to access the CUDA functionality. Grab the source here.
Written by Michael Zoech - 2008-09-17 01:30 - Comments - Tags: java, eclipse
There is an excellent post about Eclipse navigation shortcuts at 10 Eclipse Navigation Shortcuts Every Java Programmer Should Know. Since this post only looks at navigation shortcuts, i thought i post some of my favourite Eclipse shortcuts i use every time in Eclipse to boost my productivity.
Use Ctrl + . or Ctrl + , to cycle through the errors in the current file. This marks the next or previous error. Hitting F2 shows the error description and the quick-fix menu. This is much faster than using the mouse to locate the error, float over and wait for the description to pop up. Note, this works for warnings too.

Hitting Shift + Alt X T runs the jUnit tests found in the current file. Use Shift + Alt D T if you want to debug-run the tests.
I often find myself in the need to run the same jUnit tests again and again. The jUnit plugin provides the ReRun Test button, i think i've hit a million times now.

Luckily you can create a shortcut binding for this. Go to Window -> Preferences -> General -> Editors -> Keys and setup an appropriate binding. I've bound this command to Ctrl + Alt R R. This makes it really easy to write tests, jump back and forth to the production code and rerun the same test files over and over again.
Surrounding already existing code with something like a try-catch block or a for loop is often tedious and error-prone. Not any longer. Mark the code you want to move inside the block or loop, hit Shift + Alt Z and select the type of surrounding block.
Before

After

Hitting Shift + Alt + R lets you rename a variable, method or class name at the current cursor position. The renaming happens not only in the current file, but takes care of all references to the variable, method or class in other files of the project.

Note that the renaming fixes the reference in the other method.
Shift + Ctrl + L shows a list of all shortcuts. Although i do not use this on a daily basis you may find even more interesting shortcuts there.

Written by Michael Zoech - 2008-06-29 19:00 - Comments - Tags: comic, funny

Written by Michael Zoech - 2008-06-23 20:00 - Comments - Tags: puzzles, haskell
Every now and then i have the need to solve some programming related puzzles. There are many in the web, my current favourites are Project Euler, Ponder this and the security/hacking related exercises at Bright Shadowns. Today i tried one of the Google Treasure Hunt questions and documented my solution along the path. Off we go!
A robot is located at the top-left corner (S) of a 36 x 55 grid. The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner (F) of the grid. How many possible unique paths are there?
First i manually tried it to grasp the idea of calculating the number of paths automatically. Because the robot can only move down or right, there is one possible path for all rightmost and bottommost cells. For an inner cell (not rightmost and not bottommost) the robot can advance by using the bottom or right neighbor cell, i.e. path count for a cell is simply the sum of the bottom neighbor cell and the right neighbor cell. Doing this step manually for a 4x4 grid i got the following matrix.
S ? 4 1
? ? 3 1
4 3 2 1
1 1 1 F
And then it hit me. If you rotate the matrix, there is a mathematical structure that looks exactly the same.
F
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Yes, it's Pascal's triangle. So the right solution for a grid is somewhere in the triangle.
Writing Pascal's triangle in Haskell is a straightfoward task. Thanks to Haskell's laziness and higher-order functions the implementation is a simple one-liner:
pascal :: [[Integer]]
pascal = iterate (\x -> zipWith (+) (0:x) (x++[0])) [1]
The function generates a list of lists of ''Integer'', where the ith element is the ith row in the triangle. Taking the first 7 elements (read rows):
$ take 7 pascal
[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1],[1,5,10,10,5,1],[1,6,15,20,15,6,1]]
The missing part is the selection of the right element of the triangle. I mapped a grid to the triangle for calculating the row and element index. In the following triangle with 5 rows and 4 columns the row index is shown:
F
2 1
3 2 1
4 3 2 1
5 4 3 2 _
_ 5 4 3 _ _
_ _ 5 4 _ _ _
_ _ _ S S _ _ _
For a XxY grid the row index in the triangle is calculated by rows + columns - 1 and the element index by either selecting the Xth or Yth element (they both have the same distance from the vertical axis).
solution :: Int -> Int -> Integer
solution x y = pascal !! (x + y - 2) !! (x - 1)
The solutions for the 4x4 and 36x55 grid above:
$ solution 4 4
20
$ solution 36 55
6920581868511832633307448
Seems quite right and 10 minutes later Google Treasure Hunt confirmed my solution.