Skip to content

Instantly share code, notes, and snippets.

@garciadanny
garciadanny / Tutorial Links
Last active December 13, 2015 19:38
JumpstartLab tutorial links
@garciadanny
garciadanny / psych.rb
Created February 20, 2013 16:46 — forked from jcasimir/psych.rb
require 'highline/import'
class Question
attr_reader :text, :important, :validation, :answer
def initialize(input)
@text = input[:text]
@important = input[:important]
@validation = input[:validation] ||= /.*/
end
@garciadanny
garciadanny / Rakefile
Last active December 14, 2015 01:39 — forked from burtlo/Rakefile
# http://rake.rubyforge.org/
$:.push('lib')
require 'sales_engine'
def cleanup
puts "Cleaning Up My Mess"
end
task :environment do
puts "Loading Environment"
@garciadanny
garciadanny / refactor_sales_engine.rb
Last active December 14, 2015 03:39
Using the send method. (Refactoring Sales_Engine)
def self.most_revenue(number_of_results)
items = get_items_with_appropriate_values(:unit_price)
sort_and_return_items(items, number_of_results)
end
def self.most_items(number_of_results)
items = get_items_with_appropriate_values(:quantity)
sort_and_return_items(items, number_of_results)
end
@garciadanny
garciadanny / seconds_old.rb
Last active December 14, 2015 06:08 — forked from burtlo/example2.rb
require 'date'
# puts "What are you? #{ARGV} #{ARGV.class}"
# Called as in `ruby example2.rb 1977 10 30`
# birthdate = ARGV.map {|arg| arg.to_i }
birthdate = [ 1977, 10, 30 ]
# year, month, day = [ 1977, 10, 30 ]
# birth_in_seconds = Date.new(year,month,day).to_time.to_i
require 'time'
class Gigasecond
attr_reader :quantity
IN_SECONDS = 1_000_000_000
def initialize(quantity)
@quantity = quantity
end
@garciadanny
garciadanny / FUNDAMENTAL SQL.md
Created March 1, 2013 21:27
FUNDAMENTAL SQL (Structured Query Language)

#FUNDAMENTAL SQL The most popular SQL-based databases include PostgreSQL, MySQL, Oracle, MS SQL Server, and SQLite.

Most databases store your data in a hidden-away part of your computer’s filesystem. You’d never interact with the data directly, only through the tools provided by the database engine. SQLite, instead, stores its data in a plain-text file. This makes it incredibly easy to move, rename, delete, or transfer the database.

###Experimenting with SQLite

  • Firing up the Sqlite db:

    • In the terminal: sqlite3 example.sqlite3
  • Creating a table in the terminal:

@garciadanny
garciadanny / word_problem.rb
Created March 6, 2013 16:41 — forked from jcasimir/word_problem.rb
REGULAR EXPRESSIONS
class WordProblem
attr_reader :equation
def initialize(equation)
@equation = equation
end
def answer
calculate
end
@garciadanny
garciadanny / say.rb
Created March 12, 2013 15:44
Katrina's Solution
class Say
attr_reader :value
def initialize(value)
@value = value
end
def in_english
guard_range
say_small_number || say_big_number
class NilClass
def join
""
end
end
class Chunks
attr_reader :value
def initialize(value)