Instantly share code, notes, and snippets.

View postgresql_cheat_sheet.sh
pg_restore -h 127.0.0.1 -p 5432 -U horse -d horse -v late
View compression_original.sh
[[ -f "$1" ]] && \
NAME="$1" && \
sname=$(awk -F_original '{print $1}' <<< $NAME) && \
extname=$(cut -d"." -f2 <<< $NAME) && \
convert $NAME \
-sampling-factor 4:2:0 \
-strip \
-quality 85 \
-interlace JPEG \
-colorspace sRGB \
View docker.md

example to create docker image in tar file

tar \
    --numeric-owner \
    --exclude=/boot \
    --exclude=/dev \
    --exclude=/pack \
    --exclude=/proc \
    --exclude=/sys \
View generator_svg_with_rect_and_text.awk
# GNU Awk 4.2.1, API: 2.0
#
# before run - set variable values, after
# awk -f generator_svg_with_rect_and_text.awk > document.svg
#
# after you can convert svg to png with inkscape
# inkscape --export-png=document.png document.svg
function print_start( page_width, page_height, unit_size) {
printf "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"
View screen_record.sh
#!/bin/bash
# how to use
#
# |----------------------- $1 - filename; can be _
# | |------------------ $2 - window coordinate x
# | | |---------------- $3 - window coordinate y
# | | | |------------ $4 - width
# | | | | |------- $5 - height
# | | | | | |--- $6 - display number
View ldd.short.sh
ldd "$1" | awk '/=>/{sub(/\.so\.[0-9]{0,}$/, "", $1); print $1}'
View get_font_params.sh
fc-scan --format "{\"family\":\"%{family}\",\"fontformat\":\"%{fontformat}\",\"postscriptname\":\"%{postscriptname}\"}"
# fc-scan --format "{\"family\": \"%{family}\" , \"postscriptname\": \"%{postscriptname}\"}" ~/.fonts/7288.ttf | jq .
#
# {
# "family": "Lazurski",
# "postscriptname": "LazurskiBoldCyrillic"
# }
View update_package.json.sh
# jq - jq-1.5
# awk - GNU Awk 4.2.1, API: 2.0
jq .dependencies,.devDependencies package.json | awk '/^\s/{gsub(/("|:)/, "", $0); command="npm info " $1 " version"; command | getline version; close(command); print " \"" $1 "\": \"" version "\","}'
View bash.sh
date -d "$(date +%Y/%m/%d)-10 day" +%Y/%m/%d # => 2018/07/11
date -d "$(date +%Y/%m/%d)-0 day" +%Y/%m/%d # => 2018/07/21