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
| Obligatory Philosophical Rich Hickey talk about systems-level IPC and data formats | |
| http://www.youtube.com/watch?v=ROor6_NGIWU | |
| * EDN | |
| EDN Spec and Rationale: | |
| https://github.com/edn-format/edn |
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 playingwithmacros.core | |
| (:require [clojure.java.browse :refer [browse-url]] | |
| [clojure.pprint :as pp] | |
| [clojure.core.strint :as strint])) | |
| (defmacro my-simple-macro | |
| "A docstring" | |
| [first-arg second-arg & varargs] | |
| "A return value of some kind") |
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 'package) | |
| (add-to-list 'package-archives | |
| '("marmalade" . "http://marmalade-repo.org/packages/") t) | |
| (package-initialize) | |
| (require 'auto-complete) | |
| (add-to-list 'ac-dictionary-directories "~/.emacs.d/dict") | |
| (require 'auto-complete-config) | |
| (ac-config-default) |
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
| a = ["first", "second", "third", "fourth"] | |
| puts "#{a}" | |
| puts a[0] | |
| puts a[3] | |
| b = {"key1" => "value1", | |
| "key2" => "value2"} |
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 'mechanize' | |
| def google_search(query_text) | |
| agent=Mechanize.new | |
| goog = agent.get "http://www.google.com" | |
| search = goog.form_with(:action => "/search") | |
| search.field_with(:name => 'q').value = query_text | |
| results = search.submit | |
| return results | |
| end |
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 rcf | |
| "Reports from the calling stack frame, useful for utility | |
| assertion functions to workaround clojure.test's reporting of file-and-line info." | |
| [& expr] | |
| `(let [reports# (atom []) | |
| out# (with-redefs [clojure.test/do-report (fn [m#] (swap! reports# conj m#))] | |
| ~@expr) | |
| final# @reports#] | |
| (doseq [m# final#] | |
| (clojure.test/do-report m#)))) |
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
| <btn icon="icon-step-backward">Replay</btn> | |
| angular.module('myApp', []).directive('btn', function() { | |
| return { | |
| scope: { icon: '@' }, | |
| template: '<button class="btn span4"><i class="{{icon}}"></i>{{extra}}</button>', | |
| restrict: 'E' | |
| } |
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
| Error: Invalid isolate scope definition for directive btn: <i class=@icon></i> | |
| JS: | |
| angular.module('myApp', []).directive('btn', function() { | |
| return { | |
| scope: { inner: '<i class=@icon></i>' }, | |
| template: '<button class="btn span4">{{inner}}</button>', | |
| restrict: 'E', | |
| replace: true, | |
| transclude: true |
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> (clojure.pprint/pprint (macroexpand-all '(defn constrained-fn [f x] | |
| {:pre [(pos? x)] | |
| :post [(= % (* 2 x))]} | |
| (f x)))) | |
| (def | |
| constrained-fn | |
| (fn* | |
| ([f x] | |
| (if | |
| (pos? x) |
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
| ; nREPL 0.1.7 | |
| user> (defmacro my-macro [name params] `(defn ~name ~params (prn 1))) | |
| #'user/my-macro | |
| user> (my-macro a [b c d]) | |
| #'user/a | |
| user> (a) | |
| ArityException Wrong number of args (0) passed to: user$a clojure.lang.AFn.throwArity (AFn.java:437) | |
| user> (a 1 2 3) | |
| 1 | |
| nil |