Skip to content

Instantly share code, notes, and snippets.

@versusvoid
versusvoid / prepare-russian-malt.sh
Last active January 8, 2019 11:06
Download, extract and set up all things necessary to parse russian with malt and Serge Sharoff model (corpus.leeds.ac.uk/mocky/)
#!/bin/bash
PREFIX=$(readlink -m $(dirname $0))
if [[ ! $(command -v wget) && ! $(command -v curl) ]]; then
echo "You need either 'wget' or 'curl' programm to download necessary files"
exit 1
fi
if [[ ! $(command -v perl) ]]; then
echo "You'll need some perl. Consider installing it."
@versusvoid
versusvoid / PhysInstancedStaticMeshComponent.cpp
Created April 17, 2015 10:28
InstancedStaticMeshComponent with physics support
#include "Test1.h"
#include "PhysInstancedStaticMeshComponent.h"
#include "PhysXIncludes.h"
#include "PhysicsPublic.h"
#include "Private/PhysicsEngine/PhysXSupport.h"
UPhysInstancedStaticMeshComponent::UPhysInstancedStaticMeshComponent(const FObjectInitializer& initializer)
: Super(initializer)
{
@versusvoid
versusvoid / main.c
Created August 13, 2015 11:45
AVR morse hello world
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <stdint.h>
// First four bits encode morse code - 1 is dash and 0 is dot
// then goes length of code
char message[] = {
0x04, // .... - H
0x01, // . - E
@versusvoid
versusvoid / overlapping-area.py
Last active January 5, 2022 23:58
Illustrated implementation of algorithm computing total area of overlapping circles
#!/usr/bin/env python3
'''
Original idea by red Ants Aasma at
http://stackoverflow.com/a/1667789/2122529
'''
import numpy as np
import numpy.random as rnd
import itertools
import matplotlib.pyplot as plt
@versusvoid
versusvoid / voronoi.py
Created November 3, 2017 15:29
Implementation and visualization of Fortune's algorithm for generating a Voronoi diagram
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from collections import namedtuple
import heapq
fig, ax = plt.subplots()
fig.tight_layout()
ax.set_axis_off()
@versusvoid
versusvoid / radix.py
Last active January 14, 2019 17:59
python "compressed" radix tree (in plain arrays)
def radix_tree_push_last_subtree_down(tree, level, segment_index):
prev_word_old_segment, prev_word_old_next_child_pos = tree[level][-1]
assert segment_index < len(prev_word_old_segment)
prev_word_new_segment_prefix = prev_word_old_segment[:segment_index]
prev_word_new_segment_suffix = prev_word_old_segment[segment_index:]
tree[level][-1] = (prev_word_new_segment_prefix, prev_word_old_next_child_pos)
old_next_level = tree[level + 1][prev_word_old_next_child_pos:]
tree[level + 1] = tree[level + 1][:prev_word_old_next_child_pos]
@versusvoid
versusvoid / CA.cnf
Last active October 2, 2019 11:56
Generate CA and certificate with subjectAltName for HTTPS
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
C = RU
ST = Москва
L = Москва
O = Секурные разработки
@versusvoid
versusvoid / build.sh
Last active April 16, 2019 19:07
WebAssebly misaligned load test
clang -cc1 -emit-llvm-bc -triple=wasm32-unknown-unknown-wasm -std=c11 test.c
llc -filetype=obj test.bc -o test.o
wasm-ld --no-entry test.o -o test.wasm --export=aligned --export=misaligned --import-memory
wasm2wat test.wasm
@versusvoid
versusvoid / integrals.sage
Last active November 7, 2019 10:08
SageMath expression "linearization". Incomplete, inaccurate, but works to the first order :-)
# vi: ft=python
from sage.symbolic.operators import add_vararg, mul_vararg
from sage.symbolic.integration.integral import definite_integral, indefinite_integral
w0, w1, w2, w3 = map(SR.wild, range(4))
definite_integral_pattern = integrate(w0, w1, w2, w3)
indefinite_integral_pattern = integrate(w0, w1)
@versusvoid
versusvoid / 61-microsoft-4000.hwdb
Last active October 24, 2021 04:14
Scroll with Microsoft Natural® zoom slider
# installed in /etc/udev/hwdb.d/
# after installing run
# $ sudo udevadm hwdb --update
# $ sudo udevadm control --reload
# Microsoft Natural Ergonomic Keyboard 4000
evdev:input:b0003v045Ep00DB*
KEYBOARD_KEY_c022d=scrollup # zoomin
KEYBOARD_KEY_c022e=scrolldown # zoomout