Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Korakot Chaovavanich http://korakot.stumbleupon.com

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Thai election ID checking

The online service here aims to help people
check where they are to vote. However, it can be
used as ID certification as well.
   1  
   2  # nnnn is the id to be checked
   3  http://www.dopa.go.th/cgi-bin/inqelect.sh?pid=nnnn

Here I make it into a function call.
   1  
   2  import urllib, re
   3  def getname(id):
   4    url = 'http://www.dopa.go.th/cgi-bin/inqelect.sh?pid=' + str(id)
   5    src = urllib.urlopen(url).read()
   6    pat = '<H3> *(.*?) *<'
   7    name = re.findall(pat, src)[0]  # don't use other info
   8    return name
   9  
  10  print getname(5100900050063)  # show a name (one of my relatives)

Using multiple tags on Code Snippets

I spent a lot of time trying to select snippets with
contain multiple tags. (series60 and sql)
There is no '+' links I can click anymore.
After about 10 minutes of trial and error, I find out how.
This also answer another question on correct use of URL.
   1  
   2  # for tag 'series60' AND 'sql'
   3  http://www.bigbold.com/snippets/tags/series60/sql/
   4  
   5  # this doesn't work
   6  http://www.bigbold.com/snippets/tag/series60/sql/
   7  
   8  # all of these work (single tag case)
   9  http://bigbold.com/snippets/tag/series60/
  10  http://bigbold.com/snippets/tags/series60/
  11  http://www.bigbold.com/snippets/tag/series60/
  12  http://www.bigbold.com/snippets/tags/series60/

My conclusion is that.
For a single tag, use '/tag/...'.
For multiple tags, use '/tags/...'.
The first is quicker to type, while the second is flexible in case you want to filter further.

Open browswer from python

You can do it by starting browser app given url as a parameter.
   1  
   2  import e32
   3  apprun = 'z:\\system\\programs\\apprun.exe'
   4  browser = 'z:\\System\\Apps\\Browser\\Browser.app'
   5  url = 'http://www.google.com'
   6  
   7  e32.start_exe(apprun, browser + ' "%s"' %url , 1)

Nick Burch also write a webbrowser.py module to allow
using opera and any other browswers.

Google free proxy

From Google Hack
   1  
   2  http://www.google.com/translate?langpair=en|en&u=www.forbiddensite.com
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS