Skip to content

Instantly share code, notes, and snippets.

@vi
vi / Makefile
Last active August 29, 2015 13:56
I2P daily graph extraction framework
#wget 'http://127.0.0.1:7657/viewstat.jsp?stat=tunnel.participatingTunnels&showEvents=false&period=60000&periodCount=1500&end=1744&width=2400&height=600' -O 2014-03-01.png
INITIAL_DAY=2014-01-28
WIDTH=1200
HEIGHT=600
ADDR=http://127.0.0.1:7657
DATE_NOW=$(date -u +'%Y-%m-%d')
@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 / 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"
@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

@vi
vi / genetic_regex.pl
Created November 24, 2014 11:42
Generate regular expressions using genetic algorithm.
#!/usr/bin/perl -w
use strict;
$|=1;
if ($#ARGV != 3) {
print STDERR "Usage: genetic_regex.pl file_with_passing_lines file_with_failing_lines {file_with_hints|''} {file_with_bans|''} \n";
print STDERR "Created by Vitaly '_Vi' Shukela, in 2014. License is LGPLv2+.\n";
exit 1;
R! 16.0403 l=4 PPCG
R! 15.0236 l=2 ^P
R! 14.0646 l=6 ^[P^]P
R! 13.0919 l=9 [^?][PG]$
R! 12.1617 l=16 (?<!\\..)(?!]).$
R! 8.19108 l=19 ^[\w^]*$|!|]P|G]\$$
R! 8.17125 l=17 !|[^?]P(CG|G..)?$
R! 5.25195 l=25 !|((G.|P|\.)\$|[^?]P|CG)$
R! 4.2402 l=24 ^[(!P]|G..$|]..\||[^?]P$
R! 3.29278 l=29 ^.{3,23}[.-~]..\$$|[^P?][PG]$