Friday, January 30, 2009

XUL Development using Komod IDE/Editor


XUL Explorer is an XULRunner application that aims to provide an IDE for XUL development.

It provides some useful features -
  1. A variety of XUL "templates" a.k.a. "snippets", which allow you to quickly insert commonly used XUL into your code.
  2. A preview pane which shows you a live preview of what the finished application will look like.
Neat idea! Except that the project is in its infancy and bundles a barely usable editor which renders the whole contraption impractical.

I have a license for Komodo IDE and find it very usable and intuitive. Komodo IDE/Editor is also based on the Mozilla platform and therefore has native support for XUL. What's more, it already includes a live preview option for quickly testing out your changes. So to fill in the missing piece, I set out to port the XUL snippets to Komodo format.

A lot of manual copy paste later - Voila!

It's in the Komodo KPZ format. Downoad, Drag drop into the IDE, Enjoy.

PS: Use the Trigger Macro to enable Textmate style macro functionality for more hacking bliss!


Wednesday, January 28, 2009

Resending meeting invites from Mozilla Lightning


Scenario -

You use Mozilla Thunderbird with the Lightning extension. Someone sends you an email with a meeting invite which you accept and it's added to the lightning calendar. Then you delete that email.

Problem -

You need to invite a third person to that same meeting. You cannot forward the mail (since you deleted it) and there seems to be no way to forward an event from your Lightning calendar.

Solution - 
  1. Right click on the event in Lightning and select "copy".
  2. Open a blank text file and "paste".
  3. Save that file as event.ics or anything else with a .ics extension.
  4. Forward the newly created ICS file as an attachment.
Problem solved!

Note: The ICS file is in the iCalendar format which is supported by a wide variety of software including thunderbird, iCal, and outlook.

Hardware virtualisation

1. Use VMWare Player - Excellent, extremely easy to use and free (as in beer). i386 only.


2. Use QEmu - Excellent, Free (as in speech) and supports a variety of targets.


Use these steps for QEmu installation under Ubuntu (ignore the stuff about Windows, and use the QEmu images available here). Follow the directions for KQEmu to speed up i386 emulation (Alas it does not seem to speed up MIPS emulation).

Use Sourcery G++ for cross compilation with a MIPS target. (Supports Linux and Windows both).

NOTE: QEmu for Windows does not work fine. Ignore!


Friday, January 23, 2009

Free online books on category theory

http://www.cs.le.ac.uk/people/akurz/books.html

All free and available online! I'm going through "J. Adamek, H. Herrlich, G. Strecker: Abstract and Concrete Categories. John Wiley and Sons, 1990"..


Great business resource

Going "up" from the link inside the previous post will get you to this page - http://www.npdbd.umn.edu/deliver/

It's a great resource for information on a variety of business topics.


Elevator Pitch template


Here's a great template for creating an elevator pitch for your next big idea -

(Quoting Verbatim from here till the end of the post)

Elevator Story


Positioning a product requires a pyramid of messages from lengthy proof statements at the base to a product name or logo at the tip. The messages at the top of the pyramid are used to communicate the product essentials when the message receiver has almost no time, e.g. the name of your product on the package when the product sits on a crowded shelf. The messages at the bottom are used when the receiver has more time, for example a venture capitalist reading a business plan.

Just below the top is the elevator story. This is the 2-sentence, 15-second story about your product that you would use if you happened by chance to be in the elevator with a VP or VC who was in a position to fund the next stage of your project and you only had a very short time to get your message out.

For this deliverable, you will create a 2-sentence elevator pitch for your product using the method described in "Crossing the Chasm" by Geoffrey A. Moore. Moore's method is very structured, but surprisingly effective. Please follow exactly for this deliverable.

The essence of the story is to answer five questions: (1) who is the product aimed at? (customer segment), (2) what problem does it solve? (problem), (3) what category of product is it? (category), (4) what/who is the competition? (competition), and (5) what is the key differentiator? (differentiation).

The pitch is set up in this order using the trigger words on the left:

For:Target customers
Who:Need or opportunity or problem
The:Product/Service name
Is A:Product category
That:Key benefits/reason to buy
Unlike:Primary competitive alternative
We:Primary differentiation

Here is an example if we were pitching the new products course to prospective students.

For:engineering and business students
Who:want to become product development leaders
The:New Product Design and Business Development Program
Is A:nine month course
That:takes teams of engineering and business students through a real-life, comprehensive product development process working with a client company to create a working prototype and a comprehensive business plan
Unlike:design courses in the engineering school and marketing courses in the business school
We:offer the opportunity to work on both engineering and business tasks with teams that combine engineering and business students, and the chance to work on a real product that is important to the client company.

