Skip to content

Instantly share code, notes, and snippets.

View GeertJohan's full-sized avatar

Geert-Johan Riemer GeertJohan

View GitHub Profile
type block struct {
height int64
time time.Time
diff *big.Int
}
@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
@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 / 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.

panic stacktrace inlined vs not-inlined.

For this code:

package main

var x map[string]string

func add(a, b string) {
	x[a] = b
package linenoise
// +linux
// #include <stdlib.h>
// #include "linenoise.h"
import "C"
import (
"unsafe"
@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
#!/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 / sgrBlockquotesRegexp.go
Created February 11, 2013 08:21
block-quotes code regexp for SGR (github.com/foize/go.sgr)
Regexp: `(?:(?:^\[?\[([a-zA-Z0-9\- ]+)\])|([.\n\r]+))*`
Input: "[red] blabla [[ escaped? [bla-fd] ]] escaped?"
Output(fmt %#v): []string{"[red]", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""}
Expected: []string{"[red]", " blabla [[ escaped? ", "[bla-fd]", " ]] escaped?"}
Regexp: \[([^\]]+)\]
Input: "[red] blabla [[ escaped? [bla-fd] ]] escaped?"
Output(fmt %#v): [][]int{[]int{0, 5}, []int{13, 33}}
@GeertJohan
GeertJohan / tc.go
Created February 7, 2013 08:57
terminal colors
package main
import (
"fmt"
"tc" //terminal color
)
// First syntax idea
// Please skip this and take a look at the second idea.