Skip to content

Instantly share code, notes, and snippets.

@vi
vi / csv2srt.rs
Created August 22, 2023 02:37
Converter from twitchchatdownloader to srt.
#!/usr/bin/env -S cargo +nightly -Zscript
//! Convert Twitch subtitles exported as CSV from https://www.twitchchatdownloader.com to srt format
//!
//! ```cargo
//! [package]
//! edition="2021"
//! [dependencies]
//! csv = "1"
@vi
vi / pbcopy_html.swift
Created June 24, 2023 23:32
Command line tool, like `xclip -in -t text/html` for Mac. For preparing content for Google Docs/Sheets.
#!/usr/bin/env swift
// Based on https://github.com/chbrown/macos-pasteboard/issues/8#issuecomment-906537204
import Cocoa
import Foundation
let pasteboard: NSPasteboard = .general
let dataTypeName : String = "public.html"
@vi
vi / Cargo.toml
Created December 18, 2022 20:14
Rust async executor abuse to avoid both blocking and threads (v2)
[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 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 / 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

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 1, 2024 22:12
List of crates that improves or experiments with Rust, but may be hard to find

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
#!/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
#!/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.
#!/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