Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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)
View get_github_stars.sh
#!/bin/bash
set -e
TOKEN=...
USERNAME=...
D=$(mktemp -d)
cd "$D"
P=1
View keybase.md

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:

@vi
vi / interesting_crates.md
Last active March 19, 2023 22:09
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 / png2yuva
Created September 13, 2019 20:39
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"
@vi
vi / mvimg_mpv
Created August 11, 2019 22:37
Shell script to play Google Motion Photos with mpv from command line
View mvimg_mpv
#!/bin/bash
if [[ -z "$1" || "$1" == --help || "$1" == "-?" ]]; then
echo "Usage: mvimg_play MVIMG_20190806_183324.jpg [other files]"
echo "Plays Google's Motion Photo using mpv. Depends on exiftool, mktemp, bash and mpv."
exit 0
fi
FOUND=0
ARGS=()
@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
@vi
vi / dnsmanageweb.rs
Last active April 18, 2019 23:15
Simple web portal to update dynamic DNS records
View dnsmanageweb.rs
#!/usr/bin/env run-cargo-script
//! ```cargo
//! [package]
//! name = "dnsmanageweb"
//! version = "0.1.0"
//! authors = ["Vitaly _Vi Shukela <vi0oss@gmail.com>"]
//! edition = "2018"
//!
//! [dependencies]
//! rouille = {version="3.0.0", default-features=false}
@vi
vi / hyper_hack.rs
Created March 24, 2019 22:22
Dump of hacky experimentation with Hyper. Not suggesting to write code like this
View hyper_hack.rs
// Trying to imiate `rust-websocket`-like interface with hyper 0.12
#![allow(unused)]
#![deny(unused_must_use)]
use tokio::prelude::*;
use tokio::net::tcp::{TcpListener,TcpStream};
use std::net::SocketAddr;
use hyper::server::conn;
use hyper::service::Service;