So I have change my job, which is interesting in many levels.
For one it is one of the very few python development shop in malaysia, which uses a open source stack. It is the first time I involve in a enterprise development in coding side. And probably need to get used to a structured environment unlike the web startup i involved not too long ago.
First thought is, I probably need to know more of django, because they uses stuff that I didn't use before, the web startup i involve switch to a nosql store because of flexibility. The company project using django south, and uses part of django that I didn't use before. But than django can be big....
So I think that would be a interesting experience........
this is a place where i put my thought of technology and things that i do.
Saturday, May 22, 2010
Tuesday, May 11, 2010
get the correct datetime value for python datetime module
UPDATE: Turn out that i did it in django shell, which, set the time to chicago, which make the time wrong in my system, the information here is right, except on the datetime.now() error. in normal python shell, or apps, datetime.now() should show the correct datetime. but on django, we need to setup the timezone
So I have to use datetime in this project. the more I use it I realized that it can bite, unless used properly.
So I have to use datetime in this project. the more I use it I realized that it can bite, unless used properly.
Let start with a simple example, start with
from datetime import datetime
from the doc, datetime.now() show today date and time.
the time i tested the line is 12:47 on 12 may 2010.
>>> datetime.now()
datetime.datetime(2010, 5, 11, 23, 46, 50, 383091)
Notice that the day and the date, is wrong. you should try it to see it yourself. Not wrong but unexpected
Run
>>> datetime.utcnow()
datetime.datetime(2010, 5, 12, 4, 56, 13, 315120)
better, but in utc time. That is in 12:56 pm on 12 may 2010
The way to solve it is to implement tzinfo class, which I didn't do, or we can use pytz
Which does it for us anyway. Run the following in the shell
import pytz
mytz = pytz.timezone('Asia/Kuala_Lumpur')
datetime.now(mytz)
after setting up the timezone with the right tzinfo. datetime.now() should show the correct datetime.
Note to self, python datetime can bite us,
Friday, April 30, 2010
arduino's from #hackerspacekl open hardward ftw
So today I go to hackerspacekl which is a awesome place. One of their project now involving arduino. And they making their own. For the rest, I allow the pictures to do the talking. Check the links too
off the shelve components, from pasar rd
prepare acids, for etching,
schematic from arduino websites
now you etch it, before that you need a laser printer
after that based on schematics, solder it
now you get a arduino
Components RM55, Solder with own hand free. Having a hackable hardware, priceless
Sunday, April 25, 2010
android, foss and geeks @ #barcampkl 2010
BarcampKL 2010 just ended yesterday. It is a pretty awesome with many geeky talk, me as a geek, like it.
Yesterdays BarcampKL feature a few first in BarcampKL,
- we have the first podcast of This Week In Asia, and it is pretty awesome, it is something of a talk show with audience, now transmitted to cyberspace thanks to p1 wimax(aka the sponsor of BarcampKL)
- First time in barcampkl, we voted for talk. Where everywhere else, it is there already. And interestingly it serve as a check and balance of the talk. So we ends up with pretty interesting talk
- For the first time, I've seen Jedi vs Ninja.... What really happens is, KageSenshi was in the room where somebody brought a Light Saber, and kagesenshi teaching some sword fighting technique. and the other guys, practice their light saber skills. lolz
What is notable for barcampKL,
- Android hacks, member of Code Android malaysia, showing a android controlled robot, using a g1 and arduino. With python. No worry, the robot is benign, it still not a rival of the Governator.
- Time management by kaeru, i surprisingly learn alot
- Ditesh enlighten us with javascript
- Project Nimbus the Geeks On A Train in Singapore, they have manage to convence the government on singapore and some company to release data and using Open Data Protocol, they releases data to be used.
- Nginx talk is awesome too.
- Cookies and Cupcakes, that is real tasty!!!!
There is plenty to take away from barcampkl. Things to learn, things to do. So this year, it is awesome.
p.s Code Android Malaysia, thanks for make me doubt my decision of getting a n900(luckily didn't buy yet)
Tuesday, April 20, 2010
Accessing world bank api using python
World bank have recently release their data and you can access it through
http://data.worldbank.org/
It also includes API access through it. Which is a web api. Either way it is pretty easy to access from my 5 minute toying around. My experiment attempting to find population of malaysia,
http://data.worldbank.org/
It also includes API access through it. Which is a web api. Either way it is pretty easy to access from my 5 minute toying around. My experiment attempting to find population of malaysia,
import urllibimport urllib2
# here i use json, but the api also support xml
import json
# for url parameter, just to make it look niceparam = urllib.urlencode({'api_key':'your api key','format':'json'})
# get population of malaysia
url = 'http://open.worldbank.org/countries/my/indicators/SP.POP.TOTL'
data = urllib2.urlopen(url+'?'+ param)result = json.load(data)
# btw result[0] is the data on the pages etc, data start at index 1
print result[1]
This is the result, after i clean up my codes and clarify it
Subscribe to:
Posts (Atom)