Year 2009 in a glance

FireworksThis is it. Year 2009 has gone. Other than actually new date in a calendar not much has changed. Still same old. I do hope though that new 2010 will be different. At least I will give it a credit of a doubt for the time being.

What happened to me and my family in 2009?

I spend 5 great months in Sydney, Australia. You can check back my blog to see some of the pictures. Good times in there. Meet lots of new interesting and less interesting people. I got exposure to new perspectives. My family has rested from UK and all UK related problems. Enjoyed nice weather and central Sydney location.

In a mean time when we were in the Oz land our house got totally flooded by water from the loft (water pipe burst in a freezing weather). It also turned out that insurance is not willing to pay us a single penny for that accident.

I tried to dry the house when I took a week off and got back to UK to rescue whatever was left from our house.

In May we returned to a horrible reality (after a week of awesome holidays in Bangkok, pictures also earlier on a blog). Had to settle back in a house that was a huge mess. Stinking and full of dump. All our savings went into repairs.

We are still fighting consequences of a flood but at least house is in a reasonable state now. We also need to buy some furniture (again), as old were rubbished by water.

While in Australia I was working on a .NET project for insurance company. I got my skills polished in JavaScript as well. I think I’m having a second thoughts about JavaScript after hating it for so long.

I spent some time developing F1 Dashboard web site. Formula 1 related site with news, images and videos. While I was developing it I learned and studied different platforms for cloud programming. F1 Dashboard is running on Google App Engine and is written in Groovy (oh, I learned Groovy as well).

After Australia when we came back to UK I didn’t have to much time to go deep into technology and experiment in free time. I got some time on a train to/from work that I devoted to reading. I got into literature about Lean software development (expect more blog entries in 2010 about that).

Bad weather in December ruined our plans of travel to Poland for Christmas holidays and we spent this time in UK.

So, for all of you who are waking up now, near the end of the post.

2009 was shit. I’m happy it is over. Entire year was full of clouds with rarely few sunny spells (metaphor). I hope 2010 will be better and I wish you ALL that it will be better for you.

So, happy new 2010 year and take care.

Greg

Ps. Oh, I forgot to mention recession and Michael Jackson.

The secreat art of learning or … help me, I'm bored

Android

I just picked up new Development exercise. I decided to learn some programming for Android devices. I’m missing a truly great app for my Android handset that I could get for iPhone or desktop app, TweetDeck. This is my driver and my goal.

I spent some time to get to know the platform and the architecture. Reading some very good documentation that Google Android team put together. I downloaded SDK and some tools. Got it setup (turned out to be a trivial task).

So, what do I do now. I know Java, but that’s only 10% of what I need to know to develop for Android. SDK is the next bit. Plus there are some tips and tricks on how to develop for mobile devices.

I opened one of the tutorials on Android page and after a 10 minutes of reading and following on my computer I got bored. I realized that I enjoy to learn most by pairing on a problem with someone who knows more or at least know some. I don’t really have anyone to pair with me on my new task. I figured there has to be a better way of learning then.

Question is … what it is?

Guys, any help? How should I tackle it, so it is not boring as hell?

Cheerios, Greg

Answers to all your (and mine) problems

If you ever asked yourself a question, what is the purpose of life? Why are we here? Where are we going to? I’m totally convinced you can get an answer from this guy 🙂 Professor Sahib is the answer to anything (if you still don’t know what I’m talking about read the leaflet on a picture). A friend of mine in London got this delivered in his letter box. This is real stuff 🙂 Perhaps some of you need help with the addition 🙂.

professor_sahib

Greg and Professor 🙂

F1 Dashboard released

In last few months I was working on a little personal project. When Google App Engine team announced that preview of Java version is available I decided to give it a try. When I was looking for a subject of my application, one of the ideas started to emerge more that others. I was looking for a web site that could aggregate all the information about Formula 1 racing. Because there was none available (or my Google search ended on first few results that were not satisfactory) I decided to make one.

Few weeks and cups of coffee latter F1Dashboard.com is released.

F1 Dashboard screen shot
F1 Dashboard screen shot

Generalities

So, in few words, F1 Dashboard is agregator of news, and media feeds from world of Formula 1. I decided not to collect content, just store information where to find it and short description.

News are harvested from a number of web sites. Twitter updates serves as another source of news.

Images are comming from Flickr, videos from YouTube.

All updates  are happening every few minutes and are 100% automated.

Technicalities

GAE supports Groovy as one of JVM programming languages. I decided to give it a try. I love Groovy, it is somewhere in between a friendly and known Java API and Ruby programming language.

It took me a moment to use to BigTable type of DataStore. It restrictes a way I used to work with databases normaly. Google provide entire environment for local development, whitch means I don’t have to upload to a cloud to see working result.

I created a little homegrown Model Views Presenter/Controller framework and used StringTemplate as rendering engine.

jQuery is the library of choice to handle all JavaScript.

Page styling was done by a friendly and kind designer from Circa82 Michael Austin (thanks buddy).

