Skip to content

Instantly share code, notes, and snippets.

View slvrfn's full-sized avatar

Cameron White slvrfn

View GitHub Profile
@glnds
glnds / less-cheatsheet.md
Last active November 4, 2024 06:42
Less Cheatsheet

Less Cheatsheet

less {filename}

Navigation
SPACE forward one window
b backward one window
d forward half window
@tliron
tliron / rest.py
Last active August 9, 2024 13:43
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
#!/usr/bin/env python
'''
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
Features:
* Map URI patterns using regular expressions
* Map any/all the HTTP VERBS (GET, PUT, DELETE, POST)
* All responses and payloads are converted to/from JSON for you

np.einsum

I had this gross reshape/tensor product/transpose stuff on huge matrices, and I knew it was making intermediate copies of the matrices that I didn't want to. So I tried out np.einsum, and I think it actually turned out simpler than thinking through the other matrix manipulation.

Here are some quick notes.

Real blogs/documentation

@pclucas14
pclucas14 / conv_einsum.py
Created August 17, 2019 18:44
Convolutions with `as_strided` and `einsum`
class einsum_conv(nn.Module):
def __init__(self, kernel_size, stride=1):
super(einsum_conv, self).__init__()
self.ks = kernel_size
self.stride = stride
def forward(self, x, kernel):
if len(x.size()) == 3:
x = x.unsqueeze(0)
@shigenobuokamoto
shigenobuokamoto / network-mirrored.service
Last active November 14, 2024 12:14
/etc/systemd/system/network-mirrored.service
[Unit]
Wants=network-pre.target
Before=network-pre.target shutdown.target
[Service]
User=root
ExecStart=/bin/sh -ec '\
[ -x /usr/bin/wslinfo ] && [ "$(/usr/bin/wslinfo --networking-mode)" = "mirrored" ] || exit 0;\
echo "\
add chain ip nat WSLPREROUTING { type nat hook prerouting priority dstnat - 1; policy accept; };\