Skip to content

Instantly share code, notes, and snippets.

@neomantra
neomantra / pointerValueMap.go
Created March 31, 2023 13:31
NewPointerValueMap converts a map[string]*T to a map[string]T, omitting nil pointers.
// NewPointerValueMap converts a map[string]*T to a map[string]T, omitting nil pointers.
func NewPointerValueMap[K comparable, V any](src map[K]*V) map[K]V {
dst := make(map[K]V)
for k, ptr := range src {
if ptr != nil {
dst[k] = *ptr
}
}
return dst
}
@neomantra
neomantra / install_onload.sh
Created February 2, 2023 12:45
Installing OpenOnload on Ubuntu 22.04 Jammy
# adapted from https://github.com/neomantra/docker-onload/blob/master/jammy/Dockerfile
# install dependencies
sudo apt-get update -y
sudo apt-get install -y --no-install-recommends \
autoconf \
automake \
ca-certificates \
coreutils \
curl \
 
 --------
 ////////\\
/ \\
| o o |
| /_ @|
 \ /
 \ \__/ /\
 \____/
How badly does MIT
@neomantra
neomantra / sleepy-cat.pl
Created January 16, 2023 14:25
sleepy-cat - like cat, except delay a little bit to emulate the # behavior of an old terminal
#!/usr/bin/env perl
# From: https://klipkyle.gitlab.io/blog/2017-10-22-vt100-ani.html
#
# scat
#
# sleepy-cat - like cat, except delay a little bit to emulate the
# behavior of an old terminal
#
# By default a delay is inserted after every line feed (to emulate
# screen refresh), and a smaller delay is inserted between every
@neomantra
neomantra / cnum.lua
Created December 7, 2022 13:51
Lua function to convert thousands-separated numbers into plain numbers
-- converts thousands-separated numbers into plain numbers
-- for example:
-- cnum(0) == 0
-- cnum(1,000) == 1000
-- cnum(3,141,593) == 3141593
-- cnum(-9,001) == -9001
function cnum(...)
local superbase = 1000
local sign = 1
local result = 0
@neomantra
neomantra / pi_from_dns.sh
Created April 27, 2022 15:19
Extract PI from pi.neomantra.com
# Extract Pi from pi.neomantra.com
# IPv4
dig pi.neomantra.com +short
# 3.141.59.26
dig pi.neomantra.com +short | tr -d . | sed -re 's/^.{1}/&./'
# 3.1415926
@neomantra
neomantra / High_Performance_Redis.md
Last active February 7, 2024 03:41
Notes on running Redis with HPC techniques

High Performance Redis

In response to this brief blog entry, @antirez tweeted for some documentation on high-performance techniques for Redis. What I present here are general high-performance computing (HPC) techniques. The examples are oriented to Redis. but they work well for any program designed to be single- or worker-threaded and asynchronous (e.g. uses epoll).

The motivation for using these techniques is to maximize performance of our system and services. By isolating work, controlling memory, and other tuning, you can achieve significant reduction in latency and increase in throughput.

My perspective comes from the microcosm of my own bare-metal (vs VM), on-premises deployment. It might not be suitable for all scenarios, especially cloud deployments, as I have little experience with HPC there. After some discussion, maybe this can be adapted as [redis.io documentation](https://redis.io/do

@neomantra
neomantra / taskset_child_threads.sh
Created March 11, 2019 03:20
Invokes `taskset` on the child threads of the specified processes.
#!/bin/bash
# Copyright 2013-2019 Neomantra BV. All rights reserved.
# Released under the MIT License.
usage()
{
cat >&2 <<EOF
usage: $0 [-h] [-v] [-c cpulist] ppid1 [ppid2 [...]]
Given a list of parent process IDs, this script finds their child
# Builds lua_ipython_kernel on centos
ARG IMAGE_BASE="centos"
ARG IMAGE_TAG="7"
FROM ${IMAGE_BASE}:${IMAGE_TAG}
RUN yum install -y \
epel-release \
&& yum install -y \
@neomantra
neomantra / Dockerfile_cpp
Created September 19, 2017 21:11
Aeron C++ Dockerfile
# Dockerfile for Aeron C++ SDK
#
# Copyright (c) 2017 Neomantra BV
# Released under the MIT License, see LICENSE.txt
FROM debian:stretch-slim
MAINTAINER Evan Wies <evan@neomantra.net>
ARG AERON_VERSION="master"