Skip to content

Instantly share code, notes, and snippets.

Brendon Murphy bemurphy

Block or report user

Report or block bemurphy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:222706
class Foo
def bar
puts "bar!"
end
end
foo = Foo.new
foo.bar # outputs "bar!"
class Foo
View gist:222724
class FooTwo
def bar
puts "bar"
end
def cap_bar
def bar
puts "BAR!!!"
end
end
View gist:228299
module Bar
@@bar = "blah blah"
end
class Foo
include Bar
def self.bar
@@bar
end
View snippet.rb
class Foo
def initialize(bar)
@bar = bar
end
def foobar(prefix)
"#{prefix}: imaginary long running process: #{@bar}"
end
end
View gist:822606
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
@bemurphy
bemurphy / gist:1053254
Created Jun 29, 2011
hacker news user filter
View gist:1053254
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');
}
View maybe_better.rb
# With tweaks
text.scan(/#/).each do |match|
line1
line2
foo
end
describe "Foo" do
it "finds customers" do
View first_example.rb
def fizzy?(string)
string.match(/fizz/)
end
p fizzy?("foobar") # => nil
p fizzy?("fizzbuzz") # => #<MatchData "fizz">
View gist:1125414
| | | | +-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 / gist:1424311
Created Dec 2, 2011
run ctags in a post-checkout hook
View gist:1424311
#!/usr/bin/env ruby
require "shellwords"
def run_tags
`ctags -R . 2>/dev/null`
end
def project_dir
File.basename Dir.pwd
You can’t perform that action at this time.