Skip to content

Instantly share code, notes, and snippets.

View bkeating's full-sized avatar
🤙
Gettin’ SUM & CALCin’ out

Benjamin Keating bkeating

🤙
Gettin’ SUM & CALCin’ out
View GitHub Profile
"""
jQuery templates use constructs like:
{{if condition}} print something{{/if}}
Or like:
{% if condition %} print {%=object.something %}{% endif %}
This, of course, completely screws up Django templates,
@ryanlabouve
ryanlabouve / gist:2322528
Created April 6, 2012 19:56
Sublime text keybinding for reversing selecting lines
// Add to 'Default (OSX).sublime-keymap'
// Reverse selected lines.
[
{ "keys": ["super+shift+r"], "command": "permute_lines", "args": {"operation": "reverse"} }
]
@mtigas
mtigas / gist:1961114
Created March 2, 2012 20:36
lambda assisted elections magic
# GIVEN:
# `counties` is a dict with each key being the slug of a county,
# containing a sub-dict with keys including vote counts and stuff.
# each candidate's vote count is stored in a key that is the candidate's
# name as a slug
# find vote leader for each county and store it in a 'leader' key for that county
for county_slug in counties.iterkeys():
vals = [(candidate, counties[county_slug][candidate]) for candidate in CANDIDATES]
vals.sort(key=lambda c: c[1], reverse=True)
@robnyman
robnyman / Fullscreen API.js
Last active February 12, 2018 23:42
Fullscreen API
var docElm = document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
}
else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
}
else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
}
@stefanv
stefanv / sparks.py
Created November 17, 2011 00:25
Command line sparks in Python
#!/usr/bin/python
# coding=utf-8
# Python version of Zach Holman's "spark"
# https://github.com/holman/spark
# by Stefan van der Walt <[email protected]>
"""
USAGE:
@david-torres
david-torres / AmazonSignatureUtil.py
Created September 9, 2011 15:13
A basic utility class written in Python that verifies an Amazon Simple Payments return url or IPN url using VerifySignature from the FPS API
import base64
import hmac
import hashlib
import urllib
import urllib2
import time
from datetime import datetime, tzinfo
from xml.dom import minidom
@davist11
davist11 / gist:1204569
Last active July 1, 2024 02:51
Campfire sounds
56k: "https://123.campfirenow.com/images/56k.gif"
bell: ":bell:"
bezos: ":laughing::thought_balloon:"
bueller: "anyone?"
butts: ":open_hands: :smoking:"
clowntown: "https://123.campfirenow.com/images/clowntown.gif"
cottoneyejoe: ":notes::hear_no_evil::notes:"
crickets: "hears crickets chirping"
dadgummit: "dad gummit!! :fishing_pole_and_fish:"
dangerzone: "https://123.campfirenow.com/images/dangerzone.png"
@bitprophet
bitprophet / gist:1189894
Created September 2, 2011 20:56
Partial Cony settings file
def github(query, url):
url = "https://github.com/%s/issues" % url
# Direct to issue number
try:
redirect("%s/%s" % (url, int(query)))
except ValueError:
# New ticket
if query == "new":
redirect("%s/new" % url)
# Issue list
@kennethreitz
kennethreitz / 0_urllib2.py
Created May 16, 2011 00:17
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
"""
jQuery templates use constructs like:
{{if condition}} print something{{/if}}
This, of course, completely screws up Django templates,
because Django thinks {{ and }} mean something.
Wrap {% verbatim %} and {% endverbatim %} around those
blocks of jQuery templates and this will try its best