Skip to content

Instantly share code, notes, and snippets.

@vi
vi / Cargo.toml
Last active June 19, 2023 20:03
Rust async executor abuse to avoid both blocking and threads
[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 / hacky_streamer
Created September 5, 2011 07:00
Ad-hoc HTTP video streamer from webcam using socat and ffmpeg
#!/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.
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 / simplevpn
Last active February 15, 2023 12:20
simplevpn: Simple IPsec and ipip[6] tunnel configuration for Linux using SSH for key exchange
#!/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 / setup_ipv6_hacky_router.sh
Created March 19, 2014 01:09
A script to set up IPv6 router advertisment proxy for single peer
#!/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 / split_by_silence_kf.sh
Last active December 5, 2022 14:40
Video-enhanced split_by_silence.sh script.
#!/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 / rust_wine.md
Last active November 28, 2022 22:21
Using Rust in Wine as a sort of cross-compiler

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 / get_github_stars.sh
Last active October 28, 2022 09:38
Hacky workaround to track new stars of your repositoes (previously displayed on Github home page)
#!/bin/bash
set -e
TOKEN=...
USERNAME=...
D=$(mktemp -d)
cd "$D"
P=1
@vi
vi / no_new_privs.c
Created July 25, 2015 22:16
Do prctl(PR_SET_NO_NEW_PRIVS) and exec
// Pre-built static i386 version: http://vi-server.org/pub/no_new_privs
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sys/prctl.h>
int main(int argc, char* argv[])
{
if (argc == 1 || !strcmp(argv[1], "--help")) {

Keybase proof

I hereby claim:

  • I am vi on github.
  • I am vi0oss (https://keybase.io/vi0oss) on keybase.
  • I have a public key whose fingerprint is 5CF2 87F9 4EE8 ECD6 B68A B0AC 0FF5 8BF9 3D7B 965F

To claim this, I am signing this object: