Skip to content

Instantly share code, notes, and snippets.

@stomatocode
stomatocode / index.html
Last active December 19, 2015 22:19 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>

Instructions:

  1. Download this application skeleton.
  2. Convert the app to use AJAX.
  3. Add any files you changed to your gist and submit your code.
require 'sqlite3'
require 'csv'
# If you want to overwrite your database you will need
# to delete it before running this file
$db = SQLite3::Database.new "politicians.db"
module PoliticianDB
def self.setup
class Vehicle
attr_reader :color, :speed, :status
def initialize(args)
@color = args[:color]
@speed = :slow
@status = :stopped
end
class Die
attr_reader :dice, :top
@@dice = [['A','A','E','E','G','N'],
['E','L','R','T','T','Y'],
['A','O','O','T','T','W'],
['A','B','B','J','O','O'],
['E','H','R','T','V','W'],
['C','I','M','O','T','U'],
def factorial_iterative(number)
until number == 1
number *= number - 1
number -= 1
p number
end
fib_num
@stomatocode
stomatocode / vehicle.rb
Last active December 18, 2015 09:19 — forked from aespaldi/vehicle.rb
class Vehicle
def powerplant(args)
@engine
@transmission
@drivetrain
end
def chassis(args)
def has_ssn?(string)
if string =~ /\d{3}\W\d{2}\W\d{4}/
true
elsif string =~ /\d{9}/
true
else
false
end
end
def super_fizzbuzz(array)
array.each do |w|
if w % 15 == 0
puts "FizzBuzz"
elsif w % 3 == 0
puts "Fizz"
elsif w % 5 == 0
puts "Buzz"
else
# test to see if valid triangle
def valid_triangle?(a, b, c)
if ((a == 0 or b == 0 or c == 0) or (a == nil or b == nil or c == nil))
return false
end
if a + b > c
return true