Skip to content

Instantly share code, notes, and snippets.

@Odinodin
Odinodin / gist:8188135
Created December 30, 2013 21:06
animation frame
(def animate
"Request animation frame"
(or (.-requestAnimationFrame js/window)
(.-oRequestAnimationFrame js/window)
(.-mozRequestAnimationFrame js/window)
(.-webkitRequestAnimationFrame js/window)
(.-msRequestAnimationFrame js/window)
(fn [callback] (js/setTimeout callback 17))))
@Odinodin
Odinodin / .profiles.clj
Created August 31, 2013 06:34
Clojure linters in leiningen profile
{:user
{:plugins [[lein-kibit "0.0.8"] [lein-bikeshed "0.1.3"] [jonase/eastwood "0.0.2"]]}
...
}
@Odinodin
Odinodin / gist:6192393
Created August 9, 2013 09:32
Clojure validation with Metis
(ns app.controllers.validation
(:require [app.views.a :as a-view]
[metis.core :as metis]))
;; Validates that the required environment keys are present
(metis/defvalidator :environment-validator [[:core-url :db :auth-token] :presence ])
(metis/defvalidator :preview-body-validator [[:type :filter :template :index ] :presence ])
(metis/defvalidator :preview-request-validator [:body :preview-body-validator ])
@Odinodin
Odinodin / Plus
Created July 26, 2013 07:40
Rolling your own + using add1, sub1 and recursion
(define +
(lambda (a b)
(cond
[(zero? b) a]
[else (add1 (+ a (sub1 b)))])))
@Odinodin
Odinodin / readabletest.groovy
Created January 23, 2012 21:43
Groovy readable test names
class FooBarTest {
@Test
public "should do foo"() {
// ...
}
@Test
public "should do bar"() {
// ..