Skip to content

Instantly share code, notes, and snippets.

Larry Diehl larrytheliquid

Block or report user

Report or block larrytheliquid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View bug_walk_simulation_test.rb
module BugWalkSimulation
describe Bug, "#dead?" do
it "should be false when the number of moves is less than the moves lifetime" do
bug = new_bug(:moves_lifetime => 3)
bug.expects(:number_of_moves).returns(2)
bug.should_not be_dead
end
it "should be true when the number of moves is greater than the moves lifetime" do
bug = new_bug(:moves_lifetime => 2)
View gist:31633
(ns clojure (:use specjure))
(describe + "without arguments"
(it "returns 0"
(should = 0 (+))))
(describe + "with a single argument"
(it "returns the argument"
(should = 1 (+ 1))
(should = 1337 (+ 1337))))
View gist:31635
(ns clojure (:use specjure))
(it + "without arguments returns 0"
(should = (+) 0))
(it + "with a single argument returns the argument"
(should = 1 (+ 1))
(should = 1337 (+ 1337)))
(it + "with multiple arguments returns the sum of the arguments"
View gist:31637
;;; RSpec stack example: http://rspec.info/examples.html
;;; Implementation
(ns specjure.examples
(:refer-clojure :exclude [empty? peek])
(:use specjure))
(defn stack []
(ref ()))
View gist:41468
(share-test "non-empty specjure.examples/stack" []
(test "is not empty"
(is (not (empty? ($get :stack)))))
(test "returns the top item when applied to specjure.examples/peek"
(is (= ($get :last-item-added) (peek ($get :stack)))))
(test "does not remove the top item when applied to specjure.examples/peek"
(is (= ($get :last-item-added) (peek ($get :stack))))
(is (= ($get :last-item-added) (peek ($get :stack)))))
View client.rb
require "rubygems"
require "rack/client"
require "rack/contrib"
puts "PUT'ing /store/fruit (with strawberry)"
puts
Rack::Client.put "http://localhost:9292/store/fruit", "strawberry"
puts "GET'ing /store/fruit"
View gist:151724
# tail.rb
# JAVA_OPTS="-Djruby.tailcall.enabled=true" jruby tail.rb --1.9
# Error: Your application used more stack memory than the safety cap of 1024k.
# Specify -J-Xss####k to increase it (#### = cap size in KB).
# Specify -w for full StackOverflowError stack trace
def fact(n, acc)
if n == 0
acc
else
View gist:177894
require 'rubygems'
require 'eventmachine'
require 'em-http'
require 'dataflow'
Thread.new {
EM.run{}
}
module EventMachine
View regex_of_doom.rb
"the /data/nginx/servers/:application.rewrites for the customer's application file exists" =~ /^the ((?:\w+|\/|\.|-|~|:)+(?:for the \S+ application)?) file exists$/
View filesystem.feature
Scenario Outline: filesystem setup
Then the <path> <type> exists
And the owner of <path> is the <user> user
And the group of <path> is the group of the <user> user
And the permissions for <path> are <permissions>
Scenarios: configuration
| type | permissions | user | path |
| file | 0644 | customer's | /data/nginx/nginx.conf |
| directory | 0775 | customer's | /data/nginx/ssl |
You can’t perform that action at this time.