Skip to content

Instantly share code, notes, and snippets.

View rldotai's full-sized avatar

Brendan Bennett rldotai

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cube-drone
cube-drone / automation.md
Last active August 7, 2024 10:34
Automation For The People

Automation for the People

Long ago, the first time I read "The Pragmatic Programmer", I read some advice that really stuck with me.

"Don't Use Manual Procedures".

This in the chapter on Ubiquitous Automation. To summarize, they want you to automate all the things.

The trouble was that I hadn't much of an idea how to actually go

@reywood
reywood / how-to.md
Last active October 28, 2024 21:10
How to get a stack trace from a stuck/hanging python script

How to get a stack trace for each thread in a running python script

Sometimes a python script will simply hang forever with no indication of where things went wrong. Perhaps it's polling a service that will never return a value that allows the program to move forward. Here's a way to see where the program is currently stuck.

Install gdb and pyrasite

Install gdb.

# Redhat, CentOS, etc
@jwhendy
jwhendy / set_opencv_webcam.py
Last active July 27, 2024 02:48
An example of setting webcam settings via v4l2-ctl in a python script. Some of the CAP_* settings in opencv didn't seem to work.
import cv2
import subprocess
### for reference, the output of v4l2-ctl -d /dev/video1 -l (helpful for min/max/defaults)
# brightness (int) : min=0 max=255 step=1 default=128 value=128
# contrast (int) : min=0 max=255 step=1 default=128 value=128
# saturation (int) : min=0 max=255 step=1 default=128 value=128
# white_balance_temperature_auto (bool) : default=1 value=1
# gain (int) : min=0 max=255 step=1 default=0 value=0
# power_line_frequency (menu) : min=0 max=2 default=2 value=2
@rldotai
rldotai / convenient_sort.py
Created February 5, 2018 04:04
A slightly more convenient alternative to the builtin `sorted()` which allows you to specify a key as something other than a function.
"""
A slightly more convenient alternative to the builtin `sorted()` which allows
you to specify a key as something other than a function.
For example, with a list of lists, if you wanted to sort by the last element you
could use `sort(lstseq, key=-1)` rather than `sorted(lstseq, key=lambda x: x[-1])`.
If your key *is* a function, it behaves identically to `sorted()`, because it is
really just wrapping the builtin.
Examples
--------
@druska
druska / engine.c
Created September 17, 2018 15:18
Quant Cup 1's winning order book implementation
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list
@rldotai
rldotai / comfy.py
Last active July 31, 2020 22:57
Common packages and utility functions that I find helpful
"""Setting up the local environment."""
import itertools
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from functools import reduce
@willmcgugan
willmcgugan / calculator.css
Created August 30, 2022 15:16
Textual calculator example
Screen {
overflow: auto;
}
#calculator {
layout: table;
table-size: 4;
table-gutter: 1 2;
table-columns: 1fr;
table-rows: 2fr 1fr 1fr 1fr 1fr 1fr;