Skip to content

Instantly share code, notes, and snippets.

View biesnecker's full-sized avatar

biesnecker

  • Orlando, FL
  • 06:21 (UTC -04:00)
View GitHub Profile
/** @jsx React.DOM */
var ReadingTimeWidget = React.createClass({
getInitialState: function() {
return ({
secondsRequired: null,
});
},
componentWillMount: function() {
var cdiv = this.props.contentDiv;
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 */
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.';
@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 = []
@biesnecker
biesnecker / amazon_rds_connection.rkt
Created March 15, 2015 18:19
Connect to an Amazon RDS instance over SSL.
(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))
@biesnecker
biesnecker / ScalaJetty.scala
Created August 17, 2011 23:17
Main method
package com.biesnecker.scalajetty
import cc.spray._
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.xml.XmlConfiguration
import org.eclipse.jetty.webapp.WebAppContext
import java.io.File
object ScalaJetty {
@biesnecker
biesnecker / akka.conf
Created August 17, 2011 23:18
Akka configuration
####################
# Akka Config File #
####################
# This is the Akka config template to be used for spray SERVLET CONTAINER deployments
akka {
version = "1.1.3" # Akka version, checked against the runtime version of Akka.
# spray requires nothing but akka-actors, which are implicitly enabled
@biesnecker
biesnecker / simple-work-queue.clj
Created January 14, 2012 08:39
A very simple set of functions create a work queue with an arbitrary number of workers attached in Clojure
(ns nadsack.utils.queue
(:import (java.util.concurrent BlockingQueue LinkedBlockingQueue)))
(defn- generic-worker [worker-function #^BlockingQueue queue switch]
(future
(let [worker-id (.toString (java.util.UUID/randomUUID))]
(while (not (realized? switch))
(let [work-item (.take queue)]
(cond
(import '(org.joda.time LocalDate))
(defn today [] (LocalDate.))
;; basic functions to increment or decrement a date
(defn inc-date [#^LocalDate ds] (.plusDays ds 1))
(defn dec-date [#^LocalDate ds] (.minusDays ds 1))
;; generate infinite streams of LocalDate objects starting with start-ds
(defn inc-date-stream [#^LocalDate start-ds] (iterate inc-date start-ds))
(def charvals (apply vector "ABCDEFGHJKMNPQRSTUVWXYZ23456789")) ; some characters weren't allowed in the codes
(defn rand-char [] (charvals (rand-int (count charvals))))
(apply str (take 10 (repeatedly rand-char)))