Don't need a database for your Rails application or any extra object-relational mapping layer? :)
Then put this in your <RAILS_ROOT>/config/environment.rb file within the Rails::Initializer.run do |config| block:
config.frameworks -= [:active_record]
Tuesday, October 26, 2010
Saturday, September 25, 2010
Backup and Restore Postgres DB
pg_dump --create --format=t --file=mydb.tar mydb
pg_restore --clean --format=t --dbname=mydb mydb.tar
[2011-01-17]
Maybe a better idea is to use the plain SQL export format, as this gives you an option to edit the output file and e.g. to change the text format from LATIN1 to UTF8 later on. It is also easy to change the name of the database before recreating it! Last not least, the -d parameter uses insert instead of copy statements. This is much slower when recreating the database, but unlike with copy, this once worked successfully for me when changing the encoding at the same time.
pg_dump --create -d --format=p --file=mydb.sql mydb
#emacs mydb.sql
createdb -E UTF8 mydb
pg_restore -d mydb -f mydb.sql
pg_restore --clean --format=t --dbname=mydb mydb.tar
[2011-01-17]
Maybe a better idea is to use the plain SQL export format, as this gives you an option to edit the output file and e.g. to change the text format from LATIN1 to UTF8 later on. It is also easy to change the name of the database before recreating it! Last not least, the -d parameter uses insert instead of copy statements. This is much slower when recreating the database, but unlike with copy, this once worked successfully for me when changing the encoding at the same time.
pg_dump --create -d --format=p --file=mydb.sql mydb
#emacs mydb.sql
createdb -E UTF8 mydb
pg_restore -d mydb -f mydb.sql
Saturday, August 28, 2010
Change Terminal Dir to Current Finder Dir
From Switch Terminal dir to frontmost window of certain apps:
function ff { osascript -e 'tell application "Finder"'\
-e "if (${1-1} <= (count Finder windows)) then"\
-e "get POSIX path of (target of window ${1-1} as alias)"\
-e 'else' -e 'get POSIX path of (desktop as alias)'\
-e 'end if' -e 'end tell'; };\
function cdff { cd "`ff $@`"; };
Friday, August 20, 2010
Sunday, May 16, 2010
Ruby Hex Escaping
How to represent characters in regular expressions in hexadecimal format?
content.gsub!( /\xe2\x80\x99/ms, "'" )
Saturday, January 23, 2010
Git Work Cycle
[ 2011-01-09]
Create a new git project:
cd my_project
git init .
git add some_file.txt
git commit
Let's share the project with other local users (from Setting Up a Private Repository):
git clone --bare $PWD/.git /tmp/my_project.git
scp -r /tmp/my_project.git myserver.com:/opt/git/my_project.git
Somewhere else in the galaxy:
cd my_projects
git clone myserver.com:/opt/git/my_project.git
cd my_project
[2010-01-23]
Typical git work cycle (from: Git for the lazy):
git status
git diff
git add file1 file2
git commit
Synchronize new project version back with the git server:
git push origin master
[2011-01-13]
Later that day somewhere else:
git pull
Create a new git project:
cd my_project
git init .
git add some_file.txt
git commit
Let's share the project with other local users (from Setting Up a Private Repository):
git clone --bare $PWD/.git /tmp/my_project.git
scp -r /tmp/my_project.git myserver.com:/opt/git/my_project.git
Somewhere else in the galaxy:
cd my_projects
git clone myserver.com:/opt/git/my_project.git
cd my_project
[2010-01-23]
Typical git work cycle (from: Git for the lazy):
git status
git diff
git add file1 file2
git commit
Synchronize new project version back with the git server:
git push origin master
[2011-01-13]
Later that day somewhere else:
git pull
Subscribe to:
Posts (Atom)