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 | |
""" | |
The idea of this program is to equate the strings "rock", "paper", | |
"scissors", "lizard", "Spock" to numbers as follows: | |
0 - rock | |
1 - Spock | |
2 - paper | |
3 - lizard | |
4 - scissors |
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
FALSE_STRINGS = ("0", "false", "[]", "{}", "()", "None", "no") | |
def boolean(obj): | |
""" | |
A helper method for converting POST and JSON data | |
to an expected Boolean object (Python bool). | |
We expect that the following are false: | |
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
import os | |
import sys | |
DEFAULT_SIZE = 128 * 1024 * 1024 #128 MB | |
class Bucket(object): | |
""" | |
Handles the writing of a stream into a bucket. | |
Pass a path to a directory which holds the bucket, and |
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
#!/bin/bash | |
DIR=/var/www/YOUR_APP_NAME | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
NODE_PATH=/usr/local/lib/node_modules | |
case $1 in | |
start) | |
nohup "node" "$DIR/proxy.js" 1>>"$DIR/logs/proxy.log" 2>&1 & | |
echo $! > "$DIR/pids/proxy.pid"; | |
;; |
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
var crypto = require('crypto'); | |
var secret = crypto.randomBytes(24); | |
function encrypt(plaintext) { | |
var cipher = crypto.createCipher('aes-256-cbc', secret); | |
cipher.setAutoPadding(false); | |
var ciphertext = ''; | |
for (var i=0; i < plaintext.length; i+=16) { | |
ciphertext += cipher.update(plaintext.substr(i, i+16), 'utf8', 'base64'); |
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
var crypto = require('crypto'); | |
var secret = crypto.randomBytes(24); | |
function encrypt(plaintext) { | |
var encoded = new Buffer(plaintext, 'utf8', 'hex'); | |
var cipher = crypto.createCipher('aes-256-cbc', secret); | |
// cipher.setAutoPadding(false); | |
var ciphertext = cipher.update(encoded, 'hex'); | |
return ciphertext.toString('base64'); |
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
#! /bin/sh | |
# Copyright (c) 2013 OpenWIMs.org | |
# All rights reserved | |
# | |
# Author: Benjamin Bengfort, 2013 | |
# | |
# /etc/init.d/wimss | |
### BEGIN INIT INFO |
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 | |
from nltk import Text | |
from nltk.corpus import PlaintextCorpusReader | |
CORPUS_ROOT = '/Users/benjamin/Development/corpora/gutenburg/' | |
if __name__ == "__main__": | |
reader = PlaintextCorpusReader(CORPUS_ROOT, '.*') |
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 | |
# multiconn.py | |
# | |
# Author: Benjamin Bengfort <benjamin@bengfort.com> | |
# $ID: multiconn.py [1] benjamin@bengfort.com $ | |
""" | |
An example showing how to fetch multiple links from the same host with the | |
same, open httplib.HTTPConnection object. This is the basis for an attempt |
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 | |
import sys | |
from datetime import datetime | |
from dateutil.tz import tzlocal | |
class Clock(object): | |
FORMATS = { | |
"code":"%a %b %d %H:%M:%S %Y %z", |
OlderNewer