Skip to content

Instantly share code, notes, and snippets.

View pmarreck's full-sized avatar

Peter Marreck pmarreck

  • formerly desk.com, thredup.com and lifebooker.com. currently Director of Engineering @addigence
  • Long Island, NY
  • 10:07 (UTC -04:00)
View GitHub Profile
@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
Created May 26, 2023 15:34
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:

@pmarreck
pmarreck / split_file.bash
Last active December 5, 2023 02:00
Split a text file into a directory of files each of which contains 1 line from the original file
#!/usr/bin/env bash
# Ensure a file name is provided
if [ -z "$1" ]
then
echo "No file name provided. Usage: ./split_file.bash <filename>"
exit 1
fi
# Extract the directory and base name from the file
@pmarreck
pmarreck / on_the_ridiculon.txt
Created May 9, 2023 01:37
On the Ridiculon particle (taken from a 1997 Usenet post by Gregg E Economou and enhanced by ChatGPT4 in Douglas Adams' style)
Background: It has come to my attention that an abundance of baffling occurrences plague our universe.
Theory: A fundamental force exists, intricately intertwined with the rampant absurdity we witness.
Behold:
Introducing the latest particle, the ridiculon.
The ridiculon is the diligent messenger of the force of Ridiculosity.
Ridiculous things spew them at a rate directly proportional to the sheer ludicrousness or imbecility they possess, and these particles engage with matter through a cosmic dance known as universal ridiculosity thermalization, wherein stupidity yearns to disperse until it reaches an equitable distribution.
Ridiculons themselves are the noble steeds upon which ridiculosity gallantly spreads throughout the cosmos.
The more preposterous a thing, the more ridiculons it emits, and anything that survives the onslaught of nonscattering collisions with ridiculons becomes increasingly ridiculous each time such a collision transpires. Although the ridiculon is weightless whilst stationary, it acqui