Skip to content

Instantly share code, notes, and snippets.

require 'rack'
class StevenApp
def call(env)
p env['PATH_INFO']
p env['HTTP_ACCEPT']
[200, {'Content-Type' => 'text/html'},
['<h1>Hello <a style="color: pink" href="http://students.flatironschool.com/students/stevenbrooks.html">Steven</a></h1>']]
def reverse_each_word(sentence)
sentence.split.collect { |word| word.reverse }.join(" ")
end
puts reverse_each_word("Hello world")
# Testing / Assertion
# Define a method that takes two values and compares them, printing pass or fail
class Person
attr_accessor :name, :birthday :age
def name(string)
@name = string
end
# Columns to add to Students table:
# Name
# Profile Pic
# Social media links/ Twitter, LinkedIn, GitHub, Blog(RSS)
# Quote
# About/ Bio, Education, Work
# Coder Cred / Treehouse, Codeschool, Coderwal .reject(Github)
require 'nokogiri'
require 'open-uri'
ITEMS = [ {"AVOCADO" => {:price => 3.00, :clearance => true}},
{"KALE" => {:price => 3.00,:clearance => false}},
{"BLACK_BEANS" => {:price => 2.50,:clearance => false}},
{"ALMONDS" => {:price => 9.00, :clearance => false}},
{"TEMPEH" => {:price => 3.00,:clearance => true}},
{"CHEESE" => {:price => 6.50,:clearance => false}},
{"BEER" => {:price => 13.00, :clearance => false}},
{"PEANUTBUTTER" => {:price => 3.00,:clearance => true}},
{"BEETS" => {:price => 2.50,:clearance => false}}
]
@stevenabrooks
stevenabrooks / basketball
Created June 11, 2013 12:43
actually really impressed how i was able to do this pretty well
$basketball_game =
{
:team_1 =>
{
:team_name => "Nets",
:color => ["black", "grey"],
:player_1 =>
{
:name => "Brooke Lopez",
:jersey => 11,
# Temperature bot is American but takes Celsius temperatures.
#
def temperature_bot(temp)
case temp
when temp = 18..22
"I like this temperature"
else
"This is uncomfortable for me"
end
end
puts "hello".upcase
puts "hello".upcase.downcase
puts "hello".upcase.downcase.capitalize
puts "hello".upcase.downcase.capitalize.concat(" world!")
puts "hello".upcase.downcase.capitalize.concat(" world!").upcase
movies_by_genre = { 'rocky' => 'love', 'tropic thunder' => 'comedy', 'star wars' => 'unknown'}
recipes =
{
:"steak" => ['steak', 'salt', 'pepper'],
:"salad" => ['lettus', 'dressing']
}
users =
{
#Construct an array with your favorite foods. It should have at least 5 elements.
array = ['Lobster', 'Bacon', 'Steak', 'Grilled Chicken', 'Ice Cream']
#Write a puts which returns your most favorite food out of the array.
puts array[0]
#Construct an array with the colors of the rainbow (ROYGBIV)