Skip to content

Instantly share code, notes, and snippets.

View phlco's full-sized avatar

Phillip Lamplugh phlco

  • Los Angeles, CA
View GitHub Profile
@phlco
phlco / movies lab
Created July 10, 2013 19:19
movies lab
# Moviez
Use the IMDB gem to create a new movies_app.
Users should be able to search for movies.
Display search results that link to a show page for each movie.
Include a button to save favorited movies to the database.
Saved movies should have a title, year, plot, mpaa_rating and a rating that goes from 0 to 100.
var lStations = [ "8th", "6th", "Union Square", "3rd", "1st" ];
var nStations = [ "Times Square", "34th", "28th", "23rd", "Union Square", "8th" ];
var sixStations = [ "Grand Central", "33rd", "28th", "23rd", "Union Square", "Astor Place" ];
var gStations = [ "Greenpoint", "Nassau", "Metropolitan", "Broadway" ];
// write a function that accepts a line, and returns a function
// to calculate the distance between two stops on one line
function getDistanceForLine(line){
// code here?
@phlco
phlco / gist:6201045
Last active December 20, 2015 21:58
Optimization Gems
# Optimization Gems
group :development do
gem 'bullet' # help to kill N+1 queries and unused eager loading
# https://github.com/flyerhzm/bullet
gem 'lol_dba' # scans your models and displays a list of columns that should be indexed
# https://github.com/plentz/lol_dba
gem 'rack-mini-profiler' # displays speed badge for every html page.
# https://github.com/harleyttd/miniprofiler
gem 'rails_best_practices' # a code metric tool to check the quality of rails codes
# https://github.com/railsbp/rails_best_practices
@phlco
phlco / testing_gems.rb
Created August 15, 2013 15:11
putting together testing gems
group :test do
gem 'cucumber' # a tool for running automated tests written in plain language
# https://github.com/cucumber/cucumber
gem 'test-unit'
gem 'guard'
gem 'guard-rspec'
gem 'shoulda-matchers'
gem 'rb-fsevent'
end
@phlco
phlco / dalli_production.rb
Created August 20, 2013 00:31
configuration for Dalli - caching client
client = Dalli::Client.new
config.action_dispatch.rack_cache = {
metastore: client,
entitystore: client,
allow_reload: false
}
config.cache_store = :dalli_store
config.serve_static_assets = true
@phlco
phlco / Procfile
Last active December 21, 2015 08:08
unicorn config file
# ./Procfile
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
@phlco
phlco / Procfile
Last active December 21, 2015 08:08
puma config file
# ./Procfile
web: bundle exec puma -p $PORT -C ./config/puma.rb
@phlco
phlco / gist:6286225
Created August 20, 2013 19:43
Fixing Postgres
# If your postgres isn't working properly
## check
- Is the elephant in your menu bar?
- Are you pointing to the correct psql?
```
$ which psql
=> /Applications/Postgres.app/Contents/MacOS/bin/psql
```
@phlco
phlco / fix_postgres.md
Created August 20, 2013 19:44
Fixing Postgres

If your postgres isn't working properly

check

  • Is the elephant in your menu bar?
  • Are you pointing to the correct psql?
$ which psql
=> /Applications/Postgres.app/Contents/MacOS/bin/psql
@phlco
phlco / benchmark.rb
Last active December 21, 2015 19:19
ruby benchmarking template
##############
### Benchmarks
##############
require 'benchmark'
# http://www.ruby-doc.org/stdlib-1.9.3/libdoc/benchmark/rdoc/Benchmark.html
# http://rubylearning.com/blog/2013/06/19/how-do-i-benchmark-ruby-code/
# http://stackoverflow.com/questions/556405/what-do-real-user-and-sys-mean-in-the-output-of-time1/556411#556411
iterations = 100_000 # How many times to test?