Med fokus på din virksomheds forretningsgange watermark with eaktion circles

Templating with Smarty for Ajax Enabled Applications

August 18th, 2011

JavaScript is the future

The future is pretty clear to me, JavaScript will be the one and only on the web.
And I mean both on the client side and the server side. Am I going crazy?
Just wait for node.js to be ready for prime time and let the YUI Library be finished with the application framework, then we start talking.

However, while we wait for the day of the grand merging of technologies, we still have to do some work and keep the code nicely organized. Smarty helps me to do that. I use Smarty templates to separate code from presentation and (among other things) Smarty plugins to organize my code.

In the meanwhile, get YUI and AJAX to work nicely with Smarty and PHP

When I started using Ajax it was with the help of Xajax. What I like of Xajax is that it allows me to target a single function right from the client code, and to control the JavaScript code from inside the PHP code. A pretty fine grained 2-way communication.

Now that I use YUI more and more, I wanted to get rid of the duplication of JavaScript code that is caused by having to load both the Xajax and the YUI JavaScript libraries. Anyone serious about JavaScript would have no doubt, I had to say goodbye to Xajax.

However, YUI is naturally slanted to the JavaScript side. With YUI you produce modules and stuff that encapsulate XHR transactions, and you pass a url to the transaction. On the server side you’re on your own for how to organize your code in a manageable way.

Manageable to me means among other things that:

  • I can include my php files from wherever I want, especially from outside my server root
  • I can have a one-to-one relationship between the page I’m showing to the user and the code that supports it
  • I don’t need to create extra urls just to pull in responses to my JavaScript code
  • I don’t have to reinvent a new set of conventions each time I write some JavaScript code

These are the things I felt YUI was making difficult to me.

To make up for this I’ve developed a set of two modules: inlineXHR(php), a lightweight PHP module, that works together with inlineXHR, a lightweight JavaScript module for YUI 3. With the two inlineXHR modules, I have re-established a fine grained 2-way communication between my PHP code on the server side and my JavaScript code on the client.

Now I can again target directly from JavaScript, PHP functions, class methods and Smarty plugins. All AJAX / JSON stuff is taken care of once and for all, the cursor is spinning when it has to, errors are logged to console or popped up in alerts, and I can write PHP code without even thinking about the fact that the output has to be sent through the wire, as JSON.

If you use YUI and PHP, and you too think that life is too nice to use time reinventing the wheel each time a JS code need to talk to your server, you might want to give it a try. It’s free, open source and BSD licensed.

Click to see usage instructions and working examples

Upgrading from Debian Lenny to Squeeze (version 6)

June 6th, 2011

You want to update to Debian Squeeze from Lenny. You don’t want to scour the whole Debian documentation just to be sure not to have overlooked details that apply to your situation. Here is a complete step-by-step tutorial for upgrading to Squeeze from Debian Lenny.

In 4 steps is listed here the procedure we’ll follow. There are quicker, more risky, procedures, however the time saved doing otherwise is count in seconds, who bothers.

  1. minimal system upgrade, followed by
  2. a kernel upgrade, udev upgrade and reboot, and then
  3. (optionally) upgrade the packages associated with your critical services.
  4. full upgrade

I spell out here all the preconditions that apply for this condensed but complete step-by-step tutorial for upgrading from Debian Lenny to Squeeze. You can easily find out if this is for you or not. For web developers that use Debian as a testing/production machine this will apply in 95% of all cases.

If you don’t meet all preconditions you’ll have to go read the full documentation.

Our Goal

The goal is to be able to update from a remote terminal with as little disruption and as few risks as possible, by risks meaning the need to resort to a local console to fix problems. However no guarantees are given. None at all. The only guarantee I can give, is that I have tried the upgrade myself on 3 different Debian boxes. On one it failed because I followed a different, shorter, recipe. Two were successful following this one.

Preconditions for the Upgrade

Your Debian Lenny is a pure command line installation (no GUI, that is, x-server and more). You are running some servers and other stuff, but you don’t have external users logging in their own /home directory to care of.

You have a Debian Lenny (version 5) that is up to date to the last update point. Otherwise

aptitude update

aptitude full-upgrade

should resolve any issues. Verify with

dpkg -l | pager

no packages should have a combination of h and fh as the first 2 flags in the output.

