Tools to start the new year organized

I was needing a cloud based todo application with support for the iPhone, preferably native. I need something that I can adapt to my workflow and doesn’t change it completely (as for instance OmniFocus). After evaluating several web applications I decided to use todoist . I thought about Things for Mac & iPhone but I have read some bad reviews about syncing and it has no web support, making it unusable on work. todoist has a freemium model so is free unless you want the extra features (notes and SMS alarms). On the mobile side, I have bought Doings, an iPhone application that works with todoist and can sync back to it.

And by the way, happy new year.


Skype for the iPhone

I’ve woken up this morning to the news that skype finally released a version for the iPhone with video chat support.

Tried it, but as Engadget pointed out, quality sucks. I’ve only used a phone to laptop call, the video from the other side was looks great but the one i’m sending looks awful. See for your self.



Catalina Log Reader

Some web applications generate lots of exceptions and dump exaggerated amounts of stacktraces. i’ve wrote a small script in perl that parses catalina.out and can remove or shorten those stacktraces and also prove some syntax highlight.


Start clog with:

$ clog

Check the last 100 lines from the log:

$ clog 100

If you want only to see the first five lines of the stacktrace:

$ clog -st 5

If you want to see the full stacktrace:

$ clog -e 100

The code is available here.


Clojure working and all set

I have been all night hacking. Result for tonight, .emacs needs cleaning. also i have some ideas about templates and component base architecture.


Mifi a funcionar em Portugal?

Para quem não conhece o mifi é um aparelho que se liga á rede 3g e permite que estejam 5 computadores ligados através do wifi. Mas infelizmente não existe nenhuma operador a oferecer este produto em Portugal.

Mas como somos o pais do desenrasca, dá se a volta.

