This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var choose = function(a, b, teams) { | |
if (teams[a] && teams[b]) { | |
return teams[a] < teams[b] ? a : b; | |
} else if (teams[a]) { | |
return a; | |
} else if (teams[b]) { | |
return b; | |
} else { | |
return Math.random() < 0.5 ? a : b; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function choice(set, choice) { | |
return set.indexOf(choice) > -1 ? choice : ''; | |
} | |
function blankArray(l) { | |
return (new Array(l)).map(function(){ return ''; }); | |
} | |
Array.prototype.pairChoice = function(c) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- FizzBuzz in Dart -- | |
void fbPrint(c) { | |
if (c % 15 == 0) { print ('FizzBuzz'); } | |
else if (c % 5 == 0) { print ('Buzz'); } | |
else if (c % 3 == 0) { print('Fizz'); } | |
else { print(c); } | |
} | |
void fbFlow(c) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Converts any PNG into pure HTML | |
# | |
import png, array | |
reader = png.Reader(filename='wedding.png') # << -- enter the image path here | |
width, height, pixels, metadata = reader.read() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Version = 4 | |
Booleans = {'caretLineVisible': False, 'preferFixed': 1, 'useSelFore': True} | |
CommonStyles = {'attribute name': {'fore': 7872391}, | |
'attribute value': {'fore': 3100463}, | |
'bracebad': {'back': 9117943, 'bold': 1, 'fore': 16777215}, | |
'bracehighlight': {'bold': 1, 'fore': 16777215}, | |
'classes': {'bold': True, 'fore': 9117943}, | |
'comments': {'fore': 2696233, 'italic': 1}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.io.Source | |
if (args.length > 0) { | |
def formatSourcePrefix(line: Int, suffix: String, max: Int = 5): String = { | |
var prefix: String = "" | |
for (i <- 1 to (max - line.toString.length)) | |
prefix += " " | |
prefix + line.toString + suffix | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import json | |
import urllib2 | |
import time | |
LAST_DAY = datetime.datetime(2010, 6, 30) | |
TODAY = datetime.datetime.now() | |
CALENDAR_API_URL = 'http://www.hanalani.org/api/calevents/range.json?cal=all-school-calendar' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.shortcuts import _get_queryset | |
class ChildAwareModel(models.Model): | |
class Meta: | |
abstract = True | |
def get_child_model(self): | |
""" | |
Attempts to determine if an inherited model record exists. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
from dirsearch import DirSearch | |
# Global variables | |
PREFIX = '' | |
# | |
# Print the basic help to the screen |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# A python module to implement recursive search/copy of files | |
# | |
import datetime | |
import shutil | |
import os | |
import re | |
class DirSearch(object): |