Skip to content

Instantly share code, notes, and snippets.

View newmetl's full-sized avatar

Adalbert Gorecki newmetl

View GitHub Profile
@newmetl
newmetl / setup_digitalocean_rails.md
Last active May 10, 2019 06:04
Setup a Droplet on Digital Ocean for Rails with Nginx, Passenger and Postgresql

Setup new Server

This setup guide was created with the following components:

  • DigitalOcean Droplet (Ubuntu 16.04.4 x64)
  • Postgresql 9.5
  • Nginx + Passenger
  • Rails 5.2
  • Ruby 2.4.1
createuser -R -S -L -D -I newusername;
psql -d postgres
postgres=# alter role newusername LOGIN;
postgres=# alter role newusername CREATEDB;
postgres=# alter role newusername SUPERUSER; # if needed
Apart from select statements you can use the following commands on psql prompt:
\d [NAME] describe table, index, sequence, or view
\d{t|i|s|v|S} [PATTERN] (add "+" for more detail)
list tables/indexes/sequences/views/system tables
\da [PATTERN] list aggregate functions
\db [PATTERN] list tablespaces (add "+" for more detail)
\dc [PATTERN] list conversions
\dC list casts
\dd [PATTERN] show comment for object
@newmetl
newmetl / gist:1111699
Created July 28, 2011 15:00
Show human readable RAM usage
ps -eo size,pid,user,command | awk '{ hr=$1/1024 ; printf("%13.6f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | sort