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 '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 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 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 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 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 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 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 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 |
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
; Global settings | |
[redshift] | |
temp-day=6000 | |
temp-night=3500 | |
transition=1 | |
gamma=0.8:0.7:0.8 | |
;location-provider=geoclue | |
location-provider=manual | |
adjustment-method=randr |
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 ^:dynamic *times* nil) | |
(defmacro timek | |
"Evaluates expr and prints the time it took. Returns the value of | |
expr." | |
{:added "1.0"} | |
[k expr] | |
(let [plus (fn [val val2] (if val (+ val val2) val2))] | |
`(let [start# (. System (nanoTime)) | |
ret# ~expr |