Skip to content

Instantly share code, notes, and snippets.

View JangoSteve's full-sized avatar

Steve Schwartz JangoSteve

View GitHub Profile
@JangoSteve
JangoSteve / to_haml.rb
Created November 14, 2011 06:14
Converting all ERb views to Haml, modified from http://snippets.dzone.com/posts/show/5449
require 'hpricot'
require 'ruby_parser'
class ToHaml
def initialize(path)
@path = path
end
def convert!
Dir["#{@path}/**/*.erb"].each do |file|
@JangoSteve
JangoSteve / ps1.custom.sh
Created November 16, 2011 02:10
Custom ps1 bash customization in ~/.bash_profile_includes/ps1.custom.sh
############################################
# Modified from emilis bash prompt script
# from https://github.com/emilis/emilis-config/blob/master/.bash_ps1
#
# Modified for Mac OS X by
@JangoSteve
JangoSteve / .gitignore
Created November 16, 2011 04:43
Global .gitignore in ~/.gitignore
Procfile.me
.sass-cache/
@JangoSteve
JangoSteve / cache.rake
Created November 17, 2011 03:32
Automatically cache pages in Rails, put this in /lib/tasks/cache.rake
# See rails source:
# https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/caching/pages.rb
#
# Turn on caching in development, by changing this line to true in config/environments/development.rb:
#
# config.action_controller.perform_caching = true
#
# Then run:
#
# bundle exec rake pages:cache
@JangoSteve
JangoSteve / commands.sh
Last active September 28, 2015 10:58
Cloning and filtering file to new repo
git clone --no-hardlinks orig_repo new_repo
cd new_repo
git filter-branch --subdirectory-filter directory/containing/desired/file --prune-empty HEAD
git reset --hard
rm -rf .git/refs/original/
git remote rm origin
git update-ref -d refs/original/refs/heads/master
git reflog expire --expire=now --all
git gc --aggressive --prune=now
git repack -ad
@JangoSteve
JangoSteve / .gitattributes
Created January 15, 2012 18:23
Example .gitattributes for jasmine-given
spec/ export-ignore
src/ export-ignore
.gitignore export-ignore
Gemfile export-ignore
Gemfile.lock export-ignore
Guardfile export-ignore
Rakefile export-ignore
@JangoSteve
JangoSteve / session_secret.rb
Created March 1, 2012 21:13
Generate session secret
require 'active_support/secure_random'
random_string = ActiveSupport::SecureRandom.hex(30)
puts random_string
@JangoSteve
JangoSteve / redmine_trunk_on_heroku.md
Created March 1, 2012 21:39
Importing Redmine to Git, Deploying to Heroku
@JangoSteve
JangoSteve / mysql_install.rb
Created March 31, 2012 18:21
Install mysql with capistrano on Ubuntu server
namespace :slicehost do
# The following will install mysql with default user/pw.
# Be sure to setup proper user/pw via mysql.
desc "Install MySQL"
task :install_mysql, :roles => :app do
apt_quiet_install('mysql-server libmysql-ruby')
#sudo "apt-get install mysql-server libmysql-ruby -y"
end
@JangoSteve
JangoSteve / gist:2294823
Created April 3, 2012 19:13 — forked from bruno-/gist:2294117
Capistrano mysql interactive installation
desc "Install the latest stable release of MySql."
task :install, roles: :db, only: {primary: true} do
#run "echo #{mysql_password}"
run "#{sudo} apt-get -y update"
run "#{sudo} apt-get -y install mysql-server" do |channel, stream, data|
# prompts for mysql root password (when blue screen appears)
channel.send_data("#{mysql_root_password}\n\r") if data =~ /password/
end
run "#{sudo} apt-get -y install mysql-client libmysqlclient-dev"
end