it might be bad if you have any other combination of letters. Here is an excerpt of mine.

ii  apt-utils    APT utility programs
ii  aptitude  terminal-based package ...
rc  aspell-en     6.0-0-5.1                  English dictionary for G...

ii is OK, rc is OK

From here on we’ll use Apt instead of Aptitude (it is officially recommended for a Lenny to Squeeze upgrade)

Other preconditions to “qualify” for blindly following this step-by-step recipe:

You don’t have third party packages (from repositories other than the official Debian Lenny repositories), if you do, remove them prior the upgrade and treat their upgrade independently.

“If you are using some VPN services (such as tinc) they might not be available throughout the upgrade process”

“You should not upgrade using telnet, rlogin, rsh”, you might loose connection, use ssh instead.”

“If you have configured APT to install certain packages from a distribution other than stable (e.g. from testing), you may have to change your APT pinning configuration. In this case you want to read the whole document on Debian org.

Let’s start

1 Minimal System Upgrade

Take a backup of

  • all /etc
  • the file ./curr-pkgs.txt after having done: dpkg --get-selections "*" > ./curr-pkgs.txt
  • /var/lib/dpkg
  • /var/lib/apt/extended_states
  • /var/lib/aptitude/pkgstates
  • Any other files you care of (DB, web files, /home files etc.)

Do evaluate ”what if” in case you should be forced to reboot from the console terminal and the off/on button on your box.

If things go wrong this is the link you need.

Start doing your upgrade.

Change the sources to squeeze:

less /etc/apt/sources.list

Substitute any occurrence of lenny with squeeze. Don’t use stable, to avoid getting into troubles at the next version upgrade, write squeeze. Codenames are unique, category names are not.

Also remove sources for debian-volatile that are no longer used. Be sure to have all of main, contrib and non-free (for network cards firmware)

Here are my sources :

deb squeeze main contrib non-free
deb-src squeeze main contrib non-free

deb squeeze/updates main contrib non-free
deb-src squeeze/updates main contrib non-free

deb squeeze-updates main contrib non-free
deb-src squeeze-updates main contrib non-free

Record your upgrade session with

script -t 2>~/upgrade-squeeze1.time -a ~/upgrade-squeeze1.script

When finishd you’ll stop recording typing: ”exit” Timing info is in the .time file, you can see all what happened and console messages reading the .script file.

Now enter:

apt-get update
apt-get upgrade

(we’re only doing a minimal upgrade now)

You might need to open an extra terminal during the upgrade to examine some situations as to be able to reply to questions posed to you by the upgrade process. To do so type

Alt-right arrow.

2. Upgrade Kernel and Udev

Upgrade the kernel
Start by finding a suitable linux kernel image

apt-cache search linux-image-2.6.

And choose one that suits your architecture and is equal or older to linux-image-2.6.26-2

apt-get install linux-image-2.6-<your flavor>

Although you had non-free among your sources you might end up into the following situation, due to bad handling of firmwares by the installer:

W: Possible missing firmware /lib/firmware/tigon/tg3_tso5.bin for module tg3
W: Possible missing firmware /lib/firmware/tigon/tg3_tso.bin for module tg3
W: Possible missing firmware /lib/firmware/tigon/tg3.bin for module tg3

In this case install manually the nonfree firmware package:

apt-get install firmware-linux-nonfree

And you google about it to be reassured that you’ll have the correct driver installed anyway.

In another case I got the corresponding message for another driver:

This system is currently running Linux 2.6.26-2-686 and you are installing Linux 2.6.32-5-686.
In the new version some of the drivers used on this system may require additional firmware files:
r8169: rtl_nic/rtl8168d-2.fw, rtl_nic/rtl8168d-1.fw

choose not to do anything, however I ended up anyway with a well functioning Debian, go figure it!

Install the new version of udev

apt-get install udev

stop the script recording by entering ”exit”
Reboot the system.

Restart recording in a different filename with

script -t 2>~/upgrade-squeeze2.time -a ~/upgrade-squeeze2.script

3. Optionally Upgrade Your Critical Packages

For extra control, on a production machine, upgrade some individual packages by their own.

apt-get dist-upgrade <package-name>

Go on doing the full upgrade

4. Complete the Upgrade

apt-get dist-upgrade

