Skip to content

Instantly share code, notes, and snippets.

<!doctype html>
<!--
XMPP SVG logo clean up
klg, May 2014
-->
<html>
<meta charset="UTF-8">
<title>XMPP logo</title>
<body>
<p>This is an
@mwgamera
mwgamera / ybt.pl
Last active December 25, 2015 09:10
#!/usr/bin/env perl
# Convert Torrent files between Bencode and YAML
# klg, May 2014
use strict;
use open ':std', IO => ':bytes';
use Digest::SHA 'sha1_hex';
use Bencode qw/bencode bdecode/;
use YAML;
my $data = do { local $/; <> };
#!/usr/bin/env perl
# Generate typical image for Paeth predictor
# Same idea as in <http://tmblr.co/ZBKCGy18m4n57>
# klg, May 2014
use strict;
use Compress::Zlib;
use Graphics::ColorObject qw/RGB_to_Lab Lab_to_RGB RGB_to_RGB255/;
use Math::Vec ':terse';
use constant PNG_SIG => "\x89PNG\r\n\x1A\n";
; Quick hack to print 16 bytes from /dev/urandom with minimal overhead.
; nasm -f elf64 -o random.o random.asm && ld -s -o random random.o
; klg, Jun 2014
read equ 00h
write equ 01h
open equ 02h
exit equ 3Ch
LEN equ 16
sub lcp(@) {
use List::Util 'reduce';
our ($a, $b);
reduce {
($a ^ $b) =~ m/^\0*+/;
substr $a, 0, $+[0]
} @_
}
sub comp($) {
#!/usr/bin/env perl
# Check valitidy of a leap-seconds.list file.
# klg, Jan 2014
use strict;
use open ':std', IN => ':bytes';
use Digest::SHA 'sha1';
use Time::Local 'timegm';
use constant EPOCH => timegm 0, 0, 0, 1, 0, 1900;
(* Dijkstra's fusc function *)
let rec fusc x =
if x < 2 then x
else
let n = x / 2 in
if x mod 2 == 0
then fusc n
else fusc n + fusc (n + 1)
let iota n =
\version "2.18.0"
\header {
title = Warszawianka
composer = "Karol Kurpiński"
poet = "Casimir François Delavigne (przekład: Karol Sienkiewicz)"
}
\score {
{
#include <stdint.h>
#define LCG64(N, a, c) \
static uint64_t lcg_ ## N (uint64_t x) { \
x *= (a); x += (c); \
return x; \
}
LCG64(C1, 3935559000370003845, 2691343689449507681)
" Shavian keymap for vim
" klg, Aug 2014
let b:keymap_name = "·𐑖𐑱𐑝𐑾𐑯"
loadkeymap
q 𐑶 " oil
Q 𐑬 " out
w 𐑢 " woe