Archive
Installation of PIL under Ubuntu
Problem
Using PIL, I ran in the following error: “decoder zip not available”.
Solution
I found the solution here. Here I make a summary:
sudo pip uninstall PIL sudo apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib sudo pip install -U PIL
Credits
Tip from here.
Random Python projects on GitHub
Problem
You are looking for some interesting Python projects on GitHub. Either because (1) you want to use them, or (2) you are looking for a project where you could contribute to.
Solution
I’ve made a simple script that picks two Python projects from GitHub and shows the basic information about them. The first one is a popular one from the Top 100, while the second one is a less popular project.
Example:
$ ./ghpp.py kennethreitz/requests (watchers: 2800, forks: 325, updated: 2012/05/16) Python HTTP Requests for Humans. https://github.com/kennethreitz/requests / docs.python-requests.org ========== DASPRiD/DASBiT (watchers: 6, forks: 4, updated: 2012/04/29) Python based IRC bot https://github.com/DASPRiD/DASBiT
Source:
#!/usr/bin/python
"""
Random Python projects from GitHub.
"""
import random
import urllib2
import json
import textwrap
MAX = 196
PAGE = random.randint(2, MAX)
URL_POP = 'http://github.com/api/v2/json/repos/search/python?language=Python'
URL_ALL = URL_POP + '&start_page={page}'.format(page=PAGE)
WIDTH = 78
def remove_non_ascii(text):
return ''.join(c for c in text if ord(c) < 128)
def process(r):
print '{o}/{n} (watchers: {w}, forks: {f}, updated: {u})' \
.format(o=r['owner'], n=r['name'], w=r['watchers'],
f=r['forks'], u=r['pushed'][:10])
desc = '\n'.join(textwrap.wrap(remove_non_ascii(r['description']), WIDTH))
print '{d}'.format(d=desc)
print '{url}'.format(url=r['url']),
if r.has_key('homepage') and r['homepage']:
print '/ {hp}'.format(hp=r['homepage'])
else:
print
# print 'fork: {f}'.format(f=r['fork'])
def choose_from(url):
text = urllib2.urlopen(url).read()
repos = json.loads(text)['repositories']
repo = random.choice(repos)
process(repo)
def main():
choose_from(URL_POP)
print '=========='
choose_from(URL_ALL)
#############################################################################
if __name__ == "__main__":
main()
b4ltazar, the script kiddie
He has lots of exploits, written in Python. Unfortunately he hasn’t pushed his work yet on github…
Python Modules You Should Know
Simple JSON time service (with timezone support)
Current time in Budapest: http://json-time.appspot.com/time.json?tz=Europe/Budapest
install gevent
sudo apt-get install libevent-dev python-all-dev sudo pip install gevent
Nice tutorial on gevent: here.
Python decorators cheat sheet
http://hairysun.com/downloads/DecoratorHandout.pdf
This is a cheat sheet for Matt Harrison’s book, Guide To: Learning Python Decorators. Here is a review.

You must be logged in to post a comment.