Skip to content

Instantly share code, notes, and snippets.

View kpearson's full-sized avatar
💭
Building 💪

Kit Pearson kpearson

💭
Building 💪
View GitHub Profile
@kpearson
kpearson / location_finder.rb
Last active August 29, 2015 14:11
location_finder A solution to Jeffs location challenge
require 'json'
class LocationFinder
attr_reader :locations
def initialize(locations)
file = File.read(locations)
@locations = json_parse(file)
end
@kpearson
kpearson / Homebrew Cheatsheet.md
Last active February 27, 2017 08:39
Quick and dirty guide to Homebrew

[Homebrew] is the missing package manager for osx.

##Homebrew Commands which brew Tells us if and where Homebrew is installed.
brew doctor Tells us about the health and status of our instilation.
brew update update the formulas and brew itself.
brew install <app_name> installs app.
brew unistall <app_name> --force uninstall app.
brew info <app_name> view the output from the initial install of the app.
brew upgrade updates all apps.

Readline keybindings (work in the shell, some of the nav ones work everywhere in a mac)
C-something # hold control and press the "something" key
M-something # hold control and press the "something" key
Navigation
C-a # beginning of line
C-e # end of line
C-b # back a char
M-b # back a word
@kpearson
kpearson / Ruby.sublime-build
Last active August 29, 2015 14:16
SublimeText 2 - Ruby Version Manager
{
"cmd": [ "/Users/user_name/.rvm/bin/rvm-auto-ruby", "$file" ],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.ruby"
}
@kpearson
kpearson / whatevz.rb
Last active August 29, 2015 14:19 — forked from JoshCheek/whatevz.rb
require 'active_record'
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
ActiveRecord::Schema.define do
self.verbose = false
create_table :businesses do |t|
t.string :name
end
create_table :orders do |t|
t.string :name
t.integer :business_id
// layout file
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>

Guides Table of Contence

require 'active_record'
require 'logger'

ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
ActiveRecord::Base.logger = Logger.new $stdout
ActiveSupport::LogSubscriber.colorize_logging = false
@kpearson
kpearson / gist:746b1f0b1f02fa32f394
Last active September 5, 2015 08:30 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

Commands examples

If the namespace is not used then the commands will perform on top of the default database. bundle exec rake db:create bundle exec rake db:migrate

By using the namespace we are going to use all the configuration for our alternate DB. bundle exec rake store:db:create bundle exec rake store:db:migrate

@kpearson
kpearson / http request header dump | Rails Controller code.md
Created March 9, 2016 19:59
Place in a controller action to have the server print to screen the contents of the http request headers.

Place in a controller action to have the server print to screen the contents of the http request headers.

logger.warn "*** BEGIN RAW REQUEST HEADERS ***"
self.request.env.each do |header|
  logger.warn "HEADER KEY: #{header[0]}"
  logger.warn "HEADER VAL: #{header[1]}"
end
logger.warn "*** END RAW REQUEST HEADERS ***"