Skip to content

Instantly share code, notes, and snippets.

@vi
vi / split_by_silence_kf.sh
Last active Sep 17, 2020
Video-enhanced split_by_silence.sh script.
View split_by_silence_kf.sh
#!/bin/bash
IN=$1
OUT=$2
true ${SD_PARAMS:="-55dB:d=0.3"};
true ${MIN_FRAGMENT_DURATION:="20"};
export MIN_FRAGMENT_DURATION
if [ -z "$OUT" ]; then
@vi
vi / split_by_silence.sh
Last active Sep 16, 2020
Using FFmpeg to split multimedia file into parts based on audio volume level
View split_by_silence.sh
#!/bin/bash
IN=$1
OUT=$2
true ${SD_PARAMS:="-55dB:d=0.3"};
true ${MIN_FRAGMENT_DURATION:="20"};
export MIN_FRAGMENT_DURATION
if [ -z "$OUT" ]; then
@vi
vi / cgroup_memory_pressure_monitor.c
Created Jul 19, 2015
Simple command-line tool use cgroup's memory.pressure_level
View cgroup_memory_pressure_monitor.c
#include <sys/eventfd.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
// Implemented by Vitaly "_Vi" Shukela in 2015, License=MIT.
@vi
vi / simplevpn
Last active Aug 9, 2020
simplevpn: Simple IPsec and ipip[6] tunnel configuration for Linux using SSH for key exchange
View simplevpn
#!/bin/bash
# Setup encrypted IPv4 tunnel over IPv4 or IPv6 on two Linux nodes using SSH for tunnel setup.
# Requires only ipsec-tools, iproute2, ssh and necessry kernel modules locally and remotely.
# Warning: it flushes IPsec settings both locally and remotely.
# Don't use with other IPsec tunnnels.
# Sample usage:
# simplevpn -6 fc::1 fc::2 ssh -T root@fc::2
@vi
vi / rust_wine.md
Last active Jun 15, 2020
Using Rust in Wine as a sort of cross-compiler
View rust_wine.md

Cross-compiling Rust from Linux to Windows using Wine

🔴 Note: this article is obsolete. This cross-compilation direction may just work out of the box. 🔴

0. Ensure Rust works on Host

Let's create a dummy project for a test.

$ cargo new test
@vi
vi / reedsolomon.c
Created Sep 16, 2012
Simple command-line Reed-Solomon encoding and decoding tool
View reedsolomon.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ecc.h"
/* Reed-solomon command-line tool by Vitaly "_Vi" Shukela; 2012 */
/*
Usage:
1. Download http://sourceforge.net/projects/rscode/
@vi
vi / README
Created Sep 5, 2012
Create tun/tap device that just copies all packets to/from the given ethernet interface.
View README
Primary use case: workaround non-working "ip link set wlan0 netns ..." for some network drivers.
Secondary use case: simple demo for getting/setting the MAC address, tun/tap, raw sockets...
Pre-built version: http://vi-server.org/pub/tap_copy
@vi
vi / hacky_streamer
Created Sep 5, 2011
Ad-hoc HTTP video streamer from webcam using socat and ffmpeg
View hacky_streamer
#!/bin/sh
schedtool -R -p 2 -e /usr/bin/socat tcp-l:5555,fork,reuseaddr system:'printf "HTTP/1.0\\\\x20200\\\\x20OK\\\\r\\\\nContent-Type\:\\\\x20video/x-matroska\\\\r\\\\n\\\\r\\\\n" && ffmpeg -f video4linux2 -ss 2 -i /dev/video0 -ss 2 -f oss -ac 1 -i /dev/dsp -s 320x240 -vcodec libx264 -vpre ultrafast -b 300k -ar 22050 -acodec libmp3lame -ab 32k -f matroska pipe\:1 < /dev/null'
@vi
vi / tcpclose.crs
Created Aug 2, 2018
Rust Tokio fast TCP socket close handling
View tcpclose.crs
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [dependencies]
//! tokio = "=0.1.7"
//! tokio-codec = "*"
//! tokio-io = "=0.1.7"
//! futures-cpupool = "*"
//! mio = "*"
//!
//! [replace]
@vi
vi / png2yuva
Created Sep 13, 2019
Convert RGBA pictures to bigger grayscale picure showing colour planes and back using FFMpeg
View png2yuva
#!/bin/bash
S=$(identify "$1" | cut -d' ' -f 3-3)
IFS=x SS=($S)
W=${SS[0]}
H=${SS[1]}
ffmpeg -v warning -i "$1" -pix_fmt yuva444p -f rawvideo - | ffmpeg -v warning -pix_fmt gray -s ${W}x$((H*4)) -f rawvideo -i - -y "$2"
You can’t perform that action at this time.