Posts in Category: Coding

Japanese colors for BlackBerry

For my upcoming japanese course, I created an app for memorizing the most common japanese colors.

(Tweet says: Who has a BlackBerry? There's an app for you!)

(Tweet says: BlackBerry? Nobody ^_~)

The app is not available on App World, due to some bugs, it's in private beta, just contact me to have it.

Fun facts:

  • It was working on BB OS 6, crashed on BB OS 5
  • Edited to work BB OS 5, crashes on BB OS 6
  • The back button does not work (possible fix)
  • Japanese words had to be romanized because BlackBerry OS does not support asian characters...
  • I used an "iPhoney" style for the user interface, because the default one looks so 2006...

How to show the new softkeys in the Ice Cream Sandwich emulator

For some reason, the Ice Cream Sandwich emulator does not show the new softkeys that will replace the home back and menu hard keys on new Android handsets. How to enable it?

Just go to the AVD Manager (the program that manages the emulator virtual images), select the Android 4 image, then add the property "Hardware Back/Home keys" and set it to "no"

 

And this is the final result:

The Android tutorials doesn't work?

Have you ever tried to follow the Android programming tutorials at developer.android.com?

The writer gives too much for granted, many examples do not work as written if you copy them with a simple copy&paste. To permit a simplified view of the code, the header is omitted and the overall vision of how methods and classes are placed is not very clear.

You might end up with errors as:

array cannot be resolved or is not a field

or

The method setOnItemClickListener(AdapterView.OnItemClickListener) in the type AdapterView<ListAdapter> is not applicable for the arguments (new OnItemClickListener(){})

etcetera.

So, I created a public Bitbucket repository where beginners can go and compare the code.

Doraemon in HTML5

While I was searching some tips about web design, I found this japanese designer.

He shows how you can let your browser draw Doraemon using SVG and HTML5

Here it is:

And this is the code behind:

<div>
<svg height="300px" width="400px">
<circle cx="200" cy="150" r="100" fill="#000000"></circle>
<circle cx="200" cy="150" r="98" fill="#5ccff0"></circle>
<circle cx="200" cy="168" r="80" fill="#ffffff"></circle>
<circle cx="180" cy="90" r="20" fill="#000000"></circle>
<circle cx="220" cy="90" r="20" fill="#000000"></circle>
<circle cx="180" cy="90" r="19" fill="#FFFFFF"></circle>
<circle cx="220" cy="90" r="19" fill="#FFFFFF"></circle>
<circle cx="190" cy="92" r="5" fill="#000000"></circle>
<circle cx="210" cy="92" r="5" fill="#000000"></circle>
<circle cx="200" cy="110" r="14" fill="#000000"></circle>
<circle cx="200" cy="110" r="13" fill="#ff0000"></circle>
<circle cx="200" cy="182" r="58" fill="#ff0000"></circle>
<rect x="140" y="124" width="120" height="58" fill="#ffffff"></rect>
<rect x="199" y="124" width="1" height="58" fill="#000000"></rect>
<rect x="210" y="130" width="40" height="1" fill="#000000"></rect>
<rect x="152" y="130" width="40" height="1" fill="#000000"></rect>
<rect x="210" y="150" width="50" height="1" fill="#000000"></rect>
<rect x="142" y="150" width="50" height="1" fill="#000000"></rect>
<rect x="210" y="170" width="60" height="1" fill="#000000"></rect>
<rect x="132" y="170" width="60" height="1" fill="#000000"></rect>
</svg>
</div>

The explanation: first he creates a new layer (<div> ...</ div>), then puts in a tag that tells the browser to interprete the following instructions as an svg design (<svg> ...</ svg> ). Inside the svg tag he has specified the height and width of the drawing, and then there are the instructions for drawing circles and rectangles to make the face, eyes, whiskers, etc., and here it seems pretty obvious: rect is for rectangles, circle is for cirles, xy the relative position, width, height, is width and height (want to draw a linge? Set the height to 1 pixel) and fill designates a color to fill, in 8bit RGB hexadecimal.

The main advantages of using this technique instead of placing an image are two:

  1. takes up much less space and so is faster to load
  2. you can enlarge the image indefinitely without losing quality or making it look pixelated

Reverse DNS lookup (rDNS)

Have you ever wanted to know which URL belongs to an ip address? For example, what is the URL of the Google public DNS service, 8.8.8.8?

To overcome to this problem I wrote a program to do the reverse DNS lookup (rDNS), of a given IP address, here it is:

For example, looking 8.8.8.8, you get google-public-dns-a.google.com