Skip to content

Instantly share code, notes, and snippets.

View kostja's full-sized avatar
🐢
Working from home

Konstantin Osipov kostja

🐢
Working from home
View GitHub Profile
#include <stdio.h>
#include <unistd.h>
#include <sys/inotify.h>
int main(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stderr, "Usage: %s path\n", argv[0]);
return -1;
}
@kostja
kostja / output
Created February 8, 2015 18:26
pthread_self() returns the same value across after fork()
kostja@atlas ~ % gcc -pthread foo.c; ./a.out
thread id: 140508398954304
thread id: 140508398954304
thread id: 140508398954304

Keybase proof

I hereby claim:

  • I am kostja on github.
  • I am kostja (https://keybase.io/kostja) on keybase.
  • I have a public key whose fingerprint is 8468 AA2E AC65 D92D 2698 7FC1 B32B 96A9 7AEA 33B5

To claim this, I am signing this object:

@kostja
kostja / lua-call
Created April 14, 2015 09:46
lua call conversion rules
tarantool> function foo() return end
---
...
tarantool> c:call('foo')
---
- []
...
tarantool> function foo() return nil end
@kostja
kostja / ansible-sucks
Last active October 15, 2020 11:03
Ansible vs. GNU Make
instances := $(basename $(wildcard *.lua))
hosts := n4 n6 n11 n12 n16 n17 n18 n19 n20
all:
echo "nothing"
start: clean
$(foreach i, $(instances), tarantoolctl $@ $i;)
stop:
#ifndef TARANTOOL_IPC_H_INCLUDED
#define TARANTOOL_IPC_H_INCLUDED
/*
* Copyright 2010-2015, Tarantool AUTHORS, please see AUTHORS file.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* 1. Redistributions of source code must retain the above
@kostja
kostja / tnt_parse
Created November 4, 2015 13:08
tnt_parse
#!/usr/bin/env python
import io
import json
import msgpack
import crcmod
crc32 = crcmod.mkCrcFun('4812730177', 0)
int main()
{
int i = 0;
switch (i)
switch (i)
switch (i)
switch (i)
switch (i)
switch (i)
switch (i)
@kostja
kostja / foo.c
Created August 17, 2017 13:55
malloc of large objects
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
enum {
ALLOC_STREAK_MAX = 1024,
ALLOC_MIN = 1024 * 1024,
ALLOC_MAX = 1024 * 1024 * 128,
ITERATIONS = 1024,
};
@kostja
kostja / memtx_tree.cc
Created February 26, 2019 16:09
Template for memtx tree
struct index {};
struct index_vtab {
void (*build_index)(struct index *);
};
#define bps_declaration \
struct bps_tree { \
bps_tree_node node; \
};