Skip to content

Instantly share code, notes, and snippets.

View jacobtomlinson's full-sized avatar

Jacob Tomlinson jacobtomlinson

View GitHub Profile
@jacobtomlinson
jacobtomlinson / good-timeout.py
Last active July 19, 2021 22:49
Asyncio wait_for can be foiled by blocking code
import asyncio
async def eternity():
await asyncio.sleep(2) # Sleep asynchronously
print("I should've timed out")
async def main():
# Wait for at most 1 second
try:
await asyncio.wait_for(eternity(), timeout=1.0)
@jacobtomlinson
jacobtomlinson / Dask CuPy cuDF Example.ipynb
Created February 11, 2020 16:02
Example of using CuPy and cuDF with Dask CUDA
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jacobtomlinson
jacobtomlinson / 2020-02-03 Azure UCX-Py Testing.ipynb
Last active September 27, 2021 11:06
UCX-Py testing on Azure
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jacobtomlinson
jacobtomlinson / config.yaml
Created January 8, 2020 08:55
Opsdroid Home Assistant example config
## Set the logging level
logging:
level: info
## Show welcome message
welcome-message: true
## Connector modules
connectors:
homeassistant:
@jacobtomlinson
jacobtomlinson / sun.py
Created January 8, 2020 08:30
Opsdroid Home Assistant sun lights
from opsdroid_homeassistant import HassSkill, match_sunrise, match_sunset
class SunriseSkill(HassSkill):
@match_sunset
async def lights_on_at_sunset(self, event):
await self.turn_on("light.outside")
@match_sunrise
@jacobtomlinson
jacobtomlinson / skill.py
Created January 8, 2020 08:25
Opsdroid Home Assistant example
from asyncio import sleep
from opsdroid_homeassistant import HassSkill, match_hass_state_changed
class MotionLights(HassSkill):
@match_hass_state_changed("binary_sensor.drive", state="on")
async def motion_lights(self, event):
"""Turn the outside light on with motion if after sunset."""
if await self.sun_down():
def gpu(doc):
fig = figure(title="GPU Utilization", sizing_mode="stretch_both", x_range=[0, 100])
def get_utilization():
return [
pynvml.nvmlDeviceGetUtilizationRates(gpu_handles[i]).gpu
for i in range(ngpus)
]
gpu = get_utilization()
#!/bin/bash
PATH="/path/to/your/miniconda3/bin:<rest of your path>"
eval "$(conda shell.bash hook)"
conda activate jupyter
cd ~ && /path/to/your/miniconda3/envs/jupyter/bin/python -m jupyter lab --port 8888 --no-browser
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>jupyter-startup</string>
<key>ProgramArguments</key>
<array><string>/path/to/my/jupyter/startup/script.sh</string></array>
<key>RunAtLoad</key>
<true/>
---
layout: default
---
## Getting Started
{{ site.description }}
You can add this repository to your local helm configuration as follows :