Skip to content

Instantly share code, notes, and snippets.

@xpe
xpe / intro.md
Created Feb 26, 2021
ISO 8601 Profiles
View intro.md

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 Jan 7, 2021
View a man page as PDF
View pman.sh
#!/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 Dec 23, 2020
Hiding macOS Icon Files
View hide_macOS_icon_files.md

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
xpe / hormonal_obesity.txt
Created Jun 14, 2020
Insulin & Insulin Resistance : Feedback Loops
View hormonal_obesity.txt
ASCII Diagram version of
https://thefastingmethod.com/wp-content/uploads/HOT-Fatty-Liver2.1.jpg
┌────────┐
┌───────────┐ │ high │ ┌───────────┐
│ glucose │────┬────▶│insulin │────┬────▶│ obesity │
└───────────┘ │ └────────┘ │ └───────────┘
│ │
│ ▼
┌────────────┐ ┌─────────────┐
@xpe
xpe / comment_327243.md
Created Oct 29, 2019
Let's retire Lines of Code and just count characters instead!
View comment_327243.md
@xpe
xpe / question.md
Created Oct 27, 2019
Machine Leaning Theory: Double Descent Curve
View question.md

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
xpe / numeronym.py
Last active Oct 7, 2019
Use this when your phrases need numeronyms!
View numeronym.py
def abbreviate(phrase):
def shorten(w, t=7):
if len(w) <= t:
return w
else:
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
xpe / policy_gradient_loss.py
Last active Dec 23, 2018
Policy Gradient Loss function for PyTorch
View policy_gradient_loss.py
import torch
import torch.nn as nn
import torch.optim as optim
from torch._jit_internal import weak_module, weak_script_method
@weak_module
class PolicyGradientLoss(nn.Module):
"""
Multiplies an unreduced CrossEntropyLoss by a `q` vector.
"""