Do the various configuration as asked during the process, if you choose to upgrade to the configuration  (which is recommended) you can always retrieve the old configuration in the .dpkg-old version of your config files.

Enjoy your new Debian.

The Risk Of “Don’t Make Me Think”

April 22nd, 2011

Or, when the knowledge should be in the box, that you call your company

We have (almost) all heard about the Amazon cloud outage at the North Virginia data center, and for sure we have been hearing many bloggers’ thoughts about it. Here is my take at it.

Disclaimer: all what I write doesn’t aspire to a general validity, it only tries to have a very special validity for my own approach to producing web applications and IT services, and at being an entrepreneur in general. The current hyperspace event is a very good opportunity to double check the concept of ”Don’t make me think”.

As Leon Katsnelson writes, this outage has shown how many companies use cloud computing. The question to me is not whether this is a good or a bad thing, or whether they should have bought a different sevice from Amazon, the question to me is more whether they are at all aware of it.

Cloud computing as a business model has taken some knowledge out of the companies and has collected it inside the service itself. Cloud computing has taken on because of the “don’t make me think” drive.  Together with  the knowledge, what has been thrown out of the companies, are also a lot worries and that is what  companies pay for, they pay to be able to think about something else than computing.

This is all right and well, in the end “Don’t make me think” is what all businesses sell in a way or the other. However some business should rather re-think what their core business is.

I by pure chance know of at least one company that has been down due to this outage, and whose very business is selling backup services. And they not only sell to final customers, they sell to resellers. This means that many, and many companies, whose business, among other things, is selling continual availability of data, have been down for over 24 hours, and without having any chance to do anything about it, for themselves or for their customers.

The lesson: when you sell “Don’t make me think” it should be based on your own knowledge of what’s in the box. If you sell a box that you bought from someone else that bought it from someone else that … you got it, then you not only take the thinking out of the equation, but also the responsibility, and that’s overselling.

Differently from Leon Katsnelson, I think that there are other options than buying cloud computing from Amazon, whether it is with a silver lining or not: one is to build your own cloud, the technology is readily available and if your business is backup services, the knowledge too should be in your own box.

You won’t fund my startup? I give you a free software tool!

March 30th, 2011

On the onStartup Linked In group someone posted what boils down to the question “what do you do when you realize that no VC would finance your startup”. Among the many “combat” answers, there was one that I picked up as the path I would follow in such case.

Some months later I have in fact been contacting some VCs and I’ve got a bunch of negative replies, directly or indirectly. I have understood the arguments and made some realizations. So I got back to that one answer and now I’m going to  follow that path.

  1. Why did they turn me down
  2. What did I understand and
  3. What is the path I will follow,

you’ll ask? Well here it comes, but first comes the answer to another fundamental question:

0. Why did I spoke to VCs in the first place?

0. To try and get funds of course, but also and most importantly to come out of my comfort zone, to stop coding and start thinking, that is, to start relating to reality as it presents itself on the market place, VCs being a part of the market.

This means that I used VCs more like sparring partners than possible sources of funds. Of course, if they would have chosen my startup to invest in, that would have been an added bonus, however not getting funded has not been a complete failure at all.

Question 1. Why did they turn me down?

To make it short, among the different reasons they gave me, the fundamental one is that I’m out too early, the project is untested with real people so as things stand now, although lots of proof of concepts has been done on the critical technical aspects, the whole thing  to them is not much more than pies in the sky. (Other untold reasons deserve their own post, stay tuned for more).

Question 2. What did I get out of this exercise (speaking to VCs)

The fundamental result of doing this is that I had to prepare myself for speaking, that is I had to speak out my ideas, so people understand them. I saw the reactions on their faces when I spoke, I heard the arguments used to test my ideas. Still more important: I heard the many people I spoke with to prepare for speaking to the VCs. Further, each VC  wants you to present your idea in a different way, someone wants you to make an “odd presentation” that shows whether you’re able to stand out of the crowd, others want a 3 minutes pitch, others again want to see your exec summary first, while some wants to see the whole business plan, before engaging in any discussion.

Staying in good shape

This alone got me at work to refine my ideas and plans to make them viewable from all these different angles. It compelled me to cut down the fat and get to the essence of what is the product, what makes this different from others, what will make it or brake it.

