This file contains 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
(require db openssl) | |
; connect to a Amazon RDS MySQL instance using SSL | |
(define sslcontext | |
(let ([ctx (ssl-make-client-context 'tls)]) | |
(ssl-load-verify-root-certificates! ctx "./rds-combined-ca-bundle.pem") | |
(ssl-set-verify! ctx #t) (ssl-set-ciphers! ctx "DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2") | |
(ssl-seal-context! ctx) | |
ctx)) |
This file contains 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 | |
# usage: choices choice_a 1 choice_b 5 choice_c 4 | |
# will return choice_a 10% of the time, choice_b 50% of the time | |
# and choice_c 40% of the time | |
from random import randrange | |
import sys | |
options = [] |
This file contains 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
/** @jsx React.DOM */ | |
var SVGComponent = React.createClass({ | |
render: function() { | |
return this.transferPropsTo( | |
<svg>{this.props.children}</svg> | |
); | |
} | |
}); |
This file contains 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
/** @jsx React.DOM */ | |
var GameStatus = { | |
NOTSTARTED: 0, | |
FINISHED: 1, | |
INPROGRESS: 2 | |
} | |
var Suits = ['H', 'D', 'C', 'S']; | |
var Cards = []; |
This file contains 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
/** @jsx React.DOM */ | |
FBLoginMessageComponent = new React.createClass({ | |
render: function() { | |
var status = this.props.status; | |
var message = ''; | |
if (status === 'logged_in') { | |
message = 'You\'re already logged in.'; | |
} else if (status === 'not_logged_in') { | |
message = 'You\'re not logged in yet.'; |
This file contains 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 csv | |
import json | |
from collections import defaultdict | |
datafiles = ['./GL{0}.TXT'.format(x) for x in range(1960,2014)] | |
counts = defaultdict(lambda: defaultdict(lambda: defaultdict(int))) | |
max_i = 0 |
This file contains 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
/** @jsx React.DOM */ | |
var ReadingTimeWidget = React.createClass({ | |
getInitialState: function() { | |
return ({ | |
secondsRequired: null, | |
}); | |
}, | |
componentWillMount: function() { | |
var cdiv = this.props.contentDiv; |
This file contains 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
print(sum([x for x in range(1000) if x % 3 == 0 or x % 5 == 0])) |
This file contains 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 math import sqrt, ceil, trunc | |
# Sieve of Eratosthenes | |
def seive(max): | |
nums = range(max + 1) | |
nums[0] = None | |
nums[1] = None | |
for i in range(2, max + 1): | |
if nums[i]: | |
c = i * 2 |
This file contains 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
# add this to your config.rb | |
ready do | |
wikitargets = Hash.new | |
wikiwords = Hash.new | |
sitemap.resources.select {|p| p.ext == ".html" }.each do |p| | |
unless p.data['wikitag'].nil? | |
wikitargets[p.data['wikitag']] = p.url | |
end |