Skip to content

Instantly share code, notes, and snippets.

# ~/.bashrc
# vim:set ft=sh sw=2 sts=2:
source "$HOME/.hashrc"
# Store 10,000 history entries
export HISTSIZE=10000
# Don't store duplicates
export HISTCONTROL=erasedups
# Append to history file
@mzaragoza
mzaragoza / app-models-user.rb
Created September 2, 2016 14:30
Best way to store bank account information of users?
#file name and path app/models/user.rb
class User
attr_encrypted :bank_account_number, key: ENV['salt']
end
#lib/tasks/db.rake
namespace :db do
desc "Import most recent database dump"
task :import_from_prod => :environment do
puts 'heroku run pg:backups capture --app sushi-prod'
restore_backup 'sushi-prod'
end
def path_to_heroku
['/usr/local/heroku/bin/heroku', '/usr/local/bin/heroku'].detect {|path| File.exists?(path)}
@mzaragoza
mzaragoza / gist:d86af1859711f8efb8cf
Created January 22, 2015 21:31
alias for ~/.bashrc.local
alias git_reset_all='git reset --hard HEAD'
alias find_large_files='find . -type f -size +10000k -exec ls -lh {} \;'
alias push_github="gp"
alias db_up="up"
alias bashrc="vim ~/.bashrc.local"
alias up="rake db:migrate db:test:prepare"
alias down="rake db:rollback"
alias cucumber='bundle exec cucumber'
alias bottle="git add . && git stash"
alias poop="git stash pop"
class Users::RegistrationsController < Devise::RegistrationsController
layout :choose_layout
expose(:selected_plan) { Plan.find_by_slug(params[:plan]) }
after_filter :after_registration, :only => [:create]
def choose_layout
if params[:action] == 'edit' or params[:action] =='update' or params[:action] =='change_password'
'users/default'
export PATH=${PATH}:/Applications/adt-bundle-mac/sdk/tools
export PATH=${PATH}:/Applications/adt-bundle-mac/sdk/platform-tools
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then source "$HOME/.rvm/scripts/rvm" ; fi
[[ -r $rvm_path/scripts/completion ]] && source $rvm_path/scripts/completion
#opexport PS1="\u:~$ "
vim() {
(unset GEM_PATH GEM_HOME; command vim "$@")
}
@mzaragoza
mzaragoza / prepare-commit-msg
Last active August 29, 2015 14:05
Prepare Commit Message Hook Script
#!/usr/bin/php
<?php
# Git Prepare Commit Message Hook Script
#
# Location: <repository>/.git/hooks/prepare-commit-msg
#
# This script will automatically add the correct
# Pivotal Ticket ID to the beginning of each commit message
# When the branch ID is starts with the Pivotal Message ID.
require 'uri'
enc_uri = URI.escape("http://example.com/?a=\111\\115"")
p enc_uri
# => "http://example.com/?a=%09%0D"
p URI.unescape(enc_uri)
# => "http://example.com/?a=\t\r"
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "You have successfully registered, please log in!"
uEgvHsY8YQDukiNnho1xMzJrjSiDXAhWRFwRunhmLfPIHQGayk