that's where i be
Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended
require 'pry' | |
module SomeRecord | |
class Base | |
def do_something | |
raise self.class::NotFoundError.new | |
end | |
def self.inherited(subclass) | |
subclass.const_set :NotFoundError, Class.new(SomeRecord::NotFoundError) |
def puts(crap); super("stop using puts"); end #dave | |
def puts(s); super; super("WAT"); (s=s.to_s).reverse!; end # hiro | |
puts greeting = "Hello Ruby DCamp! It is %s" % Time.now # hiro | |
puts (words = File.read('/usr/share/dict/words').split).length #bryce | |
puts (butt_words = words.select {|w| w =~ /butt/}).length #bryce | |
words = words.select {|w| w =~ /ity$/ } # Jason | |
words = words.map{|w| w.tr("aeiou", ('a'..'z').to_a.sample(5).join)} # max | |
puts sentence = (5.times.map{words.sample.reverse}.join " LOL ") # Joshsz | |
puts upsentence = sentence.upcase # max | |
new_things = `ls /tmp`; puts new_things # Luqi |
(defun color-theme-sunburst () | |
(interactive) | |
(color-theme-install | |
'(color-theme-sunburst | |
((background-color . "#000000") | |
(foreground-color . "#FFFFFF") | |
(cursor-color . "#DAD085")) | |
(default ((t (nil)))) | |
(modeline ((t (:background "DarkRed" :foreground "white" | |
:box (:line-width 1 :style released-button))))) |
# http://store.apple.com/us/retailStore/availabilitySearch?parts.0=MGAU2LL%2FA&zip=33175 | |
# { | |
# "head":{"status":"200","data":{}}, | |
# "body":{"zip":"33175","success":true,"stores":[ | |
# {"address":{"postalCode":"33156","address":"Apple Store, Dadeland","address2":"7535 Dadeland Mall","address3":null},"state":"FL","country":"US","city":"Miami","storeNumber":"R312","storeName":"Dadeland","storeEmail":"dadeland@apple.com","storeDisplayName":"Apple Store, Dadeland","reservationUrl":"http://www.apple.com/retail/dadeland","hoursUrl":"http://www.apple.com/retail/dadeland","directionsUrl":"http://www.apple.com/retail/dadeland/","storeHours":{"storeHoursText":"Store Hours:","bopisPickupDays":"","bopisPickupHours":"","hours":[{"storeDays":"Mon-Sat","storeTimings":"10:00 AM-9:30 PM"},{"storeDays":"Sun","storeTimings":"12:00 PM-7:00 PM"}]}, | |
# "partsAvailability":{ | |
# "MGAU2LL/A":{"storeSelectionEnabled":false,"pickupQuote":"Currently unavailable at Apple Store, Dadeland","storeSearchEnabled":true, |
require 'pp' | |
class Object | |
def mutate | |
Mutagen.new(self) | |
end | |
end | |
class Mutagen < BasicObject | |
def initialize(collection) |
class Cell | |
def initialize | |
become_dead | |
end | |
def eigenclass | |
class << self | |
self | |
end | |
end |
# the nice thing about this improved yz api is that it's not released yet! i can | |
# do anything, i'm the master of time! | |
# this is how we search pretty much anything | |
query = Riak::Search::Query.new client, index, 'cool search term' | |
results = query.results # actually hits riak, gives us a ResultsCollection | |
# existing robject functionality | |
robject_md = results.docs[0] | |
# equivalent |
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
Vagrant.configure(2) do |config| | |
# The most common configuration options are documented and commented below. | |
# For a complete reference, please see the online documentation at |
defmodule Simple do | |
@doc ~S""" | |
# Example | |
iex> Simple.toot() | |
:toooot | |
""" | |
def toot() do |