Skip to content

Instantly share code, notes, and snippets.

View etscrivner's full-sized avatar
🦋

Eric Scrivner etscrivner

🦋
View GitHub Profile
@etscrivner
etscrivner / config.py
Last active August 29, 2015 14:02
Sample interface for reading configuration files
import os
# Configuration variable names as constants
APP_NAME = 'MY_APP_NAME'
APP_AWS_KEY = 'MY_APP_AWS_KEY'
APP_AWS_SECRET_KEY = 'MY_APP_AWS_SECRET_KEY'
class Config(object):
@etscrivner
etscrivner / app.py
Last active August 29, 2015 14:02
Application using the simple config
import sys
import config
if __name__ == '__main__':
cfg = config.Config()
print 'Welcome to {}'.format(cfg.get(config.APP_NAME))
print sys.argv
@etscrivner
etscrivner / gist:4f4e02e98465a7134e8d
Created July 31, 2014 00:43
Shame ban name generator
import random
adjectives = [
'awkward', 'ginger', 'babyfaced', 'sloppy', 'hairy', 'sweaty',
'gangly', 'ugly', 'neckbeard', 'angry', 'constipated', 'wrinkly',
'porous', 'oozy', 'cuddly'
]
nouns = [
@etscrivner
etscrivner / simple-redis-client.go
Created September 17, 2014 01:16
Simple redis client in Go
package main
import (
"bytes"
"bufio"
"fmt"
"net"
"strconv"
)
@etscrivner
etscrivner / simple-redis-client.rs
Created September 17, 2014 01:16
Simple redis client in rust
use std::io::TcpStream;
use std::str;
fn main() {
let mut client = match TcpStream::connect("127.0.0.1", 6379) {
Ok(c) => c,
Err(e) => fail!("Failed: {}", e)
};
@etscrivner
etscrivner / without_gevent.py
Created September 24, 2014 00:57
Querying google without gevent
import requests
def read_google(q):
return requests.get('https://www.google.com', params={'q': q})
def bunch_of_requests():
results = []
for i in range(100):
@etscrivner
etscrivner / euler1.ml
Created September 24, 2014 04:32
Euler problem 1 in ocaml
let result = List.range 1 1000
|> List.filter ~f:(fun n -> (n mod 3) = 0 || (n mod 5) = 0)
|> List.reduce ~f:(+);;
@etscrivner
etscrivner / bits_in_a_bool.py
Last active August 29, 2015 14:20
Figuring out how many bits are in a python bool. Researching a few approaches to implementing bit arrays in Python.
>>> (sys.getsizeof([False]*2) - sys.getsizeof([True]*1)) * 8
64
[alias]
pu = !git branch | grep '^\\*' | cut -c3- | xargs git push origin
@etscrivner
etscrivner / picture-language.rkt
Created May 27, 2015 05:43
Complete racket source code for playing with the SICP picture language.
#lang racket/gui
(require graphics/graphics)
(open-graphics)
(define vp (open-viewport "A Picture Language" 500 500))
(define draw (draw-viewport vp))
(define (clear) ((clear-viewport vp)))
(define line (draw-line vp))
(define (make-vect x y)