Skip to content

Instantly share code, notes, and snippets.

@JackHowa
JackHowa / spinal-case
Created December 21, 2017 03:43
ccc spinal case challenge
Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.
function spinalCase(str) {
return str.toLowerCase().replace(/ |_/gi, '-'); // use the | for or matching
// need to find match case [a-z] sequence
}
spinalCase('This Is Spinal Tap');
php --version
PHP 7.1.8 (cli) (built: Aug 7 2017 15:02:45) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
httpd -v
Server version: Apache/2.4.25 (Unix)
Server built: Feb 6 2017 20:02:10
scratch.rb
class Card
# wrongly added has_one
# one card can have many guesses from different users
# or even during different rounds
has_many :guesses
end
@JackHowa
JackHowa / movieClub-idea
Created May 25, 2017 16:24
Movie Club is for opinionated movie watchers and their opinionated friends
Rotten Tomatoes api
IMDB api
google sheet integration for db management
basically a crud app with user reviews and comments
----------------------------------
console:
gem install bundler
rbenv local 2.2.2
bundle install
$ postgres -D /usr/local/var/postgres
FATAL: lock file "postmaster.pid" already exists
@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
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
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
@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
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