Archive for the ‘Other’ Category

Python Wrapper For The Phish.net API

While browsing the Phish.net API documentation I noticed that it was missing a Python wrapper.  So I said to my self, this sound like a quick and fun project to test out my Python <cough> skills </cough>.

Just update the method variable to which ever method you are using and add the remaining parameters if necessary.  Here is more docuemtation on the Phish.net API and where to apply for one.

While you are at it check out Adam Scheinberg and my official Phish.Net Google Chrome Extension.

FYI, This is only been tested on Python 2.7.1.  I am pretty sure that it will not work in Python 3.

#Query Phish.net API via Python 2.71.
 
import urllib, json, sys
 
url='https://api.phish.net/'
js='api.js'
 
apikey = 'Your API Key'
format = 'json'
apiver = '2.0'
method = 'pnet.shows.setlists.latest'
 
#Build parameters to send via GET to api.js
params = urllib.urlencode({
  'api':apiver,
  'method':method,
  'format':format,
  'apikey':apikey
  })
 
#Attempt to open a connection and get the JSON formated data
try:
  f = urllib.urlopen(url + js + "?%s" % params)
 
#Do this for invalid URL
except IOError:
  print 'Error: Unable to connect. Invalid URL. '
  sys.exit(1)
 
#Get the response code
rsp = f.getcode()
 
#If the HTTP response is 200 (OK) then proceed
if rsp == 200:
 
  #Read the data
  data =  f.read()
 
  #Decode the data as JSON
  decoded = json.loads(data)
 
  #Print the Decoded JSON
  print 'DECODED: ', decoded
 
  #Print an individual JSON Record
  print 'GET INDIVIDUAL RECORD: ', decoded[0]['showdate']
 
else:
  #Do this if the not an HTTP response of 200
  print 'Error: ',  rsp
 
#close the connection
f.close()

I have submitted this to the Phish.net administrators and if it gets the Ok then it will be uploaded here.

Update: The code has been posted on Phish.net site.

Update 2: I forgot to give proper credit to Adam for his help on the Phish.net Chrome Extension.

Amazing Scanning Electron Microscope Pictures

The picture below is from the book ‘ Microcosmos’ by Brandon Brill.

This book includes many scanning electron microscope (SEM) images of insects, human body parts and household items.  These are the most amazing images of what is too small to see with the naked eye.

Follow this link to see more amazing images: MelodyMaker.posterous.com


Surface of a strawberry.

Logitech Revue with Google TV – Kevin Bacon

Simple Desktop Wallpapers

I hate really bright distracting desktop wallpapers but at the same time I do want something to jazz up my screen.  Today I stumbled upon SimpleDesktops.com, a site dedicated to “bling, drop shadow, and gradient free desktops.”  They are just plain awesome.

This is the current wallpaper on my netbook.

Geek Shirt

I kinda want this shirt, or at least I think its funny.  Yea I am a geek.

via neatoshop.com

Bed Sizes

Ok, its not really tech related but it good information anyway.

serta-chart