Skip to content

Instantly share code, notes, and snippets.

@xpe
xpe / why-wired-gigabit.md
Created November 19, 2018 20:35
Why Wired Gigabit

Various arguments for wiring your home with Cat 6 (gigabit) ethernet or better.

Bottom-line advantages of Cat 6 over 802.11ac WiFi:

  • Better capacity. While 802.11ac, under optimal conditions, can approach 500 Mbps, having a wired connection that guarantees 1000 Mbps can be useful.
  • Better reliability.
  • Better security.
  • Better latency.

All of this said, it isn't either-or -- you can use your wired connections for connecting computers to NAS or when you need maximum speed for uploading.

@xpe
xpe / policy_gradient_loss.py
Last active December 23, 2018 21:18
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
@weak_module
class PolicyGradientLoss(nn.Module):
"""
Multiplies an unreduced CrossEntropyLoss by a `q` vector.
"""
@xpe
xpe / numeronym.py
Last active October 7, 2019 18:46
Use this when your phrases need numeronyms!
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 / question.md
Created October 27, 2019 19:54
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
xpe / comment_327243.md
Created October 29, 2019 05:54
Let's retire Lines of Code and just count characters instead!
@xpe
xpe / HTML Broken Link Checkers.md
Last active December 31, 2019 16:57
HTML Broken Link Checkers
@xpe
xpe / hormonal_obesity.txt
Created June 14, 2020 10:01
Insulin & Insulin Resistance : Feedback Loops
ASCII Diagram version of
https://thefastingmethod.com/wp-content/uploads/HOT-Fatty-Liver2.1.jpg
┌────────┐
┌───────────┐ │ high │ ┌───────────┐
│ glucose │────┬────▶│insulin │────┬────▶│ obesity │
└───────────┘ │ └────────┘ │ └───────────┘
│ │
│ ▼
┌────────────┐ ┌─────────────┐
@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 {} +
@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