Skip to content

Instantly share code, notes, and snippets.

View bemurphy's full-sized avatar

Brendon Murphy bemurphy

View GitHub Profile
| | | | +-o IOAudioSelectorControl <class IOAudioSelectorControl, id 0x100000393, !registered, !matched, active, busy 0 (142 ms), retain 22>
| | | | | | {
| | | | | | "IOAudioControlType" = 1936483188
| | | | | | "IOAudioSelectorControlAvailableSelections" = ({"IOAudioSelectorControlSelectionValue"=1751412846,"IOAudioSelectorControlSelectionDescriptionKey"="Headphones"})
| | | | | | "IOAudioControlChannelNumber" = 0
| | | | | | "IOAudioControlChannelID" = 0
| | | | | | "IOAudioControlValue" = 1751412846
| | | | | | "IOAudioControlUsage" = 1869968496
| | | | | | "IOAudioControlID" = 0
| | | | | | "IOAudioControlSubType" = 1869968496
@bemurphy
bemurphy / first_example.rb
Created July 27, 2011 16:01
End the NotNot
def fizzy?(string)
string.match(/fizz/)
end
p fizzy?("foobar") # => nil
p fizzy?("fizzbuzz") # => #<MatchData "fizz">
# With tweaks
text.scan(/#/).each do |match|
line1
line2
foo
end
describe "Foo" do
it "finds customers" do
@bemurphy
bemurphy / gist:1053254
Created June 29, 2011 06:14
hacker news user filter
var users = {
"friend" : 1,
"foe" : 0
};
$("<style type='text/css'>span.djs-highlight { font-weight: bold; }</style>").appendTo("head");
function traverseFromUserLink(el) {
return $(el).closest('td').find('span.comment');
}
def daemonize(name = File.basename($0), options = {})
pid_path = options[:pid_path] || File.expand_path("tmp/pids/#{name}.pid")
# If the pid file exists, check that the process is actually still running.
begin
if File.exists?(pid_path) && Process.kill(0, File.read(pid_path).to_i)
$stderr.puts "Already running."
exit 1
end
rescue Errno::ESRCH
class Foo
def initialize(bar)
@bar = bar
end
def foobar(prefix)
"#{prefix}: imaginary long running process: #{@bar}"
end
end
module Bar
@@bar = "blah blah"
end
class Foo
include Bar
def self.bar
@@bar
end
class FooTwo
def bar
puts "bar"
end
def cap_bar
def bar
puts "BAR!!!"
end
end
class Foo
def bar
puts "bar!"
end
end
foo = Foo.new
foo.bar # outputs "bar!"
class Foo