Skip to content

Instantly share code, notes, and snippets.

Avatar

Wenbert Del Rosario wenbert

View GitHub Profile
View gist:519247
<!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">
View 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):
View gist:718969
@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 / urlopen in python
Created Dec 29, 2010
get url of image and save to local file
View urlopen in python
#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)
@wenbert
wenbert / Python save image from URL
Created Dec 29, 2010
Python save image from URL
View 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:
View Python convert a datetime to seconds from epoch
int(time.mktime(time.strptime(str(image.uploaded_on), '%Y-%m-%d %H:%M:%S')))
View category under group.py
from django.db import models
from datetime import datetime
from django.contrib.auth.models import Group, User
class Category(models.Model):
"""
class Car(models.Model):
company_that_makes_it = models.ForeignKey(Manufacturer)
# ...
"""
View 2 ajax requests?
<div id="container">
<input type="hidden" id="var" value="wenbert"/>
<input type="button" id="thebutton" value="Click"/>
</div>
<script type="text/javascript">
$(document).ready(function() {
<script type="text/javascript">
$(document).ready(function() {
$("#thebutton").click(function(){
call_ajax1();
@wenbert
wenbert / in_cfai_not_in_123signup.sql
Created Dec 2, 2011
2. All those in the CFAI list but NOT in the 123signup list>> Add them as a regular (or affiliate) SCFAS member in 123signup
View in_cfai_not_in_123signup.sql
SELECT
cfai.display_name, cfai.first_name, cfai.last_name, cfai.email
FROM
from_cfai cfai
WHERE cfai.email NOT IN (
SELECT onetwothree.email
FROM
from_123 onetwothree
@wenbert
wenbert / expired_in_123signup_and_in_cfai.sql
Created Dec 2, 2011
3. All those in the 123signup list who are listed as EXPIRED but are listed in the CFAI list>>> Upgrade their status in 123signup to REGULAR exp 07-2012
View expired_in_123signup_and_in_cfai.sql
SELECT
onetwothree.`name`,
cfai.first_name,
cfai.last_name,
onetwothree.`email`, onetwothree.`exp_date`, onetwothree.`days_due`
FROM from_123 onetwothree
INNER JOIN from_cfai cfai ON cfai.email = onetwothree.email