This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
require 'sqlite3' | |
require 'logger' | |
# ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', | |
:database => 'address_book.db' | |
ActiveRecord::Base.connection.execute <<-SQL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RouterTester::Application.routes.draw do | |
resources :companies do | |
member do | |
put 'location' | |
end | |
end | |
resources :managers do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RouterTester::Application.routes.draw do | |
get "managers/index" | |
get "managers/show" | |
get "managers/new" | |
get "managers/create" | |
get "managers/update" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="/cards" method="post" id="payment-form"> | |
<div class="form-row"> | |
<script type="text/javascript" src="https://js.stripe.com/v1/"> | |
<script type="text/javascript"> | |
// this identifies your website in the createToken call below | |
$(document).ready(function(){ | |
Stripe.setPublishableKey('pk_07T3vzpNsDZ1R1f6EXJUiQKC0u0qK'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
def janky(length) | |
start_time = Time.now | |
(1..length).each { |num| num } | |
time = Time.now - start_time | |
time | |
end | |
def benchmarked(length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_admin_devices | |
count = 0 | |
AdminDevice.limit.all.each do |admin_device| | |
device = Device.find(admin_device.id) | |
unless device.last_run_time_tester | |
puts "'last_run_time_tester' was false: #{admin_device.description}" | |
count += 1 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
require 'active_support/core_ext/integer/inflections' # Used for printing date as human text | |
require 'holidays' # Gives access to holiays | |
class Payday | |
def initialize(query_date) | |
@query_date = query_date | |
@next_payday = 'unknown' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
require 'active_support/core_ext/integer/inflections' | |
class Payday | |
def self.get_next_payday(date) | |
payday = Payday.get_next_standard_payday(date) | |
payday = Payday.weekend_adjustment(payday) | |
"Payday will be " + payday.strftime("%a %b #{payday.day.ordinalize}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
require 'rest-client' | |
#get a big block of json | |
github_json = RestClient.get('https://api.github.com/users/rails/repos') | |
#format the json for ruby to read | |
ghub_json = JSON.load(github_json) | |
#loop over all the repos in the formatted json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
attr_accessor :name, :age | |
def initialize | |
puts "name: #{name}" | |
puts "@name: #{@name}" | |
name = "David" | |
@name = "Tom" |