Skip to content

Instantly share code, notes, and snippets.

View neunhoef's full-sized avatar

Max Neunhöffer neunhoef

View GitHub Profile
@neunhoef
neunhoef / getting_started_rust_linux.md
Last active November 13, 2023 22:35
Getting started with Rust on Linux with vim

Getting started with Rust on Linux with vim

Installing Rust with rustup

URL: https://rustup.rs/

Do this command:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Metrics checklist

Pick any metric documentation snippet in Documentation/Metrics.

Check that:

  • The help string is a string which makes sense as the heading of a Grafana graph.
  • The unit is correct.
  • The category makes sense and is correct (for a list of categories see
This program does not behave as intended:
#include <atomic>
#include <iostream>
int main() {
std::atomic<long double> x;
x.store(1.0);
long double tmp = 2.0;
bool worked = x.compare_exchange_weak(tmp, 3.0);
std::cout << "worked " << worked << " set tmp to " << tmp << std::endl;
@neunhoef
neunhoef / exceptionbang.cpp
Created September 11, 2019 14:23
Expose a problem on Alpine Linux and g++ and static linking
#include <pthread.h>
#ifdef REPAIR
void* g(void *p) {
return p;
}
void f() {
pthread_t t;
pthread_create(&t, nullptr, g, nullptr);
// This program exposes a bug. Use alpine Linux and compile as follows:
// g++ exceptioncollision.cpp -o exceptioncollision -O0 -Wall -std=c++14 -lpthread -static
// Then execute the static executable multiple times:
// while true ; do ./exceptioncollision ; date ; done
// after a few tries it will freeze.
#include <thread>
#include <atomic>
#include <chrono>

Keybase proof

I hereby claim:

  • I am neunhoef on github.
  • I am neunhoef (https://keybase.io/neunhoef) on keybase.
  • I have a public key ASDgs46qFbUZf1wyO_A-x5zQOnXUjF-Rbd7DmaHFpHCTXgo

To claim this, I am signing this object:

@neunhoef
neunhoef / docker-compose.yml
Created December 7, 2016 11:08
Docker compose file to start a local arangodb cluster
version: '2'
services:
agency:
image: arangodb/arangodb
environment:
- ARANGO_NO_AUTH=1
command: arangod --server.endpoint tcp://0.0.0.0:5001 --server.authentication false --agency.activate true --agency.size 1 --agency.supervision true --database.directory /var/lib/arangodb3/agency1
coordinator:
image: arangodb/arangodb
// Cleanup to allow for multiple load:
delete customers; delete items; delete sales; delete baskets;
delete reviews; delete reviewRel; delete r; delete gg; delete g;
// Create the collections:
["customers", "items", "sales", "baskets", "reviews", "reviewRel"]
.map(db._drop);
var customers = db._create("customers",
{numberOfShards: 3, replicationFactor: 2});
var items = db._create("items", {numberOfShards: 5, replicationFactor: 2});
db._drop("fromCollection");
db._drop("toCollection");
db._drop("edgeCollection");
var fromCollection = db._create("fromCollection", {numberOfShards:2})
var toCollection = db._create("toCollection", {numberOfShards:2})
fromCollection.ensureIndex({type:"hash",unique:false,fields:["fromAttributeValue"]});
toCollection.ensureIndex({type:"hash",unique:false,fields:["toAttributeValue"]});
fromCollection.ensureIndex({type:"skiplist",unique:false,fields:["timeStamp"]});
toCollection.ensureIndex({type:"skiplist",unique:false,fields:["timeStamp"]});
var edgeCollection = db._createEdgeCollection("edgeCollection", {numberOfShards:2});
@neunhoef
neunhoef / startArangoDBClusterLocal.sh
Created July 1, 2016 21:37
Script to deploy a local ArangoDB 3.0 cluster
#!/bin/bash
if [ -z "$XTERM" ] ; then
XTERM=x-terminal-emulator
fi
if [ -z "$XTERMOPTIONS" ] ; then
XTERMOPTIONS="--geometry=80x43"
fi
ARANGOD=/usr/sbin/arangod