Skip to content

Instantly share code, notes, and snippets.

View nathanielatom's full-sized avatar

Adam Suban-Loewen nathanielatom

View GitHub Profile
@jdtsmith
jdtsmith / chain.py
Last active February 21, 2023 07:38
IPython chained exception debugging
""" %chain - IPython magic to inspect and move along exception chains.
JD Smith (2022)
Chained exceptions are associated with the messages:
"During handling of the above exception, another exception occurred"
"The above exception was the direct cause of the following exception"
and post-mortem debugging (%debug) by default can only examine the
@ArtemGr
ArtemGr / .gitignore
Last active November 2, 2022 10:59
llog
/__pycache__
/llog
@david-macleod
david-macleod / bokeh_audio_player.py
Last active February 18, 2023 17:39 — forked from nathanielatom/bokeh_audio_player.py
Custom Bokeh Model for audio playback (not so useful on its own; meant to be integrated with plot interactions).
# Forked from nathanielatom, updated to work with typescript and bokeh==1.3.4
from bokeh.layouts import column, layout
from bokeh.models import CustomJS, Model, LayoutDOM
from bokeh.document import Document
from bokeh.models.widgets import Button, Slider, Toggle
from bokeh.core.properties import Instance, String
from bokeh.io import save, output_file, show
from bokeh.util.compiler import TypeScript
from fontawesome.fontawesome_icon import FontAwesomeIcon as Icon
# Requires https://github.com/bokeh/bokeh/tree/master/examples/custom/font-awesome
# gradients based on http://bsou.io/posts/color-gradients-with-python
def hex_to_RGB(hex):
''' "#FFFFFF" -> [255,255,255] '''
# Pass 16 to the integer function for change of base
return [int(hex[i:i+2], 16) for i in range(1,6,2)]
def RGB_to_hex(RGB):
''' [255,255,255] -> "#FFFFFF" '''
@tonyfast
tonyfast / doc.js
Created February 22, 2016 17:29
Accessing Bokeh documents in BokehJS
bkdoc = Bokeh._.values( Bokeh.index )[0].model.document
$ cat fix-dropbox.sh
#!/bin/bash
# XXX: use at your own risk - do not run without understanding this first!
exit 1
# safety directory
BACKUP='/tmp/fix-dropbox/'
# TODO: detect or pick manually...
@perrygeo
perrygeo / normalize_numpy.py
Created January 11, 2013 17:10
Normalize a 2D numpy array so that each "column" is on the same scale (Linear stretch from lowest value = 0 to highest value = 100)
import numpy as np
rawpoints = np.array(
[[2500, 0.15, 12],
[1200, 0.65, 20],
[6200, 0.35, 19]]
)
# Scale the rawpoints array so that each "column" is
# normalized to the same scale
@endolith
endolith / A_weighting.py
Last active March 15, 2024 07:12
A-weighting audio files in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Translated from a MATLAB script (which also includes C-weighting, octave
and one-third-octave digital filters).
Author: Christophe Couvreur, Faculte Polytechnique de Mons (Belgium)
couvreur@thor.fpms.ac.be
Last modification: Aug. 20, 1997, 10:00am.
BSD license