Skip to content

Instantly share code, notes, and snippets.

@Ortham
Ortham / scan-backup-emails.py
Created May 23, 2022 16:04
Create CSV files from Acronis backup notification emails.
#!/usr/bin/env python3
#
# Create CSV files from Acronis backup notification emails.
import csv
import re
import sys
from dataclasses import dataclass
from pathlib import Path
@Ortham
Ortham / typestate-generics-example.rs
Last active September 15, 2023 13:28
Example of typestates in Rust using generics
trait DoorState {}
// PhantomData is a zero-sized type that tells the compiler to pretend that
// Door actually stores a value of type State, since otherwise we'd get an
// unused type parameter error.
struct Door<State: DoorState> { number: u8, state: std::marker::PhantomData<State> }
// Our states don't actually hold any data. If they did, we wouldn't need
// PhantomData.
struct Open {}
@Ortham
Ortham / intro.rs
Last active March 3, 2022 13:28
An intro to basic Rust syntax and features
// Adjust linter settings to make output less noisy.
#![allow(unused_variables, dead_code)]
/*
The Rust programming language
=============================
Website: https://www.rust-lang.org/
## Learning
@Ortham
Ortham / keybase.md
Last active October 21, 2018 10:10
My keybase proof of identity

Keybase proof

I hereby claim:

  • I am ortham on github.
  • I am wrinklyninja (https://keybase.io/wrinklyninja) on keybase.
  • I have a public key ASC3MC3YuhcXoG2t5fNglFuRGXPwOoDl4yQDiOrwi_a6kQo

To claim this, I am signing this object:

@Ortham
Ortham / win7_winhttp_tls1.2.reg
Created February 23, 2018 14:45
Enable TLS 1.2 support on Windows 7
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.1\Client]
"DisableByDefault"=dword:00000000
"Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisableByDefault"=dword:00000000
"Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp]
"DefaultSecureProtocols"=dword:00000a00
@Ortham
Ortham / clang-format.ps1
Last active February 18, 2018 09:42
clang-format everything in Git source control
clang-format -style=file -i $(git ls-files *.cpp *.h)
@Ortham
Ortham / slim_pdfs.sh
Created August 6, 2017 12:50
A script for slimming PDFs (eg. of scanned documents)
ls -1 *.pdf | (IFS=: ; while read FILENAME; do s=${FILENAME##*/} ; gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=${s%.pdf}.2.pdf ${FILENAME} && mv ${s%.pdf}.2.pdf ${FILENAME} ; done)
@Ortham
Ortham / mount_windows.sh
Last active July 4, 2017 20:09
A script to simplify mounting a Bitlocker-encrypted Windows partition using Dislocker
#!/bin/bash
# Run with 'sudo'
set -e
BITLOCKER_PARTITION=/dev/sda3
BITLOCKER_MOUNT=/mnt/bitlocker
DECRYPTED_MOUNT=/mnt/windows
echo "Please enter your Bitlocker password: "
read -s BITLOCKER_PASSWORD
@Ortham
Ortham / primitive_laser.sh
Created January 14, 2017 10:48
Image reproduction using Primitive
#!/bin/bash
# Generate a single image using Primitive.
# https://github.com/fogleman/primitive
INPUT_FILE=$(ls $1/*.jpg | head -1)
OUTPUT_FILE=$1/$1.png
SHAPES_NUMBER=$2
if [ "$3" == "combo" ]
then
@Ortham
Ortham / BSA_process_directory.m
Created September 10, 2015 17:19
Beam spot analysis Matlab script
function BSA_process_directory(path)
path = strcat(path, '\');
% Filter only camera PNGs.
files = dir(strcat(path, 'Frame_*.png'));
% Create a Gaussian filter. This will be used
% to blur the image slightly so that spots
% form contiguous regions which can be
% analysed.