Skip to content

Instantly share code, notes, and snippets.

View paulbaker3's full-sized avatar

Paul Baker paulbaker3

View GitHub Profile
@paulbaker3
paulbaker3 / create_product_controller.rb
Last active February 9, 2016 22:20
Extracting the create action from the ProductsController. Found in Fearless Refactoring Rails Controllers, pg 31
# Declare the new route in routes.rb
post 'products' => 'create_product#create'
resources :products
# Intermediate state depending on inheritance to pass tests
class CreateProductController < ProductsController
def create
@product = Product.new(product_params)
respond_to do |format|
@paulbaker3
paulbaker3 / products_controller.rb
Last active February 9, 2016 22:20
A typical Rails controller, found in Fearless Refactoring Rails Controllers pg 29 - 30
class ProductsController < ApplicationController
before_action :set_product, only: [:show, :edit, :update, :destroy]
before_filter :filter_the_things, only: [:create]
def index
@products = Product.all
end
def show
end
@paulbaker3
paulbaker3 / amazon_top_20_scanner.user.js
Last active August 13, 2016 17:21
Amazon Top 20 Scanner
// ==UserScript==
// @name Amazon Top 20 Scanner
// @namespace http://www.paulbaker3.com
// @version 1.0
// @description Scans Amazon bestseller urls similar to http://www.amazon.com/gp/bestsellers/*
// @author Paul Baker
// @grant MIT License
// @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @include https://www.amazon.com/*
// @include http://www.amazon.com/*

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@paulbaker3
paulbaker3 / gist:8857189
Last active August 29, 2015 13:56
Rolling back heroku

roll back to a version tagged as "previous"

git push -f heroku previous:master

roll back three commits:

git push -f heroku HEAD~3:master

roll back to a specific SHA. Does NOT affect your current working branch!

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@paulbaker3
paulbaker3 / populate.rake
Created December 5, 2013 18:39
Creates a set of custom rake tasks. Place this in a file in {app_root}/lib/tasks/<file_name>.rake Invoke the custom_demo_data task from the command line as => rake populate:custom_demo_data COMPANY="Foo Bar Inc"
namespace :populate do
desc "Populates the production database with demo data to support sales"
task :generic_demo_data do
puts "populating the database with demo data"
end
desc "Populates the production database with test data for manual testing"
task :test_data do
puts "populating the database with test data"
end
source 'https://rubygems.org'
gem 'active_model_serializers', git: 'git://github.com/rails-api/active_model_serializers.git'
gem 'ember-rails', git: 'git://github.com/emberjs/ember-rails.git' # so we get the pre version
gem 'rack-mini-profiler', git: 'git://github.com/SamSaffron/MiniProfiler'
gem 'vestal_versions', git: 'git://github.com/zhangyuan/vestal_versions'
gem 'message_bus', path: 'vendor/gems/message_bus'
gem 'rails_multisite', path: 'vendor/gems/rails_multisite'
gem 'simple_handlebars_rails', path: 'vendor/gems/simple_handlebars_rails'
@paulbaker3
paulbaker3 / Dev Tools
Created June 5, 2013 17:15
Useful Dev Tools
IE VMs (http://www.modern.ie/en-us)
@paulbaker3
paulbaker3 / makePianobarFromSource
Created June 7, 2012 05:05
Installing pianobar from source
Copied directly from http://www.foscode.com/install-pianobar-ubuntu/ with an additional note from me.
Here’s how to install it:
1. Install all dependencies:
1.sudo apt-get install git-core
2.sudo apt-get install libao-dev
3.sudo apt-get install libmad0-dev
4.sudo apt-get install libfaac-dev
5.sudo apt-get install libfaad-dev