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
@kostja
kostja / test.py
Last active November 19, 2019 15:32
test.py
kostja@hulk ~ % ./test.py
^CShutdown requested
/usr/lib/python3.7/asyncio/unix_events.py:861: RuntimeWarning: A loop is being detached from a child watcher with pending handlers
RuntimeWarning)
/usr/lib/python3.7/asyncio/unix_events.py:137: RuntimeWarning: coroutine 'setup_signal_handlers.<locals>.shutdown' was never awaited
del self._signal_handlers[sig]
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Traceback (most recent call last):
File "./test.py", line 59, in <module>
asyncio.run(main())
package main
import (
"bytes"
"fmt"
"github.com/gocql/gocql"
"log"
"reflect"
)
#include <stdio.h>
#include <new>
template <typename T>
struct lw_shared_ptr {
char *_mem;
void destroy() {
@kostja
kostja / lightweight shared pointer
Created August 15, 2019 18:27
lightweight shared pointer
#include <stdio.h>
#include <new>
template <typename T>
struct lw_shared_ptr {
struct Mem {
int counter;
T value;
};
@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; \
};
@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,
};
int main()
{
int i = 0;
switch (i)
switch (i)
switch (i)
switch (i)
switch (i)
switch (i)
switch (i)
@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)
#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 / 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: