Skip to content

Instantly share code, notes, and snippets.

View nnathan's full-sized avatar
💭
shopt -s globstar

Naveen Nathan nnathan

💭
shopt -s globstar
  • Compton
  • 20:05 (UTC +11:00)
View GitHub Profile
@nnathan
nnathan / Cargo.toml
Last active September 28, 2024 06:07
Generating deterministic keypairs & certificates (rough cut #66)
[package]
name = "bsvpn"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.8.5"
rand_chacha = "0.3.1"
@nnathan
nnathan / modulo_bias.py
Created September 13, 2024 07:46
Code demonstrating modulo bias
# Code based on excellent article:
# https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/
# by Yolan Romailler at Kudelski Security
import pandas
import os
# modulo bias
values = []
while len(values) <= 1000000:

As of 2024-08-05 the installation instructions to install Arch Linux ARM on pi 4 doesn't work.

This is my version, with the added bonus of using bcachefs instead of ext4 so you can get data checksumming, subvolumes, and compression.

Arch Linux ARM (aarch64) installation for Raspberry Pi 4 with bcacehfs

  1. Start cfdisk to partition the drive: cfdisk /dev/sdX.
  2. Create a dos partition table (my understanding is gpt doesn't work at this time).
  3. Press New, Partition Size 512M, press primary, and set type to c W95 FAT32 (LBA).
  4. Select "Free Space", and press New, use the suggested size which is remainder of space, press primary, and type should already be set to Linux.
@nnathan
nnathan / alarm-on-pi.md
Last active August 15, 2024 03:20
Install Arch Linux ARM (alarm) on Raspberry Pi 4 B (2024 Edition)

As of 2024-08-05 the installation instructions to install Arch Linux ARM on pi 4 doesn't work.

This is my version, with the added bonus of using btrfs instead of ext4 so you can get data checksumming, subvolumes, and compression.

If you want bcachefs flavour of these instructions click here.

Arch Linux ARM (aarch64) installation for Raspberry Pi 4 with btrfs

  1. Start cfdisk to partition the drive: cfdisk /dev/sdX.
  2. Create a dos partition table (my understanding is gpt doesn't work at this time).
@nnathan
nnathan / pingpong.c
Created December 30, 2023 01:25
Ping pong a byte over pipes and measure the exchanges (xv6 1.6 exercise)
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
size_t n_read;
void handle_alarm(int signum) {
printf("n_read = %lu\n", n_read);
fflush(NULL);
@nnathan
nnathan / example-ngate.json
Created February 5, 2020 01:06
Sample of n-gate entries as JSON.
[
{
"title": "Amazon Launchpad for Startups",
"titlelink": "https://www.amazon.com/gp/launchpad",
"date": "September 01, 2016",
"hnlink": "http://news.ycombinator.com/item?id=12398823",
"addendums": [],
"context": [],
"text": "Amazon would like to sell your shitty kickstarter products. Hackernews cannot decide if they're concerned enough about this centralization of power to post on medium about how dangerous it is; doing so would take away from the time they need to write android apps and monitor their adsense income and check their gmail accounts to make sure they're not missing a hangout. One-third of them complain that the images on the program website are not huge enough. Others are disgruntled because someone may compete with them."
},
@nnathan
nnathan / Pro - bash5.terminal
Created January 15, 2020 10:23
Pro\ -\ bash5.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlueColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGKyxYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKcHCBMZHSQoVSRudWxs1QkKCwwNDg8QERJcTlNDb21wb25lbnRzVU5TUkdCXE5T
Q29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29sb3JTcGFjZVYkY2xhc3NPEB4wIDAuMDU4ODYw
MTk2MjYgMC42NzY4NjYwOTQ2IDFPEBEwIDAgMC42MTI5OTM2NTc2ABABgAKABtMUFQ0W
@nnathan
nnathan / .mbsyncrc
Created November 19, 2019 01:13
.mbsyncrc
# this config is to facilitate one-way backups from fastmail to local maildir,
# it is specifically set to "Sync Pull" on the IMAP account to ensure
# read-only access.
#
# to run:
#
# brew install isync
# mbsync -a
BufferLimit 1024m
@nnathan
nnathan / .offlineimaprc
Created November 18, 2019 02:25
.offlineimaprc for backing up on MacOS
# to do a one-shot backup:
#
# $ offlineimap -a fastmail
[general]
accounts = fastmail
ui = blinkenlights
[Account fastmail]
@nnathan
nnathan / k-and-r-1.24.c
Created October 30, 2019 06:47
freenode ##c caze K&R C exercise 1.24 example from https://ideone.com/94U6aJ
#include <stdio.h>
#include <stdlib.h>
typedef void effector(int);
typedef struct transition transition;
struct transition {
int state;
effector *effect;
};