Skip to content

Instantly share code, notes, and snippets.

View ulope's full-sized avatar

Ulrich Petri ulope

View GitHub Profile
@ulope
ulope / ._ brew update upgrade fix.md
Last active January 18, 2023 15:09
homebrew: make update accept formula names

homebrew: make update accept formula names

Homebrew has two commands with similar names - update and upgrade. Update is intended to update brew itself while upgrade is used to update individual formula.

This division is confusing to some.

Therefore here are shell functions for bash and zsh that reroute update to upgrade if a formula name is given.

Attaching to geth-goerli_geth_1
INFO [09-07|07:59:30.638] Starting Geth on Görli testnet...
INFO [09-07|07:59:30.639] Enabling metrics collection
INFO [09-07|07:59:30.639] Enabling stand-alone metrics HTTP endpoint address=0.0.0.0:9191
INFO [09-07|07:59:30.639] Starting metrics server addr=http://0.0.0.0:9191/debug/metrics
INFO [09-07|07:59:30.642] Maximum peer count ETH=50 LES=0 total=50
INFO [09-07|07:59:30.644] Smartcard socket not found, disabling err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [09-07|07:59:30.649] Set global gas cap cap=50,000,000
INFO [09-07|07:59:30.652] Allocated trie memory caches clean=154.00MiB dirty=256.00MiB
INFO [09-07|07:59:30.652] Allocated cache and file handles database=/root/.ethereum/geth/chaindata cache=512.00MiB handles=524,288
@ulope
ulope / _.js
Created September 6, 2021 14:45
Export Wahl-O-Mat
(function() {
let result = [
'These;Auswahl;Gewichtet'
];
for (let i = 0; i < WOMT_nThesen; i++) {
result.push([WOM.getThesis(i, false), S_aThesen[i], S_aThemen[i]].join(';'))
};
return result.join('\n');
})()
@ulope
ulope / README.md
Last active September 2, 2021 13:07
asyncio's `create_datagram_socket` seems to leak socket objects

asyncio's create_datagram_socket seems to leak socket objects when Protocol instances go out of scope. The same is not the case with regular socket objects.

Usage:

  • Run this (optional pass the open file limit as positional argument, defaut: 256)
  • In another terminal run watch 'lsof -p <pid> | grep UDP | wc -l'
  • Observe that the number stays at 50 during the sync run
  • In the async run the number will increase until a "Too many open files" exception is raised
@ulope
ulope / pythonz_shellrc.sh
Created July 13, 2020 13:27
Pythonz shell RC config for macOS
if [ ! -f /tmp/brew-prefix ]; then
echo -n $(brew --prefix) > /tmp/brew-prefix
fi
if [ ! -f /tmp/brew-prefix-openssl ]; then
echo -n $(brew --prefix openssl) > /tmp/brew-prefix-openssl
fi
if [ ! -f /tmp/brew-prefix-readline ]; then
echo -n $(brew --prefix readline) > /tmp/brew-prefix-readline
@ulope
ulope / poetry-wrapper.zsh
Created April 13, 2019 15:48
Poetry Python version wrapper (ZSH)
# This helps run a globally installed poetry with specific versions of python.
# When run from inside a poetry project the correct version is automatically
# picked up from pyproject.toml.
# Outside of a project (e.g. `poetry new`) a specific version can be chosen by
# setting a `PYTHON` env variable.
# e.g.:
#
# PYTHON=3.7 poetry new someproject
# This causes Python to crash with
# `SystemError: Objects/tupleobject.c:851: bad argument to internal function`
# within a few hundered iterations at most. Typically only a handful are needed though.
# Most likely reason is: https://bugs.python.org/issue15108
from io import StringIO
import gevent
@ulope
ulope / 0xf1e.out
Created October 26, 2018 09:34
Nonce transitions for 0xf1e and 0xf2f. Script courtesy auf Paul.
Replaying state changes 22578
>>> 153 ActionInitTarget
Events: ['SendProcessed', 'SendSecretRequest']
Updated partner nonce None -> 1
>>> 157 ReceiveUnlock
Events: ['SendProcessed', 'EventPaymentReceivedSuccess', 'EventUnlockClaimSuccess', 'SendProcessed']
Updated partner nonce 1 -> 2
>>> 162 ActionInitTarget
Events: ['SendProcessed', 'SendSecretRequest']
Updated partner nonce 2 -> 3
@ulope
ulope / 01_implicit_chaining.py
Last active April 13, 2021 14:15
Python exception chaining
def implicit_chaining():
"""
This is the Python 2 style. Just raising another exception from within an except block.
In Python 3 this causes the exceptions to be chained with the message:
During handling of the above exception, another exception occurred:
Which is usually not correct when just re-raising with a more appropriate type.
"""
try:
@ulope
ulope / print_stack.py
Created June 8, 2018 18:10
traceback.print_stack() but with locals
import sys
from traceback import print_list, StackSummary, walk_stack
def print_stack(f=None, limit=None, file=None):
""" Just like `traceback.print_stack()` but shows locals of each frame. """
if f is None:
f = sys._getframe().f_back
stack = StackSummary.extract(walk_stack(f), limit=limit, capture_locals=True)
stack.reverse()