Tuesday, December 29, 2009

Install PostgreSQL on Ubuntu with python support

Recently I need it to install PostgreSQL for Django.
Here is how I did it.

$ sudo apt-get install postgresql python-psycopg pgadmin3
Note that pgadmin3 is a graphical app so unless you have Gnome or KDE installed you don't need it.

After you install everything you will need to set postgresql password.
$ sudo passwd postgres
$ su postgres
$ psql template1
Last command will open PostgreSQL shell where you can type:
ALTER USER postgres WITH ENCRYPTED PASSWORD 'password';
Thats all.

You can verify it by going to the python shell and importing it.
$ python
>>> import psycopg
>>> psycopg.apilevel
'2.0'
>>>

If you get this far than everything isup and running.

Sunday, December 27, 2009

Implement - Write a programming language in 3 hours

Yep. You read it right.
Someone told me that its impossible to implement - write a new programming language in less than a day. I said "If I can write it in python and its just has to work... Eg: no error checking or complex operation. I can write one in 3 hours".
He jumped on it VERY quickly. We agreed on all the features: "functions, global variables, local variables, addition, subtraction, print to terminal".

It has to print "Hello World", add 2+2 together and call a function which will do something.
No other restrictions. I can choose the keywords and how I represent my data types.
I did realize that it has to be very naive and super simple. I just wanted to hack something together to prove him wrong. I decided on a mixture of JavaScript and Php. I chose those two because they have a simple construct where I can easily recognize if a variable or a function getting declared or called.

Let me jump to the end of the story... I won the bet :-)
Yes, that's right. It fulfilled all the requirements we set.

In the next few blog posts I will walk you through how I hacked it together.
Stay tuned. 

Please Note!!
Don't expect a Real/True compiler or interpreter or the next big programming language!
I am NOT an expert on that field. I do love parsers/interpreters/compilers and I write simple dns(domain specific language) for work, but I am very far from understanding all the ins and outs of a language design.

Thursday, December 17, 2009

Matrix in your terminal

This has to be the one thing all geeks(inluding me) want to do at some point. Turn your teminal into a Matrix terminal. Folks at commandlinefu.com submitting their own implementation. It's great to see how much you can accomplish with such a small amount of code. Whats even sweeter is that all that is done with tools all ready shippid with every linux or unix machine.

Go over there and try out the code samples or even submit your own.

Here is the link www.commandlinefu.com

Enjoy...

Wednesday, December 16, 2009

Great deals from sitepoint.com

Just came a cross on this the other day on twitter. SitePoint.com decided that they will put together a bundle on every day until Christmas. Every day there is something new, so don't forget to check back if you don't like that day's offer.

Here is the link sale.sitepoint.com

Enjoy...

Synaptic search broken in Ubuntu 9.04

After doing a clean install of Ubuntu 9.04 desktop I fired up synaptic
and to my biggest surprise a quick search for apache2 did not show
any result. Google was bringing up mixed results so I just went strait
ahead to ubuntuforums.org. As always there was a fix listed there.

Here is how to fix it:
Open terminal and type in: sudo update-apt-xapian-index -f
This will force the index to be rebuild.
Now my synaptic works great!

Hope it helps... Good luck