First Google Wave experiments

October 7, 2009 at 10:16 pm | In Programming | 6 Comments

I 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

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);
   }
}

Twitter

August 25, 2009 at 8:25 am | In GIMP, Programming | Leave a Comment

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 Comments

I 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

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 Comment

In 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:

Top 10

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)|

Continue reading Experiments with the Google Chart API…

Hacking JIRA with Ruby

March 19, 2009 at 10:13 pm | In Programming | 3 Comments

I 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 Comments

I 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 Comments

I 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.

Sharp PC-1251

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:

  1. C: 100.000
  2. C#: 70.000
  3. Java: 20.000
  4. C++: 20.000
  5. Pascal: 5.000
  6. PV~Wave: 5.000
  7. Basic: 2.000
  8. Matlab: 1.000
  9. Lisp/Scheme: 1.000
  10. Assembly: 1.000
  11. Fortran: 200
  12. Perl: 100
  13. Python: 20
  14. Boo: 20
  15. Nemerle: 20
  16. F#: 20
  17. 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 ;)

GIMP# 0.14 released

January 4, 2008 at 2:00 pm | In GIMP, Programming | 31 Comments

A new release of GIMP# is available. New in release 0.14 are:

  • Nemerle sample added
  • Boo sample added
  • Visual Basic sample added (I know.. don’t ask ;) )
  • F# sample added
  • Ported abandoned Sky plug-in (part of PhyModMedia plug-ins)
  • GIMP# now uses C# 3.0 features for cleaner code

Have fun.

F# and GIMP#

December 2, 2007 at 10:04 pm | In GIMP, Programming | 4 Comments

I 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 Comment

After 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!

Next Page »

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.