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
def happy_birthday(name, torture_level = 100) | |
hb = "Happy Birthday to You." | |
song = "#{hb} #{hb} Happy Birthday Dear #{name}. #{hb}" | |
song.chars.reduce do |memo, char| | |
%w[a e i o u y].include?(char) ? memo + char * torture_level : memo + char | |
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
class Asset < ActiveRecord::Base | |
def self.data_delegate(*methods) | |
methods.each do |method| | |
define_method(method) { data.send "[]", method } | |
define_method("#{method}=") { |val| data.send "[]=", method, val } | |
end | |
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
;; | |
;; NS CHEATSHEET | |
;; | |
;; * :require makes functions available with a namespace prefix. | |
;; | |
;; * :use makes functions available without a namespace prefix | |
;; (i.e., refers functions to the current namespace). | |
;; | |
;; * :import refers Java classes to the current namespace. | |
;; |
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
/* LightTable themes are just CSS. LightTable, CodeMirror, and plugins apply | |
classes to tokens within the text. Most of these classes are undocumented. I | |
had to go fishing with the dev inspector and apply brightly colored rules to | |
figure it out. Hopefully I can save you the trouble by documenting the default | |
theme. Please comment if you find any errors or omissions. */ | |
/* These #multi rules apply to tabsets. Active means currently selected and dirty | |
means that the file has been edited since the last save. */ | |
#multi.theme-default .tabset .list .active { color:var(placeholder-fg); } | |
#multi.theme-default .tabset.active .list .active { color:var(highlight-fg); } |
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
(defn render-str [el] | |
(dom/render-to-str | |
(om/build | |
(fn [data owner] | |
(reify | |
om/IRender | |
(render [_] el))) | |
{}))) | |
(render-str (dom/div nil)) |
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
(defrecord User [id]) | |
; -------------------- | |
; unmatch on Routes | |
(def routes | |
(silk/routes [[User ["users" (silk/integer :id)]]])) | |
(silk/unmatch routes User (User. 42)) ; you can use a record as a params map |
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 '[automat.core :as a]) | |
(-> [1 2 (a/$ :conj) 3 4 (a/$ :conj)] | |
(a/compile {:reducers {:conj conj}}) | |
(a/find nil [1 2 3 4]) | |
:value) | |
;=> (4 2) | |
(-> [1 a/any (a/$ :conj) 3 4 (a/$ :conj)] | |
(a/compile {:reducers {:conj conj}}) |
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
### Keybase proof | |
I hereby claim: | |
* I am DomKM on github. | |
* I am domkm (https://keybase.io/domkm) on keybase. | |
* I have a public key whose fingerprint is E8A7 7F7C FC53 EE8E 59FA 5468 0A66 DE7B 9E89 228D | |
To claim this, I am signing this object: |
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
(ns namespace) | |
(defrecord Language [name]) | |
(defmacro lang [name] | |
(->Language name)) | |
(def clj | |
(lang "Clojure")) |
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
;;;; Entity wrapper | |
#?(:clj (declare ->EntityMap)) | |
#?(:clj (deftype EntityMap [^datomic.query.EntityMap entity ^boolean ident?] | |
Object | |
(hashCode [this] | |
(.hashCode entity)) | |
(equals [this o] | |
(and (instance? (class this) o) | |
(.equals entity (.entity o)))) |
OlderNewer