Skip to content

Instantly share code, notes, and snippets.

View chhhris's full-sized avatar
🚁
Working From Helicopter

Christopher Lake chhhris

🚁
Working From Helicopter
View GitHub Profile
# Temperature bot is comfortable when it's room temperature (18-21C). Help him out by completing the method below:
def temperature_bot(temp)
case temp
when 18..21
"I like this temperature"
else
"This is uncomfortable for me"
end
end
library {
:artist => {
"The Magnetic Fields" => {
"69 Love Songs" => ["Song 1", "Song 2"]
]
"Get Lost" => ["Song 1", "Song 2"]
}
"Netural Milk Hotel" => {
"In An Aeroplane Over the Sea" => ["Song 1", "Song 2"]
}
$basketball_game =
{
:team_1 =>
{
:team_name => "Knicks",
:colors => ["blue", "orange"],
:player_1 =>
{
:name => "Patrick Ewing",
@chhhris
chhhris / Message Decoding
Created June 13, 2013 23:19
The decoded message is commonly attributed to Abe Lincoln -- but for the record, it appears he never said it, brah. http://abrahamlincolnblog.blogspot.com/2010/05/lincoln-never-said-these-life-lessons.html
code = "fx1=ZY&iX3=ZW&hm5=ZU&dg7=ZS&ei9=ZQ&ge11=ZO&tr13=ZM&hh15=ZK&uX17=ZI&si19=ZG&tX21=ZE&Xn23=ZC&hp25=ZA&pX27=YY&dl29=YW&wo31=YU&XX33=YS&XX35=YQ&re37=YO&et39=YM&ia41=YK&wn43=YI&uo45=YG&dX47=YE&so49=YC&ec51=YA&do53=XY&sX55=XW&xr57=XU&so59=XS&aX61=XQ&ph63=XO&ni65=XM&nX67=XK&Xa69=XI&yX71=XG&aX73=XE&ei75=XC&ie0=ZZ&Xa2=ZX&Xy4=ZV&aX6=ZT&Xn8=ZR&in10=ZP&hp12=ZN&Xa14=ZL&os16=ZJ&rx18=ZH&Xs20=ZF&od22=ZD&ce24=ZB&os26=YZ&Xd28=YX&ou30=YV&nw32=YT&ai34=YR&te36=YP&er38=YN&XX40=YL&XX42=YJ&ow44=YH&ld46=YF&Xp48=YD&ph50=YB&nX52=XZ&Xt54=XX&is56=XV&Xu58=XT&hh60=XR&rt62=XP&eg64=XN&ie66=XL&gd68=XJ&mh70=XH&Xi72=XF&xf74=XD"
codev2 = code.split('&')
codev3 =
codev2.collect do |x|
#split each string into two more strings
x.split('=')
end
codev4 = codev3.flatten #turns array x arrays into a single array.
@chhhris
chhhris / prime lab
Created June 14, 2013 20:35
maybe not too efficient
def check_prime(number)
if number == 1
"You'd think you were prime, but you're not."
elsif number == 2
"We call 2 the Littlest Prime"
elsif number == 3
"Octavian Prime"
elsif number == 4
"Ain't Prime"
elsif number == 5
class MyApp
def call(env)
[200, {'Content-Type' => 'text/html'}, ['<a style="background-color:red;">URGENT MSG</a> from Tiny Tim: Hello']]
end
end
require 'fis/test'
class Phone
def initialize(number)
@number = number.gsub(/\D/, '')
if @number.length == 11 && @number[0] == "1"
@number = @number[1..10]
end
end

What is a closure?

How do we implement/create/use a closure in Ruby?

What's the difference between a closure in JS vs Ruby?

Why do we use closures so much more in JS as opposed to Ruby?

What is the Ruby analog of an anonymous function in Javascript?

// iOS Media Queries
// Goal: capture styles for iPhone, iPhone 3G, iPhone 3GS, iPhone 4, iPhone 4S, iPad, and iPad 2
//
// Author: Tony Schneider (@tonywok)
// Please tell me where I fail. :)
// iPhone v(4,4S) portrait
// test: black text (overwritten by v* portrait) with blue background
@media all and (-webkit-min-device-pixel-ratio: 2) and (orientation: portrait) {
a {
@chhhris
chhhris / live-emails-dev-mode.rb
Last active January 4, 2016 20:49
Sending live emails in development mode
# now with Mandrill
# with SENDGRID
# sending emails to your email while in development mode.
# mail_interceptor.rb
if Rails.env.development?
message.to = '[email protected]'