Para arranjar o mifi, pode se comprar um livre de contracto na net (

O cartão de dados também é simples. A vodafone tem uma solução chamada Vita Net Light (link aqui) que permite acesso á net por 10 horas durante 6 meses e cada aditivo de 5 horas são 5 euros. O cartão custa 15 euros. Para o utilizador esporádico pode ser uma boa solução. Outras operadoras podem ter outros contractos.



HTML5 Canvas with GWT

The other day I was playing Final Ninja Zero, a cool flash game. While i was swinging and firing ropes, I wondered if such a game could be written in HTML5 Canvas. After searching the net for a while, I didn’t a good framework to develop games or any graphic thing in Canvas.

So I started meddling with GWT. At work, we started using GWT with our Fenix Framework. The first example was FeaRS. I used the GWT compiler to translate a framework, that I developed, to JavaScript. In this framework you can manipulate high level shapes (Squares, Circles, etc.) and have handlers like in GWT, things that canvas doesn’t support (svg support some of this but svg is for vector graphics while canvas is for bitmap). Also this framework removes the interaction with the DOM, you only have access to elements inside the canvas.

My objective is to create a website like miniclip or kongregate but for canvas games and provide this framework so people could create the games. These games would be embeddable in pages, have server side services as saved games, multiplayer support, etc. Also I would provide support for iPhone and Android in the framework, and also create an application for both Phones so people would have access to accelerometer data, orientation, multitouch data, etc.

Right now, I only have a small set of examples working, but they are coming out nicely.

My question now, is what do you think of this? I’m thinking of investing on this, but i would like to hear what you have to say about it.


tesseract: transversing Java Domains using JavaScript

For those who don’t know, I’ currently working on Instituto Superior Técnico at the Fenix Project. Fenix is a web application developed to do academic administration of the entire college, from course enrollment to parking.

This application is written in Java and uses a rich domain with more than 1000 distinct entities. One of the technologies that suports Fenix is the JVSTM (Java Versioned Software Transactional Memory) and the FenixFramework. This library allows to describe complex domains (both entities and relationships) in a syntax similar to java, and generates both the SQL1 code that creates/alter the tables, and the high level code that works with the application level.

One of the first problems that i faced was the domain dimension, and and the level of relations that exist. The team is used to opening the domain model file and scroll up and down searching for relations and classes, but this file has 17000+ lines. So one of the first things i developed was the Fenix Domain Browser, a domain structure navigator that presents the domain as a series of UML schemes. But this browser only can inspect the domain structure and not his instances. For that you normally use SQL queries, that makes navigating in a relation a slow and painful process (inner joins), or you build the entire stack from the domain up to the viewing level. None of this alternatives was ideal but was what we had.

Last year, in “Programação Avançada” (Advanced Programming), one of the course projects was to develop an interpretator of Java2. Developing this REPL3 was alot of fun, because we had time and implemented a bunch of features that weren’t required (dynamic functions, macros, etc.). After the project ended, I tried to connect this REPL with the Fenix Domain, but ending up not being a nice interaction. The main problem was Java’s typification. Each time you had to create a variable you had to declare types and probably do some kind of cast. Using Object variables only delays the problem since it had then to upper cast them to call any method. Other problem was the intersection library that I was using, JA doesn’t support Java 5 and that means no foreach’s, autoboxings, etc. For that reasons I stopped using it and put it aside.

Recently I was given the responsibility of reorganize an application used in IST called FeaRS. This is a Feature request system, but uses a voting system similar to digg or reddit. This application also uses the same domain technology than Fenix. When I finally put the application running on my server I wanted to inspect the instances on the domain so I remember of using the REPL I had developed. But this time I had one of those “What if”.

What if i used rhino to interact with the domain and use JavaScript as an interface language. After a week working on this I end up with Tesseract.

Tesseract is a REPL for any domain developed with the Fenix Framework. By default uses JavaScript but can also work with Java. This is essential because the team’s know how is in Java. Since Java and JavaScript are to some extent similar, allows them to use the this program and benefit from JavaScript dynamism and functional behavior, and if needed its possible to use Java in a particular task.

With the technology that we are currently work with, at the higher layers every relation is represented as lists. Since JavaScript is a functional language, where implemented functions that operate over java.util.Collection interface (map, reduce, filter, etc.). Although these functions receive a JavaScript function, these were implemented in Java, and run really fast.

On top of this I decided to implement a query language based upon Microsoft’s LINQ. This allows the developers to create queries with the same power that in SQL (actually more power, since JavaScript is Turing Complete and SQL isn’t), fully replacing it for read/write tasks. Structural changes in the domain are not possible yet. This language can work with both Java and JavaScript objects, since the interfaces to slots and methods are similar.


To start a query, an array (either a Java Collection, or something that implements a map method) is passed to the $ function. This will generate a Query object.

[query: size: 7]
Its important to notice that in this language we are always operating over lists of objects. Its possible to for the query return the result set as a Native JavaScript Object (toArray), or a Java List (toList). Now lets see from the admins who has voted in request, only limiting the result to 3:
tes>var z = $(FearsApp.getFears().getAdmins()).where(
return find(user.getVoter(),
        return voter.getVotesUsed() > 0;
[query: where$limit, size: 3]
To show the results we ask for a table:
tes> z.table();
| [email protected] |
| [email protected] |
| [email protected] |
By default a table can returns the result of calling toString on a object. Its possible to have another results:
tes> z.table(["username"]);
| username |
| istXXXXX |
| istXXXXY |
| istXXXXZ |
The string can represent either a slot, a method or a getter (in this case “getUsername”). A table can have as many columns as desired:
tes> z.table([
label:"The UserName",
label: "Another UserName",
func:function(x) {
    return x.getUsername()
| The UserName | Another UserName |
|     istXXXXX |         istXXXXX |
|     istXXXXY |         istXXXXY |
|     istXXXXZ |         istXXXXZ |
To travel in a relation one can use the select function when is expected to return a single object, or selectAll if the relation is *-to-Many. Those functions receives a string representing a slot, method or getter, or a function that is supposed to return the selected object:
tes> var t = $(FearsApp.getFears().getAdmins()).selectAll("getVoter").select("project");
tes> t.count();
Its important to note that selectAll will collect the results as they come, so its likely to contain repetitions if they occur in the relation. To select the unique objects in a list:
tes> t.distinct().count();
To see what object you have at one position you can it with elementAt but normally what you want is to inspect it. inspect will inspect the object at index you provide. This function only works with DomainObjects:
tes> t.inspect(1);
Instance of:
|                slot |                                                                       value |
|                name |                                                             CIIST-Taguspark |
|         description | Propostas e sugest?es para melhoramento dos servi?os do CIIST no Taguspark. |
| featuresIncrementID |                                                                           4 |
|        initialVotes |                                                                           5 |
|        listPosition |                                                                           6 |
|       relation |                                             value/size |
|          voter |<lenght: 215>) |
|         author |   |
|          admin | <lenght: 0>) |
|       fearsApp | |
| featureRequest |<lenght: 4>) |
If you need to know what is the structure of the entity, you can use entity:
tes> t.distinct().entity(1);
|                slot |             type |
|                name | java.lang.String |
|         description | java.lang.String |
| featuresIncrementID |              int |
|        initialVotes |              int |
|        listPosition |              int |
|       relation |                                      type | multiplicity |
|          voter | |            * |
|         author |  |         1..1 |
|          admin |  |            * |
|       fearsApp | |            1 |
| featureRequest | |            * |
Another important thing is to know what kind of objects you have in your list. The function type returns a list with the classname of the objects:
tes> t.distinct().types();
[query: selectAll$select$distinct$types, size: 1]
tes> t.distinct().types().table();
| |
A query can be passed to another query, either as the starting list:
tes> $(z).where(function(x){ return x.getUsername().equals("istXXXXX"); });
[query: where, size: 1]
Or as a intersection to another query:
tes> $(range(0,20)).intersect($(range(5,15)));
[query: intersect, size: 10]


I executed some tests with this language and for the most part, performance is acceptable. The first iteration of a new relation is a bit slower due to the objects not being in cache.

The biggest relation that exists contains about 2 million objects. Using only integer, an iteration over a list with 2.5 millions objects took about 30 seconds. This means that the bottleneck is still in the connection to the database.

Future Work

One of the things i would like to implement is some kind of lazy evaluation. Currently each function call returns a new query object. That means that the query doesn’t generate side effects on the query object. So, its possible to create promises of execution for each new operation and when a effect requested the full set of operations would be minimized and optimized. But since this is going to be used in a development environment, this is not critical right now.

Using JavaScript as a interaction tool with Java can be useful because its not hard for a person who understands Java to work with JavaScript, and this language allows a more dynamic approach to software development in Java

Tesseract is available at githut here. Its NOT production ready, its even prior to a version 0.1 at this moment.

  1. There are attempts to use NoSQL systems, that in this kind of domain have greater performance ↩
  2. Actually was a bit different, the language was called µJava, but was essentially the same thing. ↩
  3. If you aren’t lispy enough it means Read-Eval-Print Loop ↩

JSC : A JavaScript Object System

As some of you might know, I’ve been working on a personal project for last 6 months, called Possimpable (working title).

This project is composed from 3 major components. Today I’m going to release some documentation about one of them.

Most parts of this project are written in JavaScript, including server-side. While I was attempting to write in a OO fashion, I started to feel that my code was written as a collection of JavaScript Hacks. Since that would inevitably leads to bug (and since JavaSCript is an asynchronous language, could lead to bugs hard to find). Other problem is that this project relies on a RMI between the client and the server, so I needed a way to simplify using it in JavaScript.

That made me start writing small scripts to pre-process code, but over time and several hacking sessions, I started having a small language on top of JavaScript. This language is called JSC.

I’m not releasing JSC compiler today because I’m not satisfied with the code in the current version. It still has some kinks that need to be worked on. I’m however requesting for comments.

I’m going to release 2 documents today. One is a presentation in Portuguese that I gave to grad. course. The other one is a small paper that describes the main topics for this language.


∞ – recursive photo

No ultimo twittlis, após umas caipirinhas e umas imperiais, decidiram tirar um foto circular. Para quem não esteve, tiraram uma foto do próximo a tirar uma foto ao seu seguinte, e assim sucessivamente.

Como é chato andar a passar de pagina e fixe, fixe era adicionar umas animações panisgas, o que eu fiz foi pegar nessas fotos todas e juntar uns efeitos de jquery, em particular a biblioteca space gallery, e dar um aspecto janota ao que já estava no flickr, semelhante á time machine.

Assim, para quem quiser ver o resultado: