Skip to content

Instantly share code, notes, and snippets.

View rayning0's full-sized avatar
🤪

Raymond Gan rayning0

🤪
View GitHub Profile
@rayning0
rayning0 / Alien Sandwich
Created September 24, 2013 11:27
Alien Sandwich: Create a numbered list that contains instructions for making a peanut butter and jelly sandwich, for an alien. The alien is positioned in front of a table with a plate, a knife, a jar of jelly, a jar of peanut butter, and a loaf of bread.
Coordinates of peanut butter, jelly, plate, knife, bread = [a bunch of numbers separated by commas]
Get (stuff)
Move free arm to coordinates of stuff
Lower arm
Close hand around stuff
Raise arm
end
Put (stuff) down
@rayning0
rayning0 / My Profile Content
Created September 25, 2013 06:00
My Profile Content
Your Name: Raymond Gan
Github Username: rayning0
Blog Url: http://rayning0.github.com
Tagline: surgery, teacher, chemical engineer, and web developer
Profile Picture: http://bit.ly/1anelur
Project Euler/algorithms code: https://github.com/rayning0/ProjectEuler-and-Algorithms
Favorite Websites: Project Euler (http://projecteuler.net/), fantastic site for computer science/math practice questions. Coursera (https://www.coursera.org/), fantastic site to take hundreds of free online courses from top universities. Longform (http://longform.org/), site that recommends excellent long-form non-fiction from around the web. This American Life (http://www.thisamericanlife.org/), my favorite radio show. It's mesmerizing, each week covering some strange and intimate aspect of American life. The stories are as addictive as butterscotch popcorn!
Previous Work Experience: Surgical Neurophysiologist for 4 years. Worked on over 400 surgeries at over 50 hospitals with over 50 surgeons, in 7 states. Started in Boston at 5 hospita
@rayning0
rayning0 / gist:6709617
Created September 26, 2013 03:40
Quiz - Seconds to Years
# Write a program that tells you the following:
#
# Hours in a year. How many hours are in a year?
# Minutes in a decade. How many minutes are in a decade?
# Your age in seconds. How many seconds old are you?
#
# Define at least the following methods to accomplish these tasks:
#
# seconds_in_minutes(1)
# minutes_in_hours(1)
@rayning0
rayning0 / gist:6709646
Created September 26, 2013 03:44
Fizzbuzz
# Raymond Gan
def fizzbuzz(n)
return "FizzBuzz" if (n % 3 == 0) && (n % 5 == 0)
return "Fizz" if n % 3 == 0
return "Buzz" if n % 5 == 0
end
fizz, buzz, fizzbuzz = [], [], []
@rayning0
rayning0 / gist:6709743
Created September 26, 2013 04:03
Song lengths
# Given:
# 5 songs of the following lengths in seconds
# 223,215,378,324,254
# Goals:
# Assign the length set to variables
# Calculate the Total Length of the Playlists
# Express the Length in Minutes
# Average Song Length in Minutes
@rayning0
rayning0 / gist:6722922
Last active December 24, 2015 01:19
Song List (used Bubble Sort)
# Raymond Gan
# Given this List of Songs, Construct Arrays by Artist and Album
# Hint: Make use of the split() String Method
# http://www.ruby-doc.org/core-1.9.3/String.html#method-i-split
# Simple Example of Data Parsing
songs = [
"The Magnetic Fields - 69 Love Songs - Parades Go By",
"The Magnetic Fields - Get Lost - Smoke and Mirrors",
@rayning0
rayning0 / gist:6723770
Last active December 24, 2015 01:29
Badges
# You're hosting a conference and need to print badges for the speakers. Each badge should say: # "Hello, my name is _____."
#
# Write a method that will create and return this message, given a person's name.
def badge(name)
"Hello, my name is #{name}"
end
# Now the list of speakers is finalized, and you can send the list of badges to the printer. Remember that you'll need to give this list to the printer, so it should be accessible outside of the method.
@rayning0
rayning0 / gist:6724058
Created September 27, 2013 04:15
Vowels
# Write a method that returns whether a given letter is a vowel, using if and elsif
def is_vowel?(v)
if v == 'a'
true
elsif v == 'e'
true
elsif v == 'i'
true
elsif v == 'o'
@rayning0
rayning0 / gist:6724626
Last active December 24, 2015 01:29
Tweet Shortener
def tweetsub(tweet)
tsub = {'to' => '2', 'two' => '2', 'too' => '2', 'for' => '4',
'four' => '4', 'be' => 'b', 'you' => 'u', 'at' => '@', 'and' => '&'}
tsub.keys.each do |key|
tweet.gsub!(key) {tsub[key]}
end
tweet
end
tweets = ["Hey guys, can anyone teach me how to be cool? I really want to be the best at everything, you know what I mean? Tweeting is super fun you guys!!!!",
@rayning0
rayning0 / gist:6724800
Last active October 28, 2021 22:29
My_Each method, using Yield
# Read about the yield keyword and ruby blocks.
# http://allaboutruby.wordpress.com/2006/01/20/ruby-blocks-101/
# http://ruby.about.com/od/beginningruby/a/Block-Parameters-And-Yielding.htm
# http://blog.codahale.com/2005/11/24/a-ruby-howto-writing-a-method-that-uses-code-blocks/
# http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/
# Now that you know how the yield method works, try to write your
# own version of the each method without using the each method
# provided by ruby. As in, try to build my_each using only the