Skip to content

Instantly share code, notes, and snippets.

(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)
@gtrak
gtrak / gist:6514209
Last active December 22, 2015 18:39
a = ["first", "second", "third", "fourth"]
puts "#{a}"
puts a[0]
puts a[3]
b = {"key1" => "value1",
"key2" => "value2"}
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
@gtrak
gtrak / gist:6346408
Last active December 21, 2015 18:19
Clojure.test hacks.
(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#))))
<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'
}
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
@gtrak
gtrak / pre.clj
Last active December 20, 2015 19:08
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)
; 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
@gtrak
gtrak / redshift.conf
Created August 5, 2013 16:51
~/.config/redshift.conf
; 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
(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