Skip to content

Instantly share code, notes, and snippets.

View ivankra's full-sized avatar

Ivan Krasilnikov ivankra

View GitHub Profile
@ivankra
ivankra / tail.cc
Last active August 21, 2025 17:29
Tiny tail-calling interpreter demo
// Tiny tail-calling interpreter demo
// https://godbolt.org/z/TPozdErM5
//
// As seen in
// * Protobuf:
// https://blog.reverberate.org/2021/04/21/musttail-efficient-interpreters.html
// * LuaJIT remake (Deegen):
// https://sillycross.github.io/2022/11/22/2022-11-22/
// * CPython 3.14:
// https://lwn.net/Articles/1010905/
@ivankra
ivankra / anki.Dockerfile
Last active August 31, 2023 01:44
Anki in a docker container with fcitx5
# Anki docker container with fcitx5 IME support.
#
# Anki version in debian repos is too old, besides it could really benefit
# from containerization when using third party addons.
#
# Prereqs:
# * docker or better yet podman
# * x11docker
# * `apt-get install nxagent xclip` for some features
# * `echo software >~/.local/share/Anki2/gldriver6` maybe to fix some rendering issues
@ivankra
ivankra / .python-grpc-bazel-example
Last active June 11, 2025 16:53
Minimal example of a python grpc server built with bazel.
$ bazel build ...
$ bazel run :greeter_server
Listening on :50051
$ bazel run :greeter_client
Greeter client received: Hello, you!
@ivankra
ivankra / tfrecord.py
Last active August 27, 2019 00:49
Minimal tfrecords reader/writer in pure python
# Minimal tfrecords reader/writer in pure python.
# Use either a fast compiled crc32c implementation from `pip install crc32c`:
#from crc32c import crc32 as crc32c
# Or alternatively a slower pure python crc32c implementation: {{{
CRC32C_TABLE = (
0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, 0xC79A971F, 0x35F1141C,
0x26A1E7E8, 0xD4CA64EB, 0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B,
0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24, 0x105EC76F, 0xE235446C,
@ivankra
ivankra / gist:1028443
Created June 16, 2011 00:17
ekobug.cc
#include <stdio.h>
#include <string.h>
namespace NStl {
template <class _Tp> struct __stlport_class {};
template <class _Tp, class _Allocator> struct _Alloc_traits {
typedef typename _Allocator::template rebind<_Tp> _Rebind_type;
typedef typename _Rebind_type::other allocator_type;
};
template <class _Tp> class allocator : public __stlport_class<allocator<_Tp> > {
@ivankra
ivankra / gist:1026446
Created June 15, 2011 04:00
Assertion failure at vho_lower.cxx:2183 in pathscale
namespace std { }
namespace __std_alias = std;
namespace NStl { }
namespace NStlPriv {
using namespace NStl;
}
namespace stlport = NStl;