Skip to content

Instantly share code, notes, and snippets.

@alexshpilkin
alexshpilkin / objects.tcl
Created January 15, 2012 23:25
Proposed object system for Jim Tcl
# ---------------------------------------------------------------------------
# Models - A flexible object system for Jim
# ---------------------------------------------------------------------------
# XXX Observation after writing all the code below: [ref]erences are _not_
# used to store things. They are only used to invoke finalizers.
# ---------------------------------------------------------------------------
# Stubs
# ---------------------------------------------------------------------------
@alexshpilkin
alexshpilkin / download.py
Created February 1, 2012 19:28
Turkish elections
#!/usr/bin/env python3
# ---------------------------------------------------------------------------
# download.py - Download Turkish election data
#
# Written by Alexander Shpilkin <ashpilkin@gmail.com>, Feb 2012
#
# To the extent possible under law, the author has dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
#
@alexshpilkin
alexshpilkin / .XCompose
Created February 11, 2012 21:28 — forked from astanin/.XCompose
My Compose key configuration
include "/usr/share/X11/locale/en_US.UTF-8/Compose"
# Punctuation
# знаки препинания, необходимые в русском, которых нет в en_US.UTF-8/Compose
<Multi_key> <period> <minus> : "…" U2026 # HORIZONTAL ELLIPSIS, многоточие
<Multi_key> <period> <space> : "…" U2026 # HORIZONTAL ELLIPSIS, многоточие
<Multi_key> <?> <!> : "⁈" U2048 # QUESTION EXCLAMATION, ?!
<Multi_key> <period> <colon> : "…" # ELLIPSIS
# №: набирается в русской раскладке без ухищрений,
@alexshpilkin
alexshpilkin / cikrf.py
Created February 28, 2012 20:40
Russian elections
#!/usr/bin/env python3
import sys
import time
from bs4 import BeautifulSoup
import urllib3
pool = urllib3.PoolManager(10)
# 2008 ROOT_URL = 'http://www.vybory.izbirkom.ru/region/region/izbirkom?action=show&root=1&tvd=100100022249920&vrn=100100022176412&region=0&global=1&sub_region=0&prver=0&pronetvd=null&vibid=100100022249920&type=227'
@alexshpilkin
alexshpilkin / kernel.ld
Created August 9, 2013 18:43
Linking a higher half kernel
ENTRY(start)
OUTPUT_FORMAT(elf64-x86-64)
LD_FEATURE("SANE_EXPR")
SECTIONS
{
. = 0x0100000;
_init = .;
.header : {
@alexshpilkin
alexshpilkin / polymorph.c
Last active March 15, 2016 14:27
Polymorphism in C++ and plain C
#include <stdio.h>
#include <stdlib.h>
struct A {
struct Atable *vptr;
};
struct Atable {
int (*answerp)(struct A *this);
};

Keybase proof

I hereby claim:

  • I am alex-shpilkin on github.
  • I am alexshpilkin (https://keybase.io/alexshpilkin) on keybase.
  • I have a public key ASAbZo8Qp8U-zCBRPlyofF38flV9f0EAAp_LQXFMwtwrgwo

To claim this, I am signing this object:

@alexshpilkin
alexshpilkin / beta.1
Last active September 14, 2018 20:37
Sample binomial distributions
.TH BETA 1 2018 "Alexander Shpilkin"
.SH NAME
beta \- sample binomial distributions
.SH SYNOPSIS
\fBbeta \fIcount
.SH DESCRIPTION
Given a population size \fIN\fR and a sample \fIn\fR from a binomial
distribution with parameters (\fIN\fR, \fIp\fR), \fIbeta\fR computes
\fIcount\fR more samples from it, assuming a uniform Bayesian prior for the
unknown parameter \fIp\fR.
@alexshpilkin
alexshpilkin / 8086.fth
Last active January 2, 2018 21:00
Postfix 8086 assembler in Forth
oct
( register / memory )
: reg/mem? ( m -- ? ) 70 and 0 = ;
: ?reg/mem ( m -- m )
dup 70 and 0 <> ?abort" reg/mem? " ;
: ?memory ( m -- m )
dup 70 and 0 <> over 300 and 300 = ?abort" memory? " ;
@alexshpilkin
alexshpilkin / mplalign.py
Last active March 21, 2018 20:08
Align vertical labels in subplots
#!/usr/bin/env python
import matplotlib.pyplot as plt
import random
import matplotlib.gridspec as gridspec
random.seed(20)
data1 = [random.random() for i in range(10)]
data2 = [random.random()*1000 for i in range(10)]