Skip to content

Instantly share code, notes, and snippets.

@loriculberson
loriculberson / create in task manager
Created February 17, 2015 01:10
WIP create method
def self.create(task)
database.transaction do
database[:tasks].insert("title" => task[:title], "description" => task[:description])
end
# require 'pry';binding.pry
end
{
"auto_indent": true,
"color_scheme": "Packages/Color Scheme - Default/Cobalt.tmTheme",
"font_size": 10,
"highlight_line": true,
"highlight_modified_tabs": true,
"margin": 2,
"save_on_focus_lost": true,
"smart_indent": true,
"tab_size": 2,
@loriculberson
loriculberson / oven.rb
Last active August 29, 2015 14:11 — forked from jcasimir/oven.rb
class Oven
attr_reader :state
def initialize
@state = InactiveState.new
end
def temp_up
@state = state.temp_up
end
phrase = "This is my secret message."
alpha_values =
{
"A"=>1, "B"=>2, "C"=>3, "D"=>4,
"E"=>5, "F"=>6, "G"=>7, "H"=>8,
"I"=>9, "J"=>10, "K"=>11, "L"=>12,
"M"=>13, "N"=>14, "O"=>15, "P"=>16,
"Q"=>17, "R"=>18, "S"=>19, "T"=>20,
"U"=>21, "V"=>22, "W"=>23, "X"=>24,
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'credit_card3'
class CreditCardTest < Minitest::Test
def setup
@card_num = CreditCard.new
end
card_number = "342801633855673"
credit_card = card_number.chars.map(&:to_i).reverse
double_index = credit_card.select.with_index { |_,i| i.odd? }
products = double_index.map {|num| num * 2 }
doubled_sum = products.map {|digits| digits.to_s.split('')}.map{|pair| pair.reduce(0) {|sum, x| sum + x.to_i}}.reduce(:+)
product_sum = credit_card.select.with_index { |_,i| i.even? }.reduce(:+)
bottles = 99
until bottles < 0
if bottles > 2
puts "#{bottles} bottles of beer on the wall, #{bottles} bottles of beer.\nTake one down, pass it around, #{bottles-1} bottles of beer on the wall."
elsif bottles == 2
puts "#{bottles} bottles of beer on the wall, #{bottles} bottles of beer.\nTake one down, pass it around, #{bottles-1} bottle of beer on the wall."
elsif bottles == 1
puts "#{bottles} bottle of beer on the wall, #{bottles} bottle of beer.\nTake one down, pass it around, #{bottles-1} bottles of beer on the wall."
else bottles == 0