First Google Wave experiments
October 7, 2009 at 10:16 pm | In Programming | 6 CommentsI did some initial experiments with programming for Google Wave. Basically I got the code from the tutorial and created a robot (called Dalek) which automatically translates the entered text (so called blips) from English to Spanish using the Java version of the Google Translate API. Screenshot of the result:

My first wave
Overall impression so far: very easy to use API. Google Wave itself can be terribly slow. Sometimes the syncing of ‘unsynced waves’ takes more than a minute. Next step: thinking of a more serious application.
And for those interested, the actual Java code:
package dalek;
import com.google.api.detect.Detect;
import com.google.api.translate.Language;
import com.google.api.translate.Translate;
import com.google.wave.api.AbstractRobotServlet;
import com.google.wave.api.Blip;
import com.google.wave.api.Event;
import com.google.wave.api.EventType;
import com.google.wave.api.RobotMessageBundle;
import com.google.wave.api.TextView;
import com.google.wave.api.Wavelet;
public class DalekServlet extends AbstractRobotServlet {
@Override
public void processEvents(RobotMessageBundle bundle) {
Wavelet wavelet = bundle.getWavelet();
if (bundle.wasSelfAdded()) {
addText(wavelet, "We are the Daleks");
}
for (Event e : bundle.getEvents()) {
if (e.getType() == EventType.WAVELET_PARTICIPANTS_CHANGED) {
addText(wavelet, "Exterminate... exterminate... exterminate");
} else if (e.getType() == EventType.BLIP_SUBMITTED) {
addTranslation(e.getBlip());
}
}
}
private void addTranslation(Blip blip) {
if (!blip.getCreator().equals("mjbvrijk@appspot.com")) {
String originalText = blip.getDocument().getText();
try {
Detect.setHttpReferrer("maurits.wordpress.com");
String translatedText = Translate.execute(originalText, Language.AUTO_DETECT, Language.SPANISH);
createChildBlip(blip, translatedText);
} catch (Exception e) {
createChildBlip(blip, "Translation failed");
}
}
}
private void createChildBlip(Blip blip, String s) {
addTextToBlip(blip.createChild(), s);
}
private void addText(Wavelet wavelet, String s) {
addTextToBlip(wavelet.appendBlip(), s);
}
private void addTextToBlip(Blip blip, String s) {
TextView textView = blip.getDocument();
textView.append(s);
}
}
I started using Twitter last week. My interest was triggered by a very cool workshop on programming in Scala that was given at the company I work for. Twitter has a nice API which is very easy to use from Scala or any other programming language. I still try to figure out what the business case could be for using Twitter, but for the moment it’s quite fun to do a few daily updates on what keeps me busy and/or interested.
My Twitter ID is @mauritsrijk (direct link). I probably am going to use it to give more frequent updates on my GIMP# activities.
Developing on Android
June 30, 2009 at 8:43 pm | In Programming | 2 CommentsI intend to buy an Android phone. It’s probably going to be the HTC Hero mainly because it’s almost available where I live and it also comes without a simlock, unlike for example the HTC Magic which is exclusive for Vodafone. Next I plan to develop some übercool applications but in the meantime I’ll start with porting a very old game I did more than a decade ago: it was called Groundhog. A screenshot:

