Skip to content

Instantly share code, notes, and snippets.

View ashleygwilliams's full-sized avatar

ashley williams ashleygwilliams

  • 23:11 (UTC -05:00)
View GitHub Profile
@ashleygwilliams
ashleygwilliams / assessment.md
Last active May 14, 2020 05:06
an assessment of basic ruby skills for flatiron school students.

Student Ruby Assessment

Instructions

  • Create a file with "<yourName>_assessment.rb".

Sections 1-6

  • Title each section with a comment that includes the name and number of each section.
  • Then write the ruby that fulfills each lettered instruction under the title. There is no need to structure your code based on the lettered instructions.
  • If you need to use code from a previous numbered section please cut and paste into the approrpriate section.
  1. Make a profile on Mapquest Developer and get an API key

  2. http://open.mapquestapi.com/directions/v1/route?key=Fmjtd%7Cluub20ut2h%2C8w%3Do5-9urnhf&ambiguities=ignore&from=40.76727216,-73.99392888&to=40.71911552,-74.00666661&callback=renderNarrative

  3. This is the code you get

renderNarrative({"route":{"hasTollRoad":false,"computedWaypoints":[],"fuelUsed":0.24,"hasUnpaved":false,"hasHighway":true,"realTime":-1,"boundingBox":{"ul":{"lng":-74.011184,"lat":40.767204},"lr":{"lng":-73.993721,"lat":40.71899}},"distance":3.934,"time":451,"locationSequence":[0,1],"hasSeasonalClosure":false,"sessionId":"51e6ae58-0194-0009-02b7-1665-002655800398","locations":[{"latLng":{"lng":-73.993928,"lat":40.767272},"adminArea4":"New York","adminArea5Type":"City","adminArea4Type":"County","adminArea5":"New York City","street":"West 54th Street","adminArea1":"US","adminArea3":"New York","type":"s","displayLatLng":{"lng":-73.993928,"lat":40.767272},"linkId":25584005,"postalCode":"10019","sideOfStreet":"N","dragPoint":fal

Shallow Routes: Best Practices

FROM: http://edgeguides.rubyonrails.org/routing.html

TAKEAWAY: you want routes that are DESCRIPTIVE, but you also want routes that are not stupid deep. therefore, make shallow routes. there is an shallow option for this.

  1. only build routes with the minimal amount of information to uniquely identify the resource, like this:
resources :posts do

Make the forms!

You are making a deck-building game. AWESOME. To test the efficacy and balance of the potential decks, your are building a program that simulates potential decks. Your friend and dungeon master has already written the create action for you.

  1. Using this, create the decks form in a partial called decks/_form. This form should allow you to create a deck and add multiple cards to it.
def create
  @deck = Deck.new()
  @deck.name = params[:deck][:name]
@ashleygwilliams
ashleygwilliams / instructions.rb
Last active December 19, 2015 12:49
instructions for using sinatra reloader for windows machines that can't use shotgun
from http://www.sinatrarb.com/contrib/reloader.html
#GEMFILE
development do
gem "sinatra-contrib"
gem "tux"
end
#app.rb
require "sinatra/reloader" if development?

Flexing Associations in Rails

Objectives

  • Be comfortable building and associating objects via all mechanisms available

Instructions

  1. Create 3 models: Artist, Album, and Song

  2. The artist, "Wu-Tang Clan", has the following album, with the following songs:

@ashleygwilliams
ashleygwilliams / instructions.md
Last active December 19, 2015 11:39
rails to do list assignment

Rails To-Do List

Objectives:

  • Create a Rails Application
  • Create Models that work with Active Record
  • Use Associations to relate Models
  • Use Forms to update the attributes of Objects

Product Spec

helpers do
def partial(file_name)
erb file_name, layout => false
end
end
<!doctype html>
<html>
<head>
<link href="css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<link href="css/bootstrap-responsive.min.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<div class="container-fluid">
<%= yield %>
</div>