This file contains hidden or 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
| 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 |
This file contains hidden or 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
| WEBSITE_SUBDIR = 'twilio-app' | |
| require "#{WEBSITE_SUBDIR}/config/environment" | |
| use Rails::Rack::LogTailer | |
| use Rails::Rack::Static | |
| run ActionController::Dispatcher.new |
This file contains hidden or 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
| class TwillioController < ApplicationController | |
| def digits | |
| params['Digits'] | |
| end | |
| def twaction m | |
| "http://snapclean.me:3000/twillio/#{m.to_s}" | |
| end | |
| def send_back &block |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| VOICE="Vicki" | |
| BALANCE="100" | |
| function voice_prompt () { | |
| echo " SPEAKING: $1" | |
| say -v "$VOICE" "$1" | |
| } | |
| function get_user_keypress () { | |
| KEY="" |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| (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))) |
This file contains hidden or 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
| (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))))) |
This file contains hidden or 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
| (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 + |
This file contains hidden or 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
| (sequences/random-sample-seq (ds/read-lines "phone-nums.txt") | |
| 2000000 | |
| 200) |