This file contains hidden or 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 search.core | |
(:use clojure.test)) | |
(defn truncated-half-count [items] | |
(int (/ (count items) 2))) | |
(defn middle-index [items] | |
(truncated-half-count items)) | |
(defn middle-item [items] |
This file contains hidden or 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
1.9.3-p125 :001 > require 'fog' | |
=> true | |
1.9.3-p125 :002 > Fog::Compute::AWS | |
=> Fog::Compute::AWS | |
1.9.3-p125 :003 > Fog::Compute::AWS::SecurityGroup | |
NameError: uninitialized constant Fog::Compute::AWS::SecurityGroup | |
from (irb):3 | |
from /Users/8thlight/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `<main>' | |
1.9.3-p125 :004 > c = Fog::Compute.new({:provider => "AWS", :aws_access_key_id => "a", :aws_secret_access_key => "abc"}) | |
=> #<Fog::Compute::AWS::Real:70315738224820 @use_iam_profile=nil @aws_access_key_id="a" @aws_credentials_expire_at=nil @connection_options={} @region="us-east-1" @instrumentor=nil @instrumentor_name="fog.aws.compute" @version="2012-07-20" @endpoint=nil @host="ec2.us-east-1.amazonaws.com" @path="/" @persistent=false @port=443 @scheme="https" @connection=#<Fog::Connection:0x007fe751330cd0 @excon=#<Excon::Connection:0x007fe751330c80 @connection={:chunk_size=>1048576, :connect_timeout=>60, :headers=>{}, :instrumentor_name=>"excon", :mock=>false, :nonblock=>true, :read_timeout=>60 |
This file contains hidden or 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 Coinfactorizer | |
def self.change(target, domain) | |
answer = {} | |
answer_data = domain.elements(target).reduce({target: target, answer: {}}) do |aggregator, domain_element| | |
new_target, quantity_of_element = domain.destroy_domain_element_from_total(aggregator[:target], domain_element) | |
old_answer = aggregator[:answer] | |
new_answer = assoc(old_answer, domain_element, quantity_of_element) if quantity_of_element > 0 | |
new_answer ||= old_answer | |
{target: new_target, answer: new_answer} | |
end |
This file contains hidden or 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 'coinfactorizer' | |
describe Coinfactorizer do | |
context "coins" do | |
it "changes 0" do | |
Coinfactorizer.change(0, Coins).should == {} | |
end | |
it "changes 1" do | |
Coinfactorizer.change(1, Coins).should == {1 => 1} | |
end |
This file contains hidden or 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
1.9.3-p194 :001 > [1,2,3,4]["hello"] | |
TypeError: can't convert String into Integer | |
from (irb):1:in `[]' | |
from (irb):1 |
This file contains hidden or 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 'rspec' | |
class ExceptionSad | |
def self.run(thing) | |
thing.hello | |
thing.wtf | |
rescue Exception => e | |
end | |
end |
This file contains hidden or 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 trollchanger.core) | |
(def change-hash | |
{ | |
1 [1] | |
2 [1 1] | |
3 [1 1 1] | |
4 [1 1 1 1] | |
5 [5] | |
6 [5 1] |
This file contains hidden or 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 parallel-clojure.core-test | |
(:use clojure.test | |
parallel-clojure.core)) | |
(def ^:dynamic set-me 1) | |
(deftest varset-test | |
(testing "value does not go into new thread" | |
(binding [set-me 99] | |
(let [thread (Thread. (fn [] (is (= set-me 1))))] |
This file contains hidden or 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 Foo < Hash | |
def initialize(input_hash) | |
self.class[input_hash] | |
end | |
end | |
Foo[{h: 22}] | |
# => {:h=>22} | |
Foo.new({h: 22}) |
This file contains hidden or 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
1.9.3p194 :001 > def biz | |
1.9.3p194 :002?> 22 | |
1.9.3p194 :003?> end | |
=> nil | |
1.9.3p194 :004 > biz = biz | |
=> nil | |
1.9.3p194 :005 > biz | |
=> nil |
OlderNewer