Groundhog screenshot
So stay tuned for a Groundhog coming to your mobile…
Experiments with the Google Chart API
March 26, 2009 at 9:05 pm | In Programming | Leave a CommentIn 25 years of programming I blogged about the lines of code I have written in several programming languages. I am experimenting with the Google Chart API and created a graphical overview of my personal top 7. Result:
The url to generate the pie chart:
http://chart.apis.google.com/chart?cht=p3&chtt=Top+7&chts=0000ff,32&chd=t:100,70,20,20,5,5,2,3&chs=650x250&chl=C%20(100000)|C%23%20(70000)|Java%20(20000)|C%2B%2B%20(20000)|Pascal%20(5000)|PV~Wave%20(5000)|Basic%20(2000)|Other%20(3400)|
Hacking JIRA with Ruby
March 19, 2009 at 10:13 pm | In Programming | 3 CommentsI have been reading a lot over the last couple of months. Great books like “The World is Flat 3.0″, “Dreaming in Code”, “My Job went to India”, “The five dysfunctions of a team”, “Clean Code” and quite a few more. However I started to realize that although reading is fun, it tends to keep me in my comfort zone. I should really practice writing. People remember great writers. You hardly ever hear people saying “he was such a great reader” about a person that died hundred years ago.
So I just put down here what I’m doing at the moment. Lately I started to automate some things like writing progress reports for customers. Now please don’t stop reading at the word “progress report”. It might become a bit more interesting Continue reading Hacking JIRA with Ruby…
Writing GIMP plug-ins in Object Pascal
October 23, 2008 at 2:46 pm | In GIMP, Programming | 5 CommentsI slowly picked up GIMP# development again. To get my brain in the right mode I added a plug-in in yet another .NET language: Oxygene which is a kind of Object Pascal. From what I’ve seen it is a pretty decent language although I never understood why people would like to type 10 characters (“begin;” and “end;”) instead of 2 curly braces just to open and close a block
For those interested: currently I run Mandriva 2009 with VirtualBox 2.0.2 on my loyal MacBook Pro for development. The fancy IDE I use is called Emacs.
IronRuby and the Fan Programming Language will probably be my next targets.
25 years of programming
March 8, 2008 at 11:01 am | In Programming, Ramblings | 6 CommentsI started programming in 1983 on a Sharp PC-1251 with an amazing 3486 bytes RAM. It had a Basic interpreter and we had to use it for a Calculus course at the university.
So that’s 25 years ago. That made me suddenly wonder how much code in different programming languages I have written in all those years. A completely useless question of course, but fun nevertheless. I don’t have all the code available anymore so I have to estimate some numbers from memory. The numbers I present include comment and blank lines.
The list:
- C: 100.000
- C#: 70.000
- Java: 20.000
- C++: 20.000
- Pascal: 5.000
- PV~Wave: 5.000
- Basic: 2.000
- Matlab: 1.000
- Lisp/Scheme: 1.000
- Assembly: 1.000
- Fortran: 200
- Perl: 100
- Python: 20
- Boo: 20
- Nemerle: 20
- F#: 20
- Ruby: 10
This totals 225k lines of code in 25 years.In other words, about 10k LOC’s per year, or 30 lines per day. Other interesting questions that could be asked:
- how much of this code is still in use
- how much of this code is forever lost
- how much of this code is still archived somewhere on a company network
- how much code would this have been if it all had been written using language xyz
- how many bugs did I introduce over the last 25 years
F# and GIMP#
December 2, 2007 at 10:04 pm | In GIMP, Programming | 4 CommentsI almost got my first F# plug-in running on GIMP#. It took me some time to get used to the syntax even with a background in functional languages like Lisp and Scheme. Only thing left to figure out is how I can override a C# function that returns an IEnumerable. What I’ve got sofar is:
override x.ListProcedures() : seq<Procedure> =
let procedure = new Procedure()
procedure.MenuPath <- “<Image>/Filters/Generic”
// And now what?
The C# signature of this routine is
protected abstract IEnumerable<Procedure> ListProcedures() ;
Hope to find an answer pretty soon.
Update 3 December 2007: seems that returning an IEnumerable is quite easy (many thanks to Robert Pickering):
[procedure] :> seq<Procedure>
Bah!
November 29, 2007 at 10:39 pm | In GIMP, Programming | Leave a CommentAfter Boo comes bah. I’m probably going to burn in hell forever for having done this, but I actually created a Visual Basic plug-in for GIMP. The code is currently in CVS at the GIMP# Sourceforge page. Don’t look at the code unless you have a very strong stomach. Promise to myself: I will never ever create Basic code again. On a more serious note: the performance of the Visual Basic plug-in is comparable to the C#, Boo and Nemerle version!
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.