View rearrangewrapper.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from einops import rearrange as _rearrange | |
class RearrangeWrapper(): | |
"wrapper to endow einops.rearrange with an 'inverse' operation" | |
def __init__(self): | |
self.shape, self.s = None, None # just in case someone tries to call inverse first | |
def __call__(self, x, s:str, **kwargs): # this 'forward' call is lightweight to preserve original usage | |
self.shape, self.s = x.shape, s | |
return _rearrange(x, s, **kwargs) |
View magic_mult.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def magic_mult(a, b): | |
""" | |
Tries to multiply two arrays/matrices in a variety of ways | |
Returns all possible working combos as a dict, with the shapes of their respective outputs | |
Author: Scott H. Hawley, @drscotthawley | |
""" | |
combos = ['a*b', 'a*b.T', 'a.T*b', 'a.T*b.T','b*a', 'b*a.T', 'b.T*a', 'b.T*a.T'] # elementwise multiplications | |
combos += [s.replace('*',' @ ') for s in combos] # matrix multiplications (I like the space here) | |
working_combos = {} | |
for s in combos: |
View usagebot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
""" | |
SLURM usage tracker Discord bot by drscotthawley & rom1504 | |
Requires external file token_channel.csv to connect to Discord | |
Syntax of that file should be: | |
token,channel | |
<DISCORD_BOT_TOKEN>,<CHANNEL_ID> |
View Tabular_Spotify.drawio.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View webcam_nerverot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Do violence to the Logitech C920s webcam settings in realtime | |
# To annoy your Zoom-mates by constantly changing the image | |
from pynput.keyboard import Listener | |
import os, sys | |
import random | |
import time |
View kfold_swap.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In case you didn't think to add k-fold cross-validation until late in your | |
# ML project,... | |
# This is built for a situation where datasets are arrays of, say, images. | |
def kfold_swap(train_X, train_Y, val_X, val_Y, k): | |
""" | |
Swaps val with a section of train, given a value for k | |
"Duct tape" approach used to "retro-fit" k-fold cross-validation while minimally | |
disturbing the rest of the code, while avoiding reloading data from disk and | |
keeping RAM use manageable. (e.g. np.append() is bad b/c it would copy all of train) |
View beeman_gpu_pendula.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
''' | |
Simulation of a 'magnetic' pendulum. Actually we'll just use | |
electrostatic charges instead of magnets, but..good enough, right? | |
Plots an image showing which source the object is closest to after a certain time | |
(Note: Depending on params like maxiter, the object may still be moving at the | |
end of the simulation, so the 'ending position' may not be where it comes to rest.) | |
This code integrates all the (non-interacting) test objects at once, on the GPU. |
View newpost.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# Little script I use to start a new Markdown blog entry. | |
# Run from the parent directory above the blog directory, | |
# or supply a full path to run from anywhere. | |
# | |
# Usage: newpost.py <title> | |
# It automatically figures out what the current date is to | |
# create a new entry, and supplies a default header with a title | |
# and a bibliography placement |
View grpc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/lib/gpr/log_linux.cc b/src/core/lib/gpr/log_linux.cc | |
index 561276f0c2..1af0935e1f 100644 | |
--- a/src/core/lib/gpr/log_linux.cc | |
+++ b/src/core/lib/gpr/log_linux.cc | |
@@ -40,7 +40,7 @@ | |
#include <time.h> | |
#include <unistd.h> | |
-static long gettid(void) { return syscall(__NR_gettid); } | |
+static long sys_gettid(void) { return syscall(__NR_sys_gettid); } |
View inst_freq.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# Test script for Phase 'Unrolling' / Instantaneous frequency | |
# | |
# See Jesse Engel's "rainbowgrams" script, https://gist.github.com/jesseengel/e223622e255bd5b8c9130407397a0494 | |
# | |
# Modifications by Scott H. Hawley, @drscotthawley and Billy Mitchell | |
# These modified versions seem to be both more accurate (~2000x less reconstruction error) | |
# and faster (>20%) | |
# | |
# note, to really see/hear the difference, change dtypes to np.float16! |
NewerOlder