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
# Set up git repository | |
git :init | |
# Copy database.yml for distribution use | |
run "cp config/database.yml config/database.yml.example" | |
# Set up .gitignore files | |
run %{find . -type d -empty | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store |
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
(ns redis-memo | |
(:require redis) | |
(:import (java.net URLEncoder))) | |
;; -------------------------------------------------------------------------------- | |
;; Default connection params | |
;; -------------------------------------------------------------------------------- | |
(def memo-server {:host "localhost" :port 6379 :db 14}) |
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
;; | |
;; NS CHEATSHEET | |
;; | |
;; * :require makes functions available with a namespace prefix. | |
;; | |
;; * :use makes functions available without a namespace prefix | |
;; (i.e., refers functions to the current namespace). | |
;; | |
;; * :import refers Java classes to the current namespace. | |
;; |
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
class HexNum < Numeric | |
# Create a new instance from an int or String. | |
def initialize(val) | |
case val | |
when String | |
@i = parse_string(val) | |
@s = val.frozen? ? val : val.dup.freeze | |
when Numeric | |
@i = val.to_i |
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
;annotation syntax | |
(import [java.lang.annotation Retention RetentionPolicy Target ElementType] | |
[javax.xml.ws WebServiceRef WebServiceRefs]) | |
(definterface Foo (foo [])) | |
;annotation on type | |
(deftype ^{Deprecated true | |
Retention RetentionPolicy/RUNTIME | |
javax.annotation.processing.SupportedOptions ["foo" "bar" "baz"] |
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
MyApp.MyModel.mixin({ | |
resourcePathFor: function(action, storeKey, item) { | |
var id, path; | |
id = storeKey ? MyApp.store.idFor(storeKey) : null; | |
switch(action) { | |
case 'fetch': | |
case 'create': | |
path = 'items'; |
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 'peach' | |
[1,2,3,4].peach{ |n| n + 1 } #Spawns 4 threads | |
[1,2,3,4].pmap{ |x| f(x) } #Spawns 4 threads, returns => [f(1),f(2),f(3),f(4)] | |
[1,2,3,4].pselect{ |x| x > 2 } #Spawns 4 threads, returns => [3,4] |
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
;;; All Kinds of Destructuring ;;; | |
(let [foo 1] foo) | |
; => 1 | |
(let [[foo bar] [1 2 3]] [foo bar]) | |
; => [1 2] | |
(let [[foo bar & baz] [1 2 3]] [foo bar baz]) | |
; => [1 2 (3)] |
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
class AppBuilder < Rails::AppBuilder | |
include Thor::Actions | |
include Thor::Shell | |
def test | |
append_test_gems | |
rspec | |
cucumber | |
jasmine | |
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
source :rubygems | |
gem 'rails' | |
# Or find something else that returns true | |
# locally, but false on heroku | |
if RbConfig::CONFIG['host_os'] =~ /darwin/ | |
group :test do | |
# heroku fails hard on this gem | |
gem 'specjour' |
OlderNewer