Skip to content

Instantly share code, notes, and snippets.

View meaganewaller's full-sized avatar

Meagan Waller meaganewaller

View GitHub Profile
@meaganewaller
meaganewaller / coin_changer.rb
Created February 3, 2014 23:43
Coin Changer Kata
class CoinChanger
def initialize
@purse = Hash.new(0)
@coin_values = { :quarter => 25, :dime => 10, :nickel => 5, :penny => 1}
end
def make_change(amount)
@coin_values.each_value do |value|
if amount >= value
(ns wishes.wishlist-spec
(:require
[wishes.wishlist :refer all]
[speclj.core :refer all]))
(describe "Wishlist"
(with fake-wishlist
{:name "Fake Wishlist"
:description "My Fake Wishlist"})
one_through_five = *1..5
print one_through_five
#=> [1,2,3,4,5]
super_simple_rack_proc = lambda { puts 'Super Simple Rack App' }
super_simple_rack_proc.call
@meaganewaller
meaganewaller / before_clojure.clj
Created January 1, 2015 00:38
Conditional Binding in Clojure
(defn first-function [args]
(let [first (first/suggest (:input args))]
{:status 200 :headers {"Content-Type" "application/json"} :body {:first-entity
first}}))
(defn second-function [args]
(let [second (second/suggest (:input args))]
{:status 200 :headers {"Content-Type" "application/json"} :body {:second-entity
second}}))
@meaganewaller
meaganewaller / wishlist-spec.clj
Last active August 29, 2015 14:12
Mocking Functions in Clojure
(ns wishes.wishlist-spec
(:require
[wishes.wishlist :refer all]
[speclj.core :refer all]))
(describe "Wishlist"
(with fake-wishlist
{:name "Fake Wishlist"
:description "My Fake Wishlist"})
@meaganewaller
meaganewaller / 1.clj
Created January 1, 2015 00:51
clojure fizzbuzz
(ns fizzbuzz.core-spec
(:require [speclj.core :refer :all]
[fizzbuzz.core :refer :all]))
(describe "fizzbuzz"
(it "1 is 1"
(should=1 (fizzbuzz 1))))
@meaganewaller
meaganewaller / anon.clj
Created January 1, 2015 00:57
anonymous functions in clojure
; the syntax
(fn [param-list]
function body)
(map (fn [n] (str "hello " n)) [ "alice" "bob" "carl"])
; => ("hello alice", "hello bob", "hello carl")
((fn [x] (* x 3)) 5)
;=> 15
@meaganewaller
meaganewaller / gotchas.vim
Created January 1, 2015 00:59
getting started with clojure
" Vim indent file
....
"Speclj Indentation Support
setlocal
lispwords+=describe,it,context,around,should=,should-not=,should-not,should,should-be,with,run-specs
...
@meaganewaller
meaganewaller / example.rb
Created January 1, 2015 01:00
adding environment to rake task
desc "Rake task description"
task :task => :environment do
puts "My rask taks does this thing!"
end