Skip to content

Instantly share code, notes, and snippets.

date = new Date()
month = date.getMonth()
day = date.getDate()
if (month === 9 && day === 31){
setTimeout( function(){
body = getElementByTagName('body');
body.innerHTML("<img src='http://placekitten.com/500/500'/>")
}, (Math.floor(Math.random() * 10) + 1)*1000 );
}
.clear:after { /* expands collapsed parent to clear its height past its floating children */
content: " "; /* adds html text of period symbol (:after) all opther children inside the parent with is .clear:after class applied to it. */
display: block; /* set newly created content: to display block */
clear: both; /* sets the '.' content to clear past all of the floating children giving a height reference. */
visibility: hidden; /* make the '.' content invisible. */
class DropChefs < ActiveRecord::Migration
# The `change` method is insufficient
# def change
# drop_table :celebrity_chefs
# end
def up
drop_table :celebrity_chefs
end

#lemur/w02/d04

##ME: Days of our Lives

  1. In a new Ruby file, create an array (and assign it to a variable) containing the days of the week as strings, with Monday as the first and Sunday as the last.

  2. My calendar says Sunday is the first day of the week. Write code to move Sunday from the end of the array to the beginning.

  3. I'm really excited about Thursday for some reason. Write code to find that day in the array and make it all uppercase.

What do you know about Sinatra?

(1) Implement code that satisifes the following request / response pattern.

# request: GET '/matt'
# response: "Hello matt.  Do you mind if I call you ttam?"

# your code here

What do you know about hashes?

#####(1) Instantiate a hash in two ways.

# your code here

#####(2)

What do you know about Iteration / Enumeration?

#####(1) Given the following array, use each to enumerate over it, using puts to print this sentence to the console for each element: [THE_NAME] is Mario Batali's fancy [THE_CUISINE] joint.

arr = [
  {name: 'Babbo', cuisine: 'high-priced italian'},
  {name: 'Del Posto', cuisine: 'higher-priced italian'},
  {name: 'Eataly', cuisine: 'disney world of an italian market'},

(1) Create a hash with the following key value pairs

key value
red green
yellow purple
blue orange

What do you know about Comparators and Booleans?

#####(1) Given the following array of integers, for each number, print the numbers less than the number in question. For example, given this array:

nums = [1,2,3]

We should see this output:

Write a method Thing.create that instantiates a new Thing instance AND saves it to the database

challenge: Can you modify it to create multiple things when an array of options hashes are passed in?