Skip to content

Instantly share code, notes, and snippets.

View pmarreck's full-sized avatar

Peter Marreck pmarreck

  • formerly senior engineer @ desk.com, chief engineer @ thredup.com, software engineer @ lifebooker.com. Director of Engineering @ addigence.com, currently available
  • Long Island, NY
  • 02:48 (UTC -04:00)
  • X @pmarreck
  • LinkedIn in/petermarreck
View GitHub Profile
a few tests using `cjxl` (the reference `jpeg-xl` converter) I performed on a 120.7 MB PNG (the Carina Nebula, first photo from the James Webb Space Telescope):
there's 2 main parameters, "distance" (where 0 is lossless and 1 is the least detectable lossy; higher numbers are more lossy) and "effort" (compression effort, where 1 is quick and 9 is exhaustive/very long)
distance 0 effort 9 took 3 hours (obviously this is for a "write once, read many" sort of archival use-case) and got it down to about half of PNG, 67.2 MB; not bad for maintaining lossless.
distance 0 effort 6 took 1m43s, got it down to 75 MB, about 63% of PNG.
distance 1 effort 8 took 3 minutes and got it down to 7.7 MB which is about 1/15th of the PNG.
distance 1 effort 6 took 4s; got it to 7.1 MB... wait, _whut?_ That's... odd. Smaller than with effort 8. Anyway.
All encodings only used 1 of my 128 cores. Whole-image compression of this nature may not be "trivially parallellizable" ::shrug::
@pmarreck
pmarreck / convert_font_filenames
Last active July 25, 2023 17:49
Convert terrible 8.3-formatted font filenames to their internal fullname using the Fontconfig library tools.
#!/usr/bin/env bash
needs() {
local bin="$1";
shift;
command -v "$bin" > /dev/null 2>&1 || {
printf "%s is required but it's not installed or in PATH; %s\n" "$bin" "$*" 1>&2;
return 1
}
}
@pmarreck
pmarreck / hendricks_formatter.ex
Created July 25, 2023 14:02
An Elixir formatting module for `mix format` that converts leading spaces to tabs.
defmodule HendricksFormatter do
@moduledoc """
This module is a formatter plugin for Elixir's `mix format` task
that converts leading whitespace to tabs.
It tries to intelligently determine the tab width based on the most common
counts of leading space runs in the file.
It allows additional space characters for minor adjustments that are below the tab width.
OK, why tabs? Why resurrect this age-old nerd debate again?
Very simple: It's an accessibility issue:
https://adamtuttle.codes/blog/2021/tabs-vs-spaces-its-an-accessibility-issue/
@pmarreck
pmarreck / randompass.js
Created July 19, 2023 14:52
Put this as the URL of a browser bookmark and now you have a good password generator.
javascript:(function(){var%20password;var%20regex=/^(?=.*[A-Z].*[A-Z])(?=.*[a-z].*[a-z])(?=.*\d.*\d)(?=.*[!@#$%^&*].*[!@#$%^&*]).{20,}$/;do{password=Array.from(crypto.getRandomValues(new%20Uint32Array(25)),%20x%20=>%20"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*"[x%20%%2070]).join('');}while(!regex.test(password));alert(password);})()
@pmarreck
pmarreck / elixir_concurrency_demo.exs
Created July 17, 2023 20:39
Elixir concurrency demo: 1 million process spawn and garbage-collect.
#!/usr/bin/env elixir
# make sure to bump max erlang processes limit first:
# export ERL_FLAGS="+P 2000000"
defmodule Concurrency do
def millions_of_us(n) do
receive do
{sender_pid, message} ->
Process.sleep(:rand.uniform(2000))
@pmarreck
pmarreck / randompass.js
Created July 5, 2023 20:06
Generate a random password or randomized multiple-word dictionary password using Javascript (NO other dependencies!)
const CHARSET_LOWER = "abcdefghijklmnopqrstuvwxyz";
const CHARSET_UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const CHARSET_NUM = "0123456789";
const CHARSET_ALPHA = CHARSET_LOWER + CHARSET_UPPER;
const CHARSET_ALNUM = CHARSET_ALPHA + CHARSET_NUM;
const CHARSET_ALNUM_SANE = CHARSET_ALNUM.replace(/O|l|I/g, "");
// const CHARSET_PUNC = "!@#$%^&*-_=+[]{}|;:,.<>/?~";
// I shortened the possible punctuation chars due to incompatibility with various sites:
const CHARSET_PUNC = "!@#$%^&*";
const CHARSET_HEX = CHARSET_NUM + "abcdef";
@pmarreck
pmarreck / grandfather_clock_chime.bash
Last active June 27, 2023 02:29
Bash script to produce a grandfather clock sound on the hour with the number of gongs equal to the hour
This file has been truncated, but you can view the full file.
grandfather_gong() {
function needs() {
local bin=$1;
shift;
command -v $bin > /dev/null 2>&1 || {
echo "I require $bin but it's not installed or in PATH; $*" 1>&2;
return 1
}
}
@pmarreck
pmarreck / kill_steam_proton_pids.bash
Last active January 29, 2024 13:14
Automatically clean up any orphaned Steam or Proton processes on Linux if any didn't exit cleanly
#!/usr/bin/env bash
function kill_steam_proton_pids() {
# This bash one-liner performs the following tasks:
# 1. It sets the PS_PERSONALITY environment variable to 'linux' which standardizes the output format of the 'ps' command.
# 2. Runs the 'ps' command with the following options:
# - 'e' to include processes from all users,
# - 'o pid,args' to only show process ID and command arguments,
# - '--sort=-pid' to sort by process ID in descending order (so it kills the newest processes first),
# - '--no-headers' to not include column headers in the output.
@pmarreck
pmarreck / pmarreck_twitter_personality_profile.md
Last active March 15, 2025 16:54
Peter Marreck personality profile from ChatGPT4 based on Twitter profile

Twitter Account Owner Info

You

What can you tell me about the person who owns this twitter account? https://twitter.com/pmarreck

ChatGPT

The Twitter account @pmarreck is owned by Peter "Not an AI Doomer" Marreck. According to the description on his Twitter profile, Peter is a secular-humanist technologist. His interests include tech, Elixir (a dynamic, functional language designed for building scalable and maintainable applications), gaming, open source, Linux, Apple, biking, and sailing. He is also a United States Air Force (USAF) veteran. He uses the handle @pmarreck@genserver.social in addition to his Twitter handle. His professional background appears to be in software development, as he identifies himself as a software developer, programmer, and software engineer. He joined Twitter in August 2008​​.

You

Can you assess his personality from his tweets, replies and likes?

@pmarreck
pmarreck / materialism_incompleteness_with_chatgpt4.md
Created May 25, 2023 14:35
A philosophical debate with ChatGPT4+web browsing about materialism and consciousness

Materialist Model's Potential Incompleteness

pmarreck>

Is there any evidence that the materialist model of the human body is incomplete?

ChatGPT4>

The materialist model of the human body, often referred to as physicalism or materialism in the context of philosophy of mind, is the view that everything that exists is no more than the sum of its physical parts. This includes the human body and mind. According to this view, all phenomena, including thoughts, feelings, and consciousness, are the result of physical processes and can be explained through the laws of physics, chemistry, and biology.

This model has been incredibly useful in scientific understanding and has led to many advances in medicine and psychology. However, it is not without its challenges and criticisms, some of which suggest that it may be incomplete: