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, 

  1. 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)
  2. 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
  3. 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,

  1. 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. 
  2. Time management by kaeru, i surprisingly learn alot
  3. Ditesh enlighten us with javascript
  4. 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. 
  5. Nginx talk is awesome too. 
  6. 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,


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

Monday, April 19, 2010

BarcampKL is back 2010




Barcampkl is back to town, and this time it will be held in Segi Summit USJ on 24-25 April 2010. 

Barcamp for a uninitiated is a ad-hoc conference, where people share topic of their interest. and due to the origins of barcamp, it tend to be geeky in nature. 

This year barcamp will feature topic to be voted by the participant, and we have dedicated track for foss.my and social media club KL aka smckl

BarcampKL is free to join, come join us on that day, 

for information
twitter hashtag #barcampkl

and register here

Sunday, April 18, 2010

using the subprocess module

I was trying to automate some task involving shell programs, which actually a handful to type. As a lazy programmer, AUTOMATE WE MUST. Just turn out it involve with virtualenv, or rather virtualenv bootstrap script(that is another story altogether). So I do it in python. 

One of the thing added in python 2.6 is the subprocess module. To start use it


import subprocess


to use it, after the import, run this
subprocess.call(['programname','parameter1','parameter2'......])


for example to call some unix command
subprocess.call(['ls','-l'])
subprocess.call(['ps','-aux'])


or in my case, i use it to run setup.py in bootstrap script for virtualenv 


subprocess.call(['python','setup.py','install'])
subprocess.call(['easy_install','-U','packagename'])


Just a little writeup of subprocess, probably gonna use this a lot

Wednesday, April 14, 2010

A date parser from python dateutil library

Sometime you need to extract date form a string, and that is actually pretty hard to do even on python. On the other hand, there is dateutils, a python library which you can install using easy_install. The library is pretty nifty, and have many component, but now i concentrate on the date parser

Start by 
from dateutil.parser import *


lets have fun, after the import, we should have the parser imported


parse("monday")


You should get the date of next monday as python datetime.datetime object.


parse('14th of april')
parse('14th of april 3pm')


you should get a datetime.datetime object of the date, 


For python programmer, check it out, it is pretty useful. 


http://labix.org/python-dateutil

Thursday, April 01, 2010

Adventure with Virtualenv

In the python development world, people are using virtualenv, to isolate their python development environment from their system. Why that is cool,
  • You don't conflict with the global python library. Because all new library will be in the isolated environment, on linux many software uses python
  • Then you have a fine grain control of what library is needed what is not, for each environment. 
  • Because all of the cool pythonista use that...ok that is not quite true, but many python based project strongly recommend using virtualenv, such as turbogears. 
  • and some tools are available for this, such as pip. 
  • It make it more easier to move project between directory
Lets get started,
here I assume that python setuptools is installed, i assume each project is one environment
to install, just run below as administrator.
easy_install -U virtualenv
 To start a project
virtualenv projectname
This will setup an environment, with their own setuptools.
Let start using it
 source projectname/bin/activate
and it should have the whole python environment there, isolated from the system. including python, their own site-packages

To stop using it
deactivate
To totally isolate from the system, start a new project by
virtualenv --no-site-packages projectname
 It will not use library from the system.

Some tools already begin to support virtualenv. Such as pip, a replacement for easy_install, with uninstall support. To use pip with virtualenv
pip -E projectname packagename
So, virtualenv is now the requirement of most project now. Time to learn it...