- Keep one-point.
- Relax completely.
- Keep weight underside.
- Extend Ki.
- Ki is extending.
| 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 |
| # 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 |
| (def pipe_delim_text | |
| "Lorem|ipsum|dolor | |
| sit|amet,|consectetur | |
| ") | |
| (def fixed-width-text "122333455666") | |
| (defrecstruct lorem-record | |
| (:field1 (delimiter "|")) | |
| (:field2 (delimiter "|")) |
| resource organisation do | |
| responds_to do | |
| get new { | |
| success: -> {render "a page"}, | |
| error: (reason) -> {redirect_to some_error(reason)} | |
| } | |
| end | |
| end |
| # 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 |
| ; 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"))) |
| (ns homoiconic.my-defn) | |
| ; ----------- --- --- -- -- - - | |
| (defn hello [what] | |
| (str "hello " what)) | |
| (hello "world") | |
| ; ----------- --- --- -- -- - - |