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
import pcbnew | |
from dataclasses import dataclass | |
@dataclass | |
class local_pad_representation: | |
pad: object = None | |
footprint: object = None | |
pos: object = None | |
friendly_name: str = None |
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
root = true | |
[*] | |
end_of_line = lf | |
insert_final_newline = true | |
charset = utf-8 | |
indent_style = tab | |
indent_size = 4 |
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 hexdump(buf, size, minor_width=4, major_width=12, addr_len=4, ljust_char='·', unprintable_char='�', indent=''): | |
lines = list() | |
disp = '' | |
hexa = '' | |
row_start = 0 | |
for i, c in zip(range(size), buf): |
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
import time | |
def get_day_minutes(t): | |
s = time.strptime(t, '%H:%M') | |
return s.tm_hour * 60 + s.tm_min | |
def calc_duration(start_time, stop_time): | |
'Returns how many minutes have passed between two times expressed as HH:MM' | |
'Wraps around for midnight' | |
'Does not track DST' |
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
import sys | |
if not 'gunicorn' in sys.argv[0]: | |
import pathlib | |
name = pathlib.Path(sys.argv[0]).stem | |
print('# To test this script:') | |
print(f'gunicorn -w1 -k uvicorn.workers.UvicornWorker {name}:app') | |
sys.exit(1) | |
async def handle_lifespan(scope, receive, send): | |
while True: |
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
import sys, time, subprocess, threading, queue, os, fcntl | |
''' | |
For some reason, even with all the flushing, if python is running buffered (without -u), it will sometimes not flush! | |
Until I can figure this one out I'll use -u | |
Even with -u it sometimes will output stdout and stderr in different order, some buffering somewhere is messing things up. | |
As is this is still a decent tool for watching output that contains ANSI escapes watch -c won't manage. | |
''' |
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/python | |
import sys, os | |
#Usage: https://gist.github.com/devilholk/d1dcbb194086c84915c718d9ccafd95a | |
def combine_args(args): | |
result = list() | |
for a in args: | |
if result and result[-1].endswith('\\'): | |
result[-1] = result[-1][:-1] + ' ' + a |
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
#bashcomp.py: https://gist.github.com/devilholk/b176b9c62c83636eb7552b3629e0b067 | |
_bashcomp() { | |
COMPREPLY=( $(eval `python /path/to/bashcomp.py $COMP_LINE`;) ); | |
return 0; | |
} | |
complete -F _bashcomp my_command |
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 math import log, exp, sqrt | |
cbrt = lambda x: x**(1/3) | |
invert = lambda x: 1/x | |
def solve_steinhart_hart_eq(R1, T1, R2, T2, R3, T3): | |
#Solving the Steinhart-Hart equation | |
#Source: https://en.wikipedia.org/wiki/Steinhart%E2%80%93Hart_equation#Steinhart%E2%80%93Hart_coefficients |
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
#Note that this is not recommended, we may not be able to rely on locals() being mutable on other platforms or future versions | |
#Also note https://stackoverflow.com/questions/29333359/python-class-scoping-rules | |
scope_transfer = dict() | |
class my_namespace: | |
class some_thing: | |
pass |
NewerOlder