Skip to content

Instantly share code, notes, and snippets.

View andrewfowlie's full-sized avatar

Andrew Fowlie andrewfowlie

View GitHub Profile
@miracle2k
miracle2k / odict.py
Created July 26, 2012 20:56
Make PyYAML do very basic things.
"""Make PyYAML output an OrderedDict.
It will do so fine if you use yaml.dump(), but that generates ugly,
non-standard YAML code.
To use yaml.safe_dump(), you need the following.
"""
def represent_odict(dump, tag, mapping, flow_style=None):
"""Like BaseRepresenter.represent_mapping, but does not issue the sort().
@tillahoffmann
tillahoffmann / weighted_kde.ipynb
Last active June 24, 2023 07:39
Weighted kernel density estimation based on `scipy.stats.gaussian_kde`.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jquacinella
jquacinella / violin_weighted_plot.py
Last active February 3, 2023 15:51
Violin Plots for Weighted Data in Matplotlib
import weighted
from matplotlib.cbook import violin_stats
from scipy import stats
import statsmodels.api as sm
def vdensity_with_weights(weights):
''' Outer function allows innder function access to weights. Matplotlib
needs function to take in data and coords, so this seems like only way
to 'pass' custom density function a set of weights '''
@yookoala
yookoala / 90-mac-superdrive.rules
Last active July 24, 2024 16:58
udev rules to use Apple SuperDrive on Linux
#
# Apple SuperDrive initialization rule
#
# See: https://gist.github.com/yookoala/818c1ff057e3d965980b7fd3bf8f77a6
ACTION=="add", ATTRS{idProduct}=="1500", ATTRS{idVendor}=="05ac", DRIVERS=="usb", RUN+="/usr/bin/sg_raw %r/sr%n EA 00 00 00 00 00 01"