[my weblog] [my software] [contact me]

h3's weblog

(garbage in, garbage out)

 

19 april 2009

Another GAE bug

Today I played again with the Google App Engine (Java preview release) for a couple of hours and found another bug.

Seems like the MemcacheService namespaces are completely ignored in production.

Bug 1364 already reported.

The JCache API I used last week was just an higher-level interface built on top of the MemcacheService.
I found that using the low-level API directly is a better approach because it exposes some additional functionalities with no drawbacks.
Atomic-increment of cached entries for example is an extremely useful feature in a clustered environment.
 
 

13 april 2009

Google App Engine bug

In these days of holiday I've been playing with the Java version of the Google App Engine (yes I have been lucky to have access to the "early look" version).
In general I find it wonderful. I really like how the Eclipse plugin integrates with the App engine and GWT.
The included services are implemented using standard APIs whenever possible, but you are free to use the underlying technologies in a more low-level way if needed.

My first idea has been to implement a sort of "comet" service for a GWT application, and I must admit: it's not easy because of the many limitations:
1) You can't create threads.
2) You can't use continuations.
3) All threads (generated from http requests) have a maximum lifetime of 30 seconds.

Anyway finally I found a tricky way to implement a sort of slow-polling using the Memcache service, but..
I found a bug: JCache entries' expiration time is not reset when entries are updated! I think this is quite a big issue.

Bug report 1284 already submitted :)
 
 

8 november 2008

Knack released as Open Source

It feels like opening the cage of your beloved pet and staring at him while he walks into the wild, finally free like wild animals.
It's a bit scary and you hope he is ready for this step, but you know that this is good for him, in the long run.
Knack has been my pet project for some years and starting from today it is Free Software.

Please contribute!
 
 

11 august 2008

IM me from the web

If you want to chat with me just click below :)

 
 

8 june 2008

I.T. Salaries

Sadly, in Italy you must divide this by 2 or 3...
 
 

20 may 2008

My new remix

You can listen it here in streaming:

FoalsElectric Bloom (h3-r3 remix)

or downlad the MP3

If you are a Last.fm user please scrobble it!!
 
 

23 december 2007

J2ME rotozoomer

Today I tried to code an oldschool demo effect for my mobile phone (a Nokia 3110 classic)...
I created a simple rotozomeer :)

here is the code (J2ME MIDP 2.0)

package org.postronic.h3.testmidlet;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class RotozoomerMIDlet extends MIDlet {

  public RotozoomerMIDlet() { }

  protected void startApp() throws MIDletStateChangeException {
    RotozoomerCanvas canvas = new RotozoomerCanvas();
    Display display = Display.getDisplay(this);
    display.setCurrent(canvas);
    canvas.run();
  }

  protected void pauseApp() { }

  protected void destroyApp(boolean arg0) throws MIDletStateChangeException { }

}



package org.postronic.h3.testmidlet;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;

public class RotozoomerCanvas extends GameCanvas {

  protected RotozoomerCanvas() {
    super(true);
    setFullScreenMode(true);
  }

  public void run() {
    int imgWidth = getWidth();
    int imgHeight = getHeight();
    Graphics g = getGraphics();
    int[] img = new int[imgWidth * imgHeight];

    Image texture = Image.createImage(32, 16);
    Graphics tg = texture.getGraphics();
    tg.setColor(200, 200, 255);
    tg.drawString("h3-r3", 2, 0, Graphics.TOP | Graphics.LEFT);
    tg.setColor(200, 200, 255);
    tg.drawString("h3-r3", 4, 0, Graphics.TOP | Graphics.LEFT);
    tg.setColor(0, 0, 255);
    tg.drawString("h3-r3", 3, 0, Graphics.TOP | Graphics.LEFT);
    int[] txImg = new int[32 * 16];
    texture.getRGB(txImg, 0, 32, 0, 0, 32, 16);
    texture = null; // dispose the texture Image

    float tx, ty;
    float dtx, dty;
    float otx, oty;

    double cont = 0;
    double cos, sin;
    double size;
    int offs;
    for(;;) {
      cos = Math.cos(cont);
      sin = Math.sin(cont);
      tx = (float) cos * 20;
      ty = (float) sin * 20;
      size = cos;
      dtx = (float) (cos * size);
      dty = (float) (sin * size);
      cont += 0.02;
      for (int y = 0; y < imgHeight; y++) {
        otx = tx;
        oty = ty;
        offs = y * imgWidth;
        for (int x = 0; x < imgWidth; x++) {
          img[x + offs] = txImg[((int)(tx) & 31) + (((int)(ty) & 15) * 32)];
          tx += dtx;
          ty += dty;
        }
        tx = otx - dty;
        ty = oty + dtx;
      }
      g.drawRGB(img, 0, imgWidth, 0, 0, imgWidth, imgHeight, false);
      flushGraphics();
    }
  }

}

 
Links:
Syndications:
XML RSS feed
XML RSS comments feed
Klip Klipfolio Klip
Klip Comments Klip

Blog friends: