Skip to content

Instantly share code, notes, and snippets.


Lars Christensen larsch

View GitHub Profile
larsch /
Last active Nov 8, 2020
Run firefox with Wireguard VPN using network namespaces
exec ip netns exec vpn su user -c "$*"
larsch /
Created Oct 10, 2020
Installing Arch Linux AArch64 on the NanoPi R2S

Installing Arch Linux AArch64 on the NanoPi R2S

There is current no support for the NanoPi R2S in ArchLinuxArm, but it's possible to run it using the generic aarch64 installation.

Prepare sd-card/image

  1. Copy bootloader and uBoot from an armbian image using for the NanoPi R2S using dd (sectors 32 to 32767) everything before the partition, except the partition table).
  2. Create an ext4 partition on /dev/mmcblk0p1 at offset of 32768 sectors (16384 KiB):
Device         Boot Start      End  Sectors  Size Id Type
A python keyring backend that uses 'git-credential-cache'
To enable, edit '~/.local/share/python_keyring/keyringrc.cfg':
To enable use with mercurial, edit ~/.hgrc:
View big_slow.glsl
vec3 hsv2rgb(vec3 c) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract( + * 6.0 - K.www);
return c.z * mix(, clamp(p -, 0.0, 1.0), c.y);
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
View freqmon.c
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <stdio.h>
/* #define F_CPU 16000000UL */
#define BAUD 115200L
#include <util/setbaud.h>
larsch / termbench.c
Created Sep 9, 2018
Basic terminal benchmark program
View termbench.c
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <stdint.h>
#include <stdlib.h>
void writestr(int fd, const char* str) {
write(fd, str, strlen(str));
larsch / iso8610_time.c
Created Aug 30, 2018
Minimal function to format current time according to ISO8601 with milliseconds
View iso8610_time.c
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
int iso8601_time(char* buf, size_t size)
struct timespec ts;
struct tm tm_local;
struct tm tm_gm;
View 0_rational_intermediate.rb
#!/usr/bin/env ruby
def lesseq(a, b, c, d)
return a * d <= c * b
lower_numer = 2
lower_denom = 1
upper_numer = 3
upper_denom = 1
larsch / rotary.cpp
Created Oct 12, 2017
Rotary Encoder Interrupt Handler
View rotary.cpp
// Rotary Encoder Driver
// Copyright (C) 2016 by Lars Christensen <>
// MIT License
#include "rotary.hpp"
#include <avr/interrupt.h>
#include <avr/io.h>
larsch /
Created Jul 6, 2017
Install Arch Linux ARM for Raspberry Pi Zero W on SD Card (with commands to configure WiFi before first boot).
#!/bin/sh -exu
cd $(mktemp -d)
function umountboot {
umount boot || true
umount root || true
# RPi1/Zero (armv6h):