Skip to content

Instantly share code, notes, and snippets.

@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 / gist:5bb156bdeea314b215fc2816500bd759
Created January 16, 2019 02:18
compare go1.12beta2 and go1.10.7 compile times
(env3) jaten@Jasons-MBP ~/go/src/github.com/cosmos72/gomacro (generate) $ go version
go version
go version go1.12beta2 darwin/amd64
(env3) jaten@Jasons-MBP ~/go/src/github.com/cosmos72/gomacro (generate) $ time go install -a -toolexec=time -x
time go install -a -toolexec=time -x
WORK=/var/folders/2x/hm9gp5ys3k9gmm5f_vzm_6wc0000gn/T/go-build619075523
mkdir -p $WORK/b004/
mkdir -p $WORK/b010/
cat >$WORK/b004/importcfg << 'EOF' # internal
# import config
@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 / 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 / buggy_test.go
Created May 7, 2025 06:45
Two scenarios under synctest here A) with a time.Sleep() that never returns; B) sleep commented, the synctest.Wait never returns. Why? Seems like both are bugs, but...??
package main
import (
"sync"
"sync/atomic"
"testing"
"testing/synctest"
"time"
"fmt"