Skip to content

Instantly share code, notes, and snippets.

View larsch's full-sized avatar

Lars Christensen larsch

View GitHub Profile
@larsch
larsch / vpnexec.sh
Last active November 8, 2020 17:49
Run firefox with Wireguard VPN using network namespaces
#!/bin/sh
exec ip netns exec vpn su user -c "$*"
@larsch
larsch / archlinuxarm-on-nanopi-r2s.md
Created October 10, 2020 10:48
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':
[backend]
default-keyring=cachekeyring.CacheKeyring
keyring-path=/path/to/dir
To enable use with mercurial, edit ~/.hgrc:
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);
}
#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 September 9, 2018 10:23
Basic terminal benchmark program
#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 August 30, 2018 13:43
Minimal function to format current time according to ISO8601 with milliseconds
#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;
#!/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 October 12, 2017 19:45
Rotary Encoder Interrupt Handler
//
// 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 July 6, 2017 06:05
Install Arch Linux ARM for Raspberry Pi Zero W on SD Card (with commands to configure WiFi before first boot).
#!/bin/sh -exu
dev=$1
cd $(mktemp -d)
function umountboot {
umount boot || true
umount root || true
}
# RPi1/Zero (armv6h):