short && sweet

  • MySQL to Postgres Cheat Sheet

    Nav­i­gat­ing the psql util­i­ty for peo­ple know­ing the mysql utility: mysql com­mandDescrip­tionpsql command SHOW DATABASESList all DBs\l USE <db>Switch to DB\c <db> SHOW TABLESList Tables in DB\dt SHOW INDEX FROM <table>List index­es of a Table\di <table> EXPLAIN TABLE <table>Show table schema\d <table> Dump & Restore

    # Dump the database to a file
    pg_dump -U <user> <database> >  dump.sql
    # Restore from dump
    psql -U <user> <database> < dump.sql
    
    ...

  • Make a WEBM as a Gif alternative

    Require­ment: ffm­peg must be com­piled with the --enable-libvpx-flag! ...

  • Make high-quality gif

    Start­ing from a Source file, extract only the Video and cut it down:

    ffmpeg -ss <start> -i <video-file> -t <length> -map 0:v -c copy cut.mp4
    
    ...

  • PostgreSQL UTF-8 Database

    Cre­at­ing a UTF‑8 encod­ed Data­base requires at a min­i­mum the encod­ing. Locale and col­late can be spec­i­fied as well, which will influ­ence case-insen­si­tive search­ing and sort­ing behavior:

    # Minimum 
    CREATE DATABASE "<db>" WITH OWNER '<user>' ENCODING 'UTF8';
    # Explicit
    CREATE DATABASE "<db>" WITH OWNER '<user>' ENCODING 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';
    
    ...

  • Change Audio Sample-Rate

    Some Video Edit­ing soft­ware, such as Sony Vegas and Adobe After­ef­fects have prob­lems sync­ing Audio/​Video if the Audio sam­ple rate isn’t 48kHz. The fol­low­ing com­mand re-encodes all Audio chan­nels in the input file to AAC and sets their sam­ple-rate to 48kHz:

    # Re-Encode and Re-Sample Audio
    ffmpeg -i <file> -map 0 -c:v copy -c:a aac -ar 48000 <out>.mp4
    
    ...

  • Dropping streams from a file

    To remove streams (video, audio, sub­ti­tles, etz) from a file, cre­ate a new file and spec­i­fy the appro­pri­ate map­ping of streams:

    # Keep all Video streams, only take Audio Stream 1 and 2
    ffmpeg -i <file> -map v -map a:1 -map a:2 -c copy <out>
    
    ...

  • Changing container format

    To change only the con­tain­er for­mat (for exam­ple from mkv to mp4) map all streams, set copy for all codecs and spec­i­fy an out­put file with the desired con­tain­er for­mats file-ending.

    # Only changes container format!
    ffmpeg -i <file>.mkv -map 0 -c copy <out>.mp4
    
    ...

  • Cut up Video

    To cut a video-file down to a sec­tion in the file, use the fol­low­ing command:

    # Absolute times (see note below!)
    ffmpeg -ss 00:02:05 -i <file> -map 0 -c copy -to 00:23:01 <out>.mkv
    
    # Relative times
    ffmpeg -ss 00:02:05 -i <file> -map 0 -c copy -t 00:21:54 <out>.mkv
    
    ...

  • Java libraries in WEB-INF/lib get corrupted

    When putting .jar-libraries into the WEB-INF/lib direc­to­ry of an App Engine project, the file get’s cor­rupt­ed (wrong size) and can’t be opened by the serv­er (throw­ing ZipException: error in opening zip file) after compiling. ...

  • Initial ZSH setup on a new machine

    Install the zsh-pack­age via packagemanager Install Oh-My-Zsh via the pro­vid­ed install-script Install a patched sym­bol-font for more inter­est­ing ZSH themes Pre-patched fonts are avial­able in the patching-strategy branch of awesome-terminal-fonts Down­load a font and it’s cor­re­spond­ing .sh-file from the patched/-fold­er of the repo Install the font in the sys­tem (usu­al­ly just by dou­ble-click­ing it) Copy the script to ~/.fonts Add this to the ~/.zshrc file: source ~/.fonts/*.sh to get named font-mappings Set the ter­mi­nal emu­la­tor to use the new­ly installed font! Install the Powerlevel9k theme Clone the repo to ~/.oh-my-zsh/custom/themes/powerlevel9k Set the theme in the prfile (~/.zshr) via: ZSH_THEME="powerlevel9k/powerlevel9k" Con­fig­ure the theme to use the patched fonts by adding POWERLEVEL9K_MODE='awesome-patched' to the profile Con­fig­ure the theme in the profile Change the ter­mi­nal col­or-scheme. For gnome-ter­mi­nal, see Gogh ...