Skip to content

Instantly share code, notes, and snippets.

View rmja's full-sized avatar

Rasmus Melchior Jacobsen rmja

View GitHub Profile
@rmja
rmja / vbaccess.ino
Last active December 6, 2022 06:56
// This program runs on the Arduino Uno Rev. 3 on the paddle and tennis court gates at Vesterø Boldklub.
// It controls the N10001ST electromagnetic lock (http://www.gianni.com.tw/Waterproof_Series.html)
// It supports two channels such that two doors (A and B) can be individually controlled from one arduino.
#define GATE_HOLD_MS 4000 // The time (in milliseconds) it takes from opening the gate until it is closed again
#define KEYPAD_GATE_ID GATE_A // The gate where the keypad is located
#define KEYPAD_STATE_PIN A0 // The input pin where the keypad state is sampled
#define KEYPAD_LOCK_PIN 12 // The output pin where the keypad lock signal is sent.
#define KEYPAD_HOLD_MS 3000 // The time (in milliseconds) it takes from opening the gate until the keypad is signalled to reverse the lock
#define KEYPAD_PULSE_MS 2000 // The lock pulse duration in mulliseconds
#define KEYPAD_ROTATION_MS 2000 // The lock pulse duration in mulliseconds
@rmja
rmja / Lz4BlockInfo.cs
Last active September 13, 2022 12:09
lz4 frame
internal readonly record struct Lz4BlockInfo(byte[] BlockBuffer, int BlockLength, bool Compressed, uint? BlockChecksum = null)
{
public Span<byte> Span => BlockBuffer.AsSpan(0, BlockLength);
public bool IsCompleted => BlockLength != 0;
}
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKCaH3UEgw8l3nwivmwfVbuv+COU/zNIAYEAu4XBSbcm rmj@DESKTOP-5VE6KMP
@rmja
rmja / hcloud-access.py
Last active June 16, 2020 08:33
authorized_keys maintenance for hcloud
#!/usr/bin/env python3
# hcloud-access.py
# Example: ./hcloud-access.py assign-key hcloud-ssh-key-name -u username server1 server2
import os
import requests
import sys
import argparse
import toml
import pwd
@rmja
rmja / hcloud-failover.py
Last active December 18, 2020 13:15
Hetzner Cloud alias IP failover using keepalived
#!/usr/bin/env python3
# hcloud-failover.py
# Inspired by https://github.com/lehuizi/hcloud-failover-keepalived
# This script is to be called from keepalived on the notify action
# and causes the alias IPs to be updated for the configured network,
# possibly promoting a current backup to master.
# The arguments are
# = Type ("GROUP" or "INSTANCE")
# = Name of group or instance
# = Target state of transition ("MASTER", "BACKUP", "FAULT")
using Microsoft.Data.Entity;
namespace ConsoleApp1
{
public class MyContext : DbContext
{
public DbSet<Address> Addresses { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
using Microsoft.Data.Entity;
namespace ConsoleApp1
{
public class MyContext : DbContext
{
public DbSet<Address> Addresses { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{