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
@adder = 0 | |
@adder_queue = Dispatch::Queue.new('adder_queue') | |
@nums = (0..9).to_a | |
@nums.p_each do |n| | |
val = n ** 2 | |
@adder_queue.sync do | |
@adder += val | |
end | |
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
$h = {} | |
$s = "" | |
$f = proc do | |
ObjectSpace.count_objects($h) | |
$c += $h[:TOTAL] - $h[:FREE] | |
$s = "" | |
ObjectSpace.define_finalizer($s, $f) | |
$s = nil | |
puts "Total objects allocated: #{$c}, GC Cycles: #{GC.count}" | |
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
# Compare the results running under Ruby 1.9.2 and Ruby 1.9.3 | |
class Foo | |
def initialize | |
@@value = "Set from Foo initialize" | |
end | |
def report | |
@@value | |
end | |
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
# Both examples work under Ruby 1.9.2, but not under Ruby 1.9.3 (and yes, I | |
# realize both are bad practice anyway...): | |
# 1. | |
def test(foo, &block) | |
end | |
test 'hello', do; end | |
# 2. | |
class Foo; 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
#!/usr/local/bin/macruby | |
server = Dispatch::Queue.new('my-server') | |
in_progress = Dispatch::Group.new | |
server.async(in_progress) do | |
puts "Server running" | |
server.suspend! |
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
STATE README TEMPLATE | |
===================== | |
Metadata | |
-------- | |
Name: | |
Abbreviation: | |
Legislature Name: | |
Upper Chamber Name: | |
Lower Chamber Name: |
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
require 'benchmark' | |
require 'set' | |
[10000, 100000, 1000000].each do |length| | |
Benchmark.bmbm do |x| | |
a = (1..length).to_a | |
s = Set.new(a) | |
h = Hash[a.zip([true]*a.length)] | |
puts "\n\nSearching through #{length} elements" |
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
diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml | |
index 8c98f41..81d5e87 100644 | |
--- a/app/views/comments/_comment.html.haml | |
+++ b/app/views/comments/_comment.html.haml | |
@@ -10,10 +10,10 @@ | |
- editor_or_above ||= false | |
- too_many_comments_for_photos ||= false | |
-.clearfix.less-headroom.less-legroom.comment{:class => "#{comment.reply_to_id ? 'prepend-2' : ''}"} | |
+.clearfix.less-headroom.less-legroom.comment{:class => "#{comment.reply_to_id ? 'prepend-2' : ''}", :id => "comment_#{comment.id}"} |
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
ping-audit-10-167-180-181-20101108: ~ > macirb | |
Awesome Print gem not installed | |
irb(main):001:0> Time.ancestors | |
=> [Time, Comparable, NSDate, NSObject, Kernel] | |
irb(main):002:0> Date.ancestors | |
=> [Date, #<Class:0x20023c900>, Comparable, #<Class:0x200036460>, NSObject, Kernel] | |
irb(main):003:0> DateTime.ancestors | |
=> [DateTime, Date, #<Class:0x20023c900>, Comparable, #<Class:0x200036460>, NSObject, Kernel] |
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
require 'rubygems' | |
require 'sqlite3' | |
require 'sequel' | |
queue = Dispatch::Queue.new('bug') | |
queue.async do # this crashes | |
3.times do | |
Sequel.sqlite.transaction {} | |
end |