Skip to content

Instantly share code, notes, and snippets.

View markuswustenberg's full-sized avatar

Markus Wüstenberg markuswustenberg

View GitHub Profile
@markuswustenberg
markuswustenberg / Makefile
Created December 8, 2022 20:44
Go and SQLite parallel benchmark, v3
.PHONY: benchmark
benchmark:
go test -cpu 4,8,16,32,64,128,256,512,1024 -bench=.
@markuswustenberg
markuswustenberg / sqlite.go
Created December 8, 2022 20:35
Go and SQLite benchmarks parallel, v2
package sqlite
import (
"database/sql"
"sync"
)
func Setup(db *sql.DB) error {
_, err := db.Exec(`
create table posts (
@markuswustenberg
markuswustenberg / Makefile
Created December 8, 2022 18:42
Go SQLite benchmark parallel
.PHONY: benchmark
benchmark:
go test -bench=.
@markuswustenberg
markuswustenberg / Makefile
Created December 8, 2022 09:27
SQLite benchmark with Go mutex
.PHONY: benchmark
benchmark:
go test -bench=.
@markuswustenberg
markuswustenberg / Makefile
Created December 8, 2022 09:00
Quick SQLite benchmark
.PHONY: benchmark
benchmark:
go test -bench=.
@markuswustenberg
markuswustenberg / malloc.go
Created May 24, 2017 11:57
Malloc program in Go
package main
import (
"fmt"
"strconv"
)
func main() {
var mib int
var answer string
@markuswustenberg
markuswustenberg / keymap.cson
Created September 1, 2015 14:28
atom keymap
'atom-text-editor':
'cmd-backspace': 'editor:delete-line'
'alt-shift-down': 'editor:move-line-down'
'alt-shift-up': 'editor:move-line-up'
@markuswustenberg
markuswustenberg / test.dart
Created January 6, 2015 17:19
AngularDart waitForHttp helper function
/// A little helper function to get the test to wait for the callback and
/// simulate an implicit flush to the HTTP backend.
void waitForHttp(Future future, Function callback) {
future.then(expectAsync(callback));
inject((MockHttpBackend http) => http.flush());
}
@markuswustenberg
markuswustenberg / AccelerometerActivity.java
Created November 15, 2012 20:53
Examples for the presentation "A Practical Introduction to Sensing with Android" in the Context-Aware Computing course, Department of Computer Science, Aarhus University, 2013
package dk.au.cs.ubi.cac.one;
import android.app.Activity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.util.Log;
public static String humanReadableByteCount(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B";
int exp = (int) (Math.log(bytes) / Math.log(unit));
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp-1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}