Skip to content

Instantly share code, notes, and snippets.

# Requires the following songs to be in the same directory as this file:
# phoenix.1901.mp3
# tokyo.police.club.wait.up.mp3
# sufjan.stevens.too.much.mp3
# the.naked.and.the.famous.young.blood.mp3
# far.from.home.tiga.mp3
# the.cults.abducted.mp3
# phoenix.consolation.prizes.mp3
# You can download these files from http://loganhasson.com/ruby/supporting/audio/jukebox2.0.audio.zip
# The files must be in the same level as the .rb file, not within their own directory
until Time.now.hour == 20 && Time.now.min == 59 && Time.now.wday == 0
sleep(30)
end
system("say Its time for Homeland.")
# Soon-to-be way better version.
@loganhasson
loganhasson / game.of.life.rb
Last active December 24, 2015 04:59
(Messy) game of life.
# Rules:
## Any live cell with fewer than two live neighbours dies, as if caused by under-population.
## Any live cell with two or three live neighbours lives on to the next generation.
## Any live cell with more than three live neighbours dies, as if by overcrowding.
## Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
require 'colorize'
init_array = []
function cdir () {
mkdir $1 > /dev/null
cd $1
}
def help_me
system("clear")
puts "Check it out...this is how I work:"
puts "Press 'help' to get some help. (But you already knew that.)"
puts "Press 'play' to play a song."
puts "Press 'list' to see what you can play."
puts "Press 'exit' to quit."
puts "Enter to continue..."
input = gets.chomp
end
# Download this file:
# https://gist.github.com/scottcreynolds/ac1b5c8d96de0c91bf7c/download
# Run it from your terminal with:
# ruby ruby_phone_format.rb
# (Just make sure you are in the right directory)
# ======================================
# Ignore All This Code
# ======================================
@loganhasson
loganhasson / tweet.shortener.rb
Last active December 24, 2015 01:29
Takes a list of tweets and shortens them, retaining punctuation.
class String
def punct
marks = ""
regex = "^\\w\\s\\-"
# but this part does
self.each_char do |c|
marks += c[eval("/[#{regex}]/")] if c[eval("/[#{regex}]/")] != nil
end
## 1. Write a method that returns whether a given letter is a vowel, using `if` and `elsif`
def one(letter)
if letter == "a"
true
elsif letter == "e"
true
elsif letter == "i"
true
elsif letter == "o"
def create_badge(*names)
badge_array = []
names.each { |name| badge_array << "Hello, my name is #{name}." }
badge_array
end
def get_rooms(list)
rooms = [1, 2, 3, 4, 5, 6, 7]
room_assignments = []