Skip to content

Instantly share code, notes, and snippets.

xpe /
Created Feb 26, 2021
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 /
Created Jan 7, 2021
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/$
[[ -f $file ]] || man -t $1 > $file
[[ -s $file ]] && open -a Preview $file
xpe /
Last active Dec 23, 2020
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 {} +
xpe / hormonal_obesity.txt
Created Jun 14, 2020
Insulin & Insulin Resistance : Feedback Loops
View hormonal_obesity.txt
ASCII Diagram version of
┌───────────┐ │ high │ ┌───────────┐
│ glucose │────┬────▶│insulin │────┬────▶│ obesity │
└───────────┘ │ └────────┘ │ └───────────┘
│ │
│ ▼
┌────────────┐ ┌─────────────┐
xpe /
Created Oct 29, 2019
Let's retire Lines of Code and just count characters instead!
xpe /
Created Oct 27, 2019
Machine Leaning Theory: Double Descent Curve

Neural networks are capable of interpolating (fitting the training set perfectly) and driving test error lower.

Can the AdaBoost algorithm also do this?

Why or why not?

xpe /
Last active Oct 7, 2019
Use this when your phrases need numeronyms!
def abbreviate(phrase):
def shorten(w, t=7):
if len(w) <= t:
return w
return "{}{}{}".format(w[0], len(w)-2, w[-1])
return " ".join([shorten(w) for w in phrase.split(" ")])
abbreviate("The Heilmeier Catechism demands a thoughtful approach to risk taking")
# 'The H7r C7m demands a t8l a6h to risk taking'
xpe /
Last active Dec 23, 2018
Policy Gradient Loss function for PyTorch
import torch
import torch.nn as nn
import torch.optim as optim
from torch._jit_internal import weak_module, weak_script_method
class PolicyGradientLoss(nn.Module):
Multiplies an unreduced CrossEntropyLoss by a `q` vector.