Skip to content

Instantly share code, notes, and snippets.

@townie
townie / syscheck1v2.rb
Created February 24, 2014 23:16
One iteration of the a loop to generate min, max, average test scores
score= [75, 100, 85, 65, 84, 87, 95]
min_local = 100000000
max_local = 0
total= 0
score.inject(0) do |sum, test|
if test > max_local
max_local = test
require 'csv'
require 'pry'
require 'date'
@finish_num = nil
@report_num = nil
def load_the_db(check = 0)
order_list = CSV.table('products.csv')
def number_details(number)
#returns: Jenny has the number 508.867.5309 and it is their home number
phone_numbers_2 = {
'Dan' => {
home: '508.555.5555',
mobile: '508.555.6666'
},
'Jenny' => {
home: '508.867.5309',
module BinaryTree
class Node
attr_reader :word, :count, :left, :right
include Enumerable
def initialize(word)
@word, @count = word, 1
end
class Television
def initialize(channel=3,show="24")
@channel = channel
@show = show
end
end
class Car
def initialize(color, owner, cylinders)
@color = color
@owner = owner
@cylinders = cylinders
end
def color
@color
end
def clear!
@contents =[]
end
def ink_remaining?
@capacity > 0
end
#What are the top 50 worst rated movies? The results should include the movie title and rating and be sorted by the worst rating first.
SELECT title, rating FROM movies ORDER BY rating LIMIT 50;
# What movies do not have a rating? The results should include just the movie titles in sorted order.
SELECT title FROM movies WHERE rating IS NULL;
createdb recipes
CREATE TABLE recipes (
id SERIAL NOT NULL ,
name VARCHAR(125) NOT NULL ,
yields VARCHAR(50),
total_time VARCHAR(150),
directions TEXT NOT NULL
);