Improve everyday.

pg_dump-restore.md

|

Using pg_dump and pg_restore to save and reload a PostgreSQL database

Test settings:

  • origin DB: PostgreSQL 9.5.5, saving rcwd took ~5-10 min for an output file of 1.6G
  • destination DB: PostgreSQL 9.4.8, restoring rcwd took ~5-10 min for an output file of 1.6G

Saving the database

pg_dump -F tar -f $SAVE_FILE $DB_NAME
  • $SAVE_FILE file to store the output
  • $DB_NAME db to save
  • -F tar to save in a tar file

Restoring the database

pg_restore $SAVE_FILE -d $DB_NAME --clean
  • $SAVE_FILE file to store the output (file format is inferred from the extension
  • --clean erases the database $DB_NAME before restoring the data (fresh start)
  • pg_dump http://docs.postgresql.fr/9.2/app-pgdump.html
  • pg_restore http://docs.postgresql.fr/8.1/app-pgrestore.html

mplayer_speed_stable_pitch.md

|

Keeping stable pitch when accelerating a video with mplayer

Just use :

mplayer -af scaletempo $file_name

copy_paste.md

|

How to copy paste using tmux buffers

  • switch to research mode in a pane : ctr + A + [
  • hit space to enter the vim-like visual mode and use vim commands to select what you want
  • hit enter to keep selected content into the buffer, it will quit the research mode
  • Go where you want into your tmux session, and press ctrl + A + ]

vimdiff.md

|

Vimdiff for newbies

vimdiff source1 source2

dp diffput: puts changes under the cursor in the other file
do diffget: (o => obtain) replace the change under the cursor by the content of the other file

[c jump to the previous diff
]c jump to the next diff

mysql-time-queries.md

|

Timing queries with MySQL

mysql> SET profiling = 1;

mysql> SELECT batch.rank, celebrity.name from batch, celebrity WHERE batch.celebrity_id = celebrity.id;
...

mysql> SELECT batch.rank, celebrity.name from batch INNER JOIN celebrity ON batch.celebrity_id = celebrity.id;
...

mysql> SHOW PROFILES;
+----------+------------+--------------------------------------------------------------------------------------------------------+
| Query_ID | Duration   | Query                                                                                                  |
+----------+------------+--------------------------------------------------------------------------------------------------------+
|        1 | 0.30346450 | SELECT batch.rank, celebrity.name from batch, celebrity WHERE batch.celebrity_id = celebrity.id        |
|        2 | 0.17916075 | SELECT batch.rank, celebrity.name from batch INNER JOIN celebrity ON batch.celebrity_id = celebrity.id |
+----------+------------+--------------------------------------------------------------------------------------------------------+
2 rows in set, 1 warning (0.00 sec)

mysql> SET profiling = 0;