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
  • 21:07 (UTC -04:00)
View GitHub Profile
@pmarreck
pmarreck / email_header_parser.rb
Last active August 4, 2023 09:36
Superfast email header parser in Ruby, using regular expressions. This solution is 250 times faster than using the "Mail" gem. :O Time with my regex: 0.063965 seconds Time with Mail gem: 16.327161 seconds Note that I included some encoding-fix code. YMMV and encoding fixes are all debatable or fail in some corner case.
require 'ap'
require 'mail'
# String monkeypatch
# This is one of many possible "encoding problem" solutions. It's actually an intractable problem
# but you'd have to read "Gödel, Escher, Bach" to understand why...
class String
def clean_utf8
# self.force_encoding("UTF-8").encode("UTF-16BE", :invalid=>:replace, :replace=>"?").encode("UTF-8")
unpack('C*').pack('U*') if !valid_encoding?
@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 / 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 / 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 / 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 / better_numbers_to_words.exs
Last active May 18, 2023 06:16
Numbers to words, version 2, in Elixir
defmodule MathThatShouldHaveBeenInStockElixirAlready do
def int_pow10(num, 0), do: num
def int_pow10(num, pow) when pow > 0, do: int_pow10(10 * num, pow - 1)
end
defmodule NumbersToWords do
alias MathThatShouldHaveBeenInStockElixirAlready, as: Math
def parse(0), do: "zero"
@pmarreck
pmarreck / pmarreck_resume.md
Last active May 17, 2023 19:59
Peter Marreck Resume 2023

Peter R. Marreck

Port Washington, NY 11050
203.570.4096
peter@marreck.com

Education

Cornell University, Ithaca, New York
B.A. Psychology, Computer Science (minor)

@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
@pmarreck
pmarreck / random_taoup_quote_awk_assistance.md
Created May 8, 2023 18:44
ChatGPT4 helps with `awk` script to alter output of `taoup` to get a single categorized quote

AWK Script for Quotes

You

I have a text file with a list of quotes (example excerpt below). Some of the lines are header lines for the section of quotes following, which begin with 3 or more hyphens. I want an awk script that selects a random non-header line, determines its header (the nearest line above it that starts with 3 or more hyphens), and then outputs the header and the line.

---- Characteristics of Innovative People ----
Iterate between abstract and concrete thinking.
Acknowledge the limits of your knowledge.
Step out of your comfort zone.