Saturday, February 28, 2009

CSS Language Extensions

CSS is a nice idea gone horribly wrong. It's a major pain in the butt to web content developers worldwide. I've been coding web apps for several years now and it still seems crazy to me! I am not a CSS fan and I am not alone.

So while I sit around and crib, people are coming up with extensions on top of CSS to alleviate the pain somewhat. All of them add support for nesting selectors which is something that should have been a part of CSS spec to being with. In addition -
  1. HSS adds variables, block variables, single line comments and CSS validation. Built on top of Neko.
  2. CSS Dryer adds support for variables. Written in Ruby.
  3. Sass changes the syntax to be a bit more terse (by getting rid of all the braces), and adds variables, namespaces, arithmetic/string/color manipulation operations and a bunch of other things. Written in Ruby.
  4. CleverCSS adds support for variables, property groups, lots of arithmetic/string expression operators and a bunch of other things. Written in Haskell.

Friday, February 27, 2009

Construct your own spaceships using Visio "Flexi Arrows"

I found out that Visio "Flexi Arrows" are great for creating Spacecraft like shapes!

Check out the proof of concept I threw together in about a minute and half!

Tuesday, February 24, 2009

Convert an arbitrary Erlang expression to String

It's the very counter-intuitive -

lists:flatten(io_lib:format("~p", [Term])),

Where Term is the erlang expression.

Simply using io_lib:format should have worked in this case but it returns a deep list for some reason which needs to be flattened before use. Some fun facts -
  1. The deep list returned by io_lib:format still behaves like a normal string within erlang. For example - printing it out to the console using io:format() will work as expected. But when you pass that list to some non-erlang program (Java in my example, using Jinterface) expecting a String, all hell will break loose.

  2. This works too but is more computationally expensive - 
    binary_to_list(list_to_binary(io_lib:format("~p", [Term])))

Peace Erlang! I don't wanna fight no more..

Monday, February 23, 2009

Painlessly convert code buffers in emacs to HTML

While looking for a way to convert my Haskell code to HTML, I stumbled upon HTMLize!

Steps -
  1. Download the file at to some location on your hdd (I put mine in ~/emacs.d/htmlize/).
  2. Add the following lines to your init.el file -
    (load "~/.emacs.d/htmlize/htmlize.el")
  3. Restart emacs.
  4. From within emacs, invoke - M-x customize-variable htmlize-output-type and set its value to css-inline.
  5. Switch to the code buffer and invoke - M-x htmlize-buffer
  6. Save the newly created buffer with an html extension
Behold! (An excerpt of the code from Yampa) -

-- Implementation of Yampa utilities:
module YampaUtils where
import AFRP
hold :: a -> SF (Event a) a
hold x0 = loop (arr aux >>> iPre x0 >>> arr dup)
where aux (e,x) = event x id e

PS - A useful little tip: To import HTML into an open office presentation - first open the html file in OOwriter and then copy paste into OOimpress..

Wednesday, February 18, 2009

It happened to me - IRC Netsplit

So I'm logged on to #haskell, #erlang, #python on Freenode.

Here's what an IRC Netsplit looks like -

