Skip to content

Instantly share code, notes, and snippets.

@rubycop
Created June 2, 2017 09:17
Show Gist options
  • Save rubycop/b6ad1f2ea76908f287030b685fc7236a to your computer and use it in GitHub Desktop.
Save rubycop/b6ad1f2ea76908f287030b685fc7236a to your computer and use it in GitHub Desktop.

Rails scaffolding

rails new [name] -d postgresql -T -B

html2haml convertion

convert all .erb files to .haml using gem 'html2haml' in your gemfile.

find . -name \*.erb -print | sed 'p;s/.erb$/.haml/' | xargs -n2 html2haml

After that - remove all unessesary erb files:

find . -name \*.erb -delete

GIT commands

cmd description
git config --global core.editor "subl -n -w" set sublime as a default git editor
git reset HEAD~1 undo 1 local commit
git reset --hard HEAD~1 undo 1 remote commit (DANGEROUS!!!)

MySQL commands

cmd description
mysql -u <username> -p -h <host> <db_name> < dump.sql restore db from dump file

PG commands

cmd description
pg_dump <db_name> > <file_name> make a dump (ex. pg_dump tddium > my_dump)
psql <db_name> connect to db
psql <db_name> < <file_name.sql> write dump file to db (ex. psql tddium < my_dump.sql)
sudo pg_lsclusters pg clusters info
sudo pg_ctlcluster 9.4 main start start pg 9.4
psql -U api -d tddium connect to tddium database as api
`\d{t i
\dT list data types
\i <file> read and execute queries from
\l list all databases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment