Skip to content

Instantly share code, notes, and snippets.

View oelna's full-sized avatar
😔
The light inside has broken, but I still work

Arno Richter oelna

😔
The light inside has broken, but I still work
View GitHub Profile
@oelna
oelna / closest.js
Created November 8, 2016 12:02
A vanilla javascript method that returns the closest DOM ancestor that matches a selector, or null.
var closest = function(selector, ele) {
if(!selector || !ele) return null;
//polyfill .matches()
if(Element && !Element.prototype.matches) {
Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector;
}
if(ele.matches(selector)) return ele; //return self if it matches
@oelna
oelna / Readme.md
Last active January 19, 2017 17:19
Clean an iTunes M4A audio track from all identifying/personal information with AtomicParsley and Python

What is this

This python script is a radical attempt to remove all personal information from iTunes M4A audio tracks. All ID3 information will be lost in the process, sadly. You need to figure out a special offset in one of your audio files in a hex editor for this to work. If you are looking for a very simple solution, this is not your script.

If this helps you, please consider tipping to make up for the ridiculous amount of time I lost putting this together:
Gittip Flattr

Instructions for macOS (was OS X)

@oelna
oelna / bingo.php
Last active March 5, 2021 00:01
A generator for unique Bingo cards in PHP. See in action https://bingo.arnorichter.de/ (generates cards printable on A4 paper size)
<?php
/*
Generate however many unique bingo cards you require (should be fewer than 10k though).
This is not meant to compute ALL possible bingo cards, obviously, but to help set up a
nice amount of cards for play.
If you require a free space somewhere on the board, you should probably tweak the output,
not the generator.
I wrote this because existing solutions on stackoverflow were in languages I could not
test as easily and many existing generator websites generate crap cards that do not
adhere to the bingo number distribution in the 5 rows, so you spend an eternity looking
@oelna
oelna / polychromie-architecturale.json
Created April 11, 2017 14:07
Le Corbusier's "Polychromie Architecturale" – all 63 colors as hex values, with their original name, ID and lightness coefficient (HBW) in a neat JSON array
[
{
"hex":"fff1ce",
"name":"blanc",
"hbw":72,
"id":"32001",
"collection":1931
},{
"hex":"585d5e",
"name":"gris foncé 31",
@oelna
oelna / applescript.scpt
Created June 21, 2018 14:32
macOS Automator Action to calculate file hashes
on run {input, parameters}
with timeout of 360 seconds
tell application "System Events"
activate
display dialog input buttons {"OK"} default button 1 with title "File Hashes" giving up after 300 --seconds
end tell
end timeout
end run
@oelna
oelna / resize_images.sh
Created September 3, 2018 12:52
A bash script to batch resize images on macOS, possibly through an Automator Service (uses sips, ImageOptim)
for f in "$@"
do
dir=$(dirname "${f}")
filename=$(basename -- "$f")
extension="${filename##*.}"
filename="${filename%.*}"
# array of pixel sizes (widths) to generate
sizes=(600 1200)
@oelna
oelna / hs_decode.py
Created June 11, 2019 22:47
Hearthstone decklist decode
#!/usr/bin/python
# modified for brevity from https://github.com/HearthSim/python-hearthstone/blob/master/hearthstone/deckstrings.py
import base64
from io import BytesIO
from typing import IO, List, Tuple
DECKSTRING_VERSION = 1
@oelna
oelna / ha.sh
Created November 9, 2019 14:06
Ways to generate hashes on macOS (BSD)
# shasum
## value of algorithm can be 1, 224, 256, 384, 512
## hash of string
echo -n "foobar" | shasum -a 256
## hash of file content
shasum -a 256 filename.ext
shasum --algorithm 256 /path/filename.ext
@oelna
oelna / titles-v1.js
Last active November 29, 2019 21:22
A simple script to generate pseudo-random titles for an adventure game, a la One Page Dungeon
/* outputs a simple string comprised of strings from a dictionary */
var game = window.game || {};
// inspired by https://watabou.itch.io/one-page-dungeon
game.titles = {
'typ': ['Temple', 'Prison', 'House', 'Mansion', 'Dungeon', 'World', 'Castle', 'Graveyard', 'Library', 'Water World'],
'adjektiv': ['Void', 'Blood', 'Burnt', 'Undead', 'Frozen', 'Night'],
'name': ['Queen', 'Prince', 'King', 'Delila']
}
@oelna
oelna / svg-imagemap.html
Last active April 24, 2020 12:22
A simple example of responsive image maps with HTML and SVG
<!DOCTYPE html>
<html>
<head>
<title>SVG image maps</title>
</head>
<body>
<!-- https://wiki.selfhtml.org/wiki/SVG/Tutorials/responsive_Imagemaps -->
<!-- https://n-peugnet.github.io/image-map-creator/ -->