Skip to content

Instantly share code, notes, and snippets.

@ungoldman
Created February 21, 2014 08:52
Show Gist options
  • Save ungoldman/9130887 to your computer and use it in GitHub Desktop.
Save ungoldman/9130887 to your computer and use it in GitHub Desktop.
Rad tricks from a past life

rad tricks

MySQL

Raddest db since like forever (not)

just dump it

$ mysqldump -u [user] -p [database_name] > [path/to/file].sql

dump table to CSV

$ mysql -u [user] -p [database] -B -e "select * from \`[table]\`;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > [path/to/file].csv
$ mysql -u [user] -p [database] -B -e "select * from \`[table]\` where \`[column]\` = \"[value]\";" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > [path/to/file].csv

import a dump into a db

$ mysql -u [user] -p [database_name] < [path/to/file].sql

scp

copy from remote to local

$ scp (-P [port]) [user]@[hostname]:[/path/to/remote/file] [/path/to/local/dir]

chown

pwn permissions. -R is for recursive.

change owner and group identifier

$ chown -R [user]:[group] [file OR dir]

change permish on a thing

$ chmod -R -xxx path/to/file

-xxx represents permissions, 777 is read/write/execute for all. don't do that.

Apache

restart apache .. gracefully

$ sudo apache2ctl graceful

test syntax before a restart

$ sudo apache2ctl configtest

where the vhosts live sometimes

you@nostromo $ cd /etc/apache2/sites-available

Bundler

Get path of bundled gem

$ bundle show [gem]

Open bundled gem in the best text editor

$ subl `bundle show [gem]`

or even just

$ bundle open [gem]

SSH

Super Secret H.. something

$ ssh [user]@[domain]

SSH into a server with a specific port

$ ssh [user]@[domain] -p [port]

Extreme Boxen manipulation

check memory usage

$ cat /proc/meminfo

also top and ^M can be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment