Skip to content

Instantly share code, notes, and snippets.



  • Cyberspace
View GitHub Profile
mbarkhau /
Last active Sep 7, 2021 — forked from krisrak/
Python script to download urls in a csv file
import os
import sys
import csv
import urllib
filename = sys.argv[1]
url_name = sys.argv[2]

MAD Bitcoin Energy Savings

Imagine you're a bitcoin miner. You have a huge power bill, you have your capital that is depreciating like a glass of milk in the sunshine, but as long as the price per bitcoin is high and the local government isn't driving you out of the country, things are pretty good. I mean, figuratively speaking, you're printing money.

But think about this for a minute. It's not as if the bitcoin network would work any worse if you and 99% of the mining capacity would turn

# sudo apt-get install xml-twig-tools
rm -rf "$_dest"
mkdir -p "$_dest"
mbarkhau /
Last active Jun 22, 2021
#!/usr/bin/env python3
"""A sublime-text build script, to do the right thing?.
This script takes the currently open file as a
reference point and uses it to determine which commands
to run. This means that you don't have to select a build
commands when switching between projects, the fact that
you have a different file open is enough to indicate
which build you want to run.
mbarkhau /
Last active Sep 6, 2020
# -*- coding: utf-8 -*-
"""Store simple data between multiple executions of a script.
Python2.6+, no external dependencies.
A simple class to store small amounts data between
multiple executions of a script (for one-off scripts).
Copyright: Manuel Barkhau 2020 Dedicated to the public domain.
mbarkhau /
Created Aug 23, 2020
A script to install conda and various python interpreters to use with tox
set -e;
# change this
PLATFORM=$(uname -s)
mbarkhau / notes_on_the_flying_train.txt
Last active Aug 9, 2020
Notes on the video "The Flying Train, Germany, 1902"
View notes_on_the_flying_train.txt
0:22 Arch 34 - Kaiserstrasse, after of station "Bruch" - 51.2342321,7.0766762 -
The building at the left of Arch 41, before the bend onto Göthestraße is still standing
1:04: Arch 47 - Before the bend, looking up to either "Hammerstein" or the north end of "Schrödersbusch".
I don't recognize the house on the hill anywhere today.
1:17: Arch 96 - After station "Sonneborner Straße" - 51.2385451,7.1009054 -
To the right, the three buildings on the are still standing.
mbarkhau /
Created May 24, 2020
A helper script to migrate mercurial repositories to gitlab/github
set -e;
mkdir -p $HOME/workspace
cd $HOME/workspace
if ! [[ -d fast-export ]]; then
mbarkhau /
Last active Jan 20, 2020
Python Exception Reason PSA

I have often read the error message in a stacktrace and then reread it after I realized I was reading the code to produce the error message, rather than the error message itself. Often this will not matter, but if you are using a format string to produce the error message, I recommend putting the string generation on a separate line to the raise of the exception.

Variation 1, we have two lines with the error message/reason string, but only the last line one of them has the expanded format string (it includes 1234567890 which presumably is important).

$ python3 ../ 1
Traceback (most recent call last):
  File "../", line 6, in <module>
    raise Exception(f"My error message with formatting: '{arg}'")
Exception: My error message with formatting: '1234567890'
"""Context manager for coarse grained performance measurement.
with trace("section title"):
ts: 0.104section title
ts: 123.410d: 123.000 ms