Skip to content

Instantly share code, notes, and snippets.

View sferik's full-sized avatar

Erik Berlin sferik

View GitHub Profile
require 'prime'
Prime.each_with_index.inject(0) do |sum, (number, index)|
puts index + 1 if sum % number == 0
sum += number
end
@sferik
sferik / homework.md
Last active December 16, 2015 19:29

WDI Homework - April 29, 2013

JavaScript TODO List

Create a client-side TODO list application in JavaScript.

Requirements
  • Uses jQuery
  • When you enter text into a box and press the "Add" button, it adds an item to your "TODO" list and clears the text box
  • When you click on a checkbox next to each "TODO" item, it must:
@sferik
sferik / homework.md
Last active December 16, 2015 14:20

WDI Homework - April 23-24, 2013

Triangle Area

Given the following object, write an area function in JavaScript that calculates the area of triangle:

var triangle = {
  sideA: 3,
  sideB: 4,
 sideC: 5
require 'json'
require 'open-uri'
require 'uri'
class GoogleProductsSearch
def self.find_all_by_query(query)
file = open("https://www.googleapis.com/shopping/search/v1/public/products?key=#{ENV["GOOGLE_PRODUCTS_API_KEY"]}&country=US&q=#{URI.escape(query)}")
JSON.load(file.read)["items"] || []
end
require 'prime'
t = Time.now
Prime.each_with_index.inject(0) do |sum, (number, index)|
puts "#{index + 1} (took #{Time.now - t} seconds)" if sum % number == 0
sum += number
end

WDI Lab - April 8, 2013

Movies

You will be creating a movies app using Sinatra and the OMDB API.

Requirements

  • Ability to search for a movie by title
  • Ability to click on a search result to see detailed information about a movie including:
    • Title
  • Year
@sferik
sferik / homework.md
Last active December 15, 2015 23:28

WDI Homework - April 8, 2013

Array and Hash access

Given the following data structure:
a = ["Anil", "Erik", "Jonathan"]
  • How would you return the string "Erik"?

WDI Homework - April 3, 2013

Sinatra

  1. Finish creating your own version of http://pairprogrammingbot.com/ using Sinatra, ERB templates, and custom CSS (Aron).
  2. Continue working on the Sinatra database application:
    1. Add a layout that yields to a template
    2. Add a /products route that lists all the products in the store database in an HTML table
    3. Add a root route (/) that contains links to the /users and /products pages
    4. Add a back button on /users and /products that takes you back to the home page
  3. Style the tables using CSS

WDI Homework - April 1, 2013

SQL

  1. Write a program that converts Roman numerals to Arabic numerals.
  2. Download this SQLite database and write a SQL statement that:
    1. Selects the names of all products that are not on sale.
    2. Selects the names of all products that cost less than $20.
    3. Selects the name and price of the most expensive product.
    4. Selects the name and price of the second most expensive product.
  3. Selects the name and price of the least expensive product.
class RomanNumeralGenerator
TABLE = {
1000 => "M",
900 => "CM",
500 => "D",
400 => "CD",
100 => "C",
90 => "XC",
50 => "L",
40 => "XL",