Skip to content

Instantly share code, notes, and snippets.

(ns async-example.core
(:gen-class)
(:require [clojure.core.async
:as a
:refer [>! <! >!! <!! go chan buffer close! thread
alts! alts!! timeout]]))
(def write-to-file-channel (chan 10000))
(defn get-contents [name]
#!/usr/bin/env ruby
REGXS = {
/context/ => "describe",
/assert_equal\(?\s*([^,]+), (.*)\s*\)?$/ => "\\2.should == \\1",
/setup do/ => "before( :each ) do",
/should([^_])/ => "it\\1",
/require File.dirname.*$/ => "require \"spec_helper\"",
/class (.*)Test < [^:]*::TestCase/ => "describe \\1 do"
}
@jscruggs
jscruggs / hash_with_indifferent_access_test.rb
Created December 10, 2010 19:41
Why doesn't HashWithIndifferentAccess have deep_clone in test env only? (works fine in development env)
class HashWithIndifferentAccessTest < ActiveSupport::TestCase
def test_should_have_deep_clone
h = HashWithIndifferentAccess.new
h.deep_clone
end
end
# Fails for me in Rails 2.3.5 using REE
#
# test_should_have_deep_clone(HashWithIndifferentAccessTest):
@jscruggs
jscruggs / indexes_on_foreign_keys_test.rb
Created December 7, 2010 16:24
Test that looks for Foreign Keys that have no Index in Oracle
require File.dirname(__FILE__) + '/../../test_helper/test_helper'
class IndexesOnForeignKeysTest < ActiveSupport::TestCase
context "IndexesOnForeignKeysTest" do
should "not have foreign keys without indexes as it leads to deadlocks" do
cursor = ActiveRecord::Base.connection.execute <<-SQL
select 'execute ''CREATE INDEX '||substr(constraint_name,1,28)||'_I ON '||table_name||'('||
cname1 || nvl2(cname2,','||cname2,null) ||
nvl2(cname3,','||cname3,null) || nvl2(cname4,','||cname4,null) ||
nvl2(cname5,','||cname5,null) || nvl2(cname6,','||cname6,null) ||
(ns change.maker)
; The point of this exercise is to create a change maker. That is, given any amount of cents
; the code will return an array with the minimum amount of coins that add up to the required amount.
; The array should be arranged from highest to lowest value coin.
;
; A working version will provide the output specified below:
; (make-change 26) => [25,1]
; (make-change 24) => [10,10,1,1,1,1]
; (make-change 49) => [25,10,10,1,1,1,1]