... [690 users on #haskell] ...
... [When suddenly] ...
* enascryaptio has quit (
* Asoasdeir has quit (
* amaornsfall has quit (
* reehya has quit (
* aabosyscsaared has quit (
* asdfnetcgasat has quit (
... [etc. etc.] ...
... [34 users on #haskell] ...
... [Collective gasp! Holy crap! This is the smallest I've ever seen #haskell]...
... [Later. Netburst!] ...
* MrSyzsaygy ( has joined #haskell
* Kapsfasdu (i=blah@blah/Japsu) has joined #haskell
* Dotjasde ( has joined #haskell
* sbosk (n=blah@blah/kobs) has joined #haskell
* alesaator_ ( has joined #haskell
* SAhurique ( has joined #haskell
* SssimonsRsC ( has joined #haskell
* Raiastraasdh ( has joined #haskell
... [etc. etc.] ...
... [Life back to normal] ...

And then moments later - an apology -

[Global Notice] Hi all, it would appear we've discovered yet another bug in hyperion, the ircd we run -- how we've managed to use it successfully for so long is now but a great mystery. The network is back up, for now, but in light of this we will be looking at bringing our ircd-change forward, details shall be forthcoming. Please accept my sincere apologies for the instability as of late and thank you for your patience.

And a retraction!

[Global Notice] Hi all, It appears I may have been too harsh on hyperion -- this crash wasn't a segfault after all, but some of hardened gentoo's 'security' measures deciding that our ircd is a threat. More information will be provided on the blog when we have a better picture and know what actions will be taken to prevent this from occuring again. Thank you for using freenode and have a good day!

Monday, February 16, 2009

The Byzantine Generals Problem

The problem was described by Leslie Lamport in a 1982 paper written after observing what he felt was an inordinate amount of attention received by Dijkstra’s Dining Philosophers problem.

Interested in understanding concurrent programming algorithms? Writing a program to solve this problem will make you a much better programmer..

Debian Lenny released as Stable!

Or more accurately..

Debian GNU/Linux 5.0 released!

The next version currently in testing is called "Squeeze"..

Recipe for the "perfect paper plane"

While on the topic of paper planes.

From here -

Have to try it out tomorrow!

MIA Paper Planes

MIA - Mathangi "Maya" Arulpragasam is a British songwriter and vocalist of Srilankan descent. Her 2007 album Kala includes this gem with an infectious beat to it - Paper Planes. I don't particularly care about the message she's trying to convey but the Song is awesome! Watch/Listen to it on you tube. (See the fan made video here if you have extra time) :)

This track was very well used in Slumdog Millionaire which is where I heard it first..

It's alternative hip hop.. And that's your "totally useless fact of the day"..

Friday, February 13, 2009

Graphics Solutions for Embedded Linux lists some graphics toolkits/libraries for folks deploying Linux on embedded devices.

Here's the list of Free solutions -

Dillo -- Dillo is a very small (less than 300KB), fast, Open Source multi-platform web browser that's written completely in C and built on GTK+ libraries. Dillo's high efficiency and minimal library dependencies make it quite suitable for embedded apps. Dillo can be teamed up with an embedded webserver to completely eliminate the need for a window manager in an embedded device.

DirectFB -- DirectFB is a thin library that provides developers with hardware graphics acceleration, input device handling and abstraction, integrated windowing system with support for translucent windows and multiple display layers on top of the Linux Framebuffer Device. It is a complete hardware abstraction layer with software fallbacks for every graphics operation that is not supported by the underlying hardware.

The Familiar Project -- this open source PDA Linux project, which is an offshoot of the activities at, has collected together all of the key components of a complete Linux-based PDA computing platform. The Familiar distribution currently includes a Blackbox-based window manager, Agenda Computing's Fltk+ based PIM applications, an embedded Python implementation, system configuration and settings backup utilities, OpenSSH client and server, and a Debian-based ARM kernel.

FBUI -- FBUI is a tiny GUI that resides inside the Linux kernel. The key concepts of FBUI are that firstly it is small; secondly that it is spartan, which is good; thirdly that it is just another driver; and fourthly that drivers belong in the kernel, not in userspace.

GGI project -- the "General Graphics Interface" project is dedicated to development of fast, stable, open-source cross-platform multimedia API systems. Designed from the ground up with environments such as embedded systems in mind, GGI is fast, clean, abstract, dynamically modular and highly optimizeable.

GPE Palmtop Environment -- this project aims to provide a Free Software GUI environment for palmtop/handheld computers running the GNU/Linux operating system. GPE uses the X Window System, and the GTK+ widget toolkit.

GtkFB -- beginning with version 2.0, GTK+ will support rendering directly to the Linux framebuffer instead of using the X Window System. This is good for embedded systems and devices with limited resources, because it eliminates the overhead of an X server, while still taking advantage of the power of GTK+ and the large base of existing programs. PDA support -- want to create your own unique Linux PDA implementation? is for you! Early this year, Compaq created the Open Handheld Program, an initiative designed to stimulate innovation and research on handheld devices that resulted from the company's "Itsy" pocket computer project. To support this initiative, Compaq created -- a vendor neutral website dedicated to open source handheld development. Not surprisingly, Compaq's iPAQ PDA is used as the base platform for all these activities and, consequently, a iPAQ Linux port is available as freely available open source software.

Matchbox -- a small foot-print window manager and associated applications, designed specifically for resource-constrained X11-enabled devices such as handheld computers, PDA's, set-top boxes, and consumer devices where display size, storage, CPU bandwidth, and input mechanisms are limited. Matchbox includes a window manager, a panel, a desktop, a shared utility library, and a number of small panel applications.

Microwindows -- an Open Source project aimed at bringing the features of modern graphical windowing environments to smaller devices and platforms. Microwindows applications can be built and tested on the Linux desktop, as well as cross-compiled for the target device.

NxZilla (formerly nanozilla) -- a set of libraries that allow Mozilla to be used with a NanoX server from the Microwindows project.

OpenGL ES -- a light-weight, royalty-free embedded graphics standard that provides graphics API profiles for a broad range of embedded systems and devices, including handheld wireless devices, automotive and avionics displays, and multimedia consumer devices such as advanced digital TVs, set-top boxes, and game consoles.

OpenGUI -- a fast, 32-bit, high-Level C/C++ graphics & windowing library/GUI built upon a fast, low-level x86 asm graphics kernel. It is under LGPL license. OpenGUI provides 2D drawing primitives and an event-driven windowing API for easy application development.

PicoGUI -- small, portable client/server GUI designed to work on many types of hardware including handheld computers. Like the X Window System, it has a flexible client-server architecture. Unlike X, however, fonts, bitmaps, widgets, and anything else the application needs are built directly into the server. This sacrifices a small decrease in flexibility for an increase in speed and a large decrease in size.

Qt/Embedded -- provides a full graphics stack, from the hardware interface to a full GUI tookkit. Although the API is identical to the popular Qt/X11 and Qt/Windows products, Qt/Embedded is not based on X11 and therefore it has substantially reduced memory requirements. Memory demands can be tuned to the range of 800 KB to 3 MB in ROM (Intel x86). Qt/Embedded is available as open source software, under the GNU General Public License (GPL), or can be licensed on other terms from its originator, Trolltech.

Simple DirectMedia Layer -- an open source cross-platform multimedia development API/library designed to provide fast access to the graphics framebuffer and audio device. SDL is currently being applied to a number of Embedded Linux implementations such as Microwindows.

Tiny-X -- a small footprint X Window server implementation for embedded systems. It was developed by Keith Packard of the XFree86 Core Team, sponsored by SuSE. The goal was to create something that would work well in a small memory footprint and, importantly, be robust in near out-of-memory situations. Typical X servers based on Tiny-X can fit in less than 1MB on x86 CPUs. The project has since forked into several projects, including KDrive, SmallX, and Integrated Tiny-X. 

ViewML -- a freely available, open source web browser targeted specifically at the embedded Linux platform. Currently, ViewML along with it's interface requires 2.1 MB of RAM, with a disk image of only 760K.

WML Browser -- a project, sponsored by 5NINE to develop a browser which will allow any wireless device to have WAP functionality. It must support multiple protocol stacks (WAP 1.2.1, http), in differing environments, using differing input devices. The browser will work with framebuffer graphics.

Xynth Windowing System -- a free software project to build a portable, embedded client-server windowing system. The Xynth Windowing System, released under the GPL, offers a lightweight GUI-capable windowing system usable in Linux-based embedded systems and devices, such as handhelds and set-top boxes.

I found Serenity

I went through a marathon run of 14 episodes of Firefly followed by Serenity the movie, in a span of 3 days. Head rush! Wow!

I can't get over the shock that the series got cancelled..

Image and Color handling in Java2D

Here are two handy snippets -

1. Color from String -

Color c = Color.decode("0x87CEFA");

(The hex value is for a serene "lighter" sky blue colour, which I find better than the official "sky blue" of 0x87CEEB)

2. Painting background images -

public void paint(Graphics g) {
URL imgURL = getClass().getResource("foo.jpg");
ImageIcon icon = new ImageIcon(imgURL, "image description");
icon.paintIcon(this, g, 0, 0);

(Where "foo.jpg" should be in the same folder as the compiled class.)

Thursday, February 12, 2009

I hate complications

But they seem to love me for some reason..

Tuesday, February 10, 2009

Venture capitalists don't back technologies they back people

"Give me a grade 1 person with a grade 2 idea rather than a grade 2 person with a grade 1 idea"

Saturday, February 07, 2009

Naming distributed nodes in Erlang

I was trying to setup communication between Erlang and Java, following the example code here -

Problem - 

  Server code 
  C:\Projects\mips>erl -name servernode -setcookie cookie
  Eshell V5.6.5  (abort with ^G)
  (servernode@ANUPAMDELLAPTOP.Belkin)1> delme:start().

  Client Code
  C:\>erl -name clientnode -setcookie cookie
  Eshell V5.6.5  (abort with ^G)
  (clientnode@ANUPAMDELLAPTOP.Belkin)1> rpc:call(servernode@ANUPAMDELLLAPTOP, delme, add, [1,6]).

  =ERROR REPORT==== 7-Feb-2009::18:36:16 ===
  ** System running to use fully qualified hostnames **
  ** Hostname ANUPAMDELLLAPTOP is illegal **
  (clientnode@ANUPAMDELLAPTOP.Belkin)2> rpc:call(servernode@ANUPAMDELLLAPTOP.Belkin, delme, add, [1,6]).
  * 1: syntax error before: Belkin
  (clientnode@ANUPAMDELLAPTOP.Belkin)2> rpc:call('servernode@ANUPAMDELLLAPTOP.Belkin', delme, add, [1,6]).
  (clientnode@ANUPAMDELLAPTOP.Belkin)3> rpc:call(servernode, delme, add, [1,6]).
  (clientnode@ANUPAMDELLAPTOP.Belkin)4> rpc:call(servernode@localhost, delme, add

  =ERROR REPORT==== 7-Feb-2009::18:37:56 ===
  ** System running to use fully qualified hostnames **
  ** Hostname localhost is illegal **

Solution -

  Server code
  C:\Projects\mips>erl -sname servernode@localhost -setcookie cookie
  Eshell V5.6.5  (abort with ^G)
  (servernode@localhost)1> delme:start().

  Client Code
  C:\>erl -sname clientnode@localhost -setcookie cookie
  Eshell V5.6.5  (abort with ^G)
  (clientnode@localhost)1> rpc:call(servernode@localhost, delme, add, [1,6]).

Thursday, February 05, 2009

To Read - On Intelligence by Jeff Hawkins

This book is written by Jeff Hawkins, the founder of Palm and Handspring!

New features in Javascript 1.8 (Firefox 3.0)

While on the subject of Firefox 3.0,  check out the new features in Javascript 1.8. Some of these like generators (pythonesque constructs, introduced in Javascript 1.7, souped up to support expression syntax in 1.8) are nice!

Global variables in Javascript - Across JS files!

Check out Javascript Code Modules!

JavaScript code modules are a concept introduced in Firefox 3 (Gecko 1.9) and can be used for sharing code between different privileged scopes. Modules can also be used to create global JavaScript singletons that previously required using JavaScript XPCOM objects. A JavaScript code module is simply some JavaScript code located in registered location. The module is loaded into a specific JavaScript scope, such as XUL script or JavaScript XPCOM script, using Components.utils.import.

This is only available on Firefox 3.0 or better, and then also only to extension developers. But sweet!

Oni - Concurrent Javascript

Oni is an an embedded structured concurrency language

It's a framework which allows the programmer to implement concurrent applications without having to explicitely manage the control flow. It does this by "composing" together concurrent actions using operators such as Par which performs actions in parallel, and Alt which performs actions in parallel and returns the result of whichever action finishes first (very useful in implementing timeouts).

Oni can be implemented in any host language, and an implentation exists for Javascript! Currently the implementation only works in Firefox 3.0 or better.

Greenspun's Tenth Rule

From Wikipedia -'s_Tenth_Rule

Greenspun's Tenth Rule of Programming is a common aphorism in computer programming and especially programming language circles. It states: Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

The rule was written sometime around 1993 by Philip Greenspun. Although it is known as his tenth rule, there are in fact no preceding rules, only the tenth. The reason for this according to Greenspun: "Sorry, Han-Wen, but there aren't 9 preceding laws. I was just trying to give the rule a memorable name."
The rule is often modified by replacing "Common Lisp" with the speaker's functional language of choice, such as Scheme or Haskell. It can also be generalized as: Any sufficiently complicated platform contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of a functional programming language.


It can also be applied to Erlang: Any sufficiently advanced CONCURRENT program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of ERLANG

Double Heh!

Tuesday, February 03, 2009

To Read - Yahoo Pipes

Read up!

Java Layout Manager Showdown

Very interesting "showdown" of the various layout managers in Java Swing.

Seems like there are quite some options for good looking GUI's in Java apart from the haloed GroupLayout manager.

Monday, February 02, 2009

WOTD - Word Of The Day - Segue

Yes, the title continues the acronyms theme. Let's move on.

Segue (pronounced /ˈsɛgweɪ/) - In music, "segue" is a direction to the performer. It means continue (the next section) without a pause. It comes from the Italian "it follows".
In journalism, a segue is a method of smoothly transitioning from one topic to another. A segue allows the host or writer to naturally proceed to another topic without jarring the audience. A good segue makes the subject change seem like a natural extension of the discussion.

Karthik Ramachandra - Erlang eXchange and ThoughtWorks

Video - Karthik Ramachandra is an Extreme Programmer for ThoughtWorks. He is based in Bangalore, India, and was in London recently to speak at Skillsmatter's Erlang eXchange.

He was good enough to talk to me about Erlang, Thoughtworks and the tech scene in India.

And as a slick segue, Pragmatic Programmers have recently released The ThoughtWorks Anthology.

QS: Would the seamless transitions from one sketch to the next on the Monty Python TV Series be called Segue? Stream of consciousness is what they are popularly known as.

What is JAIN?

While on the topic of acronyms -

From the Wikipedia page for JSLEE

JAIN - Java APIs for Integrated Networks

What does COB stand for?

Here is the context (from an email I received recently) -

"I will be unavailable from 9:00 AM - COB"

Close Of Business