short && sweet

  • Docker Cheat Sheet

    Dock­er commands docker build -t <image-name> . builds an image from the Dockerfile locat­ed in the cur­rent direc­to­ry and names it after image-name docker run to cre­ate a con­tain­er form an image and run it. See incom­plete!, see para­me­ters below! -p <port-internal>:<port-external> map an EXPOSEd port to a local port, so you can com­mu­ni­cate with the ser­vice in the container -v <dir or volume>:<dir-in-container>:[rw|ro] mount a local direc­to­ry or vol­ume into the con­tain­er at the spec­i­fied path with either read/​write or read-only -it open an inter­ac­tive ter­mi­nal-ses­sion on the container. <image-name> to run the default com­mand of the image or <executable> <parameters-for-exec> spawns a new con­tain­er to run the exe­cutable in it, with the giv­en parameters. Exam­ple: docker run test/image ls lists the files of the default work-dir in the image. docker ps list all run­ning docker-containers -a show all con­tain­ers (includes stopped ones!) docker logs <container> to see the out­put of the giv­en container. -f to fol­low the output docker stop <container-name or id> stops the spec­i­fied container docker images lists all local images docker exec -it <container-name or id> <program> runs he spec­i­fied program on the cur­rent­ly run­ning container. bash as the program-para­me­ter starts an inter­ac­tive shell on the container docker kill <container-name or id> kills the spec­i­fied con­tain­er (stop is preferred!) docker rmi <image-name or id> delete a dock­er image docker rm <container-name or id> delete a dock­er container docker volume create --name="<name>" cre­ate a new named data-volume docker volume ls list all data-volumes docker volume rm <name or id> remove a data-volume ...

  • 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 
    # Explicit

  • 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

  • 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 ...