Skip to content

Instantly share code, notes, and snippets.

View biesnecker's full-sized avatar

biesnecker

  • Orlando, FL
  • 20:35 (UTC -04:00)
View GitHub Profile
@biesnecker
biesnecker / choices.py
Last active August 29, 2015 14:12 — forked from anonymous/choices.py
#!/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 = []
/** @jsx React.DOM */
var SVGComponent = React.createClass({
render: function() {
return this.transferPropsTo(
<svg>{this.props.children}</svg>
);
}
});
/** @jsx React.DOM */
var GameStatus = {
NOTSTARTED: 0,
FINISHED: 1,
INPROGRESS: 2
}
var Suits = ['H', 'D', 'C', 'S'];
var Cards = [];
/** @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.';
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
/** @jsx React.DOM */
var ReadingTimeWidget = React.createClass({
getInitialState: function() {
return ({
secondsRequired: null,
});
},
componentWillMount: function() {
var cdiv = this.props.contentDiv;
print(sum([x for x in range(1000) if x % 3 == 0 or x % 5 == 0]))
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
@biesnecker
biesnecker / config.rb
Created February 17, 2013 09:31
Wiki-like automatic links for Middleman
# 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
@biesnecker
biesnecker / gist:4313816
Created December 16, 2012 22:45
Putting characters to the screen without a carriage return
def put (s)
print s
STDOUT.flush
end