new article drafts db edit
 

Debugging Clever Code

by gmosx in Dogma, at 15-4-2009
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
Brian Kernighan
0 comments programming

Latest comments

Real World Haskell

by gmosx in Technology, at 5-4-2009
According to Tim Sweeney, 'Haskell is a language that is generations ahead of today's mainstream'. Last year, in parallel to my research in financial engineering, I tried to wrap my mind around Haskell's wonderful new concepts. It was hard, even for an experienced programmer, but I had a helpful ally: the beta chapters of Real World Haskell.

After a long time the book is finished and my copy has actually arrived. I already knew this book was destined to become a technical bible. The surprise was to see my name in the prologue of this important book:

George Moschovits in Real World Haskell
1 comments Haskell functional programming book

Javascript Relational Database Interface

by gmosx in Technology, at 7-3-2009
Nitro aims to provide everything you need to develop sophisticated Web applications with ease and joy. Typical Web applications operate on data stored on some form of a database. Even though the latest trend is to experiment with specialized (some would say exotic) data stores (key-value, document/object oriented, graph based etc), the relational paradigm is still relevant. For this reason, a simple JavaScript Relational Database Interface (rdb) has landed on the repository.

Nitro's philosophy is to leverage existing, well understood and mature standards wherever possible and provide 'thin' APIs on top of them. Following this, the rdb interface is powered by JDBC. The goal is to design the simplest possible interface that combines the power and flexibility of JDBC with the feel of JavaScript.

Go on, have a look at the preliminary implementation or a simple example. To wet your appetite here is a some code:

var Database = require("database/rdb").Database;

var db = new Database("jdbc:mysql://localhost/example?user=nitro&password=p@ssw0rd");

// pre-prepare the statement
var sql = db.prepare("INSERT INTO Article (title, body) VALUES (?, ?)");

var id;

for (var i = 0; i < 10; i++) {
    // use the prepared statement.
    id = db.insert(sql, "title " + i, "body " + 1);
    print("inserted: " + id);
}

// query for one object.
var article = db.query("SELECT id, title FROM Article WHERE id=?", id).one();

print("title: " + article.title);

// query for many objects.
var articles = db.query("SELECT id, title FROM Article WHERE id>?", 20).all();

print("length: " + articles.length);

var Article = function(title, body) {
    this.title = title;
    this.body = body;
}

Article.prototype.dummy = function(extra) {
    return "---> " + this.title + " : " + extra;
}

// query for many objects, deserialize in a specific JavaScript object 'class'.
var articles = db.query("SELECT id, title FROM Article WHERE id>? LIMIT 5", 20).all(Article);

for (var a in articles) {
    print(articles[a].dummy("this is extra"));
}

// use a result iterator for optimized result processing.
var articles = db.query("SELECT id, title FROM Article WHERE id>? LIMIT 5", 20).each(function(a) {
    print("*** " + a.dummy("forEach"));
}, Article);


I would love to hear your comments and suggestions. You can leave comments under this post or start a discussion in the nitro-devel mailing list.
0 comments nitro javascript database java rdbms relational

Nitro in Javascript

by gmosx in Technology, at 28-2-2009
It's no secret that I am working on a web application framework. I was bored (not to say unhappy) with my old Ruby framework, so during the past year, I designed and implemented no less than 3 different Ruby versions and 2 different JavaScript versions. This blog, for example, runs on my latest Ruby experiment.

Why I kept redesigning the framework you ask? Well, I wanted to make sure the design is as simple, as standards compliant and as transparent as possible. Some days ago I started a new revision. This time I am confident I 'll nail down a great balance between simplicity and power. I am using JavaScript, a truly excellent language with an unfortunate name. JavaScript is the obvious choice in an era where the distinction between server and client is blurred. The show stopper for JavaScript is the omission of a standard library. Thankfully, Rhino and Java come to the rescue.

I 've released some preliminary code on github. The project is still called Nitro, but apart from the name, it has nothing in common with my older effort. There is not much in the repository yet but you can expect regular updates. Of course, I will chronicle the latest developments here.

