Skip to content

Instantly share code, notes, and snippets.

light = 5
medium = 7.50
bold = 9.75
puts "How much money does the customer owe?"
owed = gets.chomp.to_f
puts "How much money did the customer give you?"
@ewhitebloom
ewhitebloom / gist:9085487
Last active August 29, 2015 13:56
Guessing Game
NUMBER = 673
message = print "Guess a number between 0 and 1000:"
guess = gets.chomp.to_i
until guess == NUMBER
message = "Guess a number between 0 and 1000:"
difference = NUMBER - guess
if difference >= 0
puts "Too low, try again..."
@ewhitebloom
ewhitebloom / Second Cash Register Challenge
Last active August 29, 2015 13:56
Second Register Challenge
def sales_price_loop
input = nil
totals = []
subtotal = 0
until input == "done"
puts "What is the sale price?"
unless input == "done"
input = gets.chomp
subtotal = tally(input, totals, subtotal)
end
@ewhitebloom
ewhitebloom / Game of Thrones Hash Practice
Created February 20, 2014 22:49
Game of Thrones Hash Practice
characters = {
"Tyrion Lannister" => "House Lannister",
"Jon Snow" => "Night's Watch",
"Hodor" => "House Stark",
"Stannis Baratheon" => "House Baratheon",
"Theon Greyjoy" => "House Greyjoy"
}
characters.each do |key,value|
puts key + " represents the " + value
@ewhitebloom
ewhitebloom / Favorite Movies
Created February 21, 2014 00:30
Favorite Movies
favorite_movies = [
{ title: 'The Big Lebowski', year_released: 1998, director: 'Joel Coen', imdb_rating: 8.2 },
{ title: 'The Shining', year_released: 1980, director: 'Stanley Kubrick', imdb_rating: 8.5 },
{ title: 'Troll 2', year_released: 1990, directory: 'Claudio Fragasso', imdb_rating: 2.5 }
]
favorite_movies.each do |movie|
puts "#{movie[:year_released]}: #{movie[:title]}"
end
@ewhitebloom
ewhitebloom / gist:9126682
Created February 21, 2014 00:49
Grocery Git Practice
commit 1b60a793e9a74abba5eda41a265c58f011c661b5
Author: ewhitebloom <ewhitebloom@gmail.com>
Date: Thu Feb 20 19:48:55 2014 -0500
Even more items added
commit 191736b523c0cc14a191a5acc5fae586952d4a74
Author: ewhitebloom <ewhitebloom@gmail.com>
Date: Thu Feb 20 19:47:32 2014 -0500
@ewhitebloom
ewhitebloom / Sorting and Averaging Algorithms
Last active August 29, 2015 13:56
Sorting and Averaging Algorithms
nums = [75, 100, 85, 65, 84, 87, 95]
def average(nums)
sum = 0
nums.each do |number|
sum += number
end
sum/nums.length
end
@ewhitebloom
ewhitebloom / recipes.sql
Last active August 29, 2015 13:57
Recipes
1) select title, rating from movies where rating is not null order by rating asc limit 50;
2) select title from movies where rating is null order by title asc;
3) select title from movies where synopsis ilike '%thrilling%';
4) select title, year, rating from movies join genres on movies.genre_id = genres.id where genres.name = 'Science Fiction & Fantasy' AND movies.year BETWEEN 1980 AND 1990 order by rating desc;
5) select actors.name, movies.title, movies.year from cast_members join actors on actors.id = cast_members.actor_id join movies on movies.id = cast_members.movie_id where character ilike '%james bond%' order by year desc;
package edu.hu.bigdata;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;
import org.bson.Document;
import org.bson.json.JsonParseException;
import com.mongodb.MongoClient;
@ewhitebloom
ewhitebloom / NPI Importer.go
Last active September 13, 2017 16:44
ETL NPI data from NPI CSV file to MySQL.
package main
import (
"bufio"
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"os"
"reflect"
"strconv"