Skip to content

Instantly share code, notes, and snippets.

View saveologypaul's full-sized avatar

Paul Kruger saveologypaul

View GitHub Profile
@saveologypaul
saveologypaul / gist:3540773
Created August 30, 2012 20:57
Command Line Replace - Josh and Paul
! = bash history
-2 = back two commands
:gs = global substitute
:s = single substitute first only
:p = preview
!-2:gs/orgword/newword/:p
@saveologypaul
saveologypaul / gist:3539912
Created August 30, 2012 20:20
Spit out a table's columns into a vim buffer
how to spit out a table's column names:
the following are vim commands
# get the table definition from the database
:r!echo '\d domains' | psql battery_development
# strip out everything besides the column name
:'<,'>s/^\s*\(\S\S*\)\s.*/\1/
@saveologypaul
saveologypaul / gist:3535970
Created August 30, 2012 18:09
How to get shortened list of important keyboard bindings in bash
bind -p | grep -v -e 'self.insert' -e '^#' -e 'lowercase-version' | vim -
This command will give you a list of bash keyboard bindings that are useful to learn.
@saveologypaul
saveologypaul / gist:3535309
Created August 30, 2012 17:51
Notes from vim tutorial 1
To view a list of the following shortcuts and more…for bash, run the following command:
bind -p | vim - # to open it in vim
\C = ctrl
\e = alt
pry/bash/insert-mode in vim (emacs shortcuts - which is the default keyboard mode for bash)
alt-b back a word
alt-f jump forward a word
alt-l lowercase word right
@saveologypaul
saveologypaul / gist:2853223
Created June 1, 2012 16:07
Wirble and irbrc
## Required
# install
sudo gem install wirble
sudo gem install utility_belt
# settings for ~/.irbrc
require 'rubygems'
require 'utility_belt'
UtilityBelt::Themes.background(:dark) #optional
@saveologypaul
saveologypaul / gist:2660750
Created May 11, 2012 16:23
Git Workflow without merge conflict
How to make a feature with git and branches:
paul@dev:~/Sites/myapp(master)$ gpr #make sure your master branch is up todate with github
paul@dev:~/Sites/myapp(master)$ bundle #make sure all gem/plugins are installed
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.7)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.7)
require 'spec_helper'
describe FeaturePool do
it "creates a new instance given valid attributes" do
Fabricate :feature_pool
end
it "is not valid without a name" do
Fabricate.build(:feature_pool, :name => "").should_not be_valid
end
var setCryptData = function (data) {
window.cryptData = data.crypto_key;
};
var submitFormWithCrypto = function (form, callback) {
$.getScript('/profiles/crypto_key?callback=setCryptData', function () {
var queryData = {
key_id: cryptData.id,
encrypted: teaEncrypt($(form).serialize(), cryptData.key)
};
@saveologypaul
saveologypaul / capybara_save_and_open_page.rb
Created May 2, 2012 15:41 — forked from snelson/capybara_save_and_open_page.rb
Rails 3.1 Capybara save_and_open_page asset pipeline support
if Rails.version.to_f >= 3.1 and Rails.application.config.assets.enabled
require 'capybara/util/save_and_open_page'
module Capybara
class << self
def save_page(html, file_name=nil)
rewrite_css_assets
save_page_html(html, file_name)
end
protected
@saveologypaul
saveologypaul / deploy.rake
Created April 27, 2012 13:50 — forked from njvitto/deploy.rake
Rakefile to deploy and rollback to Heroku in two different environments (staging and production) for the same app
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]