Skip to content

Instantly share code, notes, and snippets.

sagax sagax

  • Russia
View GitHub Profile
@sagax
sagax / generator.sh
Created Jan 20, 2019
generator of file as json with array of words
View generator.sh
# one command line
export LINE=200000 LWORD=31 FNAME="dict.json" && printf "[" > "$FNAME" && cat /dev/random | tr -dc 'a-zA-Z' | fold -w $LWORD | head -n $LINE | sed 's/^/"/; s/$/",/' >> "$FNAME" && sed -i '$s/",/"]/' "$FNAME"
#
export \
LINE=200000 \
LWORD=31 \
FNAME="dict.json" && \
printf "[" > "$FNAME" && \
cat /dev/random | tr -dc 'a-zA-Z' | fold -w $LWORD | head -n $LINE | sed 's/^/"/; s/$/",/' >> "$FNAME" && \
@sagax
sagax / fishrc_ps1_with_git.fish
Last active Jan 17, 2019
fishrc ps1 with git
View fishrc_ps1_with_git.fish
set -gx TERM "xterm-256color"
set -gx EDITOR "vim"
set c_off "\e[0m"
set c_bold_on "\e[1m"
set c_light_on "\e[2m"
set c_underscore "\e[4m"
set c_blink_on "\e[5m"
set c_reverse "\e[7m"
set c_concealed_on "\e[8m"
@sagax
sagax / bashrc_ps1_with_git.sh
Last active Jan 17, 2019
bashrc ps1 with git
View bashrc_ps1_with_git.sh
export TERM="xterm-256color"
export EDITOR="vim"
# source link:
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
#
# download link:
# https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
PATHTOGITPROMPT="$HOME/git-prompt.sh"
[[ -s "$PATHTOGITPROMPT" ]] && source "$PATHTOGITPROMPT"
View postgresql_cheat_sheet.sh
pg_restore -h 127.0.0.1 -p 5432 -U horse -d horse -v late
@sagax
sagax / compression_original.sh
Created Oct 28, 2018
compression original image with convert
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 \
@sagax
sagax / docker.md
Last active Oct 14, 2018
docker cheatsheet
View docker.md

example to create docker image in tar file

tar \
    --numeric-owner \
    --exclude=/boot \
    --exclude=/dev \
    --exclude=/pack \
    --exclude=/proc \
    --exclude=/sys \
@sagax
sagax / generator_svg_with_rect_and_text.awk
Created Oct 5, 2018
awk script to generation svg document with text inside rect
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\"?>"
@sagax
sagax / screen_record.sh
Last active Oct 10, 2018
record screen with ffmpeg
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
@sagax
sagax / ldd.short.sh
Created Sep 26, 2018
get ldd list in short format
View ldd.short.sh
ldd "$1" | awk '/=>/{sub(/\.so\.[0-9]{0,}$/, "", $1); print $1}'
You can’t perform that action at this time.