Skip to content

Instantly share code, notes, and snippets.

@borisisok
borisisok / coproc.sh
Last active April 9, 2018 13:07
TIL: bash subshell processing of data from stdin
#!/usr/bin/bash
PID_MAIN=$$
# notify subshell on ctrl-c
trap "kill 0" SIGINT
# spawn processing subshell via coproc
coproc WORK { while IFS= read x; do echo " processed: $x" ; done }
PID_WORKER=$!
@borisisok
borisisok / coprocs.sh
Last active April 11, 2018 11:42
TIL: multiple bash coprocs with dynamic names
#!/usr/bin/bash
PID_MAIN=$$
# notify subshells on ctrl-c
trap "kill 0" SIGINT
function wrk() { while read data; do echo $1 _${data}_; done }
function shw() {
pid=$1
@borisisok
borisisok / aws-updown.sh
Last active December 17, 2021 07:52
LAB: VPN with BGP
#!/bin/bash
# debug: print all vars and function
env
set
# debug: print all commands during execution
set -x
TUNNEL_NAME="${PLUTO_CONNECTION}"
@borisisok
borisisok / googletron.py
Last active July 26, 2018 09:12
Google Translate and TTS fun
import random
import sys
from googletrans import Translator
import feedparser
import hashlib
from gtts import gTTS
from time import sleep
@borisisok
borisisok / create_ssh_chroot_jail.sh
Last active September 19, 2018 06:29
LAB: create a chroot jail for ssh logins on Centos 7 using the sshd AuthorizedKeysCommand
#!/bin/bash
set -x
jailusr=$1
pfix=jail
jaildir=/home/${pfix}_${jailusr}
devdir=${jaildir}/dev
bindir=${jaildir}/bin
@borisisok
borisisok / sshbuf_playground.c
Created November 1, 2018 16:43
Anatomy of sshbuf.c
/* sshbuf_playground.c
*
* All sshbuf code from openssh-portable for learning how sshbuf
* is used for storing ssh cert information during before signing it.
*
* Original Copyright Notice:
*
* Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2008 Alexander von Gernler. All rights reserved.
* Copyright (c) 2010,2011 Damien Miller. All rights reserved.
@borisisok
borisisok / nanoKONTROL.control.js
Created December 10, 2018 01:14
bitwig / custom controller scripts
loadAPI(7);
host.defineController("Korg", "nanoKONTROL", "1.22", "E74ABCE1-7BA8-4526-A769-25A7E1F8212F");
host.defineMidiPorts(1, 1);
var ECHO_ID = "12";
host.addDeviceNameBasedDiscoveryPair(["nanoKONTROL"], ["nanoKONTROL"]);
var SYSEX_HEADER = "F0 42 40 00 01 04 00";
var CC =
@borisisok
borisisok / mirabox_rec_ffmpgeg.sh
Last active April 6, 2022 19:36
Mirabox - Record via ffmpeg
# The Linux version
VDEV=$(v4l2-ctl --list-devices | grep -A1 -i mirabo | grep /dev | sed 's/\s//g')
ADEV=$(grep "Capture.*Mira" /proc/asound/cards | cut -f2 -d" ")
TS=$(date +%Y%m%d_%H%M%S)
nohup ffmpeg -f alsa -ac 2 -i hw:${ADEV=},0 -f video4linux2 -i ${VDEV} -acodec ac3 -ab 128k -f matroska -movflags frag_keyframe -s 1920x1080 -vcodec libx264 -preset ultrafast -qp 16 ${TS}.mkv &
sleep 5;
vlc ${TS}.mkv
killall ffmpeg
echo ${TS}.mkv
@borisisok
borisisok / bash_lib_video.sh
Last active June 1, 2022 19:22
Bash functions for movie processing
function ffmpeg_c112 { # create content for acer c112 pico beamer
m=$(dirname "$1")
n=$(basename "$1" | sed 's/mp4$//')
dir=/run/media/bgom/FCA7-F289/avi.c112
ffmpeg -i "${m}/${n}mp4" -c:v libx264 -profile:v baseline -c:a libmp3lame -b:a 128k -vf scale=720:406 -r 30 -pix_fmt yuv420p -ar 44100 "${dir}/${n}avi"
}
@borisisok
borisisok / mockbuild.sh
Last active June 17, 2020 14:58
Rebuild varnish-6.2.0 Centos7 rpm packages with the help of mock.
yum -y install mock
adduser mockbuild
usermod -a -G mock mockbuild
su - mockbuild
mock -r epel-7-x86_64 --init
wget https://packagecloud.io/varnishcache/varnish62/el/7/SRPMS/varnish-6.2.0-1.el7.src.rpm
# rebuild without modification
mock -r epel-7-x86_64 --target=x86_64 \