This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'gosu' | |
class LittleBrat < Gosu::Window | |
LETTER_LIMIT = 100 | |
def initialize | |
# Full resolution, fullscreen | |
super(Gosu.screen_width, Gosu.screen_height, true) | |
self.caption = "Leave me alone you little brat!" | |
# The letters the little brat hits on the keyboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [1, 2, 3] | |
b = [3, 2, 1] | |
class Array | |
def =~(other) | |
self.sort == other.sort | |
end | |
end | |
puts a =~ b #=> true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def start | |
# Do something important here | |
perform :start | |
end | |
def finish | |
perform :finish | |
# Clean up stuff here | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rake" | |
Gem::Specification.new do |s| | |
s.name = "GEM_NAME" | |
s.version = "0.1.0" | |
s.summary = "GEM_SUMMARY (short)" | |
s.description = "GEM_DESCRIPTION (longer)" | |
s.homepage = "http://example.com/GEM_NAME" | |
s.authors = ["GEM_AUTHOR_NAME"] | |
s.email = "GEM_AUTHOR_EMAIL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class List < ActiveRecord::Base | |
belongs_to :user | |
validates_presence_of :name | |
validates_presence_of :user | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- ruby -*- | |
require 'test/unit/assertions' | |
class Object | |
def method_missing *args | |
true | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note we are requiring Flog before any other rake task | |
# This fails with "uninitialized constant Rake::TaskLib" | |
require "flog_task" | |
FlogTask.new do |t| | |
t.verbose = true | |
end | |
# If we require this before flog_task then it will load fine | |
require "rake/testtask" | |
Rake::TestTask.new do |t| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_lambda | |
puts "About to call lambda" | |
blck = lambda do | |
puts " -- Start lambda" | |
return "lambda" | |
puts " -- End lambda" | |
end | |
val = blck.call | |
puts "The value is #{val}" | |
puts "Just called lambda" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from http://stackoverflow.com/a/9782550 | |
namespace :git do | |
desc "Analytics of changes made by author" | |
task :changes do | |
git_changes_by_author.sort_by { |a,h| -h[:total] }.each do |author, changes| | |
puts "#{author}: #{changes[:total]} (#{changes[:insertions]} insertions, #{changes[:deletions]} deletions)" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def bar | |
"bar" | |
end | |
def baz | |
"baz" | |
end | |
end |
OlderNewer