Even at this early stage, I would love to hear comments, suggestions and ideas for further improvements or better refactoring.
0 comments nitro javascript web software

Palm Pre rocks my world!

by gmosx in Technology, at 22-2-2009
I have briefly blogged about Palm Pre before, but since I cannot constrain my enthusiasm about this marvelous gadget, I thought I will write some more thoughts.

Palm pre

Please understand that I am not really excited about the sleek looks of Palm (even though it looks even better than the iPhone if you ask me). I am not excited about the impressive, smooth and intuitive user interface either. Palm is the future of mobile phones because of WebOS.

WebOS is an ingenious mix of Linux and the Browser: Linux provides the low level features and the browser is responsible for the User Interface. This is not you every-day browser by the way, Palm has integrated leading edge HTML5 features (local storage, etc) with custom WebOS specific infrastructure services (information bus, etc).

And the icing on the cake? You can use standard web technologies to develop your WebOS applications: JavaScript, HTML, CSS. Super charged of course by the modified browser rendering engine.

Utterly brilliant!
0 comments mobiles web os web javascript

AC/DC concert in Greece

by gmosx in Life, at 9-2-2009
AC/DC concert in Greece

Going to an AC/DC concert was a dream in my childhood... Well, better late than never ;-)
0 comments music

The secret of happiness

by gmosx in Dogma, at 7-2-2009
The secret of happiness is simple: find out what you truly love to do and then direct all of your energy towards doing it. Once you do this, abundance flows into your life and all your desires are filled with ease and grace.
The Monk Who Sold His Ferrari
0 comments dogma self improvement

Access JavaScript function arguments as an Array

by gmosx in Technology, at 31-1-2009
One rather cool feature of JavaScript is that you can access a method's arguments from a special variable conveniently named ...arguments. Quite annoyingly though, the arguments variable is not a real array. Sure, you can get the arguments length or iterate through it's members. But you cannot call other Array methods like .push(), .shift() etc..

Fear not, the following one-liner converts the arguments variable to a real Array:


var args = Array.prototype.splice.call(arguments, 0);


The Array .splice() method is injected into the special arguments object to extract it's members and return a new Array.
0 comments javascript tip

How to disable ipv6 on Ubuntu

by gmosx in Technology, at 15-1-2009
There are many reasons to disable ipv6 on Ubuntu (If you don't really need it). Among others:

  • Some users report a noticeable improvement in network performance.
  • It's a workaround for a serious Tomcat6 bug

After a short Google session I found many (slightly different) 'solutions'. Nothing worked though. Eventually, I came across a solution that did the trick:

$ vi /etc/modprobe.d/blacklist

append the following line:

blacklist ipv6

save the file and restart your machine!

You can verify that ipv6 is actually disabled using the following command:

$ ip a | grep inet6

If you see not output this little exercise was successful. Go make yourself a cup of coffee!

BTW, I tried this on Ubuntu 8.10
0 comments Ubuntu administration tip

Friday's Links #3

by gmosx in Technology, at 9-1-2009
Best of CES 2009 (according to me):

  • Palm Pre This is what G1 (and iPhone) should have been! No Java or objective-C crap. Standard web technologies (HTML, CSS, JavaScript) are all you need to create an intuitive and beautiful user interface. An application developer's nirvana. This marvel looks sexy as hell!
  • LG Watch Phone Is this real or science fiction? Fascinating stuff!
  • Yahoo Widgets on TV Looks cool and useful. Powered by Intel and available soon from Sony, Samsung and LG.
0 comments gadget TV mobile javascript

The benchmark

by gmosx in Dogma, at 4-1-2009
If you constantly compare yourself to others, then all you’ll ever be is
just as good as them, maybe a little better. You’ll also miss out on all
the fantastic things you might actually be good at while you’re focused on
being better than them at what they’re good at.

Zed Shaw, 2008
0 comments dogma self improvement