Skip to content

Instantly share code, notes, and snippets.

View jballanc's full-sized avatar

Joshua Ballanco jballanc

View GitHub Profile
diff -r -u ./core.rb /Volumes/Data/Users/joshua1/Source/sequel/lib/sequel/core.rb
--- ./core.rb 2010-09-03 03:28:49.000000000 -0700
+++ /Volumes/Data/Users/joshua1/Source/sequel/lib/sequel/core.rb 2010-09-26 23:08:57.000000000 -0700
@@ -188,9 +188,8 @@
# Require all given files which should be in the same or a subdirectory of
# this file. If a subdir is given, assume all files are in that subdir.
- # TODO: This method contains workarounds for <rdar://problem/8391405> and <rdar://problem/8140667>
def self.require(files, subdir=nil)
- Array(files).each{|f| Kernel::require("/System/Library/PrivateFrameworks/PodcastLibrary.framework/Vendor/sequel/#{"#{subdir}/" if subdir}#{f}")}
require 'rubygems'
require 'sqlite3'
require 'sequel'
queue = Dispatch::Queue.new('bug')
queue.async do # this crashes
3.times do
Sequel.sqlite.transaction {}
end
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]
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}"}
@jballanc
jballanc / bench.rb
Created September 5, 2011 20:54
Set#include? vs Hash#include? vs Hash#[]
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"
STATE README TEMPLATE
=====================
Metadata
--------
Name:
Abbreviation:
Legislature Name:
Upper Chamber Name:
Lower Chamber Name:
#!/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!
# 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
@jballanc
jballanc / uh-oh-scope.rb
Created October 31, 2011 21:17
Different behavior of class_eval between Ruby 1.9.2 and Ruby 1.9.3
# 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
@jballanc
jballanc / fun.rb
Created December 21, 2011 17:54
Count Objects across GC's
$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