Skip to content

Instantly share code, notes, and snippets.

View GeertJohan's full-sized avatar

Geert-Johan Riemer GeertJohan

View GitHub Profile
#!/bin/bash
# Author: slowpoke <proxypoke at lavabit dot com>
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved. This file is offered as-is,
# without any warranty.
#
# A pre-commit hook for go projects. In addition to the standard
@GeertJohan
GeertJohan / .xmonad-xmonad.hs
Created May 13, 2013 09:27
xmonad configuration foizetux
import XMonad
import XMonad.Hooks.InitialStartupHook
import XMonad.Layout.LayoutScreens
import XMonad.Layout.TwoPane
import XMonad.Hooks.InsertPosition
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeysP)
import XMonad.Hooks.SetWMName
package linenoise
// +linux
// #include <stdlib.h>
// #include "linenoise.h"
import "C"
import (
"unsafe"

panic stacktrace inlined vs not-inlined.

For this code:

package main

var x map[string]string

func add(a, b string) {
	x[a] = b
@GeertJohan
GeertJohan / coinbase.go
Last active August 29, 2015 14:03
This program calculates how many mined coins were sent to which address.
package main
import (
"fmt"
"github.com/conformal/btcrpcclient"
"log"
"sort"
)
// blockCount defines the number of blocks back into history we wish to inspect.
@GeertJohan
GeertJohan / DarkGravityWave3.cpp
Last active February 17, 2021 04:23
Dark Gravity Wave version 3
static const int64 nTargetSpacing = 2.5 * 60; // Guldencoin: 2.5 minutes between block
unsigned int static DarkGravityWave3(const CBlockIndex* pindexLast, const CBlockHeader *pblock) {
/* current difficulty formula, darkcoin - DarkGravity v3, written by Evan Duffield - evan@darkcoin.io */
const CBlockIndex *BlockLastSolved = pindexLast;
const CBlockIndex *BlockReading = pindexLast;
const CBlockHeader *BlockCreating = pblock;
BlockCreating = BlockCreating;
int64 nActualTimespan = 0;
@GeertJohan
GeertJohan / consistent-hashing-tests
Last active August 29, 2015 14:10
consistent-hashing-tests
"github.com/golang/groupcache/consistenthash"
100000 keys over 3 buckets
cacheA: 47356
cacheC: 11779
100000 keys over 9 buckets
cacheH: 10091
cacheI: 30516
cacheG: 7133
type block struct {
height int64
time time.Time
diff *big.Int
}
fatal error: fault
[signal 0xb code=0x80 addr=0x0 pc=0x5852d8]
goroutine 1 [running, locked to thread]:
runtime.gothrow(0x7ac5c0, 0x5)
/home/geertjohan/Applications/go/src/runtime/panic.go:503 +0x8e fp=0xc208087a68 sp=0xc208087a50
runtime.sigpanic()
/home/geertjohan/Applications/go/src/runtime/sigpanic_unix.go:29 +0x265 fp=0xc208087ab8 sp=0xc208087a68
github.com/jteeuwen/go-vlc.goEventCB(0x7f219b3e5e10, 0xc2082342e0)
/home/geertjohan/Workspaces/Go/gopath/src/github.com/jteeuwen/go-vlc/callback.go:32 +0xd8 fp=0xc208087b20 sp=0xc208087ab8
// Digi algorithm should never be used until at least 2 blocks are mined.
// Contains code by RealSolid & WDC
// Cleaned up for use in Guldencoin by GeertJohan (dead code removal since Guldencoin retargets every block)
unsigned int static GetNextWorkRequired_DIGI(const CBlockIndex* pindexLast, const CBlockHeader *pblock){
// retarget timespan is set to a single block spacing because there is a retarget every block
int64 retargetTimespan = nTargetSpacing;
// get previous block
const CBlockIndex* pindexPrev = pindexLast->pprev;
assert(pindexPrev);