Skip to content

Instantly share code, notes, and snippets.

View emilepetrone's full-sized avatar
🏠
Working from home

Emile Petrone emilepetrone

🏠
Working from home
View GitHub Profile
Verifying that "emile.id" is my Blockstack ID. https://explorer.blockstack.org/name/emile.id
Verifying my Blockstack ID is secured with the address 1N2QRLQj5RzuivZF3ivTRAbNadQL5WZYuR https://explorer.blockstack.org/address/1N2QRLQj5RzuivZF3ivTRAbNadQL5WZYuR
@emilepetrone
emilepetrone / gist:3147937
Created July 20, 2012 00:39
def thumbnail
from cStringIO import StringIO
@register.simple_tag
def thumbnail(image_url, width, height, quality=95):
"""
Given the URL to an image, resizes the image using the given width and
height on the first time it is requested, and returns the URL to the new
resized image. if width or height are zero then original ratio is
maintained.
"""
if not image_url:
#define LED_PIN 13
void setup () {
pinMode (LED_PIN, OUTPUT); // enable pin 13 for digital output
}
void loop () {
digitalWrite (LED_PIN, HIGH); // turn on the LED
delay (1000); // wait one second (1000 milliseconds)
digitalWrite (LED_PIN, LOW); // turn off the LED
class ConvertError(ValueError):
message = 'Whoops - one of the values you entered cannot be converted to something that will work for these calculations. Try this again.'
class BadStuff(BaseException):
message = 'Something went wrong with this calculation. Maybe try passing in new values.'
class Zero(ZeroDivisionError):
message = 'Yeah, dividing with a 0 in the mix does not work.'
@emilepetrone
emilepetrone / gist:1389705
Created November 23, 2011 19:50
SimpleGeo JS Context
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script src="http://cdn.simplegeo.com/js/1.2/simplegeo.all.jq.min.js"></script>
</head>
<body>
<script type="text/javascript">
var client = new simplegeo.ContextClient('JSON_TOKEN'); //json code of simple geo
$(document).ready(function() {
var lat,lon, callback;
<form action="{% url like_picture %}" method="post" accept-charset="utf-8" class="likeform">{% csrf_token %}
<input type="hidden" value="{{picture.id}}" name="id"/>
<button type="submit" id="like">Like Photo</button>
</form>
def picture(request, picture_search, template_name="picture/picture.html"):
picture = get_object_or_404(Picture, cleaned_title=picture_search)
def like_picture(request):
picture_id = request.POST.get('id', False)
picture = get_object_or_404(Picture, id=picture_id)
if picture.user == request.user:
return HttpResponseRedirect(reverse('home'))
import xlrd, xlwt
from xlutils.copy import copy
import time
from simplegeo import Client, json, APIError
#from multiprocessing.pool import ThreadPool as Pool
from multiprocessing import Pool
client = Client('SbAc87cM7EK2qCvmjymQtXU66MdXGNPr','CNmJaCEGGY3V7Tq3NEJsvNJCdJZjvgfN')