short && sweet
-
Docker Cheat Sheet
Docker commands
docker build -t <image-name> .
builds an image from theDockerfile
located in the current directory and names it afterimage-name
docker run
to create a container form an image and run it. See incomplete!, see parameters below!-p <port-internal>:<port-external>
map anEXPOSE
d port to a local port, so you can communicate with the service in the container-v <dir or volume>:<dir-in-container>:[rw|ro]
mount a local directory or volume into the container at the specified path with either read/write or read-only-it
open an interactive terminal-session on the container.<image-name>
to run the default command of the image or<executable> <parameters-for-exec>
spawns a new container to run the executable in it, with the given parameters. Example:docker run test/image ls
lists the files of the default work-dir in the image.docker ps
list all running docker-containers-a
show all containers (includes stopped ones!)docker logs <container>
to see the output of the given container.-f
to follow the outputdocker stop <container-name or id>
stops the specified containerdocker images
lists all local imagesdocker exec -it <container-name or id> <program>
runs he specifiedprogram
on the currently running container.bash
as theprogram
-parameter starts an interactive shell on the containerdocker kill <container-name or id>
kills the specified container (stop is preferred!)docker rmi <image-name or id>
delete a docker imagedocker rm <container-name or id>
delete a docker containerdocker volume create --name="<name>"
create a new named data-volumedocker volume ls
list all data-volumesdocker volume rm <name or id>
remove a data-volume ... -
MySQL to Postgres Cheat Sheet
Navigating the
psql
utility for people knowing themysql
utility:mysql
commandDescriptionpsql
commandSHOW DATABASES
List all DBs\l
USE <db>
Switch to DB\c <db>
SHOW TABLES
List Tables in DB\dt
SHOW INDEX FROM <table>
List indexes 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
Requirement: ffmpeg must be compiled with the
--enable-libvpx
-flag! ... -
Make high-quality gif
Starting 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
Creating a UTF‑8 encoded Database requires at a minimum the encoding. Locale and collate can be specified as well, which will influence case-insensitive searching and sorting 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 Editing software, such as Sony Vegas and Adobe Aftereffects have problems syncing Audio/Video if the Audio sample rate isn’t 48kHz. The following command re-encodes all Audio channels in the input file to AAC and sets their sample-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, subtitles, etz) from a file, create a new file and specify the appropriate mapping 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 container format (for example from
mkv
tomp4
) map all streams, setcopy
for all codecs and specify an output file with the desired container formats 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 section in the file, use the following 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
-package via packagemanager Install Oh-My-Zsh via the provided install-script Install a patched symbol-font for more interesting ZSH themes Pre-patched fonts are avialable in thepatching-strategy
branch of awesome-terminal-fonts Download a font and it’s corresponding.sh
-file from thepatched/
-folder of the repo Install the font in the system (usually just by double-clicking it) Copy the script to~/.fonts
Add this to the~/.zshrc
file:source ~/.fonts/*.sh
to get named font-mappings Set the terminal emulator to use the newly 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"
Configure the theme to use the patched fonts by addingPOWERLEVEL9K_MODE='awesome-patched'
to the profile Configure the theme in the profile Change the terminal color-scheme. For gnome-terminal, see Gogh ...