Skip to content

Instantly share code, notes, and snippets.

View sdanko11's full-sized avatar

Steve Danko sdanko11

  • Pittsburgh, PA
View GitHub Profile
@sdanko11
sdanko11 / gist:9792006
Last active August 29, 2015 13:57
Sorting Function
def find_highest_index(array)
second_array = array.clone
while array.count > 1
first_number = array.first
index = array.index(first_number)
if first_number > array[index + 1]
array.delete_at(index + 1)
else
array.delete_at(index)
end
@sdanko11
sdanko11 / analytics.rb
Last active December 31, 2015 09:19
Word Analytics
require_relative "top_three"
require 'pry'
require 'rspec'
class WordAnalytics
attr_reader :character_count
def initialize(phrase)
@phrase = phrase
@sdanko11
sdanko11 / words.rb
Created December 11, 2013 05:47
word counter
require 'rspec'
class WordCounter
def initialize(phrase)
@phrase = phrase
@all_words = []
@uniq_words = []
@word_count = []
end
@sdanko11
sdanko11 / gist:7883804
Created December 10, 2013 00:37
sql challenge
#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 WHERE rating > 1 ORDER BY rating LIMIT 10;
#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;
# What movies have the word "thrilling" in their synopsis? The results should just include the movie title.
@sdanko11
sdanko11 / circle.rb
Created December 9, 2013 04:34
TDD Shapes
class Circle
def initialize(radius)
@radius = radius
end
def area
(Math::PI * (@radius*@radius)).round(2)
end
@sdanko11
sdanko11 / gist:7863821
Created December 8, 2013 21:05
Pig Latin test suite
require 'rspec'
require_relative 'latin'
describe PigLatinTranslation do
it 'should split up all the letters in a phrase' do
expect(PigLatinTranslation.new('i am happy').words).to eql(['iway','amway','appyhay'])
end
it "should translate words that start with a vowel" do
expect(PigLatinTranslation.new(@words_in_phrase = 'happy').words).to eql('appyhay')
@sdanko11
sdanko11 / gist:7781941
Created December 4, 2013 03:37
Calculate the amount of tax for each person and if they should receive a refund.
persons_income = [
{
first_name: 'Johnny',
last_name: 'Smith',
annual_income: 120000,
tax_paid: 28000
},
{
first_name: 'Liz',
last_name: 'Lemon',
@sdanko11
sdanko11 / gist:7775575
Created December 3, 2013 19:08
Pig Latin Translation
class PigLatinTranslation
attr_reader :phrase
def initialize(phrase)
@phrase = phrase
@words_in_phrase = []
end
def translate
@sdanko11
sdanko11 / gist:7772597
Last active December 30, 2015 03:59
Animals Classes
class Animal
attr_reader :animal_name
def initialize(name)
@animal_name = (name)
end
def eat(what_they_eat)
puts "just ate #{what_they_eat}"
@sdanko11
sdanko11 / assignment_grade_class
Created December 2, 2013 22:38
Teacher Grades
class AssignmentGrade
def initialize(grade_data)
@student_grades = grade_data
end
def gets_an_asignment_grade(assignment_number)
@student_grades.student_grades.each do |person|
if assignment_number == 1
puts person[:name]