Skip to content

Instantly share code, notes, and snippets.

View verdi327's full-sized avatar
💭
Thinkful EI

Michael Verdi verdi327

💭
Thinkful EI
View GitHub Profile
@verdi327
verdi327 / gist:5551251
Created May 9, 2013 23:01
teaching return values and setting those values to variables
def whats_for_dinner
random_number = rand(4)
cars = ["ferrari", "civic", "aston martin", "corvette"]
car = cars[random_number]
car_hash = {"ferrari" => 1, "civic" => 2, "aston martin" => 3, "corvette" => 4}
random_value = car_hash[car]
dinner_picker = random_value - 1
dinner_options = ["spaghetti", "lentil soup", "pizza", "smoothie"]
dinner_options[dinner_picker]
end
@verdi327
verdi327 / gist:5552144
Created May 10, 2013 02:59
procs vs lambdas
def batman_ironman_proc
victor = Proc.new { return "Batman will win!" }
victor.call
"Iron Man will win!"
end
puts batman_ironman_proc
def batman_ironman_lambda
victor = lambda { return "Batman will win!" }
@verdi327
verdi327 / gist:5647960
Created May 25, 2013 04:59
week 2 game plan
1 - refresh (conditonals, logic, variable, gets, puts, file creation)
2 - arrays (<<, +) - where's waldo exercise (array picture)
3 - explain each
4 - loop exercise - working with each
5 - working with each
6 - array exercise (houston and dirty zipcode) adv-go to reverse
7 - putting it all together - grandma
8 - intro to hash (why use, picture)
9 - hash ex 1
10 - hash ex 2
@verdi327
verdi327 / gist:5940307
Last active December 19, 2015 10:29
strong params example
def accepted_params(*add_params=nil)
permitted = [:name, :age, :email]
if add_params
permitted = permitted.concat(*add_params.map(&:to_s))
end
params.require(:user).permits(permitted)
end
Workout A
Squat
Bench Press
Barbell Row
Workout B
Squat
Overhead Press
Deadlift
@verdi327
verdi327 / gist:6085729
Last active December 20, 2015 06:29
customer segmentation
variables
---base algorithm---
total dollars spent minus refunds
frequency of purchase since joining
Dollars spent per month / rolling month to month
email engagement
---nice to have---
amount purchased over voucher amount
@verdi327
verdi327 / gist:6122731
Created July 31, 2013 14:59
mysql 5.5 brew formula
require 'formula'
class Mysql < Formula
homepage 'http://dev.mysql.com/doc/refman/5.5/en/'
url 'http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.29.tar.gz'
version '5.5.29'
sha1 '40e26b193b6ece86ce97896c0c9c524d479e37be'
bottle do
sha1 '3c5b57df466eb538db58654c5f046ddf7bc675e9' => :mountainlion
@verdi327
verdi327 / gist:6126721
Last active December 20, 2015 11:49
codenow meetup
#string
"any text"
"put_anything_you_really_want"
'no big deal'
#integer
5
puts 4 * 3
3 / 3
[user]
name = michael verdi
email = [email protected]
[core]
autocrlf = input
safecrlf = true
editor = subl -w
excludesfile = /Users/michaelverdi/.gitignore_global
[alias]
co = checkout
@verdi327
verdi327 / gist:6408079
Created September 1, 2013 23:50
roman numeral solution
class Numeralize
def self.to_roman(number)
divisors = { 1000.0 => "M",
500.0 => "D",
100.0 => "C",
50.0 => "L",
10.0 => "X",
5.0 => "V",
1.0 => "I" }