It’s a heck of a lot of work to be doing for getting nothing, isn’t it? Yes, It ‘s a lot of work but not for getting nothing. What I got is very important. And I’m still glad I did this “too early”. The real outcome of this exercise is the cutting down, so that the shape of my business proposition is clear and explicable to many different people. Guys that not just listen politely to you, but that are there to question you and to doubt your skills and plans because they themselves have something at stake.

When you prepare to really try and convince such people your mindset changes. It is a big step closer to reality. Of course, as it is said, the biggest step is making the first person to open the wallet and pass over some money to you.  However, when that happens, you will want to know exactly why.  For an IT entrepreneur the exercise of speaking to possible investors is a more involving test than just putting up some functionality with a link to a payment gateway.

“No I don’t like coding

The irony of this is that  one VC told me, “why do you do this, because you like coding, don’t you?” Well it was just a test from him, because he meets so many “business people”, programmers that put up a system because they like coding and they like what they code, no matter if this is what the market likes, and it would be lovely if someone would pay you for doing what you like instead of the other way around. And no, that was not the case, however he was still not so happy to hear that, “no, I don’t like coding for the sake of it, as a matter of fact I haven’t coded anything at all yet”. In the end he wanted to try the system out with some would be customers, while in the end I wanted to try my ideas out with him.

What now?

Now the one path to follow, remember? the answer I picked up on the group forum. The path is to think an MVP,  a Minimum Viable Product, cut down on dreams, functionality and – most important – time and cost, and bootstrap the whole thing, i.e. just doing by myself. This is what I’m working at now. The technical/design principles however are the same as I told you last time. As a demonstration of that I want to give you the promised goody, that is a preview and a tool that follows those same principles, having some elements of the described principles 2 – 4. For you that don’t bother reading the last post these are:

2. Don’t make me think
3. Software as candies
4. The fun theory

A free software tool

I will use this tool myself to wrap in my webapplication the day it will hit the market (keep your breath, it’s within view). You can use it too if you are skilled enough to understand how to bring it to good use. NB! It is not for everything or for everybody.

The tool is a 3 panes Split Desktop. You find it on its project page with detailed explanation for how to install and use it.

I would love to hear from you, either here on this blog or on the YUI Library forum for the SplitDesktop

See you soon, Paolo Nesti Poggi

5 Ingredients That Will Change Your Life

January 29th, 2011

I told you in my last blog that I will change your life with my new startup, but I’m still not prepared to reveal my business proposition. However, what I can tell you right now is, which ingredients will make my business a success. Indeed these ingredients are those making the success of many other endeavors, so it’s just a matter of grabbing them, mixing up, adding salt and pepper and consume, right? Well, I hope you will tell me what your angle on this is. Here is mine.

The ingredients are:

1. Give me the dream of a different world
2. Don’t make me think
3. Software as candies
4. The fun theory
5. The choice of tools is key to success or failure

1. Give me the dream of a different world

Let’s start with a thought experiment. Let’s take some undisputed great successes: Apple, B&O (well, I’m writing from Denmark) and Harry Potter.
We can put these 3 to a test to try and extract which characteristics have determined their outcome. The test is to think whether a, let’s say standard, business proposition, would be able to convey the chances of success that we now know the three businesses have experienced. So: How would an honest business proposition for each of these three endeavors have been?
  • “Computers and handheld devices with superior performance and usability. A distinctive design”, for Apple.
  • “TV, radio and sound equipment with superior finish, total integration, a conservative touch”, for B&O
  • “A fantasy series, telling the story of three magical friends during their stay at a wizard school. The reader follows the story of three friends while they overcome all adversities in a caleidoscopic world of witches, wizards, villains, supernatural forces and strong family and friendship relationships”, for Harry Potter.
It is clear that no one would bet a dime on such business propositions. And why not? No one would, because these statements can be applied to thousands of other similar companies and literature works, that are the living proof of the fact, that such business propositions are not describing something able to strike a chord with so many people as it is the case for our three champions.
It is possible that Apple is now defining what superior design is, however the opposite is by no means the case. What is superior design?  A mouse with one button? What is finish, a telephone that weighs 200 grams more than necessary? What is an irresistible fantasy world? A school? We could of course go on and on, the point however is that no single element in these projects is the joker that made it, or the single answer to a specific need, neither the key to success is to be found in a description of what these projects are by and in themselves.
No, my thesis is that the success comes from the promise of a different world and from providing the stepping stones, each leading towards the realization of that same promise, and each being reaffirmation of that promise.
A world where we are free from some of the laces that binds us in the current one. It is the realisation of the fact that when I dream at night I dream of flying, I don’t dream of a cheap intercontinental ticket.
Acknowledging and reproducing this, will have to be my first ingredient.

