Skip to content

Instantly share code, notes, and snippets.

View rayning0's full-sized avatar
🤪

Raymond Gan rayning0

🤪
View GitHub Profile

Forking

essentially like cloning on github's servers - but that's inconsequential, mostly.. also: forks are not automatically up to date (relative to repo you forked)! your fork creates a snapshot of the original repo at the time you fork it.

  • fork on github

  • creates a clone on github servers

  • copy url of that clone

  • git clone [url]

    • clones the content of your fork to your local machine
@rayning0
rayning0 / gist:6761941
Created September 30, 2013 10:29
Jukebox (talks to you with computer voice, plus it opens up YouTube video for each song you play)
# Raymond Gan - Jukebox
songs = [
"The Phoenix - 1901",
"Tokyo Police Club - Wait Up",
"Sufjan Stevens - Too Much",
"The Naked and the Famous - Young Blood",
"(Far From) Home - Tiga",
"The Cults - Abducted",
"The Phoenix - Consolation Prizes"
@rayning0
rayning0 / gist:6771026
Created September 30, 2013 22:08
Apple Picker and Holiday Suppliers
def apple_picker(a)
puts "Using 'collect':"
p a.collect{|x| x if x == 'apple'}.compact
puts "Using 'select':"
p a.select{|x| x == 'apple'}
end
apple_picker(["apple", "orange", "apple"]) #=> ["apple", "apple"]
puts "'Collect' returns array with values returned by block, but it has same"
@rayning0
rayning0 / gist:6771721
Last active December 24, 2015 08:39
Deli Counter
def take_a_number(katz, name)
katz << name
return katz.size
end
def line(katz)
print "The line is currently:"
katz.each_with_index do |name, i|
print " #{i + 1}. #{name}"
end
@rayning0
rayning0 / gist:6774203
Last active December 24, 2015 08:59
Hasketball (finished ALL Hasketball questions, including all 4 bonus questions!)
# Raymond Gan, Oct. 1, 2013
game = {
:home => { :teamname => "LA Lakers",
:colors => ["gold", "orange"],
:players => [
{:playername => "Raymond Gan",
:number => 3,
:shoesize => 12,
:stats => {
@rayning0
rayning0 / gist:6774254
Created October 1, 2013 05:33
Create Some Hashes. Did a 4-level movie hash. Tried to create complicated hash with code. Didn't fully work.
movies = [
'Thriller - Denis Villeneuve - Hugh Jackman - Prisoners',
'Thriller - James Wan - Patrick Wilson - Insidious',
'Thriller - James Wan - Patrick Wilson - The Conjuring',
'Thriller - Neill Blomkamp - Matt Damon - Elysium',
'Action - Ron Howard - Chris Hemsworth - Rush',
'Action - Joss Whedon - Robert Downey Jr - The Avengers',
'Action - Joss Whedon - Scarlett Johansson - The Avengers: Age of Ultron',
'Comedy - Ron Howard - Tom Hanks - Splash'
]
@rayning0
rayning0 / gist:6774278
Last active December 24, 2015 08:59
Reverse each word
def reverse_each_word(sentence)
sentence.split.map {|word| word.reverse}.join(' ')
end
# reverse_each_word("Hello there, and how are you?")
# => "olleH ,ereht dna woh era ?uoy"
puts reverse_each_word("Hello there, and how are you?")
puts reverse_each_word("Just be creative, create a bunch of fake data.")
@rayning0
rayning0 / gist:6785130
Created October 1, 2013 21:07
Tower of Hanoi (I did both recursive and iterative solutions. I show full graphical output.)
# Raymond Gan-------Tower of Hanoi problem-------------
# http://en.wikipedia.org/wiki/Tower_of_Hanoi
# http://www.skorks.com/2010/03/solving-the-towers-of-hanoi-mathematically-and-programmatically-the-value-of-recursion/
# Recursive solution:
# http://www.sparknotes.com/cs/recursion/examples/section6.rhtml
# Iterative solution:
# http://apcentral.collegeboard.com/apc/members/courses/teachers_corner/45418.html
# http://www.ecse.rpi.edu/~wrf/p/28-sigplan84-hanoi.pdf
@rayning0
rayning0 / reddit.html
Last active December 24, 2015 12:29
Reddit API (I include my created reddit.html)
<html>
<head>
</head>
<body>
<ul> <li>
<a href='http://www.space.com/23028-super-earth-water-atmosphere-alien-planet.html?cmpid=51463012631694'>
<h1>A nearby alien planet six times the size of the Earth is covered with a water-rich atmosphere that includes a strange "plasma form" of water.</h1>
<img src='' />
<h4>Upvotes:</h4>
<p>7042</p>
@rayning0
rayning0 / gist:6803670
Last active December 24, 2015 13:19
NYC Pigeon Organizer
########################
# NYC PIGEON ORGANIZER #
########################
pigeon_data = {
:color => {
:purple => ["Theo", "Peter Jr.", "Lucky"],
:grey => ["Theo", "Peter Jr.", "Ms .K"],
:white => ["Queenie", "Andrew", "Ms .K", "Alex"],
:brown => ["Queenie", "Alex"]