Skip to content

Instantly share code, notes, and snippets.

@vi
vi / rondo.pl
Last active December 16, 2015 14:20
Output music from Perl
#!/usr/bin/perl
# Output monophonic Mozart - Rondo Alla Turca to stdout
# Implemented by Vitaly "_Vi" Shukela
# Usage: ./rondo.pl | aplay -f cd
# Used mozk331c.mid as reference
our $vq = 0.2;
71 3
69 3
68 3
69 3
72 12
74 3
72 3
71 3
72 3
76 12
@vi
vi / bug_58691.sh
Last active December 17, 2015 16:39
Script to reproduce bug 58691 in linux kernel
#!/bin/bash
# Reproduce https://bugzilla.kernel.org/show_bug.cgi?id=58691
# Depends: sshd listening :22, ssh, unshare, setkey(ipsec-tools), iproute2, ip6_tunnel.ko, veth, radvd
modprobe ip6_tunnel
export MYPID=$$
rm /tmp/unshare_pid
@vi
vi / udprelay.c
Created June 25, 2013 21:29
UDP relay - for implementing other programs working with UDP
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#ifndef WIN32
#include <netdb.h>
#include <sys/socket.h>
@vi
vi / simplecow.rs
Last active December 19, 2015 18:49
Sluggish attempt to test how Rust binds to C code
/* automatically generated by rust-bindgen */
// sources: https://raw.github.com/vi/forsnapshotfs/master/simplecow.h https://raw.github.com/vi/forsnapshotfs/master/simplecow.c
use std::libc::*;
//pub type backing_read_t = *u8;
pub type Struct_simplecow = c_void;
#[link_args = "-lsimplecow"]
@vi
vi / log.txt
Last active December 24, 2015 08:39
Failed attempt to upload a file into a release
$ curl -v -H 'Authorization: token <skipped>' -H "Accept: application/vnd.github.manifold-preview" -H "Content-Type: application/zip" --data-binary @virtual_touchscreen.jar "https://uploads.github.com/repos/vi/virtual_touchscreen/releases/54927/assets?name=virtual_touchscreen.jar"
* About to connect() to uploads.github.com port 443 (#0)
* Trying 192.30.252.97...
* connected
* Connected to uploads.github.com (192.30.252.97) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
@vi
vi / traitinherit.rs
Last active January 3, 2016 07:39
Attempt to play with trait ingeritence in Rust
trait Drawable { fn draw(&self); }
trait VeryDrawable : Drawable + Clone { fn draw_twice(&self) { self.draw(); self.draw(); } }
#[deriving(Eq, Clone)]
enum Circle { Circle }
#[deriving(Eq, Clone)]
struct Rectangle;
impl Drawable for Circle { fn draw(&self) { println("C"); } }
impl Drawable for Rectangle { fn draw(&self) { println("R"); } }
@vi
vi / md.py
Created April 10, 2014 15:43
Dump MIDI events using python-midi
# supply two command line arguments
import midi.sequencer.sequencer_alsa as S
import midi.sequencer
import sys
import select
sr = midi.sequencer.SequencerRead()
sr.subscribe_port(sys.argv[1],sys.argv[2])
p = select.poll()
@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 / 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")