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 / 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']
}

This is a crash course in JavaScript. It is intended for people who already have a bit of programming experience in other languages.

This will hopefully give a basic idea of the most-commonly-used language features, but it is not indended to be a comprehensive guide.

This guide was last updated in August 2016.

Basic syntax

To declare a variable called foo:

@oelna
oelna / map.html
Last active April 2, 2020 22:14
A simple Mapbox GL JS map with a single marker, suitable for small business websites.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Map</title>
<link rel="stylesheet" href="https://api.mapbox.com/mapbox-gl-js/v1.9.0/mapbox-gl.css" />
<style>
#map-container {
width: 100%;
@oelna
oelna / dark-light.css
Created April 2, 2020 16:34
Make elements of a website adapt to iOS/macOS display mode changes automatically
/* define some global values */
:root {
color-scheme: light dark; /* this is required so iOS knows we support display modes at all */
--system-color-blue: rgba(0,122,255,1);
--system-color-green: rgba(52,199,89,1);
--system-color-indigo: rgba(88,86,214,1);
--system-color-orange: rgba(255,149,0,1);
--system-color-pink: rgba(255,45,85,1);
--system-color-purple: rgba(175,82,222,1);
@oelna
oelna / character.js
Last active April 14, 2020 12:54
A simple hacked-together demo of Javascript modules and classes
const CHARACTER = class {
constructor(name, attributes = {}) {
this.name = name;
this.attributes = {};
// merge custom with default values
Object.assign(this.attributes, {
'strength': 3,
'constitution': 3,
'dexterity': 3,
@oelna
oelna / check_website.php
Created March 4, 2020 21:33
Detect when a website changed by logging hashes of the content (eg. check for domain availability)
<?php
/*
Since this script works by detecting changes to the page source code
it works only on static pages. Sites that often change, eg. are generated
by a CMS or embed changing script filenames will always trigger.
There is no easy way around this limitation as far as I know.
Instructions:
- Add your Email and desired URLs
@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/ -->