Here's what this elevatory story looks like in deliverable form

For engineering and business students who want to become product development 
leaders, the New Product Design and Business Development Program is a nine month course that takes teams of engineering and business students through a real-life, comprehensive product development process working with a client company to create a working prototype and a comprehensive business plan. Unlike design courses in the engineering school and marketing courses in the business school, we offer the opportunity to work on both engineering and business tasks with teams that combine engineering and business students, and the chance to work on a real product that is important to the client company.

Or, here is an example for a consumer product company

For professionals who need access to their information while on the go, Palm Computing is a technology company that provides hand held devices for mobile information access. Unlike laptop computers companies, our products are low-cost, compact and easy to use.

Notes:

  1. The elevator story is two sentences, no more and no less. The start of the second sentence is "Unlike".
  2. The target customers must be specific. For a medical product, there might be separate elevator stories that start, "For hospital purchasing agents...", "For interventional cardiologists...", "For cardiac patients...".
  3. The key benefits and primary differentiators should reflect the key value proposition for the target customer. Put yourself in the customer's head and list what will influence their adopt or purchase decision.
  4. For the last phrase, rather than "we", you may use "our product" or the product name.

Suggestion: Have the company review your elevator story before delivering to class. And, have every person on the team memorize the elevator story.

One person will recite your story in class on the due date.

Thursday, January 22, 2009

Map fusion: Making Haskell 225% faster


Now here's one more super cool thing about GHC that I didn't know -


They are one step better than strongly typed macros, as they safely transform your code while keeping the semantics the same! You have to supply your own invarient transformation rules, of course, but the compiler does the heavy lifting.


(Quoting verbatim in some places -)

Problem - We wish to compose functions which map over trees but this is grossly inefficient -

treeIncr (treeDouble tree)
 where treeIncr   = treeMap (+1)
       treeDouble = treeMap (*2)

The above snippet will basically first duplicate the tree (doubling all the node values), then duplicate the tree again (incrementing all the node values by 1).

Granted that laziness of Haskell will prevent duplication of tree nodes unless absolutely necessary but apparently it will still cause lots of intermediate heap objects to be generated which bog down the GC.

The optimisation of course is to merge the two operations into one i.e. we want something like -

treeDoubleAndAddOne tree
 where treeDoubleAndAddOne = treeMap (\x -> x*2+1)

But this requires manual intervention on the part of the programmer and is difficult to maintain.

Enter RULES PRAGMA!

Enable it by 

