Saturday, November 7, 2009

Rubik...

For few days I'm scratching, jumping, deep thinking, looking for a killer apps idea, an unique one, a web app that make people scream, so unique that make you cry... (or the other way around)...

suddenly ....... BINGO!!!



a Rubik...!!! yes... a Rubik... The idea is just like a Rubik, but with a different approach.


This is what happen when you try to solve it (or at least to me).



The left pic is a solution and a nice thing to have, the idea is
to make the scrambled/twisted rubik also a solution, and can be a better or even a nicer thing too.



The best part of it, you are not limited to single boring same color solution, but a varieties, and it is so simple anybody can do it. Just close your eyes and twist.. eureka!!!

Tuesday, November 3, 2009

New Chapter...

This is my last month working as an employee to an employer. I'm back to where i was (more or less) 10 years ago. Not expecting this myself, quite a shock for me too, but things just happened. Sad? little, what do you expect? Been working with this 'employer' for 10 years, building things together, and so... got to move and keep going, no turning back!

Preparations?, u can consider it "/dev/null". No plan, no emergency exit, but only.....

so, there will be no more post about the "new product/replacement model" like in my previous blog post all about, i'm no longer part of it...

starting a new chapter ...

Thursday, October 29, 2009

python urllib2


I'm trying to develop a code that actually get the html page of a given url, extract some text/desc from headers or body of the html page, and get some images, set it as thumbnail for the link itself.

initially i'm using this simple steps:

import urllib2

req = urllib2.Request('http://www.voidspace.org.uk')
response = urllib2.urlopen(req)
the_page = response.read()

and it works, however after several test, it fails on this
url: http://en.wikipedia.org/wiki/Sloth
and error given to me in python cli:

File "/usr/lib/python2.6/urllib2.py", line 510, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden

403: Forbidden

googling around few minutes, i found this statement in python doc :

Some websites dislike being browsed by programs, or send different versions to different browsers [3] . By default urllib2 identifies itself as
Python-urllib/x.y (where x and y are the major and minor version numbers of the Python release, e.g. Python-urllib/2.5), which may confuse the site, or just plain
not work. The way a browser identifies itself is through the User-Agent header.

so what i did just add the User-Agent header, voila it works.

user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = { 'User-Agent' : user_agent }
req = urllib2.Request(url, None, headers)
response = urllib2.urlopen(req)
doc = response.read()