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
;;; Ruby/Rails development | |
;; RVM support | |
;; Ruby Version Manager | |
(require 'rvm) | |
(rvm-use-default) | |
;; automatically add 'end' after class, module, def etc. | |
;; automatically pair braces, single and double quotes | |
(require 'ruby-electric) |
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
# Get the official Emacs repo: | |
git clone http://repo.or.cz/r/emacs.git/ | |
# Get the fullscreen patch | |
git remote add typester git://github.com/typester/emacs.git | |
git fetch typester | |
# Create a patch and apply to HEAD | |
# I had merge conflicts when rebasing and | |
# build failures for origin/emacs-23 |
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
require 'httparty' | |
class GitHub | |
include HTTParty | |
base_uri 'http://github.com/api/v2/yaml' | |
API_METHODS = { | |
:watched => '/repos/watched/' } | |
class << self |
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
user=> ; get the expt funtion | |
user=> (use '[clojure.contrib.math :only (expt)]) | |
nil | |
user=> (expt 2 3) | |
8 | |
user=> ; function to calculate no. of pairs for n people | |
user=> (defn number-pairs [n] (/ (* n (- n 1)) 2)) | |
#'user/number-pairs | |
user=> ; how many pairs for 23 people? | |
user=> (number-pairs 23) |
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
class Fixnum | |
alias_method :intdiv, :/ | |
def /(divisor) | |
(self % divisor) == 0 ? self.intdiv(divisor) : self.to_f/divisor | |
end | |
end |
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
user=> ; generate random number | |
user=> (rand) | |
0.8545074632292601 | |
user=> ; infinite list of random numbers | |
user=> ; make sure to set *print-length* | |
user=> (set! *print-length* 10) | |
10 | |
user=> (repeatedly rand) | |
(0.13569783475252373 0.585868618595554 0.7048671603900427 0.1440943435265447 0.24546858003727567 0.15406959135696596 0.41117257771529947 0.1115848319639422 0.669215744258339 0.1521494621978804 ...) | |
user=> ; get the reductions function from seq-utils |
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
(use '(incanter core charts io)) | |
(def usage (read-dataset "report.csv" :header true)) | |
(def instance-types | |
(set (filter #(re-find #"BoxUsage" %) ($ :UsageType usage)))) | |
(with-data (->> ($rollup :sum :UsageValue :UsageType usage) | |
($where {:UsageType {:$in instance-types}})) | |
(view (bar-chart :UsageType :UsageValue | |
:title "EC Instance Usage" |