Skip to content

Instantly share code, notes, and snippets.

@vi
vi / interesting_crates.md
Last active May 23, 2023 09:34
List of crates that improves or experiments with Rust, but may be hard to find
View interesting_crates.md

Let's list here crates that enhance Rust as a language.

It not "batteries" like in stdx, but Rust-specific crates for workarounds for various missing features and experimental ideals from non-accepted/postponed RFCs, or just hacky tricks.

The list is supposed to contain (mostly) crates that are internal to Rust, not ones for making Rust deal with "external world" like other languages bindings, file formats, protocols and so on.

Primary focus should be on crates that are not easy to find by conventional means (e.g. no algorithm name, format or protocol to search for).

Note that quality of the listed crates may vary from proof-of-concept to stable-and-widely-used.

@vi
vi / hacky_streamer
Created September 5, 2011 07:00
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 / README
Created September 5, 2012 03:16
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 / split_by_silence.sh
Last active April 7, 2023 17:10
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 / simplevpn
Last active February 15, 2023 12:20
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 / Cargo.toml
Created December 18, 2022 20:14
Rust async executor abuse to avoid both blocking and threads (v2)
View Cargo.toml
[package]
name = "hackyws"
version = "0.1.1"
edition = "2021"
[dependencies]
anyhow = "1.0.66"
async-tungstenite = "0.18.0"
flume = "0.10.14"
@vi
vi / setup_ipv6_hacky_router.sh
Created March 19, 2014 01:09
A script to set up IPv6 router advertisment proxy for single peer
View setup_ipv6_hacky_router.sh
#!/bin/bash
set -e
if [ -z "$2" ]; then
echo "Script to set up router advertising proxy for one peer"
echo "Usage: setup_ipv6_hacky_router UPLINK DOWNLIK"
echo "Example: setup_ipv6_hacky_router eth0 wlan0"
exit 1
fi
@vi
vi / Cargo.toml
Last active December 18, 2022 20:41
Rust async executor abuse to avoid both blocking and threads
View Cargo.toml
[package]
name = "hackyws"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0.66"
async-executor = "1.5.0"
async-tungstenite = "0.18.0"
@vi
vi / vethify.c
Created October 19, 2013 15:58
Copy packets between two network network interfaces (for workarounds)
View vethify.c
/* vethify - multiplex packets between two ethernet interfaces
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@vi
vi / split_by_silence_kf.sh
Last active December 5, 2022 14:40
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