Come on guys, give it a try and tell me what you think 😉 Feedback greatlly appriciated. http://www.f1dashboard.com

Cheerios, Greg

Groovy with JDO on Google App Engine, enhancing with DataNucleus

I have some time this days and I’m trying to fly some clouds with Google App Engine (GAE), Now when they have released Java support I can try to use Groovy. Today I tried to implement some simple storage using JDO. GAE team supports some of its features via  DataNucleus. DataNucleus is using a post compilation hook to enhance any persistable classes.

Having Groovy in a lib folder of your war (GAE runs your application from this folder) I need to put asm library as well. Latest version of Groovy (1.6.1) has a dependency on asm library in version 2.2.3. On the other hand DataNucleus enhancer has dependency on asm library in version 3.1.

GAE Java SDK is shipped with Ant task for enhancing persistable classes. It also contains Ant macro definition file that makes it simple for usage. Unfortunately this macro includes all libraries from application lib folder. This is causing Enhancer to use asm library in a version that causes it to fail massively.

[enhance] SEVERE: An error occured for ClassEnhancer "ASM" when trying to call the method "org.datanucleus.enhancer.as
m.ASMClassEnhancer" on class "getClassNameForFileName" : org.objectweb.asm.ClassReader.accept(Lorg/objectweb/asm/ClassVi
sitor;I)V

Number of this error messages is as big as the number of classes in my application.

Solution is to exclude asm library from the macro that Google shipped. Easiest way is to edit, or copy to your local application folder and use it there. The line problematic line of code is in classpath element.

<classpath>
          <pathelement path="${appengine.tools.classpath}"/>
          <pathelement path="@{war}/WEB-INF/classes"/>
          <fileset dir="@{war}/WEB-INF/lib" includes="*.jar">
          </fileset>
</classpath>

The easiest way to fix it is to exclude asm library in fileset element, just like this:

<classpath>
          <pathelement path="${appengine.tools.classpath}"/>
          <pathelement path="@{war}/WEB-INF/classes"/>
          <fileset dir="@{war}/WEB-INF/lib" includes="*.jar" excludes="asm*.jar">
          </fileset>
</classpath>

Hope that helps anyone with similar problem.

Cheers, Greg

Prototypal nature of JavaScript

Hated by many, loved by others. JavaScript is undeniably one of those troubled languages. The fact that it’s implementation and support is not compatible across different web browser makes it even worse and possibly hated by web developers. I would like to look closer into one of the JavaScript features, prototyping.

Some facts

JavaScript is object oriented language. It is “so much” object oriented that even Functions are first-class objects. It could be a surprise for a programmer (like myself) who used to classical object oriented approach, used in Java or C#.

It means that Functions can have properties, another functions, objects etc. Functions could be use to change state of the object or make calculations. They could also be used to create another Functions based on original.

Classes and Prototypes

Classical object oriented language is using types of object, or classes to describe it. In Prototypes one object is describing other, it is almost comparable to cloning.

To make it easier to understand I’d like to use this example:

  1. Using classical approach if I asks someone to make me another Aston Martin, I would be asked to get technical specs for it so it could be build it.
  2. Using prototypal approach if I ask for Ferrari I will be asked to bring one so they can look at it and build it.

I can define my object and if I need another copy of it I just use prototype to get the same one. In JavaScript world it also means that once I got a bunch of objects that have the same prototype, if I add new property to it I will be able to use it in all of them.

All objects have one common prototype that is Object prototype. Prototype for functions is Function prototype. One useful object method to determine if some object’s property is its own or inherited from its prototype is hasOwnProperty method.

Few examples

To create new Object in JavaScript we don’t need to describe it, just create it:

var myObject = { fooProperty: ‘some value’, barProperty: 2 };

Now if we would like another copy of it we could type something like this:

var Tmp = function(){};
Tmp.prototype = myObject;
var newObject = new Tmp();

You might wonder why is this necessary, looks messy and is not clear. Simple construction :

var newObject = {};
newObject.prototype = myObject;

should work. The reason that it is not is because in first line you are creating the object. Once it’s created it’s got Object as prototype its prototype. Adding another prototype to it’s chain of prototypes will not automatically make it inherit all the properties of another prototype.

Adding new property to prototype could be done using this contruction:

var newObject = {};
newObject.prototype.foo = “some text”;
newObject.prototype.bar = function(){
// do something
}

Multiple prototypes, chain of prototypes

It is impossible to define multiple prototypes for an object.

var objectA = { foo: ‘blah’ };
var objectB = { bar: ‘blah two’ };

var Tmp = function(){};
Tmp.prototype = objectA;
Tmp.prototype = objectB;
var newObject = Tmp.new();

In here newObject will only inherit properties of a last assign prototype and it would be objectB.

If you want to inherit multiple prototypes you have to get Function to help you.

function A(){
    this.foo = ‘blah’;
};
function B(){
    this.bar = ‘another blah’;
};
B.prototype = new A();
var c = new B();

Little help from jQuery

