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 / 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
-- 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 / 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
@gburd
gburd / FlattenArray.ex
Created June 8, 2022 16:59
flatten array elixir
defmodule FlattenArray do
@doc """
Accept a list and return the list flattened without nil values.
## Examples
iex> FlattenArray.flatten([1, [2], 3, nil])
[1,2,3]
iex> FlattenArray.flatten([nil, nil])
[]
"""
@gburd
gburd / idea.vmoptions
Last active June 8, 2022 16:54
IntelliJ 2021.2.4 config
-Xms128m
-Xmx2048m
-XX:ReservedCodeCacheSize=512m
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:CICompilerCount=2
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-ea
-Dsun.io.useCanonCaches=false
@gburd
gburd / build-erlang.sh
Last active October 5, 2021 14:42 — forked from bryanhunter/build-erlang.sh
This script will install dependencies and then build and install erlang using kerl on Ubuntu
#!/bin/bash
# This script will install dependencies then build and install erlang using kerl
# Pull this file down, make it executable and run it with sudo
#
# wget https://gist.githubusercontent.com/bryanhunter/adbd9c8d9fb2f6366eee/raw/build-erlang.sh
# chmod u+x build-erlang.sh
# sudo ./build-erlang.sh
#
# Version: 17.1
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@gburd
gburd / README.md
Last active August 14, 2020 14:59
Container sending data to host using net=bridge mode (e.g. container to localhost)

Rather than 127.0.0.1 I think that the route to the Docker host is always available within the container in bridge mode as the default route, so you just have to find it, here's how:

$ nc -lu 8125
$ docker run --rm -it ubuntu:latest /bin/bash
# apt install net-tools netcat
# export DOCKER_HOST_IP=$(route -n | awk '/UG[ \t]/{print $2}')
# echo 'Over here!' | nc -w 0 -u $DOCKER_HOST_IP 8125

And so we have the container send data over UDP to the default route which is the host (when docker container is run with net=bridge, the default).

BEGIN MESSAGE.
x9rwjel0WrMcwU4 mXj4FLkBRNa71Nl dLmWzQbwVFGRYCM lUngX6ghQHoGfAl
sm1kCQIbDQIfiUT QxjpGlm2E55TCKq 6Xr2MZHgg6ejNmm WrN4fnkbSrWkoEj
Pon8DjwKDDNeBMF LR1CalqETQ6GazG gjtXbI1R7rMCYFL VH8nuYoSGbfCDb1
FrUC2kOAGjq4QDl PisUBWVV6pvbmqy cPf7F.
END MESSAGE.