Skip to content

Instantly share code, notes, and snippets.

View koriroys's full-sized avatar
🐢
Slow and Steady

Kori Roys koriroys

🐢
Slow and Steady
View GitHub Profile
@koriroys
koriroys / ruby_if.rb
Created November 21, 2013 16:44
wtf ruby if
if false
wtf = :wtf
end
# I would expect this to error
wtf
@koriroys
koriroys / scary_craps.rb
Created August 21, 2013 23:33
List all the things right/wrong with this code
class Die
def roll
rand(1..6)
end
end
die1 = Die.new
die2 = Die.new
# puts dice_roll = die1.roll + die2.roll
first_roll = true
# Original method
#def process2(input)
# if input == 'q'
# Goodbye.new.exec
# elsif input == 'tweet'
# Tweeter.new.exec
# elsif input == 'dm'
# Message.new.exec
# elsif input == 'help'
@koriroys
koriroys / even_better.rb
Last active December 17, 2015 04:09
Death of Ifs
# Original method
#def process(input)
# if input == 'q'
# puts 'Goodbye'
# elsif input == 'tweet'
# puts 'tweeting'
# elsif input == 'dm'
# puts 'direct messaging'
# elsif input == 'help'
@koriroys
koriroys / pe_70.rb
Created April 6, 2013 21:54
for josh
require 'prime'
require 'pp'
def each_multiple(base, boundary)
multiplier = 1
while (product = base * multiplier) < boundary
# puts "#{prime}: totients[#{product}] -= #{multiplier}"
yield product, multiplier
multiplier += 1
end
#placeholder
@koriroys
koriroys / internal_link.rb
Created February 20, 2013 14:32
place in your /plugins folder in your jekyll project to use.
class NilClass
def to_s
nil
end
end
class Person
def initialize(options)
@first_name = options[:first_name]
@middle_name = options[:middle_name]
#original attribution https://gist.github.com/alexspeller/6251054 & https://gist.github.com/stevekane/6356006
App.ClickElsewhereMixin = Ember.Mixin.create
#use this method hook to define your desired behavior
onClickElsewhere: Ember.K
#bound version of our instance method
clickHandler: Em.computed ->
Em.run.bind @, 'onClickElsewhere'
@koriroys
koriroys / application.controller.js
Last active October 19, 2015 14:25
Current Route
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});