Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
set -eo pipefail
declare -A graph
declare -a distances
function min {
if [[ $1 -lt $2 ]]; then
printf "%s" "$1"
@kodo-pp
kodo-pp / diamond-square.cpp
Created July 15, 2019 16:12
Diamond-square algorithm. NEVER USE THIS CODE IN PRODUCTION, PLEASE. IT IS AWFUL
// Diamond-square algorithm
// MIT License
//
// Copyright (c) 2019 Alexander Korzun
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~/tmp/libelfin/libelfin $ ls
dwarf elf examples LICENSE Makefile README.md test
~/tmp/libelfin/libelfin $ make -j4
make -C elf
make[1]: Entering directory '/home/kodopp/tmp/libelfin/libelfin/elf'
g++ -g -O2 -Werror -std=c++0x -Wall -fPIC -c -o elf.o elf.cc
g++ -g -O2 -Werror -std=c++0x -Wall -fPIC -c -o mmap_loader.o mmap_loader.cc
ln -s libelf++.so.0 libelf++.so
python3 enum-print.py -u --hex --no-type --mask shf --mask pf \
~/tmp $ pacman -Qi libelfin-git # OK, Package not installed
error: package 'libelfin-git' was not found
~/tmp $ pkg-config --libs --cflags libelf++ # OK, Package not installed, so libelf++.pc does not exist yet
Package libelf++ was not found in the pkg-config search path.
Perhaps you should add the directory containing `libelf++.pc'
to the PKG_CONFIG_PATH environment variable
Package 'libelf++', required by 'virtual:world', not found
~/tmp $ # Install libelfin-git package (quite a large piece of terminal transcript; notice makepkg WARNING on line 100 and sed command on line 90)
~/tmp $ git clone https://aur.archlinux.org/libelfin-git
Cloning into 'libelfin-git'...
@kodo-pp
kodo-pp / example.py
Last active May 25, 2019 00:01
A simple bottom-up "parser". I may use this script in my future projects. Licensed under CC0 (Public Domain)
from silly_parser import *
adv = Terminal('ADV')
v = Terminal('V')
adj = Terminal('ADJ')
n = Terminal('N')
vp = adv.many().optional() + v
np = adj.many().optional() + n
@kodo-pp
kodo-pp / bracefilter.py
Created May 9, 2019 19:16
Pretty-print multiple levels of nested braces
#!/usr/bin/env python3
import sys
linechar = '\x1b[92m|\x1b[0m' if sys.stdout.isatty() else '|'
def indent(nest):
sys.stdout.write('{} '.format(linechar) * nest)
@kodo-pp
kodo-pp / demo.ipynb
Created April 25, 2019 19:30
Possible bug in the standard lexer
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kodo-pp
kodo-pp / .vimrc
Last active March 1, 2019 18:21
My .vimrc
inoremap <C-W> <Esc>:w<CR>a
inoremap <F7> <Esc>:w<CR>a
nmap <F2> :!
imap <F2> <Esc>:!
imap <C-F><F9> <F2>CC_TOOLCHAIN=clang DEBUG=yes ./run.sh -f<CR>
nmap <C-F><F9> <F2>CC_TOOLCHAIN=clang DEBUG=yes ./run.sh -f<CR>
imap <C-F><F10> <F2>FORCE_REBUILD=yes CC_TOOLCHAIN=clang DEBUG=yes ./run.sh -f<CR>
nmap <C-F><F10> <F2>FORCE_REBUILD=yes CC_TOOLCHAIN=clang DEBUG=yes ./run.sh -f<CR>
set number
@kodo-pp
kodo-pp / treap.cpp
Last active February 2, 2019 16:00
Treap
#include <bits/stdc++.h>
// Легально скопипащено с https://github.com/kodo-pp/vsosh-region-preparation/
using namespace std;
default_random_engine gen;
uniform_real_distribution<double> dist(0.0, 1.0);
void init_rng()
$ coredumpctl dump -o tilix.coredump tilix
PID: 11306 (tilix)
UID: 1000 (kodopp)
GID: 1000 (kodopp)
Signal: 6 (ABRT)
Timestamp: Fri 2019-01-25 22:50:51 MSK (1min 29s ago)
Command Line: tilix
Executable: /usr/bin/tilix
Control Group: /user.slice/user-1000.slice/session-2.scope
Unit: session-2.scope