{-# OPTIONS_GHC -O -fglasgow-exts -ddump-simpl-stats #-}

This turns on optimization, enables certain GHC-specific extensions, and tells GHC to summarize the work of the optimizer. (Also, we need to make sure that profiling is turned off, because it blocks certain optimizations.)

Then use it!

{-# RULES
   "treeMap/treeMap"  forall f g t.
   treeMap f (treeMap g t) =
     treeMap (f . g) t
#-}

And GHC will perform all such transformations automatically -

treeIncr (treeDouble tree)
-- Inline treeIncr, treeDouble
treeMap (+1) (treeMap (*2) tree)
-- Combine into a single pass
treeMap ((+1) . (*2)) tree

Similarly we can optimise folds -

{-# RULES
  "treeFold/treeMap"  forall f b g t.
  treeFold f b (treeMap g t) =
    treeFold (\l x r -> f l (g x) r) b t
#-}

Problem Solved.

Tuesday, January 20, 2009

"Schlemiel the painter" 's Algorithm


From - http://en.wikipedia.org/wiki/Schlemiel_the_painter's_Algorithm

Indiscriminate quoting follows till the end of this post -

Spolsky used a Yiddish joke to illustrate a certain poor programming practice. In the joke, Schlemiel (also rendered Shlemiel) has a job painting the dotted lines down the middle of a road. Each day, Schlemiel paints less than he painted the day before. When asked how that could possibly be, Schlemiel complains that it is because each day he gets further away from the paint can.

The inefficiency Spolsky was drawing an analogy to was the poor programming practice of repeated concatenation of C-style null terminated character arrays (in general computing parlance known as "strings")— in which the length of the destination string has to be recomputed each time because it is not carried over from a previous concatenation.
Spolsky condemned such inefficiencies as typical for programmers who had not been taught basic programming techniques before they began programming using higher level languages: "Generations of graduates are descending on us and creating Shlemiel The Painter algorithms right and left and they don't even realize it, since they fundamentally have no idea that strings are, at a very deep level, difficult."

Coined in 2001, the term has since becoming part of the vernacular to denote inefficient programming techniques. Spolsky's essays have been cited as examples of good writing "about their insular world in a way that wins the respect of their colleagues and the attention of outsiders."


Haskell GUI + DB

For building cross platform GUI programs on Haskell use Gtk2Hs. (Windows binary available too). Use HDBC for database connectivity. (The FAQ for HDBC details the steps to install Windows SQLite drivers).

PS: I'm not proud to be looking for Windows binaries but sadly I need cross platform capability(including sad OSs like Windows)  with my current project :(

Friday, January 16, 2009

Innovation should lie at the core of all business strategies


An excellent blog entry from the Sun CEO Jonathan Schwartz -

Free Advice for the Litigious...

Years back, Sun was under pressure in the market. Although many users loved our core Solaris operating system, others thought it was built for high end computers, not grid systems. Our computer business had failed to keep pace with the rest of the industry - which meant our volume systems looked expensive. In combination, and with a poor track record of supporting Solaris off of Sun hardware, we gave customers one choice - leave Sun. Many did. Those were the dark days.

Where did they go? They went to GNU/Linux, a free and open source operating system built by a growing community, running on x86 systems. Why? Because the pair ("Linux on a whitebox") delivered, then, better grid performance, with more flexibility. We didn't erect barriers to exit, we promoted customer choice. Even when it cut the wrong way, as it did here. And yes, it hurt.

With business down and customers leaving, we had more than a few choices at our disposal. We were invited by one company to sue the beneficiaries of open source. We declined. We could join another and sue our customers. That seemed suicidal. We were offered the choice to scuttle Solaris, and resell someone else's operating system. We declined. And we were encouraged to innovate by developers and customers who wanted Sun around, who saw the value we delivered through true systems engineering.

So we took that advice. We started by securing the software assets we were building - so that we could convey them under trusted open source licenses to a community we'd just started nurturing. We redoubled our focus on innovation, in hardware and software, that would differentiate our offerings. Not just as good as the competition, but vastly better. We supported Linux on our SPARC systems, and forced ourselves to open up every business we operate - Solaris wasn't the hammer for all nails. Nor was SPARC. Nor Java.

In essence, we decided to innovate, not litigate.

Net result? Our contributions, from Java to OpenOffice to Gnome and Mozilla, now account for in excess of 25% of all lines of code within your average Linux distribution (yup, read that sentence again - or see the report, here, page 51). We joined forces with the likes of Google and IBM and Red Hat to drive the Open Document Format, accelerating document interchange. ODF is now accelerating globally, as the standard trusted by governments and academic institutions for multi-generational document interchange. It is an unstoppable force, no threat can kill a country's drive for independence or self-sufficiency (remember, the network's a social utility, too).

Over the past two years, since committing to build a broad community around OpenSolaris, we've distributed nearly 8 million Solaris licenses, with nearly 70% on HP, Dell and IBM hardware (yes, we were surprised). And we've seen the OpenSolaris community burgeon to roughly 48,000 members, with only 2,000 or so working at Sun. (And I was with a leading company in the blogosphere today who told me they'd moved their core search systems to OpenSolaris - adoption feels like it's accelerating.)

We've seen Java's acceptance made permanent, on servers and desktops and mobile phones and set tops, in no small part due to our decision to use the GPL license (to simplify the Linux/Java combination on consumer devices and industrial applications). And most importantly, we've seen our software business grow - as our revenue model migrated from up front licenses to a subscription model that put payment closer to the source of value (services rendered). Embracing free and open source led to more revenue, too.

We invented our multicore Niagara UltraSPARC systems, massively powerful systems that redefine power efficiency for web-scale businesses - and we have a spectrum of design wins that recover and amplify the business we lost five years ago. Innovation and an embrace of the community (we GPL'd the core design of the chips) have led customers and collaborators to return in droves.

So what's my view on this interview in Fortune - in which one of Sun's business partners claims the open source community is trampling their patent portfolio?

You would be wise to listen to the customers you're threatening to sue - they can leave you, especially if you give them motivation. Remember, they wouldn't be motivated unless your products were somehow missing the mark.

All of which is to say - no amount of fear can stop the rise of free media, or free software (they are the same, after all). The community is vastly more innovative and powerful than a single company. And you will never turn back the clock on elementary school students and developing economies and aid agencies and fledgling universities - or the Fortune 500 - that have found value in the wisdom of the open source community. Open standards and open source software are literally changing the face of the planet - creating opportunity wherever the network can reach.

That's not a genie any litigator I know can put back in a bottle.

New Record! Missed a dozen XKCDs in a row!


I truly have been living under a rock!

I just visited XKCD.com and realised that I have missed.. brace for it.. 12.. Shudder!.. XKCD postings in a row!.. Starting with the gem displayed above..

Never happened before I swear!

Have I been living under a rock for the past few months?


I've been busy with too much office work clearly!

Three major events connected with Web Development that I only today realised took place -

  1. Google App Engine was unveiled in April 2008.. "Run your web apps on Google Infrastructure"! Can you spell "World Domination"?
  2. The latest and greatest jQuery - version 1.3 was released on Jan 14, 2009 (When it turned 3 years old!). It comes with a surgically separated CSS selector engine called Sizzle that can be used independent of jQuery. Software is all about sharing..
  3. Python 3.0 was released in Dec 2008. It breaks backward compatibility. Moves things around that really should not be moved without a strong reason and generally doesn't do as much to improve the language as it should. Worst of both worlds!
Whoa! In college I used to know news before it happened! Don't lose track now man..

Tuesday, January 13, 2009

Untar files in a specific directory


I had to untar the contents of a tarball to a specific directory (not the current one) as a part of a make process for this piece of code I'm writing. Seems easy enough? Not quite. I read through the entire manpage of 'tar' and found nothing. Some searching on the net reveals this as the solution -

tar -C /path/to/dest/dir -xvvf tarball.tar.gz

Note: The -C parameter has to come before the other parameters otherwise it doesn't work!


Sunday, January 11, 2009

Firebird Alternative FREE Database


Firebird.

It's a relatively unknown, free (fully open source) database system that is an offshoot of the Borland Interbase 6.0 source code (which was closed by Borland in 2001). In firebird developers' own words -

Why is Firebird not as popular as MySQL?

As you probably learned, Firebird is more mature, has more features, doesn't cost a dime and sure looks more enterprise ready. How come not so many people have heard about it?


The reasons are simple:

1. Firebird doesn't have a unique commercial entity that drives the development and earns money from it. There are companies, but none of them profit from selling Firebird licenses (as Firebird is completely free). They sell support, but the turnaround is much less.

Therefore, there is nobody to push the money into marketing and create a hype around the project. Similar problem plagues other open source projects like Postgres for example.

2. At the time of web server and web application boom, Firebird wasn't ready to be a web server database backend. As demand for data storage grew, people were demanding something easier and faster than Perl-parsed flat textual files. MySQL was simply in the right place at the right time. Soon, each ISP had PHP and MySQL support and the LAMP platform was conceded. As it often happens, those first on a new market quickly take it over, and it's really hard for others to take that marketshare away. 



Interestingly enough a name clash with this database is the reason Firefox developers renamed their browser from Firebird to Firefox!


Friday, January 09, 2009

Frustration with SSH - "Server refused our key"


Trying to get SSH autologin to work with putty?

This article saved me!

Steps (copied verbatim) -

Try the following:

  • ssh to your server using good old user name and password
  • do check permissions on your ~/.ssh folder and make sure to
    chmod 700 .ssh

    if they are wrong

  • do check permissions on your ~/.ssh/authorized_keys file and make sure to
    chmod 600 authorized_keys

    if they are wrong

  • generate the keys on the server with something like
    ssh-keygen -t dsa

    (or rsa - read the man pages if your don't know how to use ssh-keygen

  • accept the file names it wants to use
  • enter a strong passphrase
  • add the pub key to the authorized_keys file with something like
    cat id_dsa.pub >> .ssh/authorized_keys
  • copy the private key (id_dsa) to your local windows machine (use winscp or sftp or some such tool)
  • NOW open puttygen.exe
  • under actions select "load" and load the id_dsa file
  • enter the passphrase you set when you generated the key on the server. Puttygen will now convert the key to something that putty will understand
  • save that file to something like
    pivatekey.ppk
  • NOW change your putty settings under "connection > SSH > auth" to use
    privatekey.ppk
  • NOW try and connect
  • enter the passphrase when prompted
  • pat yourself on the back. You're connected to the server (I hope)


TODO: Get rid of the passphrase prompts as well using Putty Paegent. Do more research.