Skip to content

Instantly share code, notes, and snippets.

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

Note to Self

Be With Your Mom

that's where i be

Be Confident

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

@bkerley
bkerley / sunburst.el
Created February 10, 2009 17:02 — forked from 53cr/sunburst.el
(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)))))
@bkerley
bkerley / scout.rb
Created September 24, 2014 17:23
# 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,
@bkerley
bkerley / pipes.rb
Last active April 8, 2018 02:17
elixir-style function chaining that is also awful!
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
@bkerley
bkerley / crdt_searching.rb
Created February 12, 2015 13:22
RFC: Yokozuna and CRDTs in Ruby
# 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
@bkerley
bkerley / Vagrantfile.rb
Created January 19, 2016 16:27
my riak time series dev environment
# -*- 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