Skip to content

Instantly share code, notes, and snippets.

View kjk's full-sized avatar

Krzysztof Kowalczyk kjk

View GitHub Profile
/* Copyright 2014 the SumatraPDF project authors (see AUTHORS file).
License: Simplified BSD (see COPYING.BSD) */
/* NOTE: this is unfinished work in progress */
/* NoFreeAllocator (ScratchAllocator ?) is designed for quickly and easily
allocating temporary memory that doesn't outlive the stack frame
in which it was allocated.
Consider this piece of code:
kjk /
Created December 11, 2014 01:33
Improving smaz benchmarking


Krzysztofs-MacBook-Pro-4:go-smaz kkowalczyk$ go test -bench=.
BenchmarkCompression	     500	   3451735 ns/op	  39.60 MB/s
BenchmarkDecompression	     500	   2740847 ns/op	  27.58 MB/s


Krzysztofs-MacBook-Pro-4:go-smaz kkowalczyk$ go test -bench=.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
/* This code was written by Krzysztof Kowalczyk (
and is placed in public domain. */
kjk / test_gob.go
Created December 18, 2013 01:36
Shows that one cannot append data to a gob file - the decoder will error out with 'extra data in buffer` when trying to decode data written by append.
package main
import (
kjk / show_caller_name.go
Last active December 31, 2015 19:39
Shows that we can get the caller's function name without access to source code. go build -o test show_caller_name.go; rm show_caller_name.go; ./test
package main
import (
var (
dunno = []byte("???")
import os
import pefile
# needs to be installed
# i.e. download it, extract and python install
d = os.path.join("win", "Debug")
files = os.listdir(d)
def is_pe(s):
if s.endswith(".dll"):
kjk / reflect_slice.go
Created August 31, 2018 04:05
How to create a reflect slice
package main
import (
type S struct {
N int
kjk / cmd-git-log.go
Created March 21, 2019 00:40
Compare output of 2 git log --format=oneline commands to see commits unique in each branch
package main
import (
#!/usr/bin/env python
# This code was written by Krzysztof Kowalczyk (
# and is placed in public domain.
def v2fhelper(v, suff, version, weight):
parts = v.split(suff)
if 2 != len(parts):
return v
version[4] = weight
kjk /
Created July 2, 2019 22:34

Keybase proof

I hereby claim:

  • I am kjk on github.
  • I am kjksf ( on keybase.
  • I have a public key ASAdCRkKmAhWMJJsU_q76BM_JyYK5-MZMrwrr6qTOk3WEwo

To claim this, I am signing this object: