Skip to content

Instantly share code, notes, and snippets.

# bundlesh:
# Starts a bash session in which gem binaries are run from the bundle instead of system gems.
# Saves your fingers from typing `bundle exec` all day.
# I tried to patch bundler to implement this as bundlesh, but I had trouble
# when PS1 wasn't exported (which it isn't, out of the box).
alias bundlesh='bundle exec env PS1="(\e[32mbundler\e[0m) ${PS1}" $SHELL'
# For extra fun with RubyMine, run bundlesh and then run:
@Peeja
Peeja / something.rb
Created November 5, 2010 16:00
A demonstration of module inclusion.
class Something
def my_method
puts "(A)"
end
module PreExtension
def my_method
puts "(B)"
super
end
@Peeja
Peeja / group_of_thingies.rb
Created December 4, 2011 02:08 — forked from coffeencoke/group_of_thingies.rb
Test a block in Ruby
class GroupOfThingies
attr_accessor :thingies
# Use like this:
#
# group_of_thingies = GroupOfThingies.new
# group_of_thingies.each do |thing|
# puts "Check out this awesome thing: #{thing}!"
# end
#
task :fail do
puts "Failing..."
fail
end
task :succeed do
puts "Success!"
end
@Peeja
Peeja / checkbox_refresh_test.html
Created February 24, 2012 21:49
Check some boxes and refresh the page. Do they stay checked?
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Checkbox Refresh Test</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="pivotalcb">
<!-- Date: 2012-02-24 -->
</head>
@Peeja
Peeja / toot.rb
Created June 29, 2012 15:25
Conditional Whac-A-Mole: Another solution
class User < Struct.new(:username, :followability)
def follow
followability.follow(self)
end
end
class Follow
def self.follow(user)
user.follow
end
@Peeja
Peeja / Gemfile
Created July 27, 2012 15:01
Test Case for Timecop Issue #29
# A sample Gemfile
source "https://rubygems.org"
gem "activesupport"
gem "tzinfo"
gem "timecop", git: "https://github.com/jtrupiano/timecop"
@Peeja
Peeja / gist:3488459
Created August 27, 2012 13:35 — forked from defunkt/gist:6443
# Video: http://confreaks.com/videos/499-rubyhoedown2008-keynote
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.
@Peeja
Peeja / finalizer.rb
Created November 21, 2012 20:50
Why does this output "Finalized: false"?
finalized = false
finalizer = lambda { finalized = true }
# Hide all direct references to the object in a lambda.
lambda do
object = Object.new
ObjectSpace.define_finalizer(object, finalizer)
end.call
ObjectSpace.garbage_collect
@Peeja
Peeja / Email appears to be from Andy Lindeman.png
Created November 25, 2012 00:38
GitHub email notification "bug" in Gmail: Gmail conflates senders in list view
Email appears to be from Andy Lindeman.png