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 'objspace' | |
| require 'active_record' | |
| require 'benchmark/ips' | |
| ActiveRecord::Base.establish_connection adapter: "sqlite3", | |
| database: ":memory:" | |
| ActiveRecord::Base.connection.instance_eval do | |
| create_table(:articles) { |t| t.string :name } | |
| 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
| test_error.rb:3: [BUG] Segmentation fault at 0x00000000000000 | |
| ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux] | |
| -- Control frame information ----------------------------------------------- | |
| c:0005 p:---- s:0012 e:000011 CFUNC :inspect | |
| c:0004 p:---- s:0010 e:000009 CFUNC :inspect | |
| c:0003 p:---- s:0008 e:000007 CFUNC :p | |
| c:0002 p:0024 s:0004 E:001dc8 EVAL test_error.rb:3 [FINISH] | |
| c:0001 p:0000 s:0002 E:001f18 TOP [FINISH] |
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
| > elements = {a1: 'a', b1: 'b', b2: 'b', b3: 'b', c1: 'c'} | |
| => {:a1=>"a", :b1=>"b", :b2=>"b", :b3=>"b", :c1=>"c"} | |
| > elements.group_by {|(_, val)| val }.flat_map {|(_, vals)| vals.shuffle } | |
| => [[:a1, "a"], [:b2, "b"], [:b3, "b"], [:b1, "b"], [:c1, "c"]] | |
| > elements.group_by {|(_, val)| val }.flat_map {|(_, vals)| vals.shuffle } | |
| => [[:a1, "a"], [:b1, "b"], [:b3, "b"], [:b2, "b"], [:c1, "c"]] | |
| > elements.group_by {|(_, val)| val }.flat_map {|(_, vals)| vals.shuffle } | |
| => [[:a1, "a"], [:b1, "b"], [:b3, "b"], [:b2, "b"], [:c1, "c"]] | |
| > elements.group_by {|(_, val)| val }.flat_map {|(_, vals)| vals.shuffle } | |
| => [[:a1, "a"], [:b2, "b"], [:b1, "b"], [:b3, "b"], [:c1, "c"]] |
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
| for i in app/models/*.rb ; do sed "s/\s\+def \(self\.\)\?\([^( ]*\).*\|\s\+scope :\([^,]*\).*/\2\3/;tx;d;:x" $i | while read j ; do echo $(grep -R $j app/ lib/ config/ | wc -l) $j ; done ; done | sort -rn |
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 Taco | |
| > def self.delicious? ; true ; end | |
| > singleton_class.send :alias_method, :yummy?, :delicious? | |
| > end | |
| => #<Class:Taco> | |
| > Taco.yummy? | |
| => true |
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
| pete@balloon:~/projects/nand2tetris/phiggins/01$ pwd | |
| /home/pete/projects/nand2tetris/phiggins/01 | |
| pete@balloon:~/projects/nand2tetris/phiggins/01$ ../../tools/HardwareSimulator.sh ~/projects/nand2tetris/phiggins/01/Mux4Way16.tst | |
| End of script - Comparison ended successfully | |
| pete@balloon:~/projects/nand2tetris/phiggins/01$ |
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 'spec_helper' | |
| describe User do | |
| it "should blow up" do | |
| expect(User).to receive(:create!).and_raise(ActiveRecord::RecordNotUnique) | |
| end | |
| end | |
| =begin | |
| Fails with: |
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
| Failure/Error: expect(View).to receive(:create!).and_raise(ActiveRecord::RecordNotUnique) | |
| ArgumentError: | |
| wrong number of arguments (0 for 2) |
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
| module Kernel | |
| def method_a | |
| :foo | |
| end | |
| end | |
| def method_b | |
| :bar | |
| 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
| module Kernel | |
| def required(arg=nil) | |
| method = caller_locations(1,1)[0].label | |
| raise ArgumentError.new("required parameter #{arg.to_sym.inspect + ' ' if arg}not passed to method #{method}") | |
| end | |
| end |