Archive for the ‘Uncategorized’ Category

Install Django on Arvixe

March 31, 2012

Recently I had to spend a few good hours trying to figure out how to install Django on a shared host at Arvixe. I thought I’d document it for others and for my future reference, as I’m sure I’ll forget all this and don’t want to have to re-discover it.

It’s all done in a shell, so if you don’t have shell, you have to request it.

Step 1: Get python 2.7

mkdir temp
cd temp
tar -xzf Python-2.7.2.tgz

Step 2: Compile and install Python

cd Python-2.7.2
make altinstall prefix=~ exec-prefix=~
cd ~/bin
ln -s python2.7 python

Add an alias to your .bashrc
vi .bashrc
add this line: alias python=’~/bin/python’

Login again, and check by running python -V
You should see: Python 2.7.2

Step 3: Install Django

Get DjangoX.X.tar.gz in temp
tar -xzf DjangoX.X.tar.gz
python install

At this point you can check it was installed correctly:
import django

Step 4: Install setuptools (dependency of MySQLdb at step 5)

Download setuptools-0.6c11-py2.7.egg from
Install with:
sh setuptools-0.6c11-py2.7.egg

Step 5: Install MySQLdb (mysql-python)

Download it MySQL-python-1.2.3.tar.gz from
tar -xzf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
python build
python install

Step 6: Create a MySQL via the arvixe cpanel

This will be something like: _

Change the in django:
‘ENGINE’: ‘django.db.backends.mysql’
‘NAME’: _ (e.g. ‘mikep_mysqldb’)
‘USER’: your_arvixe_user,
‘PASSWORD’: your_arvixe_password,
‘HOST’: ”,
‘PORT’: ”

Step 7: Setup the cgi script

I’ve used this cgi script:
Place it in ~/public_html/cgi-bin

cd ~/public_html/cgi-bin

