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
# html_formatter | |
class HTMLFormatter | |
def output_report(context) | |
puts '<html>' | |
puts ' <head>' | |
puts " <title>#{context.title}</title>" | |
puts ' </head>' | |
puts ' <body>' | |
context.text.each do |line| | |
puts " <p>#{line}</p>" |
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 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 |
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
meagan = Employee.new('Meagan', 'Apprentice', 100000) | |
meagan.salary = 250000 | |
# Warning! Inconsistent state here! | |
meagan.title = 'President of the United States' |
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
desc "Rake task description" | |
task :task => :environment do | |
puts "My rask taks does this thing!" | |
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
" Vim indent file | |
.... | |
"Speclj Indentation Support | |
setlocal | |
lispwords+=describe,it,context,around,should=,should-not=,should-not,should,should-be,with,run-specs | |
... |
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
; 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 |
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 fizzbuzz.core-spec | |
(:require [speclj.core :refer :all] | |
[fizzbuzz.core :refer :all])) | |
(describe "fizzbuzz" | |
(it "1 is 1" | |
(should=1 (fizzbuzz 1)))) |
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 wishes.wishlist-spec | |
(:require | |
[wishes.wishlist :refer all] | |
[speclj.core :refer all])) | |
(describe "Wishlist" | |
(with fake-wishlist | |
{:name "Fake Wishlist" | |
:description "My Fake Wishlist"}) | |
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
(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}})) |
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
super_simple_rack_proc = lambda { puts 'Super Simple Rack App' } | |
super_simple_rack_proc.call |