Skip to content

Instantly share code, notes, and snippets.

View basnijholt's full-sized avatar

Bas Nijholt basnijholt

View GitHub Profile
@basnijholt
basnijholt / cache_method_once_dynamically_add.py
Created May 27, 2020 11:07
Dynamically cache a method of an object once
import functools
import random
import time
import types
class A:
def f(self):
time.sleep(1)
return random.random()
@basnijholt
basnijholt / asyncio_zmq_proxy.py
Created May 26, 2020 14:44
zmq.proxy and asyncio
# moddified from https://github.com/booksbyus/zguide/blob/master/examples/Python/asyncio_ioloop/asyncsrv.py
import asyncio
import sys
import zmq
from zmq.asyncio import Context, Poller
# FRONTEND_ADDR = 'tcp://*:5570'
FRONTEND_ADDR = "inproc://frontend"
#!/usr/bin/env python
from collections import Counter
import subprocess
x = subprocess.check_output('qstat -ea'.split())
out = x.decode('utf-8').split('\n')
cols = ['Job ID', 'Username', 'Queue', 'Jobname', 'SessID', 'NDS', 'TSK',
'Required Memory', 'Required Time', 'S', 'Elapsed Time']
@basnijholt
basnijholt / corona-covid19-analysis.ipynb
Created March 29, 2020 14:43
corona-covid19-analysis.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@basnijholt
basnijholt / keyboard-shortcuts-macos.md
Last active March 10, 2020 23:25
macOS keyboard shortcuts I frequently use

Frequently used shortcuts

Spectacle

  • Command + Option + > = next third
  • Command + Option + < = previous third
  • Command + Option + ← = window to left
  • Command + Option + → = window to right
  • Command + Option + N = next screen

Sublime / VS Code

@basnijholt
basnijholt / xarray.ipynb
Created February 12, 2020 12:00
xarray-tutorial-quantum-tinkerer-group-2020-02-12
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@basnijholt
basnijholt / otlog-20200208.txt
Created February 8, 2020 15:20
OTMONITOR log
15:38:19.389684 T80190000 Read-Data Boiler water temperature: 0.00
15:38:19.491478 BC0192819 Read-Ack Boiler water temperature: 40.10
15:38:20.396112 T00120000 Read-Data CH water pressure: 0.00
15:38:20.403928 R80760000 Read-Data DHW pump/valve starts: 0
15:38:20.456327 B40769A90 Read-Ack DHW pump/valve starts: 39568
15:38:20.504185 AF0120000 Unk-DataId CH water pressure: 0.00
15:38:21.493849 T80000200 Read-Data Status: 00000010 00000000
15:38:21.513543 B40000200 Read-Ack Status: 00000010 00000000
15:38:22.512055 T10010600 Write-Data Control setpoint: 6.00
15:38:22.555639 BD0010600 Write-Ack Control setpoint: 6.00
@basnijholt
basnijholt / mpi4py-test.py
Last active December 13, 2019 14:41
testing-mpi4py
from mpi4py.futures import MPIPoolExecutor
def test(x):
import time
time.sleep(1)
return x
if __name__ == '__main__':
with MPIPoolExecutor() as executor:
@basnijholt
basnijholt / homekit-bg-4.css-base64
Created November 19, 2019 12:12
iOS Dark Mode Theme background for Lovelace Home Assistant
background-image: "center / cover no-repeat fixed url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBYRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAHgKADAAQAAAABAAAHgAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+//4ANE9wdGltaXplZCBieSBKUEVHbWluaSAzLjE0LjEyLjcxOTAxNzA2IDB4NjI3Mjg0NDgA/9sAQwAFAgICAgIDAgIDBAMDAwQLBAQEBAUHBQsFCw8PEREQDxAQEhQYFRITFxMICxcdFxgaGxwcHAwOHyEfHSEbHR0c/9sAQwEFBQUHAwcNBwcNHBMQExwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc/8AAEQgHgAeAAwEiAAIRAQMRAf/EABwAAQEBAQEBAQEBAAAAAAAAAAABAgMFBAYHCP/EACQQAQEBAQEAAwEBAQEAAgMAAAABEgIRITFBYYFRcSJCscHw/8QAGwEBAQEBAQEBAQAAAAAAAAAAAAECAwUGBAf/xAAZEQEBAQEBAQAAAAAAAAAAAAAAEQExIQL/2gAMAwEAAhEDEQA/AP8AIIZHpNgACgAAAAvAAAAF6AKoCqAodEyZUURQVQBQAAAUAFBcgCCgtQXKZVQBoUAABQAABQFBegAoADQAoAKCigAAAAAKAAACgKZVUAAAXi9BQAAQAAAAAUAFAAUAFAAAAAXIAosABQAAAAAAAFAUAAQAAAQAEUAAAABQUBAARVUBABGgAFARV5VFRQBBRVRUUaZ0TlQReiioplRU1RFEDlpFZ1RRU1RU5aZ0FBkUBGuKo0zoyoqNCo0yooJ1R
@basnijholt
basnijholt / homekit-bg-3.css-base64
Created November 19, 2019 12:12
iOS Dark Mode Theme background for Lovelace Home Assistant
background-image: "center / cover no-repeat fixed url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBMRXhpZgAATU0AKgAAAAgAAgESAAMAAAABAAEAAIdpAAQAAAABAAAAJgAAAAAAAqACAAQAAAABAAAMiKADAAQAAAABAAAMiAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/+IH6ElDQ19QUk9GSUxFAAEBAAAH2GFwcGwCIAAAbW50clJHQiBYWVogB9kAAgAZAAsAGgALYWNzcEFQUEwAAAAAYXBwbAAAAAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1hcHBsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALZGVzYwAAAQgAAABvZHNjbQAAAXgAAAWcY3BydAAABxQAAAA4d3RwdAAAB0wAAAAUclhZWgAAB2AAAAAUZ1hZWgAAB3QAAAAUYlhZWgAAB4gAAAAUclRSQwAAB5wAAAAOY2hhZAAAB6wAAAAsYlRSQwAAB5wAAAAOZ1RSQwAAB5wAAAAOZGVzYwAAAAAAAAAUR2VuZXJpYyBSR0IgUHJvZmlsZQAAAAAAAAAAAAAAFEdlbmVyaWMgUkdCIFByb2ZpbGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG1sdWMAAAAAAAAAHwAAAAxza1NLAAAAKAAAAYRkYURLAAAALgAAAaxjYUVTAAAAJAAAAdp2aVZOAAAAJAAAAf5wdEJSAAAAJgAAAiJ1a1VBAAAAKgAAAkhmckZVAAAAKAAAAnJodUhVAAAAKAAAApp6aFRXAAAAFgAAAsJuYk5PAAAAJgAAAthjc0NaAAAAIgAAAv5oZUlMAAAAHgAAA