Skip to content

Instantly share code, notes, and snippets.

View njvack's full-sized avatar

Nate Vack njvack

View GitHub Profile
@AncientJames
AncientJames / pixelmap.py
Created February 28, 2025 02:14
This is the TPC I used to pixel map the Fibrovisor ( https://www.youtube.com/watch?v=zz59e1wWyVc ). It uses rgbmatrix ( https://github.com/hzeller/rpi-rgb-led-matrix ) to light up one pixel at a time, and opencv to record the position of the brightest spot in the frame.
#!/usr/bin/env python
import time
import sys
import getpass
from rgbmatrix import RGBMatrix, RGBMatrixOptions
import cv2 as cv
options = RGBMatrixOptions()
options.hardware_mapping = 'regular'
@chockenberry
chockenberry / simkill.sh
Last active December 9, 2023 14:04
A simple shell script to reset CoreSimulator
#!/bin/sh
pids=`ps axo pid,command | grep CoreSimulator | grep -v "grep CoreSimulator" | cut -c 1-5`
if [ "$1" = "go" ]; then
kill -9 $pids
elif [ "$1" = "echo" ]; then
echo $pids
else
pid_param=`echo $pids | tr -s ' ' ','`
@stfj
stfj / review parser
Created June 8, 2023 14:36
parses reviews from appfigures
import poplib
import smtplib
from email import message_from_bytes
from email.message import EmailMessage
import openai
import re
import html
openai.api_key = ''
After many failed attempts, I have installed scipy on my M1 MBP! The approach that worked for me was
[similar to this one](https://github.com/scipy/scipy/issues/13409#issuecomment-886939243):
```
pip install cython pybind11 pythran
pip install --no-binary :all: --no-use-pep517 numpy
brew install gfortran openblas
export OPENBLAS=/opt/homebrew/opt/openblas/lib/
pip install --no-binary :all: --no-use-pep517 scipy
```
# pretty sudo prompt
read -r -d '' SUDOPROMPT << EOM
πŸŒΊπŸŒ³πŸŒΈπŸŒ·πŸŒ·πŸŒΈπŸŒ»πŸŒ·πŸŒ·πŸŒΈπŸŒΈπŸŒΈπŸŒΈπŸŒ·πŸŒΌπŸŒ·πŸŒ³πŸŒΊπŸŒΌπŸŒΊπŸŒΈπŸŒ»πŸŒΌπŸŒΌπŸŒ³πŸŒ³πŸŒΌπŸŒΊπŸŒ»πŸŒ·πŸ›πŸŒ·πŸŒΌπŸŒ»πŸŒ³πŸŒΈπŸŒ·πŸŒ·πŸŒ»πŸŒΈ
πŸŒΈπŸ¦‰πŸŒ»πŸŒΈπŸŒ³πŸŒ·πŸŒΈπŸŒ·πŸŒΈπŸŒ³πŸŒΈπŸŒ»πŸŒ³πŸŒπŸŒ»πŸŒ·πŸŒ·πŸŒΌπŸŒ»πŸŒΊπŸŒΊπŸŒ»πŸŒΌπŸŒ»πŸŒ»πŸŒΌπŸŒΊπŸŒ»πŸŒ³πŸŒΌπŸŒ³πŸŒΊπŸŒ³πŸŒ·πŸŒ»πŸŒΌπŸŒ·πŸŒΌπŸŒ»πŸŒΈ
🌳🌸🌻🌺🌻🌳🌺🌺🌻🌺🌸🌻🌷🌷🌼🌻🌺🌼🌻🌻🌷🌳🌻🌸🌳🌷🌻🌳🌳🌳🌳🌼🌳🌳🌺🌷🌳🌺🌳🌺
πŸ¦‰πŸŒΈπŸŒ»πŸŒΊπŸŒΊπŸŒ³πŸŒΈπŸŒΈπŸŒΌπŸŒ»πŸŒΊπŸŒΌπŸŒ·πŸŒΈπŸŒ³πŸŒΌπŸŒΊπŸŒΈπŸŒΊπŸŒ·πŸŒ»πŸŒ·πŸŒΊπŸŒΊπŸŒ³πŸŒ·πŸŒ·πŸ°πŸŒΈπŸŒ»πŸŒ³πŸŒΈπŸŒΌπŸŒ·πŸŒΌπŸŒ³πŸŒ·πŸΉπŸŒΌπŸŒΊ
🌷🌳🌻🌸🌸🌼🐰🌷🌺🌷🌺🌻🌷🌸🌺🌻🌳🌻🌷🌻🌻🌺🌸🌸🌺🌻🌸🌻🌳🌳🌻🐦🌻🌼🌼🌻🌻🌺🌳🐰
πŸŒΌπŸ¦πŸŒ»πŸŒ³πŸŒΈπŸŒΈπŸŒ³πŸŒ·πŸŒΊπŸŒΌπŸŒ³πŸŒ·πŸŒΈπŸŒ»πŸŒΌπŸŒ»πŸ›πŸŒ»πŸŒΌπŸŒ·πŸŒΊπŸŒΌπŸŒΊπŸŒΈπŸŒΊπŸ¦”πŸŒ·πŸŒΈπŸŒ·πŸŒ»πŸŒ»πŸŒΊπŸŒΌπŸŒ·πŸŒπŸŒΈπŸŒ·πŸŒΌπŸŒΈπŸΉ
🌸🌳🌻🌼🌻🌳🌸🌷🌺🌷🌷🌼🌻🌷🌻🌺🌼🌼🌳🌸🌻🌻🌸🌼🌼🌸🌳🌺🌻🌻🌳🌺🌷🐰🌻🌼🐹🌷🌷🌳
🌼🌷🌻🌸🌼🌳🌻🌻🌳🌷🌼🌻🌺🌺🌺🌺🌺🌳🌻🌼🌷🌸🌸🌻🌺🌻🌳🌸🌷🌺🌺🌼🌸🌺🌻🌻🌷🌸🌻🌷
@katef
katef / plot.awk
Last active November 20, 2024 23:27
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
@tammoippen
tammoippen / crappyhist.py
Last active July 13, 2024 15:05
Draw a crappy text-mode histogram of an array (python 3)
import numpy as np
def crappyhist(a, bins=50, width=140):
h, b = np.histogram(a, bins)
for i in range (0, bins):
print('{:12.5f} | {:{width}s} {}'.format(
b[i],
'#'*int(width*h[i]/np.amax(h)),
h[i],
@njvack
njvack / README.md
Last active February 8, 2024 21:43
Color to hex and rgba converter

Simple canvas-based color converter

To answer this StackOverflow question I wrote this β€” a small solution based on a never-rendered <canvas> element. It fills a 1-pixel canvas with the provided fill-style, and then reads the RGBA values of that pixel. It will work with any CSS color -- name, rgba(), hex, or even something more exotic like a gradient or pattern. Invalid colors are always returned as transparent black. Transparent colors are treated as painted on a newly-cleared canvas.

It's been tested in modern-ish versions of IE, Chrome, Safari, and Firefox. The API is:

color_convert.to_hex(color)   # Converts color to a hex-based RGB triple; to_hex('red') returns '#ff0000'
color_convert.to_rgba(color)  # Converts color to an rgba() string; to_rgba('red') returns 'rgba(255,0,0,1)'
@paulirish
paulirish / rAF.js
Last active April 17, 2025 15:06
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik MΓΆller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];