Skip to content

Instantly share code, notes, and snippets.

View docwhat's full-sized avatar

Christian Höltje docwhat

View GitHub Profile
@docwhat
docwhat / hex-colors-from-strings
Created March 27, 2023 15:08
Just a simple algorithm for figuring out colors based on a string hash
#!/bin/bash
#
# Usage: ./run.bash $(sort --random-sort /usr/share/dict/words| head -n10 ) | tee /tmp/foo.html
set -euo pipefail
function string_to_color_hex {
local -r string="$1"
local -r hash=$(echo -n "$string" | md5sum | cut -d' ' -f1)
local -ir r=$((16#${hash:0:2}))
module gist.github.com/e3b13265d24471651e02f7d7a42e7d2c
go 1.18
@docwhat
docwhat / symlink-checker-tests.bash
Created June 27, 2022 18:12
Ways of checking if a file is "a symlink" and is "broken".
@docwhat
docwhat / update.bash
Created June 10, 2022 18:49
Script to update MiniUI for the Miyoo Mini
#!/bin/zsh
set -eu
cd "${0:h}"
die() {
echo "death: $*" >&2
exit
}
@docwhat
docwhat / .editorconfig
Last active April 21, 2021 19:15
Quines
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@docwhat
docwhat / README.md
Last active February 18, 2021 16:42
Running docker locally
docker network create jenkins
docker run \
  --detach \
  --rm \
  --net=jenkins \
  --volume=jenkins_home:/var/jenkins_home:rw \
  --volume=/var/run/docker.sock:/var/run/docker.sock:rw \
  --publish=8080:8080 \
 --env=JAVA_OPTS=-DexecutableWar.jetty.sessionIdCookieName=dockerjenkins \
@docwhat
docwhat / Makefile
Created January 30, 2021 02:17
Playing with clang and assembly
default: hello hello-asm
hello-asm.s: hello.c
clang -S -masm=intel -o $@ $<
%: %.s
clang -o $@ $<
%: %.o
clang -o $@ $<
@docwhat
docwhat / cwd.c
Last active January 22, 2021 16:49
macOS program to get current working directory of any PID.
#include <errno.h>
#include <libproc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Works on macOS using libproc.
int main(int argc, char *argv[]) {
int ret;
@docwhat
docwhat / Dockerfile
Created August 20, 2020 19:57
Example of mounting one stage from another
# syntax=docker/dockerfile:1-experimental
FROM alpine:3 AS fetcher
# We don't care about minimizing the number layers for this image.
RUN apk add --no-cache curl ca-certificates
WORKDIR /files
RUN curl -sSLf -o chronic https://github.com/docwhat/chronic/releases/download/v1.0.11/chronic_linux_amd64
@docwhat
docwhat / custom_404.html
Last active June 26, 2020 20:12
HTML error single pages
<!DOCTYPE html>
<html>
<head>
<title>Canvas Asteroids</title>
<style>
* {
margin: 0;
}
canvas {