Skip to content

Instantly share code, notes, and snippets.

@vi
vi / bupsplitfixup
Created April 8, 2014 11:00
bup: Script to convert a result of pre-"bup-split-to-vfs-file" `bup split` into a FUSE-accessible "data" file.
#!/bin/bash
FROM="$1"
TO="$2"
if [[ -z "$FROM" || -z "$TO" ]]; then
echo "bupslitfixup - convert \"bup split\"-generated content into a form suitable for \"bup fuse.\""
echo "Note: \"bup-split-to-vfs-file\" patch makes \"bup split\" to save content in such form automatically."
echo "Usage: bupsplitfixup treeish_to_be_fixed branch_name_to_create"
echo "Example: bup split -n qqq < something.dat; bupsplitfixup qqq qqq_fixed"
echo "Note: Existing ref with branch_name_to_create is overwritten"
@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 / dct.hs
Last active December 5, 2015 18:27
Simple command-line Discrete Cosine Transform in Haskell
-- "cabal install vector-fftw split"
import qualified Numeric.FFT.Vector.Unnormalized as FFT
import Data.Vector (fromList, toList)
import Data.List.Split (splitOneOf)
import Data.List (intersperse)
import Control.Monad (forever)
import Control.Arrow ((>>>))
main = forever $
@vi
vi / wilson.pl
Last active August 29, 2015 14:01
Simple Perl script for playing with formula from http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
#!/usr/bin/perl -wln
# Calculate lower and upper bounds of Wilson confidence interval based on upvotes and downvotes
# Based on SQL expression from http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
# Confidence parameter is hardcoded at 95%
# Each input line is two numbers: number_of_upvotes <whitespace> number_of_downvotes
# Each output line is two numbers: minimal_estimated_ratio_of_upvoters <space> maximal_estimated_ratio_of_upvoters
@vi
vi / pseudohdr.sh
Created June 9, 2014 13:20
ImageMagick-based pseudo-HDR merger script
#!/bin/bash
# Photos must be perfectly aligned
# Warning: slow
# Created by amateur, don't expect much.
k=0
D=pseudohdr_data
@vi
vi / simple_debianize
Created June 29, 2014 23:07
Simple one-step crude debianizator for my sole-executable-file Github projects
#!/bin/bash
if [ -z "$3" ]; then
echo "Usage: simple_debianize name initial_version executable_name"
exit 1
fi
set -e
NAME="$1"
#!/bin/bash
if [[ -z "$1" || "$1" == "--help" ]]; then
echo "Ouput content of the file being appended to to stdout, continue outputting as more data appears in the file, exit when no processes write to the file for a while."
echo "Usage: cat_and_follow file | something"
exit 1
fi
F="$1"
@vi
vi / gist:cc46cf95cd5b44f7964b
Last active August 29, 2015 14:04
Gdb backtrace of crashing Enki
This file has been truncated, but you can view the full file.
Thread 29 (Thread 0xe533db40 (LWP 24751)):
#0 0xf7e666b1 in poll () at ../sysdeps/unix/syscall-template.S:81
No locals.
#1 0xf71d413b in g_poll (fds=0xf1308090, nfds=2, timeout=-1) at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gpoll.c:132
No locals.
#2 0xf71c59f0 in g_main_context_poll (n_fds=2, fds=0xf1308090, timeout=<optimized out>, context=0xf13062f8, priority=<optimized out>) at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:3440
poll_func = <optimized out>
#3 g_main_context_iterate (context=context@entry=0xf13062f8, block=block@entry=1, dispatch=dispatch@entry=1, self=<error reading variable: Unhandled dwarf expression opcode 0xfa>) at /build/buildd-glib2.0_2.33.12+really2.32.4-5-i386-eISom6/glib2.0-2.33.12+really2.32.4/./glib/gmain.c:3141
max_priority = 2147483647
@vi
vi / gist:8c6ac53821fd74def0e0
Created September 30, 2014 23:00
Attempting to use a Haskell package in Nix
# su -l nix
nix@vi-notebook:~$ nix-shell -p haskellPackages.ftphs --option use-binary-caches false
\[\][nix-shell:~]$\[\] ghci -v
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help
Glasgow Haskell Compiler, Version 7.8.3, stage 2 booted by GHC version 7.4.2
Using binary package database: /nix/store/d3mchqnyysryxdyzfcgm24dn5kki6bx8-ghc-7.8.3/lib/ghc-7.8.3/package.conf.d/package.cache
Using package config file: /home/nix/.nix-profile/bin/../lib/ghc-7.8.3/package.conf.d/aeson-0.8.0.0.installedconf
Using package config file: /home/nix/.nix-profile/bin/../lib/ghc-7.8.3/package.conf.d/aeson-pretty-0.7.1.installedconf
Using package config file: /home/nix/.nix-profile/bin/../lib/ghc-7.8.3/package.conf.d/asn1-encoding-0.8.1.3.installedconf
@vi
vi / 0000-README.md
Last active August 29, 2015 14:10
rRootage red-blue recolouring patch

Intro

Playing STG requires to consider two objects: projectiles and player. This patch changes colours of objects in rRootage: player is red, projectiles are blue. This way, using anaglyph glasses, each eye sees only one of two requires thigs, which adds a bit of difficulty.

Inspired by idea of Lazy Eye Tetris.

Usage