Skip to content

Instantly share code, notes, and snippets.

View mas-4's full-sized avatar

Michael mas-4

View GitHub Profile
from typing import Optional
component_list = list[tuple[float, float]]
class Helpers:
@staticmethod
def oz2ml(oz):
return oz * 29.5735
@staticmethod
@mas-4
mas-4 / breakpoints.js
Created July 16, 2021 13:17
Simple Breakpoints For Styled Components
const numbers = {
vp3: 322,
vp4: 481,
vp7: 769,
vp10: 1025,
vp12: 1281,
}
let breakpoints = {}
for (const prop in numbers) {
@mas-4
mas-4 / setPath.js
Created June 22, 2021 20:01
JS Method for setting a path in a nested data structure even if it doesn't exist
const setPath = (obj, path, val) => {
if (path.length == 1) obj[path[0]] = val;
else {
obj[path[0]] = obj[path[0]] || {};
setPath(obj[path[0]], path.slice(1), val);
}
return;
};
const struct = {};
@mas-4
mas-4 / timing_function.py
Last active May 20, 2021 14:47
Convenient timing function
import time
def timing(t, task):
"""Helper function for timing tasks"""
now = time.time()
print(f"{now-t} for {task}.")
return now
t = time.time()
time.sleep(3)
from functools import lru_cache, wraps
def hashable_lru(func):
"""Dictionaries are unhashable, so this converts them to json for caching
purposes only. Then it converts them back from json, in order to actually
run the function. It's incredibly clever and I stole it from [stack
overflow][0].
[0]: https://stackoverflow.com/a/46590069
"""
@mas-4
mas-4 / laptop.pub
Created July 10, 2020 13:18
Laptop public ssh key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDEGS0s7dKfKnpkhFuXpZUiuuF13rwrKVcHWgcFpbVn3VK0np8hKxAXqMowTrcIT7fXbJpe8KPMtojNwJJugiXjwFLG6ydVhulTx34moK5tC1hZrRzU6s2HAlRgSMWia2kXhmcebvDCsID2okfe7knZ5iI8IaH5qbscAmICQHqPQEeXMQ0LGLinibwp3OmXZ1N1ufzxUOM0XX/Q3zJQLipp130KwBSZIstGGtvwxA936F0AG5nGU0njWu1MeP2oMXRMbx9akUoetU3b7D4DQcVbEnjFGp97B15Hk2gdMpZNeA3rMERqsXIj3gJmrTaZ0vfpbShEmGcYkcfqKoQCaNqYIiy9y1WfKN1S6alRJ6LeUjIRUiKQitzqv5UEW2xWoomomL4Vrh/aG8dNK5Rr4uc5dr/O3QhO0VSfud+u8AfnD5Y9Zvyz/foBrQdkeT1vdMkRGf1FBXA4ahBPAnsTuJ+so2xwPNzf7awuABfxJtb+1iNq1SYZJoJfAQpYCSLCMSE= malan@levain
@mas-4
mas-4 / nord.scss
Created July 6, 2020 20:20
Nord Color Palette for sass
/* * * * * * * * * * * * *
* Nord Color Variables *
* * * * * * * * * * * * */
/* For details see https://www.nordtheme.com/docs/colors-and-palettes */
/* Polar Night Palette */
$nord0: #2e3440;
$nord1: #3B4252;
$nord2: #434C5E;
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAgehJt1XYt4BQ/f7Z48cQ1TZZHkVnX5HwFvuQuJF7rLezgp7BC8IUrYDUGjd91JWsuI3+BUO77OIDmyitYnQ8WXsRg2gTrWmCb2S/wqhHAwLTX4nTZkMoLT4wO6zFGWqphfMx+1zKhv8xpWhjzfGvEOS8FRp+jirHqwAcX2M2dBTf//M5KdyDAYAu3MCQsVD3xc2D3GJ2egoIuHkk100b8xHfEEz5LzL0Uv8Z8QadgIaHbDGZe1PRgMkZHXrkrGVN+U1pST3LrU8DMuoLWF5PZNG5y4p4qzviElr4KDTVojHMWnoundjdo+AKjPyWLmUuLvRbF9/5Vv2evIzOaHZsQQ== rsa-key-20190212
@mas-4
mas-4 / gpgbackup.tex
Last active June 13, 2020 20:09
GPG Backup LaTeX PDF generator, run with `pdflatex --shell-escape gpgbackup.tex`, https://gist.github.com/joostrijneveld/59ab61faa21910c8434c#gistcomment-2339185
\documentclass{article}
\usepackage{float}
\usepackage{graphicx}
\usepackage{pgffor}
\def\gpgkey{yourkeyname}
\newcommand\gpgtopng{
\immediate\write18{gpg --export-secret-key \gpgkey | paperkey --output-type raw | base64 > temp}