Instantly share code, notes, and snippets.

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
View gen_test_data.coffee
fs = require 'fs'
random = (min, max) ->
rand = Math.floor( min + Math.random() * ( max + 1 - min ))
rand
arrDataSize = parseInt process.env['ITEM']
arrData = []
[0...arrDataSize].forEach (item) ->
arrData.push attr: random(1, 20)
View youtubeplaylistdownload.sh
#!/bin/bash
# how to use
# youtubeplaylistdownload.sh link_to_playlist format_to_download
# example
# youtubeplaylistdownload.sh PL5zohYERz9XAYqBu0HQJ_tudt2R6gbPtb 171
#
for url in $(curl -s -X GET https://www.youtube.com/playlist?list="$1" | awk '/data-video-id=/{match($0, /data-video-id="([^"]*)/, arr); print("https://www.youtube.com/watch?v="arr[1]);}'); do
youtube-dl -f "$2" $url
done
View remor_cabal_packages.sh
for item in $(cabal list --installed --simple-output | awk '{print $1}');do ghc-pkg unregister $item; done