List remote branches
git branch -a
Checkout a remote branch (from origin)
git checkout -b branch_name origin/branch_name
(ns homoiconic.my-defn) | |
; ----------- --- --- -- -- - - | |
(defn hello [what] | |
(str "hello " what)) | |
(hello "world") | |
; ----------- --- --- -- -- - - |
; My "lightbulb" moment at EuroClojure 2012 was that clojure is at it's most | |
; powerful when you build abstractions in the data and keep the functions as | |
; generic as possible so you can chain them easily | |
; For example, here is some code I wrote a few months ago to parse a freebase TSV file | |
(def keywords {"id" "freebase_id"}) | |
(defn override-keywords [field-name] | |
(let [alternative (get keywords field-name)] | |
(if (nil? alternative) field-name alternative))) | |
(defn get-field-names [line] (map override-keywords (str/split line #"\t"))) |
# Specs | |
describe "a sucessful create" do | |
it "redirects" do | |
Organization.any_instance.stub(:saved? => true) | |
controller = OrganizationsController.new | |
controller.should_receive(:redirect_to) | |
controller.create | |
end | |
end |
resource organisation do | |
responds_to do | |
get new { | |
success: -> {render "a page"}, | |
error: (reason) -> {redirect_to some_error(reason)} | |
} | |
end | |
end |
(def pipe_delim_text | |
"Lorem|ipsum|dolor | |
sit|amet,|consectetur | |
") | |
(def fixed-width-text "122333455666") | |
(defrecstruct lorem-record | |
(:field1 (delimiter "|")) | |
(:field2 (delimiter "|")) |
# Extracted from Matt Yoho's (https://github.com/mattyoho) talk at Scottish Ruby Conference 2012 | |
# Exploiting the Resource Idiom - https://speakerdeck.com/u/mattyoho/p/exploiting-the-resource-idiom | |
# | |
module ResourceModel | |
def self.inherited(inheritor) | |
inheritor.class_eval do | |
include ActiveModel::Naming | |
include ActiveModel::Validations | |
include ActiveModel::Translation |
echo HOST.DOMAIN.com > /etc/hostname | |
/bin/hostname -F /etc/hostname | |
/etc/init.d/httpd restart | |
# Add to /etc/hosts | |
127.0.0.1 HOST.DOMAIN.com |
describe "calculator" do | |
let(:calculator) { CalculatorFactory.new.create } | |
it "adds numbers" do | |
calculator.calculate("1 + 2").should == 3 | |
end | |
it "adds big numbers" do | |
calculator.calculate("11 + 22").should == 33 | |
end |