2. Don’t Make Me Think (or the Ego Wow)

Of course Don’t Make Me Think is the title of a great book on how to design websites, but the statement encompasses in general another of the traits of what makes a winning product and not only a winning web design.
In some sense it might seem counterintuitive, because one could argue that people want to think, because they want to be creative. And yet people want to make their own thoughts, actually people love to be able to produce more thoughts and be more productive, and reach more of their goals… with less effort.
This means that each additional thought that doesn’t spring from their own mind is a barrier put in the way towards their goals. In this sense, “don’t make me think” is at the root of every person’s choice, it means: “give me the tools to reach my own goals without having to think about the how”. “I don’t mind having many goals as far as these are mine and well within reach”.
As we see, this ingredient is complementary to the above: the one is the promise of a different world, and the other is the how to reach it with no effort or, more correctly and in a more fundamental way, with less effort that it seemed possible. In the end, it is a “wow effect” applied to personal performance. It is about nourishing the little child in us shouting “Mom, look what I’m capable of!”.
“Don’t make me think” will have to be the second ingredient offered to my customers.

3. Software as candies

At this point I think I must reveal at least that my startup has much to do with software, computers, the Web and all the rest (you had guessed it anyway, hadn’t you?). And speaking of software, at some point I came across a concept that I think stems from Joel Spolsky’s blog. Nonetheless I cannot find it with a search on the site, so maybe I’m wrong (can you point me to the right article, by the way?). The idea, as far as I remember, was to architect software as an experience for the user that consists of a chain of small candies, that one by one will attract the user and reveal the entire package. The goal of this approach is to not overwhelm the user with too much information and/or functionality all at a time and elicit some pleasure for the discovery.
Ideally, one should present the user with the right information only at the right time. The right time being not simply when the user needs it, but more effectively when the user is in the mood, the position, the ability, the right circumstances to explore more, even if it is just for the pleasure of it. This is of course easier said than done; however, it is a good principle to keep in mind, and combine with other very good principles like Less is more and Murder your Darlings.
This will have to be the glue that keeps all the other elements together, my third ingredient.

4. The fun theory

No trace of  “software as candies” was to be found on Joel Spolsky’s blog, however I found another article that leads me to the next ingredient bound to make my “recipe” a resounding success. In his “What Is Great Design (first draft)”  JS writes about conflicting constraints, the author brings the design of a dustbin as an example and concludes his analysis of requirements writing: “Ok, light, heavy, big, and small. What else. It should be closed on the top, so rubbish doesn’t fly away in the wind. It should be open on the top, so it’s easy to throw things away. It should be really, really, really cheap.“A paradoxical example which by itself is very enlightening, however these conflicting constraints and solving them is “only” the part that I as a software developer must solve, and my work will possibly be OK: never great, hopefully not lousy, probably something that by it’s nature will always have some flaws.
So, how can I even think of producing a great business success based on software, knowing that shortcomings is the name of the game? Well, as it is shown by this other dustbin, the secret is to let people forget about the flaws, by creating enthusiasm or fun, this is the fun theory. This ingredient will have to be used sparingly and only after due consideration of the context.

Closing remarks

This post is long enough so I will close it here and leave the last ingredient for a next post. But if you at this point still feel like reading more words, I can point you to a place where you can find as many as you wish and you can choose too.
It is clear to me that the 4 principles – and some subprinciples – mentioned above, are all descending from or necessary to fulfill the first one: The ability to suggest/evocate a whole world where things are different, easier, and where the me in the picture is a more capable person. Not simply able to exploit this or that particular feature, but more empowered, able to do more with less, and confident that, if ever in need, a loving Hermione will come to the rescue.
Many more than 4 or 5 are the ingredients that make up a business, however these seem to me absolutely required if a business is to be making an impact on the life of people.  What do you think?