Skip to content

Instantly share code, notes, and snippets.

View JackHowa's full-sized avatar

Jack Howard JackHowa

View GitHub Profile
@JackHowa
JackHowa / 20170412active_record_notes
Created April 12, 2017 21:18
active record notes - week 3 = active-record-intro
Create the Database
bundle exec rake db:create
Check Database Version
bundle exec rake db:version
Run the Test Suite
bundle exec rake spec
Run the Migrations
@JackHowa
JackHowa / gist:ed9e579859ccecae49fc42ee675df051
Created April 12, 2017 22:23
20170412active_records-editing
Pre-release: Set up Database with Old Schema
$ bundle install
$ bundle exec rake db:create
$ bundle exec rake db:migrate
bundle exec rake generate:migration NAME=RemoveWeightFromDogs
class RemoveWeightFromDogs < ActiveRecord::Migration
@JackHowa
JackHowa / 20170412active_record_retrieving
Created April 12, 2017 23:05
retrieving active records
$ bundle install
$ bundle exec rake db:create
$ bundle exec rake db:migrate
$ bundle exec rake db:seed
@JackHowa
JackHowa / 20170413ActiveRecordsRetrieval
Created April 13, 2017 13:40
active records retrieve commands - week 3
$ bundle install
$ bundle exec rake db:create
$ bundle exec rake db:migrate
$ bundle exec rake db:seed
bundle exec rake console
Dog.all
Just as it is the responsibility of our plain Ruby classes to instantiate new instances of themselves,
Active Record model classes are also responsible for instantiating instances of themselves
bundle exec rake console
@JackHowa
JackHowa / gist:2c3e1c5c8adbb6542b35d35e18cdc903
Created April 20, 2017 22:36
prime numbers refactor duke
require 'prime'
def prime_factors(number, output = [])
return [number] if number.prime?
# write def prime base case checker in method
# return output if number.prime?
factors = (2...number/2).to_a.select do |potential_factor|
number % potential_factor == 0
end
change instance vars of positions to self.position
because that's the position for the current player
delete player instance variable then just pass players into the starting_position (formerly overwriting with position method)
make attr reader for position
use insert and to_s to the value
have a hash value be knowing the position and player name
need a merge conflict xy_wing array maybe
or just assign the variables of the board from within the recursie loop because that's worked before with the lone single
@JackHowa
JackHowa / active_record_howtos
Created May 3, 2017 21:04
active record here we go
# installing gems
gem install bundler
# install bundler should already be here on dbc machines
bundle install
# creating database
# makes two dbs - one for model, one test
bundle exec rake db:create
console:
gem install bundler
rbenv local 2.2.2
bundle install
$ postgres -D /usr/local/var/postgres
FATAL: lock file "postmaster.pid" already exists