Skip to content

Instantly share code, notes, and snippets.

View wenbert's full-sized avatar

Wenbert Del Rosario wenbert

View GitHub Profile
int(time.mktime(time.strptime(str(image.uploaded_on), '%Y-%m-%d %H:%M:%S')))
@wenbert
wenbert / Python save image from URL
Created December 29, 2010 06:24
Python save image from URL
import cStringIO # *much* faster than StringIO
import urllib
import Image
try:
file = urllib.urlopen('http://freegee.sourceforge.net/FG_EN/src/teasers_en/t_gee-power_en.gif')
im = cStringIO.StringIO(file.read()) # constructs a StringIO holding the image
img = Image.open(im)
img.save('/home/wenbert/uploaderx_files/test.gif')
except IOError, e:
@wenbert
wenbert / urlopen in python
Created December 29, 2010 06:03
get url of image and save to local file
#example2.py
import cStringIO # *much* faster than StringIO
import urllib
import Image
file =
urllib.urlopen('http://freegee.sourceforge.net/FG_EN/src/teasers_en/t_gee-power_en.gif')
im = cStringIO.StringIO(file.read()) # constructs a StringIO holding the image
img = Image.open(im)
@login_required
def download(request,groupname,filename):
"""
Download a file
"""
custgroup = Group.objects.get(name=groupname)
if custgroup not in request.user.groups.all():
return render_to_response('404.html')
else:
pass
@wenbert
wenbert / tolerance
Created November 4, 2010 11:12
tolerance
tolerance = abs(float(tolerance))
if(tolerance > 0):
#get the difference of every bearing change
#if difference is within tolerance, print
#otherwise, ignore
diff = float(previous_bearing) - float(bearing)
#print abs(diff),tolerance
if(float(previous_bearing) != float(bearing)):
if(abs(diff) <= tolerance):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" href="style.css" />
<title>Pley: Patt&#39;s Badminton Court</title>
<!-- CSS -->
<link rel="stylesheet" href="/css/style.css" type="text/css" media="screen, projection">