jQuery has a method that helps us to extend one object with some properties from another. Here how you can use it:

function A(){
   this.foo = ‘some text’;
}
var anotherObject = { bar: 2 };
$.extend(A.prototype, anotherObject);

 

Cheers, Greg

Verify JavaScript with JSLint during build using Nant

image Project I’m working on has a lot of JavaScript. We are minimizing JavaScript files during the build and combining them into one file. Problem is when someone checks in some invalid JavaScript into repository that doesn’t minify properly. As a result you can end up with not working JavaScript at all. There is a tool called JSLint. It is created by Douglas Crockford who is also the author of a very good book about JavaScript: “JavaScript: The Good Pars”.

JSLint is a very strict JavaScript verifier. JS files corrected to a JSLint specification could be minified with confidence.

We made the decision that build should brake when JSLint detects invalid JavaScript file, so developer will need to fix it before the code checkin.

Prepare the tool base

As a first step we need to get all the tools that will execute JSLint validation against our codebase. You can grab fulljslint.js from the JSLint home page. There is no executable binary for JSLint, it is just a JavaScript file with set of rules and function to execute verification. Our working environment is Windows we can execute validation using cscript.exe command line tool that Windows has. There is a very useful script created by Jason Diamond that helps to execute JSLint validation. You can get it from from here: jslint.wsf. One last thing is a command line batch file that helps execute this tool. You can name it whatever you would like to. I named it jslint.bat. The content of it looks like this:

@cscript //nologo %~dp0\jslint.wsf %*

I put all those three files into build tree, in tools folder. You can check if all the files are valid and working properly by running this command from command line:

jslint.bat c:\path\to\your\js\file.js

Create a build target

Now that we have all the tools we can create a build target. We are using Nant as a build tool. I created Nant target and called it jslint. It looks like this.

<target name="jslint" description="validates JS files">

    <foreach item="File" property="jsfile">

        <in>

            <items>

                <include name="path\to\scripts\folder\**\*.js" />

            </items>

        </in>

        <do>

            <exec program="jslint.bat" commandline="${jsfile}" />

        </do>

    </foreach>

</target>

There is a lot of stuff that could be turned on/off during validation. If you type jslint.bat without any parameters it will give you a list of possible options. Those could as well be tweaked in the jslint.wsf file.

Hope this helps you as it did for us.

Some says that JSLint might hurt your feelings. I say, bring it on 🙂

Gregster

The machine that changed the world

image I heard a lot about Lean software development. By heard a lot I mean that I heard people saying the world, not actually knowing what it really is. Being a very curious man I decided to read about it. Colleague of mine, Jason Yip recommended this book “The Machine That Changed The World: The Story of Lean Production – Toyota’s Secret Weapon in Global Car Wars That Is Revolutionizing World Industry” by James P. Womack, Daniel T. Jones and Daniel Roos. I have to agree, the tile is rather long. It tells a story of Lean Production in a way it was born, in car industry after World War II. I started to read it and decided that I’m going to blog what’s in the chapters that I go through. I hope it will serve me as a notes from the book and as a teaser for anyone else.

Introduction

What I learned in introduction is:

  • a bunch of scientists that meet in MIT decided to collect all the information from all major car manufacturers around the world about every single aspect of car manufacturing
  • team of 65 people were gathering information from all major car manufacturing companies
  • book is based on academic research but presents a dry summary of findings, instead of being a report

Continue reading “The machine that changed the world”

Custom JavaScript KungFu and management for Microsoft MVC.NET

Rails community got a lot things right for web application. One of them is the way they manage JavaScript files. I’m working on a web project where I use a lot of JavaScript and MVC.NET as Web Framework. Team is quite big and JavaScript is getting out of control. Files are everywhere with a lot of code. And then when it goes into production it is the best to have it as one compressed and minified file. So, here what we did.

Where am I, ups, production, I better behave

The easiest possible way of telling the app where it is running will be in Web.config. There is already a bunch of custom setting in there, so why not just have one more. When the time comes based on the Environment information we can decide if we will still spit out single un-minified files for a development environment or serve one minified file for lightning fast production performance.

Continue reading “Custom JavaScript KungFu and management for Microsoft MVC.NET”

MySQL console beep … grrrrrrr

Sitting and doing some evening bed time development is usually not a stressful event. Listening to a calm music and than, in a middle of a chilled out thinking process, awesome, LOUD beep from a PC speaker announcing to my neighbours 10 floors up that I just made a typo when I tried to execute SQL query from mysql console. This awesome feature cased me a heart attack and Wife attack (I got a slap in a head for the attempt of waking my Daughter up).

After a 10 minute relaxation session I decided to put a ripped out speaker back to its original spot in the machine and google for a solution.

It looks like when you are starting the command line MySQL terminal there is a way of disabling the fantastic feature so happily put there by the awesome MySQL team. –b option does it.

C:\projects\>mysql –b –u root –p

Hope you will avoid the little BEEP sound that could wake up dead.

Cheers, Greg