Skip to content

Instantly share code, notes, and snippets.

View wyattdanger's full-sized avatar

Stephen Bush wyattdanger

View GitHub Profile
{setup:"Our wedding was so beautiful,",punchline:"even the cake was in tiers"},{setup:"I'm reading a book on the history of glue",punchline:"I just can't seem to put it down"},{setup:"What do you call an Argentinian with a rubber toe?",punchline:"Roberto"},{setup:"I am terrified of elevators,",punchline:"I'm going to start taking steps to avoid them"},{setup:"Why do crabs never give to charity?",punchline:"Because they're shellfish."},{setup:"Why don't skeletons ever go trick or treating?",punchline:"Because they have no body to go with"},{setup:"What do you call cheese by itself?",punchline:"Provolone"},{setup:'"Ill call you later."',punchline:"Don't call me later, call me Dad"},{setup:"Dad, I'm hungry.",punchline:"Hello, Hungry. I'm Dad"},{setup:"Where does Fonzie like to go for lunch?",punchline:"Chick-Fil-Eyyyyyyyy"},{setup:"Did you hear about the cheese factory that exploded in France?",punchline:"There was nothing left but de Brie"},{setup:"I knew I shouldn’t have had the seafood",punchline:"I’m feeling
var compiled = _.template("hello: <%= name %>");
compiled({name : 'moe'});
=> "hello: moe"
var list = "<% _.each(people, function(name) { %> <li><%= name %></li> <% }); %>";
_.template(list, {people : ['moe', 'curly', 'larry']});
=> "<li>moe</li><li>curly</li><li>larry</li>"
var locations = [[37,-122],[38,-121],[39,-120]], // An array of arrays of [ lat , lng ]. You'll find the closest to target
target = [37.75,-121], // starting point
radians = function (deg) {
return Math.PI*deg/180; // needed function not native to JavaScript's Math object
};
function getDistances (target, locations) {
var spots = [];
for (var i=0;i<locations.length;i++) {
var distance = 0,
# Place in models.py
class ExternalLink(db.Item):
title = db.NameProperty()
href = db.LinkProperty(verbose_name='Link')
@site.item_view.define(ExternalLink)
def link_view(item, request):
return http.HttpResponseRedirect(item.href)
from re import sub
from django import template
register = template.Library()
@register.filter(name='cleanhtml')
def cleanhtml(value):
'''Removes inline styles from WYSIWYG-generated markup.'''
return sub('(\s?style\s?=\s?[\'\"].+[\'\"])', '', str(value))
from re import sub
from django import template
register = template.Library()
@register.filter(name='cleanhtml')
def cleanhtml(value):
"""Removes all attributes from all HTML tags, but keeps <img> tags intact.
Ideal for cleaning WYSIWYG-generated mess."""
return sub('(<\w+(\ssrc=[\'"][\w:/\.-]+[\'"])?)[^>(/>)]*(>)', r'\1\2', str(value))
.clearfix {
line-height: 1px;
height: 1px;
width: auto;
clear: both; }
def main():
import csv, sys, re
from pykk.message import site, db
from yourapp.apps.models import YourModel # import your relevant models
db.initialize()
reader = csv.DictReader(open(sys.argv[1]))
with db.transaction('Importing Employees'):
for row in reader:
/* grids */
@media screen and (max-width: 319px) {.unit { float: none !important; width: auto !important;}
}
.line:after,.lastUnit:after { clear: both; display: block; visibility: hidden; overflow: hidden; height: 0 !important; line-height: 0; font-size: xx-large; content: " x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x ";}
.line {*zoom:1;}
.unit { float: left;}
.size1of1 { float: none;}
.size1of2 { width: 50%;}
.size1of3 { width: 33.33333%;}
.size2of3 { width: 66.66666%;}
@wyattdanger
wyattdanger / base.sh
Created December 13, 2010 16:41 — forked from jamessanders/base.sh
# change directory to the base of your project
# Your project base is the directory that contains
# either _darcs or .git or .hg
# to use as a command add to .zshrc or .bashrc
# alias base='source <path/to/base.sh>
CUR=$(pwd);
while [ ! "$CUR" = "/" ]