Tested with OS X 10.9 only, YMMV.
Install homebrew http://brew.sh if you don't have it by launching Terminal.app and entering
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Follow all the prompts.
class Monster | |
def initialize(options) | |
@name = options[:name] | |
@lifepoints = options[:lifepoints] | |
@drop_mechanic = options[:drop_mechanic] | |
@hit_log = [] | |
@output_buffer = [] | |
end | |
def get_hit(player, hit) |
Tested with OS X 10.9 only, YMMV.
Install homebrew http://brew.sh if you don't have it by launching Terminal.app and entering
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Follow all the prompts.
class Article < ActiveRecord::Base | |
scope :published, -> { where("draft = false AND publish_at <= ?", Time.now) } | |
end | |
foo = Article.find(123) | |
foo.published? |
-- Setup some tables. | |
CREATE TABLE `users` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`name` varchar(45) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB AUTO_INCREMENT=1; | |
CREATE TABLE `internal_messages` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`owner_user_id` int(11) DEFAULT NULL, |
require 'resolv' | |
hostname = 'hiscore.runescape.com' | |
names = [ "The Orange", "SkyTeck", "Font", "iGlacor", "Tohru x", "Weir", "Parenthesis", "OneLegendKid", "Lekerashi", "Aus Zealand", "Lordofd70", "No Orion", "BadSmurF", "Dunder_miffl", "Stephen VII", "Jonnys D", "God H8s Bots", "Wey burn", "nabulsi", "Blur", "Man killa", "Titsicle", "Bedevere", "lilybele", "l Jigg l", "zabeey", "xRatonhnhake", "st drew", "Kre8tive", "He Belongs", "Sannse", "almostcomp", "IrishEIK", "Haydunn", "kouth sorea", "dark_king_I4", "Unheard pray", "Co Justin", "Chalder", "mihal80", "inburst21", "Slaye", "Mish", "Doctor Doak", "ttaM", "nova science", "Rrman of w48", "saylor", "minergoo", "jason 72", "Advokat", "Lofna", "Dissori", "R2h Guard", "Izobelle", "Eleanor Lamb", "Mischievio", "Dead Masterr", "Man killa", "iBryce", "Boo Bee", "Mattmann28", "xowen", "fdsatakanuva", "Steeve", "J T R9", "mercifull", "Randomjagged", "Samyuel", "Cassus", "Dyzt", "Melbshuffle", "Neo687", "Metabolizer", "S9 Gnit2", "Joe Longo", "3u0", "Xw0", "Saul", |
# Symbols aren't anything special really, just use a colon in front of a word instead of quotes | |
:foo.class # => Symbol | |
"foo".class # => String | |
# They are easier to write and pass around than strings so we use them. That's all you really need to know about them. | |
# They also don't come with all the baggage methods strings do (which we wouldn't need for identifiers) | |
:foo.methods.count # => 50 | |
"foo".methods.count # => 176 |
# Blocks are a way of "injecting" code to run in the context of the original method. | |
# Side note: we can open an existing class and add methods. | |
# Let's make the String class awesome, don't worry about the blocks yet | |
class String | |
def hax0rify | |
replac0rs = { | |
'o' => '0', | |
'a' => '4' | |
} |
str = "It's not too scary when you realize that everything is an object" | |
str.size # => 64 | |
str.class # => String | |
str = "and you call methods on them" | |
str.reverse # => "meht no sdohtem llac uoy dna" | |
# EVERYTHING is an object |
rows = 8 | |
t = [] | |
rows.times do |i| | |
t[i] = [] | |
(i+1).times do |j| | |
if j == 0 || j == i | |
t[i] << 1 | |
else | |
t[i] << t[i-1][j-1] + t[i-1][j] |
framework "ScriptingBridge" | |
unless `ps aux | grep Safari.ap[p]` == "" | |
safari ||= SBApplication.applicationWithBundleIdentifier("com.apple.Safari") | |
if ARGV.empty? | |
safari.windows.each do |window| | |
puts "Window #{window.index}:" | |
window.tabs.each do |tab| | |
puts "\t#{tab.name}" |