Skip to content

Instantly share code, notes, and snippets.

View pascaldekloe's full-sized avatar

Pascal S. de Kloe pascaldekloe

View GitHub Profile
@pascaldekloe
pascaldekloe / dec64.s
Created December 19, 2023 21:46
Experimental Integer Compression (Status Unknown)
.global _pack32dec64
.text
.align 2
// Decode64 reads X2 amount of bytes at address X1 and it writes the 32
// encoded-values to address X0. The first delta is applied against X3.
// X2 must be a multiple of 4, and no more than 32 × 8 (bytes).
_pack32dec64:
// TODO(pascaldekloe): validate X2
@pascaldekloe
pascaldekloe / terminal-out.txt
Created August 30, 2023 12:43
CTRL + C ignored by iostat(1) on OSX
% iostat 1
disk0 disk4 cpu load average
KB/t tps MB/s KB/t tps MB/s us sy id 1m 5m 15m
20.46 33 0.67 34.86 201 6.84 3 2 96 1.60 1.36 1.27
4.00 46 0.18 65.06 234 14.85 2 1 97 1.60 1.36 1.27
4.00 35 0.14 56.85 215 11.93 8 3 89 1.56 1.35 1.27
4.00 16 0.06 37.93 190 7.04 2 1 97 1.56 1.35 1.27
4.34 82 0.35 28.71 230 6.44 2 2 96 1.56 1.35 1.27
4.42 86 0.37 33.94 248 8.23 3 3 94 1.56 1.35 1.27
4.00 25 0.10 75.17 191 14.02 2 1 96 1.56 1.35 1.27
@pascaldekloe
pascaldekloe / shasum.txt
Created August 27, 2023 19:06
Ethereum Freezer [Ancient] Checksums
f8df3a18a60eae038e30f99309b58aba1466eaf3 bodies.0000.cdat
3d9ed0e68ed89656b6758b9a6f53d70e49b9f668 bodies.0001.cdat
1157a083bb6f5105dbdf7ae30970e66ebec22a39 bodies.0002.cdat
fe4d5fcae14df2a8bea640fa14b00011f5686ba8 bodies.0003.cdat
23f69ee4c6c254ebcba3f8aacee990cfd3c13da5 bodies.0004.cdat
cf4986cd3e23b3e59b4b581304a24bcc01ca53f5 bodies.0005.cdat
2af4df7beac5741b93c9ac68f7542845e4c135f9 bodies.0006.cdat
480912845a44cb89230f5984edf1605965a195ba bodies.0007.cdat
be8665c0f3e88e9435be65024353818a16df97a2 bodies.0008.cdat
1f86b65b9d6f1ef4266ab00d57b3c66fb7d33dcc bodies.0009.cdat
@pascaldekloe
pascaldekloe / wordbench_test.go
Last active April 2, 2023 13:41
Go serialization speed test
// Package wordbench measures serialization speed.
package wordbench
import (
"encoding/binary"
"fmt"
"math/rand"
"testing"
)

Go Project Structure Standards

Now that Go undergoes mainstream adoption, you can witness a hunger for more and more convention. The core guidelines are impressive, but obviously they can not cover everything. The following sections address some ongoing attempts on the matter.

Reusable Code

All code is pkg if the definition is "library code that's OK to use by external applications”, with the exception for main packages and any code placed in an internal (sub)directory. Using pkg is the same redundancy as using src in a source code repository/directory, or a java directory with .java files.

Yes, there are many projects that don't write APIs in a reusable manner, just like many projects don't follow the compatibility rules from the semantic versioning model. None of it means that we need extra nesting to get it right.

@pascaldekloe
pascaldekloe / unit.go
Last active July 25, 2020 18:52
Concept: I/O units with Go
package io
// ReadUniter provides an extension pattern for transaction metadata.
type ReadUniter interface {
Reader
ReadUnits() Units // best effort: possibly zero
}
// WriteUniter provides an extension pattern for transaction metadata.
type WriteUniter interface {
@pascaldekloe
pascaldekloe / int64.js
Created April 22, 2017 11:02
Big-endian 64-bit integer decoding with TypedArray
// Unmarshals an Uint8Array as a signed 64-bit integer, big-endian.
function decodeInt64(data, i, allowImprecise) {
var v = 0, j = i + 7, m = 1;
if (data[i] & 128) {
// two's complement
for (var carry = 1; j >= i; --j, m *= 256) {
var b = (data[j] ^ 255) + carry;
carry = b >> 8;
v += (b & 255) * m;
}
@pascaldekloe
pascaldekloe / dmesg
Last active May 1, 2018 11:50
OpenBSD 6.3 - Panasonic ToughBook CF-31 mk2, 3G, GPS
OpenBSD 6.3 (GENERIC.MP) #107: Sat Mar 24 14:21:59 MDT 2018
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 8456351744 (8064MB)
avail mem = 8192995328 (7813MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.6 @ 0xeb360 (31 entries)
bios0: vendor American Megatrends Inc. version "V2.00L12" date 08/01/2011
bios0: Panasonic Corporation CF-31JECAJFG
@pascaldekloe
pascaldekloe / Course.java
Last active April 7, 2017 01:19
Demo Java Compilation
package com.example.demo;
// Code generated by colf(1); DO NOT EDIT.
import static java.lang.String.format;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
@pascaldekloe
pascaldekloe / Colfer.js
Last active April 2, 2017 22:25
Demo JavaScript Compilation
// Code generated by colf(1); DO NOT EDIT.
// The compiler used schema file demo.colf for package demo.
// Package demo offers a demonstration.
// These comment lines will end up in the generated code.
var demo = new function() {
const EOF = 'colfer: EOF';
// The upper limit for serial byte sizes.
var colferSizeMax = 16 * 1024 * 1024;