Skip to content

Instantly share code, notes, and snippets.

Avatar

Lars Christensen larsch

View GitHub Profile
@larsch
larsch / vpnexec.sh
Last active Nov 8, 2020
Run firefox with Wireguard VPN using network namespaces
View vpnexec.sh
#!/bin/sh
exec ip netns exec vpn su user -c "$*"
@larsch
larsch / archlinuxarm-on-nanopi-r2s.md
Created Oct 10, 2020
Installing Arch Linux AArch64 on the NanoPi R2S
View archlinuxarm-on-nanopi-r2s.md

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
View cachekeyring.py
"""
A python keyring backend that uses 'git-credential-cache'
To enable, edit '~/.local/share/python_keyring/keyringrc.cfg':
[backend]
default-keyring=cachekeyring.CacheKeyring
keyring-path=/path/to/dir
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(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 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
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
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
end
lower_numer = 2
lower_denom = 1
upper_numer = 3
upper_denom = 1
@larsch
larsch / rotary.cpp
Created Oct 12, 2017
Rotary Encoder Interrupt Handler
View rotary.cpp
//
// Rotary Encoder Driver
//
// Copyright (C) 2016 by Lars Christensen <larsch@belunktum.dk>
// MIT License
//
#include "rotary.hpp"
#include <avr/interrupt.h>
#include <avr/io.h>
@larsch
larsch / install-arch-linux-rpi-zero-w.sh
Created Jul 6, 2017
Install Arch Linux ARM for Raspberry Pi Zero W on SD Card (with commands to configure WiFi before first boot).
View install-arch-linux-rpi-zero-w.sh
#!/bin/sh -exu
dev=$1
cd $(mktemp -d)
function umountboot {
umount boot || true
umount root || true
}
# RPi1/Zero (armv6h):