Skip to content

Instantly share code, notes, and snippets.

View routevegetable's full-sized avatar

Lee Marshall routevegetable

  • Berkeley, CA
View GitHub Profile
DISPLAY= socat TCP-LISTEN:1337,crlf,fork exec:"mplayer -vo caca -quiet /home/lmarshall/Downloads/Rick_Astley_-_Never_Gonna_Give_You_Up_dQw4w9WgXcQ.mp4",pty
template<class T>
struct PolyBox {
typedef std::unique_ptr<T> Ptr;
/* Regular constructor */
PolyBox(Ptr&& p): ptr(std::move(p)) {}
/* Copy */
PolyBox(const PolyBox& t) : ptr(Ptr(t.ptr->clone())) {}
PolyBox& operator=(const PolyBox& t) {
def ingest(s):
counts = {}
for c in s:
if not c in counts:
counts[c] = 0
counts[c] += 1
return counts
import math
@routevegetable
routevegetable / origin.sh
Last active July 12, 2022 17:52
ssh things
SOCK_LINK=/tmp/ssh_auth_sock_link
start_ssh_agent() {
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
ln -vsnf $SSH_AUTH_SOCK $SOCK_LINK
}
if [[ $- == *i* ]] && ! [[ -e $SOCK_LINK ]]; then
# Agent socket link doesn't exist - assume agent isn't running
start_ssh_agent
fi
months = [
("January", 3),
("February", 0),
("March", 3),
("April", 2),
("May", 3),
("June", 2),
("July", 3),
("August", 3),
("September", 2),
@routevegetable
routevegetable / xga.spin
Last active March 18, 2022 17:38
Propeller SPIN XGA driver
'VGA Driver by Lee Marshall
CON
_clkmode = XINPUT + PLL16X
_xinfreq = 4_000_000
VAR
long bitmapbase[1536]
byte cog
@routevegetable
routevegetable / source_list.py
Created June 3, 2020 18:36
Extract source file list from GDB
source_list = open("$SOURCE_LIST_FILE", "w")
lines = gdb.execute('info sources', to_string=True).split('\n')
for line in lines:
line = line.strip()
if not line.startswith('/'):
continue
parts = line.split(',')
for part in parts:
source_list.write(part.strip() + '\n')
source_list.close()
get_win_path() {
P=${PWD/\/usr\/lib/\/windows\/system32}
P=${P/\/usr\/bin/\/program files}
P=${P/$HOME/\/Documents and Settings\/$USER}
P=$(echo ${P//\//\\} | tr '[:lower:]' '[:upper:]')
echo "C:$P"
}
export PS1="\$(get_win_path)>"
@routevegetable
routevegetable / asyncratelimiter.js
Last active April 10, 2020 15:53
No idea if this works
function AsyncRateLimiter() {
/* Operation is in progress */
this.doingThing = false;
/* Next operation to do after this one */
this.nextFn = false;
}
AsyncRateLimiter.prototype.submit = function(fn) {
@routevegetable
routevegetable / led-balls.c
Created March 23, 2020 05:39
ws2811 mood lighting
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <stdbool.h>
#include <time.h>