Skip to content

Instantly share code, notes, and snippets.

View whalesalad's full-sized avatar
🖨️
PC LOAD LETTER

Michael Whalen whalesalad

🖨️
PC LOAD LETTER
View GitHub Profile
# On branch jstagger
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: ../beta_signup/index.html
# deleted: ../groups/list/groups.html
# deleted: ../groups/view/group_view.html
# deleted: ../splash/home_nohh.html
# renamed: ../upload/simple_upload.html -> ../upload/upload_simple.html
# deleted: pulse.html
<<<<<<< HEAD:blacktip/api/bounding_box.py
from django.db import transaction
=======
from cStringIO import StringIO
from decimal import Decimal
from PIL import Image
from urllib2 import urlopen
from django.db import transaction
Number.prototype.apnumber = function() {
var numberMap =
[ 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ];
return (9 >= this) ? numberMap[this] : this;
};
// Examples
var foo = 4;
alert(foo); // 4
String.prototype.shorten = function(n, i) {
var indicator = i || '…';
return (this.length > n) ? String(this.substr(0, n)+indicator) : String(this);
};
// Examples
var foo = 'Snuggleuffagus';
alert(foo.shorten(10)); // Snuggleuff…
alert(foo.shorten(3, '&raquo;')); // Snu»
Number.prototype.pluralize = function(singular, plural) {
var a = '', b = 's';
if (singular && plural) { a = singular; b = plural; }
return (this == 1) ? a : b;
};
// Examples
function cherries(numCherries) {
alert('You have '+numCherries+' cherr'+numCherries.pluralize('y', 'ies')+' in mai bucket.');
};
$sizes = array(
"WB-1" => array(
"men" => array('6', '7', '8', '9', '10', '11', '12'),
"women" => array('5', '6', '7', '8', '9', '10', '11', '12')
),
"WK-1" => array(
"men" => array('4', '5', '6', '7', '8', '9', '10', '11'),
"women" => array('4', '5', '6', '7', '8', '9', '10', '11')
),
"WK-79" => array(
$sizes = array(
"WB-1" => array(
"men" => array('6', '7', '8', '9', '10', '11', '12'),
"women" => array('5', '6', '7', '8', '9', '10', '11', '12')
),
"WK-1" => array(
"men" => array('4', '5', '6', '7', '8', '9', '10', '11'),
"women" => array('4', '5', '6', '7', '8', '9', '10', '11')
),
"WK-79" => array(
if (self.groups) {
var g = new Array(), g_strings = new Array();
for (group in self.groups) {
g.push({ id: group, name: self.groups[group] });
}
for (var i=0; i < g.length; i++) {
var g_suffix = (i == g.length) ? ' and ' : '';
var g_string = '<a href="/dashboard/ents/'+g[i].id+'/">'+g[i].name+'</a>'+g_suffix;
g_strings.push(g_string);
# Screwing around...
String.prototype.inter = function(r) {
return this.replace(/\{([^}]+)\}/g, function() {
return r[arguments[1]];
});
}
$(document).ready(function() {
var string = 'There are {num_kids} kids in the {room_name}.';
// Screwing around with string interpolation
String.prototype.inter = function(r) {
return this.replace(/\{([^}]+)\}/g, function() {
return r[arguments[1]];
});
}
$(document).ready(function() {
var string = 'There are {num_kids} kids in the {room_name}.';