Wednesday, June 3, 2009

Mercurial on code.google

I played with mercurial on code.google.. Here are some simple instructions

a. Create the project in the interface
b. Create a local repository

hg clone https://USERNAME@PROJECT.googlecode.com/hg PROJECTDIR

When it prompts for a password, key-in the password available on
http://code.google.com/hosting/settings (Profile > Settings)

I created trunk directory and stored all the code.. (to allow branching).. This probably not mercurial way and is svnish..

c. I prefer to edit wiki through mercurial..

hg clone https://wiki.PROJECT.googlecode.com/hg wiki-PROJECTDIR

Tuesday, March 17, 2009

"reset is not a function" - Firebug error

I am a newbee to javascripting and I was stuck at reseting a form to default values for 2 full days..


Firebug kept saying
$("#addpropertyForm")[0].reset is not a function

Turned out that I had named the reset button as reset...!!
input type="reset" name="reset".....

Friday, March 13, 2009

Django serialization - Deserialization

I have a table
desc property;
+--------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+----------------+
| property_id | int(11) | NO | PRI | NULL | auto_increment |
| property_name | varchar(30) | NO | | NULL | |
| property_address_1 | varchar(120) | NO | | NULL | |
| property_address_2 | varchar(120) | YES | | NULL | |
| property_city | varchar(30) | NO | | NULL | |
| property_state | varchar(30) | NO | | NULL | |
| property_pincode | int(7) | NO | | NULL | |
| property_country | varchar(30) | NO | | NULL | |
| property_user_id | int(11) | NO | MUL | NULL | |
| property_price | int(20) | NO | | NULL | |
+--------------------+--------------+------+-----+---------+----------------+

Serialize

python manage.py shell
Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49)
>>> from users.models import Property
>>> from django.core import serializers

>>> json = serializers.serialize("json", Property.objects.filter(pk=2)
>>> print json
[{"pk": 1, "model": "users.property", "fields": {"property_user_id": 1, "property_state": "aa", "property_country": "aa", "property_pincode": 323, "property_city": "aa", "property_price": 1, "property_address_1": "aa", "property_name": "aa", "property_address_2": "aa"}}]



Deserialize
>>> json = '[{"pk": 2, "model": "users.property", "fields": {"property_user_id": 2, "property_state": "aa", "property_country": "aa", "property_pincode": 323, "property_city": "aa", "property_price": 1, "property_address_1": "aa", "property_name": "aa", "property_address_2": "aa"}}]'

>>> for obj in serializers.deserialize("json", json):
... obj.save()


I finally dint use it because I dint know how to convert a UTF encoded dictionary to string.. shame on me..!!

Wednesday, March 11, 2009

foreign key across different mysql engines

I had a pre existing table(MYISAM) and I was creating new table innodb.
Dint realize for a long time that you cant have a foreign key relationship across 2 tables of different engines.
Error that you would see are

mysql> alter table property add (FOREIGN KEY(id) REFERENCES AUTH_USER(id));
ERROR 1005 (HY000): Can't create table 'sportland.#sql-134d_a' (errno: 150)
mysql> show engine innodb status;
------------------------
LATEST FOREIGN KEY ERROR
------------------------
090311 15:36:27 Error in foreign key constraint of table sportland/#sql-134d_a:
FOREIGN KEY(id) REFERENCES AUTH_USER(id)):
Cannot resolve table name close to:
(id))

took me sometime to figure out the issue..!!

Saturday, March 22, 2008

Qemu and Debian

After a few hiccups, I had a new debian machine running on Qemu in my Ubuntu Gutsy machine

1. sudo apt-get install qemu
2. wget http://cdimage.debian.org/debian-cd/4.0_r3/i386/iso-cd/debian-40r3-i386-CD-1.iso
Ensure the md5 check sum matches with the site(md5sum debian-40r3-i386-CD-1.iso of the file should match what is there on the server). This would save a lot of trouble. Don't skip it.
3. Create the image file
dd if=/dev/zero of=rootfile bs=1M count=2048
4. qemu -cdrom debian-40r3-i386-CD-1.iso -hda rootfile -net user -net nic -boot d
Install only the base system if you want to save time
5. If you complete the above step... Voila you can now boot into your brand new debian machine
qemu -hda rootfile -net user -net nic
Boot into it and get excited about seeing the shell prompt.

No wonder I soooooo love debian..

Saturday, March 15, 2008

New kubuntu system..

Here is something I have to brag out. I scrapped the default (only prescribed) OS on my office laptop and installed Kubuntu- gutsy... What a relief..

Must haves in no particular order
1. Amarok
2. Firefox
3. Compiz
4. Pidgin
5. KNetworkManager
6. Ktorrent (Yes in office laptop.. cant live without it..)
7. Kontact
8. AventailLinuxconnect..


Voila.. I am up and running (Running.. no flying high)...

Life has never been better..
apt-get... never ending list..

Wednesday, March 12, 2008

Torn between C and Java

I started my career 3 years back.. Fresh out of college, I stepped into the wonderful world of C and Linux with a great mentor. I dint realise how lucky I am. I have thrown all that away for a few more bucks and great company name. Tomorrow I shall be committing the sin of opening an Eclipse for the first time. Shame on me...