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
# 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 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
require 'httparty' | |
class GitHub | |
include HTTParty | |
base_uri 'http://github.com/api/v2/yaml' | |
API_METHODS = { | |
:watched => '/repos/watched/' } | |
class << self |
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=> ; 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 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 Fixnum | |
alias_method :intdiv, :/ | |
def /(divisor) | |
(self % divisor) == 0 ? self.intdiv(divisor) : self.to_f/divisor | |
end | |
end |
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=> ; 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 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
(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" |
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
Usage: clj [java-opt*] [init-opt*] [main-opt] [arg*] | |
With no options or args, runs an interactive Read-Eval-Print Loop | |
java options: | |
-<javaopt> Configure JVM (see `java -help` for full list) | |
-d, --debug port Open a port for debugging | |
init options: | |
-i, --init path Load a file or resource |
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 Lucky < [String, Array][rand(2)]; end | |
puts Lucky.superclass |
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 Polynomial | |
def initialize(coefficients) | |
raise ArgumentError, "Need at least 2 coefficients" if coefficients.size < 2 | |
@co = coefficients | |
@powers = Array.new(@co.size - 2) { |i| "x^#{i+2}"}.reverse << 'x' << nil | |
end | |
def to_s | |
return "0" if @co.all? { |c| c.zero? } # not much to do in this case | |
@co.zip(@powers).map do |el| |