Skip to content

Instantly share code, notes, and snippets.

View basnijholt's full-sized avatar
💭
Obsessing over local AI and NixOS

Bas Nijholt basnijholt

💭
Obsessing over local AI and NixOS
View GitHub Profile
@basnijholt
basnijholt / pymc3-Hello-World.ipynb
Created December 17, 2020 12:00
pymc3-Hello-World.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import ipywidgets as widgets
class SelectMultipleInteract(widgets.HBox):
def __init__(self, combos, **plot_kwargs):
self.W1 = widgets.SelectMultiple(
options={str(x): x for x in combos},
description="Combinations",
disabled=False,
)
@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: