Skip to content

Instantly share code, notes, and snippets.

// rendered: http://vi-server.org/pub/rustfeat.png
digraph G {
rankdir=TD;
node [shape=rect fontsize=16 margin=0.06 style=filled fillcolor="white"];
edge [fontsize=14 arrowsize=0.5 style=bold];
ranksep=0.17;
T [label="Thinking, discussions, etc" fillcolor="#fff8e8"]
T -> PR;
PR [label="optional pre-RFC\npost on internals.rust-lang.org" fillcolor="#fff8e8"];
@vi
vi / rustsafecrash.rs
Last active January 17, 2016 23:13
Crashing Safe Rust code with OS help
// This code demonstrates that with OS's external help
// one can crash even Safe Rust's code
// Implemented by Vitaly "_Vi" Shukela
use std::process::Command;
fn getpid() -> i32 {
let so = Command::new("sh")
.arg("-c")
@vi
vi / disque-call
Created January 14, 2016 23:31
Spawning processes / calling remote commands using Disque
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: disque-call queue-name < input > output" >&2
exit 1
fi
QN="$1";
set -e
@vi
vi / git
Created November 24, 2015 16:17
Hacky git wrapper to automatically supply --reference for `git clone` based on URL
#!/bin/bash
# git wrapper, to auto-supply --reference to `git clone`
# edit the table below to suit your setup
LOG=/tmp/git.log
echo git: "$@" >> "$LOG"
CLONE=0
@vi
vi / 0001-libbpg-Implement-noalpha-option-to-skip-PNG-s-alpha-.patch
Created September 3, 2015 16:56
Patch for libbpg's bpgenc v0.9.5 to add -noalpha option like in cwebp
From fd121ea3730530289422566bdae6e77a45402e34 Mon Sep 17 00:00:00 2001
From: Vitaly _Vi Shukela <vi0oss@gmail.com>
Date: Wed, 26 Aug 2015 02:22:50 +0300
Subject: [PATCH] libbpg: Implement -noalpha option to skip PNG's alpha channel
pngenc command line tool loves PNG.
Sometimes users need to convert the picture to png in order
to feed it to pngenc.
While converting to png, alpha channel may creep in.
This makes bpgenc to fail to work in x265 mode and also produce
@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 / 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")) {
@vi
vi / pseudohdr2
Created July 22, 2015 23:42
Make pseudo-HDR photo from a bunch of input JPEGs using GraphicsMagick, ImageMagick, pfsalign, enfuse and bash
#!/bin/bash
INS=("$@")
OUTNAME="${INS}_${INS[${#INS[@]}-1]}.png"
# 1. Sort images in order of increasing brightness
declare -a LEVS
for i in "${INS[@]}"; do
LEVS+=($(
@vi
vi / inhibitseekfail.c
Created July 22, 2015 22:28
Inhibit seek failures to force programs to continue when writing to pipes/sockets, LD_PRELOAD-based
#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <errno.h>
static int (*orig_llseek)(
unsigned int fd, unsigned long offset_high,
@vi
vi / selectfuzz.c
Created July 22, 2015 22:25
Intentionally cause select/poll spurious activations for testing, LD_PRELOAD-based
#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <dlfcn.h>
#include <sys/time.h>
#include <sys/select.h>
#include <time.h>
#include <sys/stat.h>