Skip to content

Instantly share code, notes, and snippets.

from bs4 import BeautifulSoup
from requests import Session
import csv
def ref(head):
return '%s%d' % (chr(ord('A') + theads.index(head)), irow)
sess = Session()
theads = ('Breed Name', 'Tested', 'Passed', 'Failed', 'Percent')
@reinderien
reinderien / particle math.txt
Created December 21, 2017 16:05
Particle Math (Advent 2017 20.1)
2
min[lim t→∞ ∑ | p_i + ∫v_i dt + ∫∫a_i dt |
i=0
2
~ min[ ∑ |a_i| ]
i=0
@reinderien
reinderien / pfsense-11_1-openconnect.md
Last active January 26, 2018 21:21
pfSense 11.1 with OpenConnect
@reinderien
reinderien / insanity.md
Created August 15, 2019 03:50
xlsxwriter and insane units

Welcome to the descent into madness that is Excel units.

xlsxwriter has this lovely nugget that, unless you really care about exact column widths, you probably never had the urge to look up:

# Convert column width from user units to character width.
# For Calabri 11.
max_digit_width = 7
@reinderien
reinderien / kwartzlab-electronics.md
Last active January 27, 2020 15:19
KwartzLab Electronic Session with Greg

What?

This is a handful of sessions to learn various subjects in electronics, including component selection, mains safety, a little bit of embedded design and programming, prototyping, and CAD. It will be done by making a simple clock with easy-to-manipulate through-hole parts.

These sessions are to be run separately from Ryan's KiCad session because this has a different focus - electronics basics - and uses a different CAD program, Eagle, because it's what I'm familiar with. All software used is free.

Attendees are to bring their laptop, note-taking material, and a calculator if they have one. (Math will not exceed the elementary school level.) Grid paper is recommended but not necessary. Bring $20.00 in total (not per session) to cover the cost of parts. If the attendee elects to purchase fabrication, that cost will be separate.

In the lab we will be using oscilloscopes, power supplies, multimeters and prototyping parts brought in for this project.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from _decimal import Decimal
from dataclasses import dataclass
from locale import currency, setlocale, LC_ALL
from sys import stdout
from typing import Collection
TAX = Decimal(0.15)
@dataclass
from abc import ABC, abstractmethod
from contextlib import contextmanager
from dataclasses import dataclass
from os import path
from pathlib import Path
from typing import List, Dict, Optional, Any
from urllib.parse import urljoin
from bs4 import BeautifulSoup, SoupStrainer
@reinderien
reinderien / demo.py
Created May 7, 2022 15:56
Generators close context managers
class SomeCtx:
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
print('I exited')
"""
Based on https://stackoverflow.com/questions/76647505
"""
import pandas as pd
import pulp
data = {
'Product': ('Product 1', 'Product 2', 'Product 3', 'Product 4',
'Product 1', 'Product 2', 'Product 3', 'Product 4',