Skip to content

Instantly share code, notes, and snippets.

// automatically adds JS bindings to attach Google Analytics tracking
//
// defaults
//
// class: ga-track all elements with this class will have
// handlers attached on DOM ready
//
// data-ga-binding: click the binding on which to fire the tracking
//
// data-ga-event: _trackEvent the analytics event send to Google
deals:
idle_timeout: 1800
dir: ~/ls/deals
rvm: foreman start
app_port: 3000
server_port: 4000
kill_with: KILL
cupcake:
idle_timeout: 300
dir: ~/ls/cupcake

What exactly does ::SomeModule do? I first expected that it was a method like any other, getting called in the context it was in, so I went into irb to confirm.

1.8.7 :001 > class A; class B; end; end
 => nil 
1.8.7 :002 > A.send(:::, :B)
SyntaxError: compile error
(irb):2: syntax error, unexpected tSYMBEG, expecting tCONSTANT
A.send(:::, :B)
          ^
@tyre
tyre / gist:4045730
Created November 9, 2012 13:46
Keyword Arguments + iVars
2.0.0-preview1 :001 > class Walrus
2.0.0-preview1 :002?> attr_accessor :bubbles
2.0.0-preview1 :003?> def initialize(bubbles: @bubbles)
2.0.0-preview1 :004?> end
2.0.0-preview1 :005?> end
=> nil
2.0.0-preview1 :006 > Walrus.new bubbles: 'It works!'
=> #<Walrus:0x007fe8a1e78e48>
2.0.0-preview1 :007 > _.bubbles
=> nil
(defmacro create-tag-fn [tag-name]
`(def css-str (atom ""))
(defn (symbol ~tag-name) [properties]
(apply (fn [k v]
(swap! css-str
(str @css-str " " k ": " v "; ")))
(seq properties))))
@tyre
tyre / gist:2996086
Created June 26, 2012 14:25
clojure.lang.Symbol cannot be cast to java.lang.String
(defpage "/boundary" {:keys [latitude longitude distance]}
(resp/json (apply LatLong/bounding-box
(
(fn [a b c]
(map read-string '(a b c) ))
latitude longitude distance)))
)
; LatLong/bounding-box takes three arguments which should be numbers (though not necessarily ints)
; latitude, longitude, and distance are strings coming in and need to be numbers passed in
@tyre
tyre / gist:2992360
Created June 26, 2012 00:44
Stacktrace for lein help
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at jline.ConsoleRunner.main(ConsoleRunner.java:69)
Caused by: java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.eval(Compiler.java:5391)
at clojure.core$eval.invoke(core.clj:2382)
@tyre
tyre / gist:2903823
Created June 10, 2012 04:29
Configuration for File Uploader
class FileUploader < AWS::S3::S3Object
AWS::S3::Base.establish_connection!(
access_key_id: AWS_KEY,
secret_access_key: AWS_SECRET)
set_current_bucket_to 'hackchat'
end
@tyre
tyre / gist:2863794
Created June 3, 2012 14:48
“We value code that is easy to maintain over code that is easy to write.” -#goos Discuss.
That's because we adopt these practices from the business itself.
Consider the startup world. It's easy to make something flashy that piques your interest for a week or two, but then again 99% of those businesses fail.
The ones that succeed have a real market, data to back it up, and a solid internal organization.
Is it harder to make a business structured this way? Absolutely, but the payoff of creating something that is more than just a fad is huge.
Don't build software that's meant to be a fad.