Skip to content

Instantly share code, notes, and snippets.

View kyleburton's full-sized avatar

Kyle Burton kyleburton

View GitHub Profile
@kyleburton
kyleburton / swank-runner.sh
Created March 9, 2011 14:02
Attempts to run Swank regardless of project type (Lein, Maven).
function swank () {
PORT="${1:-4005}"
if [ -e project.clj ]; then
slime-connect & ## see gist: https://gist.github.com/866324
lein deps; lein swank "$PORT"
elif [ -e pom.xml ]; then
slime-connect &
if [ -e patch.dev.pom.xml.patch ]; then
cp pom.xml dev.pom.xml
patch -p0 < patch.dev.pom.xml.patch
@kyleburton
kyleburton / config.ru
Created February 20, 2011 19:15
Twilio In 10 Minutes Heroku App Configuration
WEBSITE_SUBDIR = 'twilio-app'
require "#{WEBSITE_SUBDIR}/config/environment"
use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new
@kyleburton
kyleburton / twilio_ivr_prototype.rb
Created February 17, 2011 23:52
Better IVR Protoype: using twilio
class TwillioController < ApplicationController
def digits
params['Digits']
end
def twaction m
"http://snapclean.me:3000/twillio/#{m.to_s}"
end
def send_back &block
@kyleburton
kyleburton / abtab-examples.sh
Created February 17, 2011 15:00
Examples of using the Abstract Tables command line utilities
user@host ~$ gem install abstract-tables
# convert csv file to an Excel Spreadsheet:
user@host ~$ atcat your-file.csv xls://your-file.xls
# dump a table into an Excel Spreadsheet:
user@host ~$ atcat atcat dbi://pg/localhost/the_database_name/some_table xls://some-table.xls
# dump a list of tables into an Excel Spreadsheet:
user@host ~$ atcat dbi://pg/localhost/the_database_name xls://tables-and-rowcounts.xls
@kyleburton
kyleburton / simple-ivr-simulator.sh
Created February 16, 2011 21:04
Simple IVR Simulator for testing out user experience (Works on OSX)
VOICE="Vicki"
BALANCE="100"
function voice_prompt () {
echo " SPEAKING: $1"
say -v "$VOICE" "$1"
}
function get_user_keypress () {
KEY=""
@kyleburton
kyleburton / mvn-clj-runner.sh
Created November 29, 2010 19:41
Maven / Clojure Bash Script for running a compiled class.
function project_dir () {
if [ -z "${PROJECT_DIR:-}" ]; then
abspath=$(cd ${0%/*} && echo $PWD/${0##*/})
path_only=$(dirname "$abspath")
path_only=$(dirname "$path_only")
path_only=$(dirname "$path_only")
PROJECT_DIR="$path_only"
export PROJECT_DIR
fi
(defun krb-rename-file-visited-by-this-buffer (new-name)
(interactive (list (read-string (format "Rename [%s] to: " buffer-file-name))))
(let ((file-name buffer-file-name))
(if (not (string-match "/" new-name))
(setq new-name (format "%s%s" (file-name-directory file-name)
new-name)))
(message "rename-file: %s to %s" file-name new-name)
(rename-file file-name new-name)
(kill-buffer (buffer-name))
(find-file new-name)))
(reduce
(fn [res counts]
(merge-with + res counts))
(pmap (fn [[start end]]
(count-area-codes
(io/read-lines-from-file-segment inp-file start end)))
(partition 2 1
(io/byte-partitions-at-line-boundaries
inp-file
(* 1024 1024)))))
(defn count-area-codes [inp-seq]
(reduce (fn [m line]
(let [phnum (second (.split line "\t"))
[_ area-code] (first (re-seq #"\((\d+)\)" phnum))]
(assoc m area-code (inc (get m area-code 0)))))
{}
inp-seq))
(apply
merge-with +
(sequences/random-sample-seq (ds/read-lines "phone-nums.txt")
2000000
200)