Skip to content

Instantly share code, notes, and snippets.

View gburd's full-sized avatar

Greg Burd gburd

View GitHub Profile
@gburd
gburd / skip_list.c
Created March 21, 2024 17:46 — forked from zhpengg/skip_list.c
skiplist implementation in c
/* Skip Lists: A Probabilistic Alternative to Balanced Trees */
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#define SKIPLIST_MAX_LEVEL 6
typedef struct snode {
int key;
@gburd
gburd / fifo_q.h
Last active December 1, 2023 13:50
A (well tested) ANSI C macro-based implementation of a bounded FIFO Queue. h/t QuviQ
/*
* fifo_q: a macro-based implementation of a FIFO Queue
*
* Copyright (c) 2012 Basho Technologies, Inc. All Rights Reserved.
* Author: Gregory Burd <greg@basho.com> <greg@burd.me>
*
* This file is provided to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain
* a copy of the License at
@gburd
gburd / clang-blocks.c
Created November 19, 2012 20:26
ANSI-C lambda blocks
/*
sudo apt-get install libblocksruntime-dev
clang -fblocks clang-blocks.c -lBlocksRuntime -o clang-blocks
CAVEAT: only works with clang and BlocksRuntime
*/
#include <stdio.h>
int main(void)
{
@gburd
gburd / shell.txt
Created October 6, 2023 17:57
Symas OpenLDAP in a container (thanks Bitnami!)
```
docker buildx build --format docker --progress=plain --no-cache --rm --platform linux/x86_64 --load -t symas/openldap:latest .
mkdir /tmp/ldap
chmod 0777 /tmp/ldap
clear; sudo rm -rf /tmp/ldap/{.ldap_setup_complete,slapd.d,data}; docker run --rm -e BITNAMI_DEBUG=true --name=symas-openldap -p 1389:1389 -p 1639:1639 --volume /tmp/ldap:/bitnami/openldap --user 1001 symas/openldap:latest
```
gburd@floki ~/w/c/o/2/debian-11 (main)> sudo rm -rf /tmp/ldap/{.ldap_setup_complete,slapd.d,data}; docker run --rm -e BITNAMI_DEBUG=true --name=symas-openldap -p 1389:1389 -p 1639:1639 --volume /tmp/ldap:/bitnami/openldap --user 1001 symas/openldap:latest
17:55:10.09 INFO ==> ** Starting LDAP setup **
17:55:10.12 INFO ==> Validating settings in LDAP_* env vars
@gburd
gburd / async_nif.h
Last active October 3, 2023 05:12
Technique for running Erlang NIFs functions asynchronously, not on scheduler threads.
/*
* async_nif: An async thread-pool layer for Erlang's NIF API
*
* Copyright (c) 2012 Basho Technologies, Inc. All Rights Reserved.
* Author: Gregory Burd <greg@basho.com> <greg@burd.me>
*
* This file is provided to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
@gburd
gburd / trace_decorator.py
Created February 15, 2023 15:33
Easy annotation to add OpenTelemetry into Python projects
## This file is a direct import of code from an MIT licensed project:
## digma-ai/opentelemetry-instrumentation-digma
##
## https://github.com/digma-ai/opentelemetry-instrumentation-digma/blob/main/LICENSE
## https://raw.githubusercontent.com/digma-ai/opentelemetry-instrumentation-digma/main/src/opentelemetry/instrumentation/digma/trace_decorator.py
##
import inspect
import types
from functools import wraps
-- This is done once per database instance.
BEGIN;
CREATE SCHEMA partman;
CREATE EXTENSION pg_partman SCHEMA partman;
COMMIT;
BEGIN;
CREATE ROLE partman WITH LOGIN;
GRANT ALL ON SCHEMA partman TO partman;
@gburd
gburd / sysctl.conf
Created January 5, 2019 02:43 — forked from voluntas/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
-module(timeit).
-compile(export_all).
%% @doc Dynamically add timing to MFA. There are various types of
%% timing.
%%
%% all - time latency of all calls to MFA
%%
%% {sample, N, Max} - sample every N calls and stop sampling after Max
%%