Skip to content

Instantly share code, notes, and snippets.

View ryanswood's full-sized avatar

Ryan Wood ryanswood

  • Able Health
  • San Francisco, Ca
View GitHub Profile
Analysis of sampling ruby (pid 8228) every 1 millisecond
Process: ruby [8228]
Path: /Users/pairing/.rbenv/versions/2.4.1/bin/ruby
Load Address: 0x108ab2000
Identifier: ruby
Version: 0
Code Type: X86-64
Parent Process: zsh [917]
class PigLatin
def initialize
end
def convert(original_string)
word_collection = original_string.split(" ").map(&:downcase)
word_collection.map! do |word|
word.match(/(.)(.+)/)
$2 + $1 + "ay"
@ryanswood
ryanswood / gist:639a967bd75841137f62
Created August 9, 2014 03:34
Pickie No Workie. hahahaha
pickie [master] :> npm install
npm ERR! install Couldn't read dependencies
npm ERR! package.json ENOENT, open '/Users/ryan/Desktop/pickie/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.
npm ERR! System Darwin 13.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/ryan/Desktop/pickie
npm ERR! node -v v0.10.24
@ryanswood
ryanswood / my_inject.rb
Created July 15, 2014 20:54
Reduce / Inject
class Array
def my_inject(*args)
acc = args.length >= 1 ? args[0] : self.shift
self.each {|el| acc = yield acc, el}
acc
end
end
def assert_equal(actual, expected)
puts "You expected #{expected} and got #{actual}" unless actual == expected
class ChangeDispenser
attr_reader :purse
MONEY_TO_VALUE = {
quarter: 25,
dime: 10,
nickel: 5,
penny: 1
}
# Given an array_of_ints, find the highest_product you can get from three of the integers.
# The input array_of_ints will always have at least three integers.
def highest_product(arr)
highest = arr[0]
lowest = arr[0]
highest_of_two = arr[0] * arr[1]
highest_of_three = arr[0] * arr[1] * arr[2]
@ryanswood
ryanswood / factorial.rb
Last active August 29, 2015 14:00
Factorial Recursion
require 'benchmark'
def factorial(n)
if n <= 1
n
else
n * factorial(n-1)
end
end
@ryanswood
ryanswood / grocery.js
Last active August 29, 2015 13:58
Gocery JS App
$(document).ready(function(){
controller = new SingleListApp.Controller();
controller.bind();
list = new SingleListApp.GroceryList
view = new SingleListApp.View('#grocery_list', '#total_cost')
});
SingleListApp = {};
//Controller
@ryanswood
ryanswood / jasmine.md
Last active August 29, 2015 13:57
Jasmine

#What is Jasmine?

My talk is about showing the basic similarities between Jasmine and Rpsec. The best way to learn a new concept is to relate to existing knowledge.

Jasmine is a behavior-driven development framework for testing JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM.

Ruby / Rspec

def hello_world