Skip to content

Instantly share code, notes, and snippets.

@mattmarcello
Last active August 29, 2015 14:07
Show Gist options
  • Save mattmarcello/4592de96c74f43bc7b54 to your computer and use it in GitHub Desktop.
Save mattmarcello/4592de96c74f43bc7b54 to your computer and use it in GitHub Desktop.

#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.

  4. Create and assign a new array which contains two sub-arrays: One containing all the weekdays, and one containing the weekends.

  5. Let's get in touch with our Viking heritage. With your new array of arrays, write code that will change Wednesday to "Woden's Day".

  6. On second thought, I don't like weekdays at all. Write code that deletes the weekdays from the array of arrays, leaving only the weekend days.

  7. Going back to your original array of days, write code that sorts the days alphabetically and assigns these to a new variable.

  8. Finally, print out (on the terminal) the list of sorted days, with each day on its own line.


##bills_from_billings Using Andrew's video as a guide. Configure a Digital Ocean droplet and build a basic Sinatra application on it. Do not worry about complicated application logic. The point of this is to practice working with remote servers.


##blog Do some blog stuff.


##sinatra_pick_me_up

Create a site like Emergency Compliment...except it will be WDI themed. When a Lemur visits the site, they'll be greeted with a compassionate, WDI-related message.

Folder structure:

├── Gemfile
├── Gemfile.lock
├── app.rb
├── config.ru
├── public
│   └── stylesheets
│       └── styles.css
└── views
    ├── compliment.erb
    └── layout.erb

Part 1:

request response
GET / Displays greeting and randomly chosen compliment. Displays a random background color. Displays form prompting user to input their name. Form submits POST request to /names.

Part 2:

request response
POST /names Receives form input. Redirects to "/names?name=#{the_name_from_params}".
GET /names Display random pick me up with name included in greeting

Note: It is considered bad practice to render html from a post request. This is why we redurect from our POST request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment