Skip to content

Instantly share code, notes, and snippets.

Jacob Tomlinson jacobtomlinson

Block or report user

Report or block jacobtomlinson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jacobtomlinson
jacobtomlinson / good-timeout.py
Last active Feb 18, 2020
Asyncio wait_for can be foiled by blocking code
View good-timeout.py
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 Feb 11, 2020
Example of using CuPy and cuDF with Dask CUDA
View Dask CuPy cuDF Example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View 2020-02-03 Azure UCX-Py Testing.ipynb
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 Jan 8, 2020
Opsdroid Home Assistant example config
View config.yaml
## Set the logging level
logging:
level: info
## Show welcome message
welcome-message: true
## Connector modules
connectors:
homeassistant:
@jacobtomlinson
jacobtomlinson / sun.py
Created Jan 8, 2020
Opsdroid Home Assistant sun lights
View sun.py
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 Jan 8, 2020
Opsdroid Home Assistant example
View skill.py
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():
View nvdashboard_example.py
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()
View startup.sh
#!/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
View jupyter.plist
<?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/>
You can’t perform that action at this time.