Skip to content

Instantly share code, notes, and snippets.

@eush77
eush77 / letter-counting-ru.el
Created December 22, 2019 22:43
Exploration of the letter-counting function for Russian language
;; Exploration of the letter-counting function for Russian language.
;; Inspired by Matt Parker's https://youtu.be/LYKn0yUTIU4
(defvar t-prims
'((1 . "один")
(2 . "два")
(3 . "три")
(4 . "четыре")
(5 . "пять")
(6 . "шесть")
@eush77
eush77 / main.c
Created November 8, 2018 09:30
Repetition macros for C preprocessor. Inspired by https://stackoverflow.com/a/53110569
#include "rep.cpp"
#include <stdio.h>
int main(void) {
unsigned num = 0;
// Repeat the block 1011_2 = 11 times.
REP4(1, 0, 1, 1, {
printf("%u\n", num++);
})
@eush77
eush77 / Cello_Eval.c
Created October 8, 2017 17:47
Toy interpreter using libCello https://github.com/orangeduck/Cello
#include <Cello.h>
/*
* `Eval' is a type class that describes a node that can be evaluated.
*/
struct Eval {
var (*eval)(var);
};
@eush77
eush77 / input.qbe
Created September 24, 2017 19:03
Example of a QBE pass
function w $add(w %a, w %b) { # Define a function add
@start
%c =w add %a, %b # Adds the 2 arguments
ret %c # Return the result
}
function w $sum(w %n) {
@entry
%s =w add 0, 0
@eush77
eush77 / pdfdecol.sh
Created June 8, 2017 19:28
Decolumnize PDFs for ebook readers
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: t; tab-width: 4; -*-
set -euo pipefail
IFS=$'\n'
function help {
cat <<-EOF
Usage: $0 <input.pdf> <output-file-or-directory>
@eush77
eush77 / etsplit.py
Created June 7, 2017 12:17
Execution time splitter for flame graphs
#!/usr/bin/env python3
"""
Execution time splitter for flame graphs.
The script takes a flame graph SVG [1] and splits the samples by execution
time: a sample can be either compile time, or a run time. Useful for profiling
VMs employing JIT compilation.
Currently, functions with names starting with "llvm::" are compile time,
@eush77
eush77 / nbsp-ru.sed
Created June 1, 2017 14:08
Simple non-breaking space fixer for Russian language
#!/bin/sed -rf
#
# Simple non-breaking space fixer for Russian language.
#
# Usage: nbsp-ru FILE_IN > FILE_OUT
#
s:\b(без|безо|в|во|для|до|за|из|из-за|из-под|изо|к|ко|на|над|о|об|от|ото|по|под|подо|при|про|ради|с|со|у) :\1 :gI
-[:*_:_*:]-
@eush77
eush77 / quine.bf
Created May 21, 2017 12:13
Quine in Befunge-98
<@,+1!',k9"
@eush77
eush77 / quine.mk
Last active May 15, 2017 10:22
Quine in GNU Make
Q=$(info Q=$(value Q))$(info $$(call Q))
$(call Q)