Skip to content

Instantly share code, notes, and snippets.

@BrianJoyce
BrianJoyce / rspec_lessons.rb
Created October 23, 2012 04:43
being concise with RSpec
# the way I was used to doing it
describe Dog do
it 'respond to name' do
dog = Dog.new
dog.should respond_to(:name)
end
end
# "subject" allows you to instantiate Dog in a cooler way
describe Dog do
@BrianJoyce
BrianJoyce / one_to_one_schema.xml
Created October 22, 2012 06:44
one_to_one_schema
<?xml version="1.0" encoding="utf-8" ?>
<!-- SQL XML created by WWW SQL Designer, http://code.google.com/p/wwwsqldesigner/ -->
<!-- Active URL: http://socrates.devbootcamp.com/sql.html -->
<sql>
<datatypes db="mysql">
<group label="Numeric" color="rgb(238,238,170)">
<type label="Integer" length="0" sql="INTEGER" re="INT" quote=""/>
<type label="Decimal" length="1" sql="DECIMAL" re="DEC" quote=""/>
<type label="Single precision" length="0" sql="FLOAT" quote=""/>
<type label="Double precision" length="0" sql="DOUBLE" re="DOUBLE" quote=""/>
@BrianJoyce
BrianJoyce / doctor.rb
Created October 22, 2012 02:22
doctor
require 'pry'
require_relative 'employee.rb'
class Doctor < Employee
def initialize(name, birthdate, gender)
super(name, birthdate, gender)
@salary = 200_000
@title = "Dotor"
@tasks = "Diagnose Patients, Prescribe Medicine"
@BrianJoyce
BrianJoyce / simplicity
Created October 21, 2012 22:02
newstuff
class JobsReport < Array
def self.from_stream(input = $stdin)
@arr = self.new
file = File.open(input, 'r')
file.each_line do |job|
company_name,contact_email,url = job.split("\t")
p "#{company_name},#{contact_email},#{url}"
@arr << JobProspect[company_name(company_name)] if job[0] != "#"
end
require 'yaml'
require_relative 'todo_item_yaml.rb'
my_new_todo = Todo.new("ZZZZZZZZND")
top_to_do = Todo.new("This at the top")
todo_list = TodoList.new
input = ARGV
# puts input
@BrianJoyce
BrianJoyce / task_list.rb
Created October 18, 2012 06:00
todo-new
{:time=>"10/17/2012", :item=>"This at the top", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/17/2012", :item=>"This at the top", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/17/2012", :item=>"This at the top", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/17/2012", :item=>"This at the top", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/17/2012", :item=>"This at the topBOTTOM", :priority=>"high", :complete=>"", :tags=>""}
{:time=>"10/17/2012", :item=>"THIS IS THE END", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/17/2012", :item=>"THIS IS THE END", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/17/2012", :item=>"THIS IS THE END", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/17/2012", :item=>"THIS IS THE END", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/17/2012", :item=>"THIS IS THE END", :priority=>"", :complete=>"", :tags=>""}
@BrianJoyce
BrianJoyce / block_fun.rb
Created October 18, 2012 04:00
block fun
class Do_Lotsa_Stuff
def one
save_after { puts "i'm one!"}
end
def two
save_after { puts "i'm two!"}
end
@BrianJoyce
BrianJoyce / classes.rb
Created October 18, 2012 02:49
classes fuck around
class Food
def edible?
true
end
end
class Human
attr_reader :hungry
@BrianJoyce
BrianJoyce / setTraceBits
Created October 18, 2012 02:48
set_trace_func mess around
set_trace_func proc { |event, file, line, id, binding, classname|
# puts "event: #{event} file #{file} line #{line} id #{id} binding #{binding.inspect} classname #{(classname.nil?) ? classname : classname.name}"
# p binding
# only interested in events of type 'call' (Ruby method calls)
# see the docs for set_trace_func for other supported event types
puts "#{classname} #{id} called" if id == 'method2'
}
{:time=>"10/16/2012", :item=>"This at the topBOTTOM", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/16/2012", :item=>"This at the topBOTTOM", :priority=>"", :complete=>"", :tags=>"#will #you #work #will #you #work "}
{:time=>"10/16/2012", :item=>"This at the topBOTTOM", :priority=>"", :complete=>"", :tags=>"#will #you #work "}
{:time=>"10/16/2012", :item=>"This at the topBOTTOM", :priority=>"", :complete=>"", :tags=>"#will #you #work "}
{:time=>"10/16/2012", :item=>"This at the topBOTTOM", :priority=>"", :complete=>"", :tags=>"#will #you #work "}
{:time=>"10/16/2012", :item=>"This at the topBOTTOM", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/16/2012", :item=>"This at the topBOTTOM", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/16/2012", :item=>"some interesting stuff", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/16/2012", :item=>"some interesting stuff", :priority=>"", :complete=>"", :tags=>""}
{:time=>"10/16/2012", :item=>"some interesting stuff", :priority=>"", :complete=>"