Skip to content

Instantly share code, notes, and snippets.

@abudden
abudden / format_eng.py
Created October 16, 2023 06:06
Engineering format function
import math
def format_eng(number, places=2, force_exponent=None, use_si=False, use_unicode=False, use_latex=False, return_components=False, strip_zeros=True, unit=None, pos_sign=False):
si_lookup = {
24: 'Y', 21: 'Z',
18: 'E', 15: 'P', 12: 'T',
9: 'G', 6: 'M', 3: 'k',
-3: 'm', -6: 'μ', -9: 'n',
-12: 'p', -15: 'f', -18: 'a',
-21: 'z', -24: 'y',
@abudden
abudden / ebayblacklist.js
Last active April 20, 2022 16:14
ebay.co.uk doesn't have a blacklist feature - this tampermonkey script allows me to avoid buying from blacklisted sellers again
// ==UserScript==
// @name Ebay Blacklist
// @namespace https://www.cgtk.co.uk
// @version 0.1
// @description Make it clear when ebay sellers are on a blacklist
// @author A. Budden
// @match https://*.ebay.co.uk/itm/*
// @icon https://www.google.com/s2/favicons?domain=ebay.co.uk
// @grant none
// ==/UserScript==
@abudden
abudden / Dockerfile
Last active March 1, 2020 11:22
gcc-avr compile issue
FROM ubuntu:18.04
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -sf /bin/true /sbin/initctl
ENV DEBIAN_FRONTEND noninteractive
RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get -y install \
make \
@abudden
abudden / weldingtrolley_error.py
Created November 27, 2019 07:25
cadquery model of a welding trolley, with error lines included.
#!/usr/bin/python3
# vim: set fileencoding=utf-8 :
import itertools
import cadquery as cq
def exportStep(object_list, filename):
"""
Simple worker function to take a list of objects and export a single step file with all objects in place.
"""
vals = list(itertools.chain(*[o.vals() for obj in object_list for o in obj.all()]))
@abudden
abudden / weldingtrolley.py
Created November 26, 2019 16:55
cadquery model of a welding trolley
#!/usr/bin/python3
# vim: set fileencoding=utf-8 :
import itertools
import cadquery as cq
def exportStep(object_list, filename):
"""
Simple worker function to take a list of objects and export a single step file with all objects in place.
"""
vals = list(itertools.chain(*[o.vals() for obj in object_list for o in obj.all()]))