Skip to content

Instantly share code, notes, and snippets.

View fionn's full-sized avatar
🦨
wars are waged by technicians

Fionn Fitzmaurice fionn

🦨
wars are waged by technicians
View GitHub Profile
@fionn
fionn / brew_downgrade.md
Last active October 7, 2020 09:23
How to downgrade a Homebrew package in 2020

Make a GitHub repository that conforms to the naming scheme $username/homebrew-$tapname. It can be empty or already exist, it doesn't matter.

Get the formula at the version you want with brew extract $package $username/homebrew-$tapname --version=$version

This will automatically tap your tap, but if you want to add this to another machine, you'll have to:

  • commit and push your changes from the $(brew --prefix)/Homebrew/Library/Taps/$username/ directory,
  • brew tap $username/$tapname from the machine you want to add the tap to.

To install, brew install $package@$version.

@fionn
fionn / main.tf
Created July 12, 2020 14:17
Package Lambda
data "external" "packaged_lambda" {
program = concat(["${path.module}/files/package_lambda.sh", var.source_folder], var.exclude_files)
}
@fionn
fionn / nsl_en.md
Last active July 5, 2020 09:37
中華人民共和國香港特別行政區維護國家安全法

The Law of the People’s Republic of China on Safeguarding National Security in the Hong Kong Special Administrative Region

中華人民共和國香港特別行政區維護國家安全法

(English translation for reference)

Contents

  • Chapter I General Principles
  • Chapter II The Duties and the Government Bodies of the Hong Kong Special Administrative Region for Safeguarding National Security
@fionn
fionn / hkid.py
Last active May 10, 2020 07:51
HKID Validator
#!/usr/bin/env python3
"""Calculate HKID check digit and validate HKID numbers"""
import sys
import operator
from typing import List
def _char_to_int(char: str) -> int:
"""Maps characters in ID to numeric value"""
try:
@fionn
fionn / bastion_vpc.tf
Last active September 30, 2020 08:45
VPC with public and private EC2 instances
locals {
common_tags = {
Description = "VPC with public and private EC2 instances",
Env = "dev",
Project = "bastion-vpc"
}
}
resource "aws_vpc" "ami_exp" {
cidr_block = "10.0.0.0/16"
@fionn
fionn / arch_ec2.tf
Last active May 5, 2020 09:04
Deploy the latest Arch Linux AMI on EC2
data "aws_ami" "arch" {
owners = ["093273469852"] # Uplink Labs
most_recent = true
filter {
name = "name"
values = ["arch-linux-hvm-*"]
}
filter {
@fionn
fionn / Makefile
Last active April 30, 2020 15:30
Simple Container
.PHONY: all
all: config.json rootfs
config.json:
sudo runc spec
busybox:
skopeo copy docker://busybox:latest oci:busybox:latest
bundle: busybox
@fionn
fionn / miller_rabin.py
Created April 30, 2020 14:19
Miller Rabin primality test
#!/usr/bin/env python3
from random import randint
def miller_rabin(n: int) -> bool:
if n <= 3 or n % 2 == 0:
raise RuntimeError("n <= 3 or n % 2 == 0")
k = 1
while (n - 1) % (1 << k) == 0 and ((n - 1) // (1 << k)) % 2 == 0:
@fionn
fionn / blackletter.txt
Created April 26, 2020 16:02
Blackletter
A: 𝔄
B: 𝔅
C: ℭ
D: 𝔇
E: 𝔈
F: 𝔉
G: 𝔊
H: ℌ
I: ℑ
J: 𝔍
@fionn
fionn / sars_cov_2.fasta
Created March 25, 2020 09:55
SARS-CoV-2
>MN908947.3 Severe acute respiratory syndrome coronavirus 2 isolate Wuhan-Hu-1, complete genome
ATTAAAGGTTTATACCTTCCCAGGTAACAAACCAACCAACTTTCGATCTCTTGTAGATCTGTTCTCTAAA
CGAACTTTAAAATCTGTGTGGCTGTCACTCGGCTGCATGCTTAGTGCACTCACGCAGTATAATTAATAAC
TAATTACTGTCGTTGACAGGACACGAGTAACTCGTCTATCTTCTGCAGGCTGCTTACGGTTTCGTCCGTG
TTGCAGCCGATCATCAGCACATCTAGGTTTCGTCCGGGTGTGACCGAAAGGTAAGATGGAGAGCCTTGTC
CCTGGTTTCAACGAGAAAACACACGTCCAACTCAGTTTGCCTGTTTTACAGGTTCGCGACGTGCTCGTAC
GTGGCTTTGGAGACTCCGTGGAGGAGGTCTTATCAGAGGCACGTCAACATCTTAAAGATGGCACTTGTGG
CTTAGTAGAAGTTGAAAAAGGCGTTTTGCCTCAACTTGAACAGCCCTATGTGTTCATCAAACGTTCGGAT
GCTCGAACTGCACCTCATGGTCATGTTATGGTTGAGCTGGTAGCAGAACTCGAAGGCATTCAGTACGGTC
GTAGTGGTGAGACACTTGGTGTCCTTGTCCCTCATGTGGGCGAAATACCAGTGGCTTACCGCAAGGTTCT