Skip to content

Instantly share code, notes, and snippets.

View codemicro's full-sized avatar

akp codemicro

  • UoB
  • Inside your computer
  • 13:52 (UTC)
View GitHub Profile
@codemicro
codemicro / instructions.md
Last active September 28, 2022 23:30
Moving from a dual-boot to a mono-boot Linux installation

Moving from a dual-boot to a mono-boot Linux installation

This guide details the steps I took to turn my Windows-Linux Mint dual-booted Thinkpad E14 into a Linux-only machine while preserving the existing Linux installation. It only applies if both operating systems are installed on the same drive and if the Windows installation is before the Linux installation on the disk.

In my case, my drive looked like this before any action was taken. The large partition on the left is Windows, the immediately adjacent one on the right is Linux.

20220928_154043.jpg

This guide is based on steps found at this page: https://help.ubuntu.com/community/MovingLinuxPartition

javascript:(() => {
const requestURL = "http://127.0.0.1:8080/api/readingList";
const token = "dfgkjlhsdfgkljghklhj";
const pageTitle = document.title;
const pageURL = window.location.href;
let metaImage = "";
let metaDescription = "";
function getMetaValue(propName) {
@codemicro
codemicro / photoRing.py
Created March 13, 2022 10:42
Add an overlay to an image with a circular cutout
from PIL import Image, ImageDraw
import argparse
parser = argparse.ArgumentParser(
description="Add an overlay to an image with a circular cutout"
)
parser.add_argument("input", metavar="INPUT", type=str, help="base image")
parser.add_argument("overlay", metavar="OVERLAY", type=str, help="overlay image")
parser.add_argument(
"--width",
@codemicro
codemicro / flagGen.py
Last active March 13, 2022 10:41
Generate basic pride flag blocks with Python
from PIL import Image, ImageDraw
FLAGS = [
["#000000", "#A3A3A3", "#FFFFFF", "#800080"], # asexual
["#5BCEFA", "#F5A9B8", "#FFFFFF", "#F5A9B8", "#5BCEFA"], # trans
]
im = Image.new("RGB", (2000, 2000), (255, 255, 255))
draw = ImageDraw.Draw(im)
bar_x_width = int(im.size[0] / len(FLAGS))
@codemicro
codemicro / main.go
Created February 16, 2022 21:18
Go program to export Google Keep data to GitJournal Markdown format
package main
import (
"encoding/json"
"fmt"
"io"
"io/fs"
"io/ioutil"
"os"
"path"
@codemicro
codemicro / backup.py
Created February 7, 2022 20:29
Basic rclone-based backup solution
import subprocess
import os
import datetime
import json
datestring = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d_%Hh%Mm")
filename = f"server_{datestring}.tar.gz"
to_backup = None
with open(os.path.join(os.path.expandvars("$HOME"), "backupConfig.json")) as f:
import math
plancks_constant = 6.63e-34
speed_of_light = 3e8
joules_per_electronvolt = 1.6e-19
meters_per_nanometer = 1e-9
mass_of_electron_kg = 9.109e-31
def wavelength_to_ephoton(nanometers):
# returns joules
@codemicro
codemicro / emailRedirect.js
Created September 1, 2020 13:39
Formspree hacky thing
const qName = new URLSearchParams(window.location.search).get("name");
const qEmail = new URLSearchParams(window.location.search).get("email");
const qSub = new URLSearchParams(window.location.search).get("_subject");
const qMessage = new URLSearchParams(window.location.search).get("message");
const referrer = document.referrer
console.log(qName)
console.log(qEmail)
console.log(qSub)
@codemicro
codemicro / update-bookstack.sh
Created August 10, 2020 10:57
Update a BookStack installation while also talking a backup
#!/bin/bash
cd bookstack
rm -rf backups
mkdir backups/
echo "Input MySQL user:"
read SQLUSER
mysqldump -u $SQLUSER -p bookstack > backups/database.sql
tar -czvf backups/files.tar.gz .env public/uploads storage/uploads
git pull origin release
# Modified version of https://github.com/techalchemy/python-proxyserver/blob/master/proxyserver.py
# Set these to control bind host and port for tcp server
# Port/host that you will connect to with your client
BIND_HOST, BIND_PORT = "localhost", 9999
# Set these to control where you are connecting to
# Server to send proxied traffic to
HOST, PORT = "www.example.com", 80