There are 3 lines you have to change:
1: #!/home//bin/python <- this is the new python you've just installed
95: sys.path.append("/home//djangorepo”)
96: os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘djangoapp.settings’

The above assumes that you have installed your django site in djangorepo and your django app is called djangoapp.
In other words, you have something like this:
/home//djangorepo/djangoapp (in this you have,, etc.)

This script needs to be executable! If you don’t have, you’ll get HTTP 500 and you can’t see the Apache error log, so you’ll be stuck.

chmod 755 ~/public_html/cgi-bin/django.cgi

Step 8: Add the .htaccess

Place a file call .htaccess in ~/public_html

AddHandler cgi-script .cgi
RewriteEngine On
RewriteRule ^/(cgi-bin.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /cgi-bin/django.cgi/$1 [QSA,L]

That’s it! Point your browser to your url and enjoy!

Javascript OOP

March 18, 2012

Javascript does not have classes. It’s not an easy concept to grasp if you’re coming from OOP languages like Java, C++, C#, etc. Javascript works with objects.

var obj = {};

That’s an object.

Objects can be manipulated at any time, you can add properties, or functions (methods). = “Object1”;
obj.method = function() { alert(; }

Objects can also be created with the new operator, which is something that might ring a few bells for the Java, C++, etc. developers:

var person = new Person(“Alice”);

Person is a function like the following:

var Person = function(name) { = name;
this.showName = function() { alert(; }

We can create as many persons as we’d like with the method above. One drawback is that the function showName is created every time, even if it doesn’t change. Enter prototype.

Prototype is just an object that every javascript object gets a reference to. If a name (property, method) cannot be resolved in the object, the prototype is also searched. So to avoid the previously mentioned drawback, we can re-write Person like this:

var Person = function(name) { = name;

Person.prototype.showName = function() { alert(; }

You can add any methods like that and they all get inherited by every instance of Person you create with the new operator.

I’m back

March 4, 2012

I haven’t wrriten in more than a year. I’ve been very busy in my new job. I’m mostly working in Python now and doing a bit of Java. On the side, I’m working on a website, a pet project which I’m writing in django with jquery on the client side. I’m planning it as a one page javascript app. The first thing that puzzled me when starting with jquery was this weird $ sign everywhere. What is it?

I was used to $ prepending variable names from shell programming.

I was also used to $ from regular expressions

I was also remembering $ from that sign we’re all chasing up in this rat race.

In turns out there’s no mystery at all. $ is just another function – javascript allows functions names to start with $, _ or letters, but no numbers. So $ is a special function, also known as jquery. $ makes it more succint, especially if you’re trying to minimize the size of your javascript scripts.

A solution – part I

July 21, 2008

The key to solve the problem posted yesterday is to determine how to structure the data such that:

a. the memory footprint

b. speed of search

are acceptable to the user.


From a memory footprint, ideally we would like to store all our data in memory, otherwise the performance will be poor. However, we only need to store the extents in memory in a data structure and then read each number from the file and search the extents data structure. The number of extents is limited to 50 millions. So, just to store extents in memory we’ll need:


2 X 4bytes X 50mil = 400 mil bytes ~ 381 MB


But this is just for the actual data, we’ll also need some meta-data. If we want to keep the data in a linked list or a binary tree, then we need 8 more bytes (assuming a 32bit machine). That doubles the amount to 762 MB. While this is huge amounts of memory to be used by a single process, it is still workable, as most machines have 1-4 GB of RAM these days anyway. Let’s work with the assumption that we can store all the extents in memory.


For the speed of search, as we have a big amount of data to process, it all boils down to the complexity of the algorithm used for the search. Mainly this complexity can be linear, logarithmic or constant (amortized). From the start we eliminate the linear complexity as it is likely to perform extremely poor on large sets of data. That was quickly confirmed during some initial tests where I had to stop the application after a half an hour as I was getting bored.

Eliminating the linear algorithms means that we automatically eliminate the vector or linked lists, as searching through these data structures has linear complexity.

And that leaves us with logarithmic or constant (amortized) complexity algorithms and the data structures that come with that: balanced binary trees and hash tables respectively. We would prefer hash tables if possible as they perform better than balanced binary trees, but binary trees still offer acceptable performance.


The challenge now is how to translate the set of extents into either one of these data structures so that a search on these data structures will give us the answer that we’re looking for: how many extents contain this number?

working for a bank

June 28, 2008

This year I’ve started a new job within the financial industry, for a major investment bank. Is the IT any different in a bank as opposed to the “real world”?

Well, although it’s a bit early perhaps to form an expert opinion on this, I can say I have noticed important differences.


In a bank, IT is support. That doesn’t mean necessarily being on the phone and helping traders use the software, it means the IT is there just to support the business. Nothing more. If the business discovers one day that it can do without IT, that’s it.

Banks are very pragmatic entities. In the good time, they grow and pay big bonuses. But in the bad times, they’re among the first to slash jobs. They have to be flexible, they’re in the services industry, they have to keep the fix cost down. Due to the ongoing credit crunch, a lot of banks have put a lot of people on the streets. Fortunately not too many in IT, but banks are known to be merciless, so if the situation gets worse, who knows what’s going to happen…

But job security is more of a concern in the financial industry than in “common” IT. If you’re looking for job security, then maybe financial IT is not for you. But it’s something you get used to, as everything else I suppose.


Because the IT is only there to support the business, it needs to be more flexible and the turnaround needs to be much quicker than in “common” IT. The “business” generally perceives the IT within the bank as very slow. They want new features yesterday all the time. If they can do it in Excel, they will do it themselves.


As such, demands for quick turnaround put pressure on the quality of the product. The IT products within the financial community are not fantastic. They’re mediocre, but they only need to get the job done, not to win awards. There’s not much time set aside for fixing code and you can find rotten code in many areas but as long as it works, why fix it. That’s the attitude.


Flexibility is key. That’s because the traders change their minds a lot. And especially with the credit crunch, a lot of things need to be reinvented. Strategies that used to work before, don’t work anymore. But also traders are not the most patient people. For them is all about the money and bonuses, so they can’t understand why IT are so slow in delivering what they need. That’s why most of them stick to Excel, because they can do a lot of stuff themselves.


Salaries are much better in banking than in common IT. And there’s always the bonus. People work more, better and they appear to care more because they’re always thinking about the bonus at the end of the year. Schedules are made so that they deliver before the bonus period, even if the product might need a bit more TLC before deployment.

So expect to work harder for better salaries and bonuses.

At the same time, it’s an opportunity to learn more about technology. The more you work, the more you learn, isn’t it?


Technology is generally lagging behind in banks. Banks are late adopters, very conservative people. So don’t expect to be on the cutting edge of the technology. But it’s not very bad either. A positive spin would be to say you only work with mature technologies.

Symbian is dead, long live Symbian

June 24, 2008

This is the news that tipped me into starting this blog:

The inevitable has happened. Nokia finally swallowed Symbian. They bought almost a controlling stake in Symbian when I was still working for Symbian, 4-5 years ago. Back in those days, Nokia was becoming more and more tighly coupled with Symbian. Nokia was Symbian’s biggest licensee, biggest customer, selling the majority of Symbian powered devices.

But there was one problem. Symbian was own by a consortium of licensees/customers. And the more Nokia was selling, the more unsettling the rest of the customers. The no-brainer: “You can’t differentiate if you’re using the same stuff as your competitors.”. And Symbian’s owners were all competing with each other.

Among the first to bail out was Motorola. They were betting on Linux and some Windows Mobile. In the end, Nokia and Sony Ericsson were the main licensees/customers and that’s because they’ve already made huge investments in the UIs: S60/S90 and UIQ.
NTT Docomo and Fujitsu were however big success stories for Symbian in Japan. And they will still continue to be.

Back when I use to work for Symbian, there was a close cooperation between Nokia and Symbian, although the communication wasn’t very good and Nokia was seen by the symbianites as a very pragmatic customer, sometimes unreasonable in its desire to cut corners for the benefits of more sales and time to market, and in some cases even canibalising the platform for its own purposes.
Nokia was really the only main driver in terms of requirements. And they were paying dosh for that.

There’s a sense of inevitability about the whole thing.

Personally I will follow the development of this with interest as I’m curious:
1. how many people will be made redundant (as Symbian and Nokia have many potential synergies in their operations
2. how will Nokia make any money by open sourcing the OS (probably they won’t)
3. how many licensees/customers will drop Symbian (Sony Ericsson already seems to be firing half of its UIQ team – sad really)
4. how will Symbian compete with the iPhone and Google’s Android, the latter being no doubt the cause of all this (Google is planning to give the Android for free and make it open source)
5. how the whole open-source model work
6. how has the code change since I’ve left 😉


In the beginning…

June 24, 2008

Not many things to say in the first post. I have been thinking for a while to start write a technical blog. But I’ve always given up, not seeing myself writing for too long before chucking it.
But an event today finally convinced me to start writing…