Skip to content

Instantly share code, notes, and snippets.

@tinderfields
tinderfields / gist:8964407
Created February 12, 2014 21:00
Create rvm ruby version file
rvm --ruby-version --create use 2.1.0@swapper_scraper
@tinderfields
tinderfields / backbone_yeoman.sh
Last active December 26, 2015 09:49
Create backbone handlebar app with yeoman
brew update
brew install node
npm install -g yo
npm install -g generator-webapp
npm install -g generator-backbone
#If you are creating the app
mkdir appname && cd $_
yo backbone --template-framework=handlebars appname
@tinderfields
tinderfields / spotlight
Created May 23, 2013 12:59
Disable / enable spotlight indexing
sudo mdutil -a -i off
sudo mdutil -a -i on
@tinderfields
tinderfields / gist:5494658
Created May 1, 2013 10:45
Linux / rails performance checks
#CPU
# http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html
sudo apt-get install sysstat
mpstat
mpstat -P ALL
# Memory
# http://superuser.com/questions/398862/linux-find-out-what-process-is-using-all-the-ram
# Passenger
@tinderfields
tinderfields / gist:5238440
Created March 25, 2013 16:29
Dump and restore a Postgres database
# Backup
pg_dump -U db_user -h localhost -xcO db_name | bzip2 - - > db/db_name.sql.bz2
# Restore
# Delete database then recreate then
bunzip2 -f db/db_name.sql.bz2
psql -U db_user -h localhost db_name < db/db_name.sql
@tinderfields
tinderfields / gist:2688605
Last active October 4, 2015 19:47
Setup a new rails project using rvm and git
# Upgrade RVM
rvm get stable
# Get latest Ruby
rvm install 2.1.0
# Create and use gemset
mkdir project
cd project
rvm --ruby-version --create use 2.1.0@swapper_scraper
@tinderfields
tinderfields / gist:2419518
Created April 19, 2012 08:02
Replace human readable dates in strings with mysql dates
string.gsub(/\"(\d+)\/(\d+)\/(\d+)\"/, "\"$3-$2-$1\"")
#
# = Capistrano database.yml task
#
# Provides a couple of tasks for creating the database.yml
# configuration file dynamically when deploy:setup is run.
#
# Category:: Capistrano
# Package:: Database
# Author:: Simone Carletti <[email protected]>
# Copyright:: 2007-2010 The Authors
@tinderfields
tinderfields / delayed_job_monit_capistrano.rb
Created September 22, 2010 15:26
Capistrano setup Monit for DelayedJob
set :monit_app_services, %w(delayed_job)
namespace :delayed_job do
desc "Restart the delayed_job process"
task :restart, :roles => :app do
sudo "RAILS_ENV=#{default_stage} #{current_path}/script/delayed_job restart"
end
end
namespace :monit do
@tinderfields
tinderfields / Log SQL queries from within the console
Created September 9, 2010 16:46
Setup rails console logging
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.clear_active_connections!