Skip to content

Instantly share code, notes, and snippets.

View xpe's full-sized avatar

David James xpe

View GitHub Profile
@xpe
xpe / cp_connecting_ip.rs
Created January 22, 2024 13:54
/src/server/extractors/headers/cp_connecting_ip.rs
use std::net::IpAddr;
use axum::http::HeaderMap;
#[derive(Debug, thiserror::Error)]
pub enum IpHeaderError {
#[error("`CF-Connecting-IP` header is missing")]
MissingHeader,
#[error("`CF-Connecting-IP` header contains invalid characters")]
@xpe
xpe / predictive-processing-20230918.md
Last active September 18, 2023 14:29
Predictive Processing Model - Introduction 2023-09-18

Predictive Processing in Consciousness

ChatGPT 4.0 transcript on 2023-09-18

User

Are you familiar with the cognitive science / neuroscience theory that consciousness is a simulation error-corrected by our senses?

What is this theory called? / In what academic disciplines is it situated? / When was it first proposed? / Please comment on how well it has or has not been adopted.

@xpe
xpe / ChatGPT-guidance-unsolicited-advice.md
Created June 10, 2023 14:39
ChatGPT Guidance: Unsolicited advice

No unsolicited advice

Do not give advice unless I specifically ask for it.

For example: don't tell me to seek out authorities, experts, or regulatatory guidance. This includes:

  • doctors
  • healthcare professionals
  • building inspectors
  • electrical codes
@xpe
xpe / open_letter_2022-09-09.md
Last active September 10, 2022 13:32
Open Letter to Paul of the Unison language
@xpe
xpe / Opinion Mike Salditch 2011.md
Created November 20, 2021 19:23
OPINION: Living in Maryland is far superior to living in Texas
@xpe
xpe / idiomatic_Rust.md
Created September 9, 2021 20:13
What does "idiomatic" mean in the Rust community?

What does 'idiomatic' mean in Rust? Like many here, I even have some (false?) confidence that I know what idiomatic means.

Three Questions

Let me ask three questions:

  1. Who gets to decide what is idiomatic?

  2. How does something become idiomatic?

@xpe
xpe / 16bit emotional encoding.md
Created August 6, 2021 17:30
16-bit Emotional Encoding

With two bytes, a considerable range of emotions can be encoded according to Plutchik's wheel of emotions:

bits 15-14 13-12 11-10 9-8 7-6 5-4 3-2 1-0
00 - - - - - - - -
01 interest serenity acceptance apprehension distraction pensiveness boredom annoyance
10 anticipation joy trust fear surprise sadness disgust anger
11 vigilance ecstasy admiration terror amazement grief loathing rage

References

@xpe
xpe / ISO 8601 profile introduction.md
Last active August 6, 2021 17:26
ISO 8601 Profiles

Here I hope to make it easier for people to find an authoritative definition for the meaning of an ISO 8601 profile. To be clear, this doesn't mean the definition itself will be simple or clear. Sorry.

I was able to find the document below by way of this [English Language & Usage StackExchange][1] post: [What does it mean for RFC 3339 to be “a profile of” ISO 8601?][2]

You need to read ISO 8601, in particular ISO/WD 8601-2 Annex B, where the term "profile" is defined. It's not a regular English meaning; rather it's tech standards jargon.

@xpe
xpe / pman.sh
Created January 7, 2021 21:51
View a man page as PDF
#!/usr/bin/env zsh
(( $# == 1 )) || {print -u2 "One argument required"; exit -1}
[[ $1 ]] || {print -u2 "First argument is empty"; exit -1}
local dir=$HOME/.man_cache/ps
[[ -d $dir ]] || mkdir -p $dir
local file=$dir/$1.ps
[[ -f $file ]] || man -t $1 > $file
[[ -s $file ]] && open -a Preview $file
@xpe
xpe / hide_macOS_icon_files.md
Last active December 23, 2020 07:48
Hiding macOS Icon Files

Hiding macOS Icon Files

If you customize a Finder icon, macOS will put an Icon file in that directory.

While ls -al will show the filename as Icon?, the real file name is Icon$'\r', which can be found using Zsh's autocomplete functionality. Yes, the last character is a carriage return. Why, you may ask. That's a fair question.

Anyhow, to apply the hidden flag to all icon files located recursively within the current directory, run this command:

find . -name Icon$'\r' -exec chflags hidden {} +