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
;; Datomic example code | |
(use '[datomic.api :only (db q) :as d]) | |
;; ?answer binds a scalar | |
(q '[:find ?answer :in ?answer] | |
42) | |
;; of course you can bind more than one of anything | |
(q '[:find ?last ?first :in ?last ?first] | |
"Doe" "John") |
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
CMRotationMatrix rotationMatrixFromGravity(float x, float y, float z) | |
{ | |
// The Z axis of our rotated frame is opposite gravity | |
vec3f_t zAxis = vec3f_normalize(vec3f_init(-x, -y, -z)); | |
// The Y axis of our rotated frame is an arbitrary vector perpendicular to gravity | |
// Note that this convention will have problems as zAxis.x approaches +/-1 since the magnitude of | |
// [0, zAxis.z, -zAxis.y] will approach 0 | |
vec3f_t yAxis = vec3f_normalize(vec3f_init(0, zAxis.z, -zAxis.y)); | |
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
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
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
$ ruby --version | |
ruby 2.0.0dev (2012-03-20 trunk 35094) [x86_64-darwin11.3.0] | |
$ ruby pipeline_bench.rb | |
IMPLEMENTATION take(10) take(100) take(1000) to_a | |
conventional (eager) 0.01416 0.01407 0.01422 0.01411 | |
enumerating 0.00003 0.00007 0.00063 0.03140 | |
lazing 0.00004 0.00011 0.00098 0.04759 | |
ruby2 Enumerable#lazy 0.00004 0.00013 0.00112 0.05304 | |
facets Enumerable#defer 0.00005 0.00018 0.00162 0.07108 |
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
;; lein settings | |
(defproject foo "1.0.0-SNAPSHOT" | |
:description "Test App" | |
:dependencies [[com.datomic/datomic "0.1.2678"] | |
[frinj "0.1.2" :exclusions [org.clojure/clojure]]]) | |
;; load libs | |
(use 'frinj.core 'frinj.calc) | |
(frinj-init!) | |
(use '[datomic.api :only (q db) :as d]) |
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
(ns test.cometd-client | |
(:import (org.cometd.bayeux.client ClientSessionChannel$MessageListener) | |
(org.cometd.client BayeuxClient BayeuxClient$State) | |
(org.cometd.client.transport ClientTransport LongPollingTransport) | |
(org.eclipse.jetty.client HttpClient))) | |
(def channel-name "/my-channel") | |
(def client-url "http://localhost:8080/cometd") |
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
# Emulates the QuickCheck ?SOMETIMES macro. | |
module Sometimes | |
def run_with_retries(example_to_run, retries) | |
self.example.metadata[:retries] ||= retries | |
retries.times do |t| | |
self.example.metadata[:retried] = t + 1 | |
self.example.instance_variable_set(:@exception, nil) | |
example_to_run.run | |
break unless self.example.exception |
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
(ns pallet.crate.rvm | |
"Standard rvm install" | |
(:require | |
[pallet.crate.git :as git] | |
[pallet.action.conditional :as conditional] | |
[pallet.action.exec-script :as exec-script] | |
[pallet.action.package :as package] | |
[pallet.action.remote-file :as remote-file] | |
[pallet.action.user :as user] | |
[pallet.context :as context] |
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
; highlight support for multiple languages | |
(defconst mumamo-highlight-tag-start-regex | |
(rx "{%" | |
(0+ space) | |
"highlight" | |
space | |
(submatch | |
(1+ (any "a-za-z"))) | |
(0+ space) | |
"%}" |
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
(defn clj->js | |
"Recursively transforms ClojureScript maps into Javascript objects, | |
other ClojureScript colls into JavaScript arrays, and ClojureScript | |
keywords into JavaScript strings." | |
[x] | |
(cond | |
(string? x) x | |
(keyword? x) (name x) | |
(map? x) (.strobj (reduce (fn [m [k v]] | |
(assoc m (clj->js k) (clj->js v))) {} x)) |