Skip to content

Instantly share code, notes, and snippets.

@glycerine
glycerine / raft-single-server-changes-safety
Created April 23, 2025 18:20 — forked from ongardie/raft-single-server-changes-safety
Safety of Raft single-server membership changes
This is an attempt to show that Raft's safety is
preserved with single-server membership changes as
described in the dissertation plus the patch that a
leader may not append a new configuration entry to
its log until it's committed an entry from its
current term.
This extends the safety argument in the
paper/dissertation. The only part that's different
(as far as I can tell) for membership changes is Step
@glycerine
glycerine / go-env-with-msys2.md
Created April 26, 2020 01:07 — forked from voidexp/go-env-with-msys2.md
Go development environment on Windows with MSYS2

Go development environment on Windows with MSYS2

Normally, it is sufficient to grab the Go MSI installer from the website in order to set up the toolchain. However, some packages that provide Go wrappers for C libraries rely on cgo tool, which in turn, needs the GCC toolchain in order to build the glue code. Also, 3rd-party dependencies are usually hosted on services like GitHub, thus Git is also needed. This mini-guide illustrates how to setup a convenient development environment on Windows using MSYS2.

@glycerine
glycerine / luajit-ffi-pushcdata.c
Created January 17, 2018 21:47 — forked from rtsisyk/luajit-ffi-pushcdata.c
An example how to work with CDATA (LuaJIT FFI) objects using lua_State
void *
luaL_pushcdata(struct lua_State *L, uint32_t ctypeid, uint32_t size)
{
/*
* ctypeid is actually has CTypeID type.
* CTypeId is defined somewhere inside luajit's internal headers
* which should not be included in init.h header.
*/
static_assert(sizeof(ctypeid) == sizeof(CTypeID),
@glycerine
glycerine / ProFi.lua
Created January 13, 2018 22:00 — forked from perky/ProFi.lua
ProFi, a simple lua profiler that works with LuaJIT and prints a pretty report file in columns.
--[[
ProFi v1.3, by Luke Perkin 2012. MIT Licence http://www.opensource.org/licenses/mit-license.php.
Example:
ProFi = require 'ProFi'
ProFi:start()
some_function()
another_function()
coroutine.resume( some_coroutine )
ProFi:stop()
@glycerine
glycerine / ns-inet.sh
Created April 17, 2017 07:07 — forked from dpino/ns-inet.sh
Setup a network namespace with Internet access
#!/usr/bin/env bash
set -x
NS="ns1"
VETH="veth1"
VPEER="vpeer1"
VETH_ADDR="10.200.1.1"
VPEER_ADDR="10.200.1.2"
@glycerine
glycerine / diskchecker.pl
Created November 2, 2015 18:34 — forked from bradfitz/diskchecker.pl
diskchecker.pl
#!/usr/bin/perl
#
# Brad's el-ghetto do-our-storage-stacks-lie?-script
#
sub usage {
die <<'END';
Usage: diskchecker.pl -s <server[:port]> verify <file>
diskchecker.pl -s <server[:port]> create <file> <size_in_MB>
diskchecker.pl -l [port]
package main
// simple example to show how to process one message at a time with nsq using the go-nsq client library.
// see config stuff in var below to play around with different scenarios.
import (
"log"
"os"
"os/signal"
"strconv"
@glycerine
glycerine / sshd.go
Last active August 29, 2015 14:15 — forked from jpillora/sshd.go
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@glycerine
glycerine / main.go
Last active August 29, 2015 14:12 — forked from wolfeidau/main.go
package main
//
// Starting point is from http://gcmurphy.wordpress.com/2012/11/30/using-epoll-in-go/
//
import (
"fmt"
"os"
"syscall"
// Package xorshift implements a 64-bit version of Marsaglia's xorshift PRNG as
// described in http://www.jstatsoft.org/v08/i14/paper.
// The generator has a period of 2^64-1 and passes most of the tests in the
// dieharder test suit.
package xorshift
// *Xor64Source implements the rand.Source interface from math/rand.
type Xor64Source uint64
// seed0 is used as default seed to initialize the generator.