Skip to content

Instantly share code, notes, and snippets.

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'
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
}
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},
@tstone
tstone / imgtohtml.py
Created November 18, 2010 14:19
Convert any PNG into a pure HTML representation (A grid of 1px by 1px tags)
#!/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()
@tstone
tstone / fizzbuzz.dart
Created January 7, 2012 15:44
FizzBuzz in Dart
// -- 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) {
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) {
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;
}
@tstone
tstone / gist:3364269
Created August 15, 2012 22:22
Divide by 3 (javascript)
<!DOCTYPE>
<html>
<body>
<script type="text/javascript">
var base10 = {
increment: function(v) {
var incrementBit = function(bits) {
var b = bits[0];
if (b == '0') {
bits.splice(0, 1, '1');
@tstone
tstone / longhand.slim
Created September 13, 2012 22:41
Template Comparison
#
# Slim Using Longhand (full tags)
# slim-lang.org
#
<!DOCTYPE html>
<html>
<head>
<title>Slim Examples</title>
@tstone
tstone / gist:3759820
Created September 21, 2012 05:08
A ruby script to make running coffeelint a bit easier
#!/usr/bin/env ruby
#
# Use:
#
# => cfl
# => cfl all
# => cfl last
# => cfl last 3
#