Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
# Compare prices for cloud storage providers:
# - S3 - AWS S3 from Amazon
# https://aws.amazon.com/s3/pricing/
# - GS/GCS - Google Cloud Storage
# https://cloud.google.com/storage/pricing#north-america
# - R2 - R2 from CloudFrame
# https://developers.cloudflare.com/r2/platform/pricing/
#include <pthread.h>
#include <dlfcn.h>
#include <stdlib.h>
// force jemalloc
void __attribute__((used)) force_jemalloc()
{
/// calloc() is used in older glibc in dlsym()
/// force this symbol from the jemalloc to trigger endless loop
(void)calloc(0, 0);
@azat
azat / test-dlsym.c
Created December 31, 2022 22:35
different behavior of dlsym since glibc 2.36
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
int main()
{
void *p = dlsym(RTLD_NEXT, "__pthread_mutex_lock");
printf("__pthread_mutex_lock: %p (via RTLD_NEXT)\n", p);
return 0;
}
@azat
azat / test-asan.cpp
Created December 31, 2022 22:34
ASan does not work with glibc 2.36+
#include <pthread.h>
int main()
{
// something broken in ASan in interceptor for __pthread_mutex_lock
// and only since glibc 2.36, and for pthread_mutex_lock everything is OK
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
return __pthread_mutex_lock(&mutex);
}
@azat
azat / kazoo-logging.patch
Created December 28, 2022 09:34
Endless wait in kazoo after AUTH_FAILED on stop
diff --git a/kazoo/client.py b/kazoo/client.py
index 27b7c38..0c0ecc0 100644
--- a/kazoo/client.py
+++ b/kazoo/client.py
@@ -400,6 +400,7 @@ class KazooClient(object):
def _reset(self):
"""Resets a variety of client states for a new connection."""
+ self.logger.log(BLATHER, "Reseting the client")
self._queue = deque()
/// Test for RWF_NOWAIT, does it always non-block?
/// The answer is, it may sometimes, for example when there is some issues with the underlying disk.
/// Or maybe when it accessing page entries, that are blocked for a long time, need to take a look deeper.
#define _GNU_SOURCE /// for preadv2()
#include <sys/uio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <stdio.h>
#include <cstdlib>
#include <memory>
struct NewDeleteOperators
{
NewDeleteOperators() = default;
static void* operator new(size_t size)
{
return ::malloc(size);
import publicsuffix2
import clickhouse_driver
ch = clickhouse_driver.Client(host='127.1')
pls = publicsuffix2.PublicSuffixList(idna=False)
def check_tld(tld):
print(tld)
host = 'foo.' + tld
ch_tld = ch.execute("SELECT cutToFirstSignificantSubdomainCustom(%(host)s, 'public_suffix_list')", params={
@azat
azat / bash_bug_wait_for.sh
Last active June 15, 2022 17:24
bash bug: wait_for: No record of process (had been fixed in bash 5.1+)
#!/usr/bin/env bash
#
# Reproducer for bash bug that had been fixed in bash 5.1+ [1], report [2]
#
# [1]: https://git.savannah.gnu.org/cgit/bash.git/commit/?h=bash-5.1&id=8868edaf2250e09c4e9a1c75ffe3274f28f38581
# [2]: https://lists.gnu.org/archive/html/bug-bash/2019-05/msg00110.html
#
function thread_worker()
#!/usr/bin/env bash
set -x
config_directives=(
--tcp_port=19000
--mlock_executable=true
)
benchmark_args=(
-d 0