Skip to content

Instantly share code, notes, and snippets.

This is purely for testing.
@alindeman
alindeman / gist:761389
Created December 31, 2010 22:35 — forked from radar/gist:756790
def self.factory(plugin, &block)
candidates = self.plugin_paths.map do |path|
Dir["#{path}/#{plugin.to_s.downcase}.rb"][0]
end
candidate = candidates.detect(&:any?)
if candidate
require candidate
Plugin.const_get(plugin.to_s.capitalize.to_sym).new(&block)
else
raise YourSystem::PluginNotFound, "The #{plugin} plugin could not be loaded"
{
"actor_attributes": {
"name": "John Britton",
"gravatar_id": "efc09baeb94ed440b185710062c8956d",
"location": "New York",
"blog": "http://www.johndbritton.com",
"type": "User",
"login": "johndbritton",
"email": "[email protected]"
},
andy@adl91desktop:~/tmp$ ls -alh setuid.rb
-rwsr-sr-x 1 root root 38 2011-01-06 14:39 setuid.rb
andy@adl91desktop:~/tmp$ cat setuid.rb
#!/usr/bin/env ruby
puts Process.uid
andy@adl91desktop:~/tmp$ ./setuid.rb
1000
require 'rubygems'
require 'nokogiri'
require 'open-uri'
class Ride4Ruby
def find_distance_between_farthest
farthest_west, farthest_east = find_farthest_west_and_east
$stderr.puts "Farthest west: #{farthest_west}"
$stderr.puts "Farthest east: #{farthest_east}"
class Foo
def self.blah
"foo"
end
end
puts Foo.blah # "foo"
Foo.define_singleton_method :blah, do
"hijink"
class Model < ActiveRecord::Base
# Just as an example, encode as JSON/XML
# excluding the created_at attribute
def serializable_hash(options = nil)
options ||= {}
(options[:except] ||= []) << :created_at
super(options)
end
end
$(function() {
// This happens when the DOM is ready
$('#my_button').bind('click', function(e) {
alert('omg it worked');
});
});
# Set these appropriately
monkey_a = 1
monkey_b = 1
problem = if monkey_a == monkey_b
"problem"
else
"not a problem"
end
@alindeman
alindeman / test.rb
Created January 21, 2011 17:08 — forked from caleywoods/test
def test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil
nil.some_method_nil_doesnt_know_about
rescue Exception => ex
puts ex.class
end
test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil