Skip to content

Instantly share code, notes, and snippets.

@randyjhunt
randyjhunt / gist:43144
Created January 4, 2009 18:04
exporting and importing MySQL databases
# Export database from MySQL:
sudo mysqldump -u database_username database_name > path_to_file_to_export_to.sql
@randyjhunt
randyjhunt / gist:43184
Created January 4, 2009 21:49
Remove and ignore .DS_Store files in git repository
# Ignore .DS_Store files from a git repository
# Find and remove existing files from the repository:
find . -name .DS_Store -print0 | xargs -0 git-rm
# Add the line ".DS_Store" to the file .gitignore, which can be found at the top level of your repository (or created if it isn't there already)
git add .gitignore
git commit -m ".DS_Store banished!"
# http://stackoverflow.com/questions/107701/how-can-i-remove-dsstore-files-from-a-git-repository
# Find what port an application is running on.
# Especially useful at Webfaction
ps -ef | grep APPNAME
# Use TextMate as default text editor
export EDITOR="/usr/bin/mate -w"
# Capistrano deployment scripts
# the deployment script will go to default environment (usually "dev"), others like "staging" can be targeted by using "cap staging deploy", etc.
# update the server with the latest revision in the repository
cap deploy
# run rake db:migrate on the server
cap deploy:migrate
# updates the server with the latest project in the repository and then runs rake db:migrate
# run Selenium tests on a whole app
./script/server -e test
# followed by
rake test:acceptance
# This is in lieu of running
./script/server -e test
# then browsing to
# common Rake commands
# run migrations
rake db:migrate
# copy the database
rake db:test:clone_structure
# display all application routes
rake routes
@randyjhunt
randyjhunt / gist:43326
Created January 5, 2009 08:09
Apache permanent redirect
# configure RedirectPermanent in Apache vhost
# step 1: new virtual hosts for each domain
# step 2: RedirectPermanent in each new vhost file
RedirectPermanent / http://mysite.org
# put the RedirectPermanent inside a vhost for each mysite.com and mysite.net
# RedirectPermanent is part of mod_alias
# this was done so multiple domain extensions would all change to the same extension
1 - In textmate, open the bundle editor> Edit Languages
2 - pick Rails: HTML(rails) from the left hand thing
3 - Then change
fileTypes = ( 'rhtml' );
to
fileTypes = ( 'rhtml', 'html.erb' );
randy-j-hunts-macbook-air-2:design-ignites-change randyjhunt$ rake gems:install
(in /Users/randyjhunt/code/rails/design-ignites-change)
gem install mislav-will_paginate --version "~> 2.2.3" --source http://gems.github.com
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/randyjhunt/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
Successfully installed mislav-will_paginate-2.2.3