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-1.8.7-p352 :001 > require 'rubygems' | |
=> true | |
ruby-1.8.7-p352 :002 > require 'bundler' | |
=> true | |
ruby-1.8.7-p352 :003 > Bundler.require | |
=> [<Bundler::Dependency type=:runtime name="sinatra" requirements=">= 0">, <Bundler::Dependency type=:runtime name="json" requirements=">= 0">, <Bundler::Dependency type=:runtime name="rest-client" requirements=">= 0">, <Bundler::Dependency type=:runtime name="passenger" requirements=">= 0">, <Bundler::Dependency type=:runtime name="capistrano" requirements=">= 0">, <Bundler::Dependency type=:runtime name="capistrano-ext" requirements=">= 0">, <Bundler::Dependency type=:runtime name="jasmine" requirements=">= 0">, <Bundler::Dependency type=:runtime name="rspec" requirements=">= 0">, <Bundler::Dependency type=:runtime name="libnotify" requirements=">= 0">] | |
ruby-1.8.7-p352 :004 > require 'jasmine' | |
Gem::LoadError: Could not find rails (>= 3.0) amongst [bundler-1.0.15, highline-1.6.2, net-ssh-2.1.4, net-scp-1.0.4, net-sftp-2.0.5, net-ssh-gateway-1.1.0, capistrano-2.6.0, |
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
;; -> lets you turn this | |
(defn deploy-definition-from-resource | |
[resource-name] | |
(.deploy | |
(.addClassPathResource | |
(.name | |
(.createDeployment (repository-service)) | |
"w00t gonna deploy") | |
resource-name))) |
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 bijector.core | |
(:require [goog.math :as math])) | |
(defn bigint | |
[n] | |
(new math/Integer n)) |
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
user=> (require '[clojure.java.io :as jio]) | |
nil | |
user=> (jio/writer "/tmp/kd4joa.txt") | |
#<BufferedWriter java.io.BufferedWriter@164feb> | |
user=> (.write *1 "TOMMY") | |
nil | |
user=> (.close *2) | |
nil |
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
(let [f (fn [f* x] | |
(print x) | |
(if (< x 2) | |
x | |
(+ (f* f* (dec x)) (f* f* (dec x))))), | |
g (memoize f) | |
h (partial g g)] | |
(h 3)) | |
; prints "3214" |
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
(require '[clojure.walk :as wk]) | |
(def whitelist | |
(let [syms ['+ '- '* '/]] | |
(zipmap syms (map eval syms)))) | |
(defn compute | |
[form] | |
(wk/postwalk | |
(fn [el] | |
(if (sequential? el) |
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
(def *config* nil) | |
(defn wrap-configged-fn | |
[f] | |
(fn [& [maybe-config :as args]] | |
(if (and *config* (not (identical? *config* maybe-config))) | |
(apply f *config* args) | |
(apply f args)))) | |
(defmacro defn-with-config |
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
; Running the (print-531) function defined at the bottom | |
; prints the following table: | |
; | |
; ================================= | |
; [m1 m2 m3 m4] | [m1' m2' m3' m4'] | |
; ================================= | |
; [0 0 0 0] | [0 0 0 0] | |
; [0 0 0 1] | [0 0 0 1] | |
; [0 0 1 0] | [1 0 1 0] | |
; [0 0 1 1] | [1 0 1 1] |
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
(defmacro defbean | |
[class-name | |
field-names | |
& interface-specs] | |
(let [sym-base (str (gensym)), | |
prefix-sym #(->> % name (str sym-base) symbol), | |
setter-name | |
(fn [field-name] | |
(->> field-name name inf/capitalize (str sym-base "set") symbol)), | |
setters |
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
(match [["foo"]] | |
[["foo"]] | |
:match-a | |
[["foo" a]] | |
:match-b | |
[["bar"]] | |
:match-c | |
[["baz" a b c d e]] | |
:match-d | |
[["baz"]] |