Skip to content

Instantly share code, notes, and snippets.

View tacaswell's full-sized avatar

Thomas A Caswell tacaswell

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tacaswell
tacaswell / handler_xoffset.py
Created August 2, 2013 02:47
Line2D handler which lets you tweak the x location of the markers.
from matplotlib.legend_handler import HandlerLine2D
class HandlerXoffset(HandlerLine2D):
def __init__(self, marker_pad=0.3, numpoints=1, x_offset=0, **kw):
HandlerLine2D.__init__(self, marker_pad=marker_pad, numpoints=numpoints, **kw)
self._xoffset = x_offset
def get_xdata(self, legend, xdescent, ydescent, width, height, fontsize):
numpoints = self.get_numpoints(legend)
if numpoints > 1:
@tacaswell
tacaswell / hough.py
Last active December 21, 2015 03:29
Tweaked version of code at http://mail.scipy.org/pipermail/scipy-user/attachments/20060803/ad246212/attachment.py with minor bug fix and improved documentation.
## Copyright (C) 2006 Stefan van der Walt <stefan@sun.ac.za>
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are
## met:
##
## 1. Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## 2. Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in
@tacaswell
tacaswell / annotate_range.py
Created August 26, 2013 01:45
gist for working on annotation range function
def add_range_annotation(ax, start, end, txt_str, y_height=.5, txt_kwargs=None, arrow_kwargs=None):
"""
Adds horizontal arrow annotation with text in the middle
Parameters
----------
ax : matplotlib.Axes
The axes to draw to
start : float
@tacaswell
tacaswell / snippits.el
Created October 5, 2013 19:22
useful elisp
(defun tac-python-header ()
(interactive "*")
(occur "^\\s-*\\(\\(class\\)\\|\\(def\\)\\)\\|\\(@\\)")
)
(define-skeleton py-np-def
"Skeleton for function definition that includes numppydoc style "
"Name: "
"def " str "(" ("Parameter, %s: " (unless (equal ?\( (char-before)) ", ")
str) "):" \n
from ophyd import SimDetector
from ophyd.areadetector.plugins import ProcessPlugin, TIFFPlugin
from ophyd.areadetector.filestore_mixins import FileStoreBase
from ophyd.areadetector.trigger_mixins import SingleTrigger
from ophyd.device import (Component as C)
prefix = 'XF:31IDA-BI{Cam:Tbl}'
class LocalTiff(TIFFPlugin, FileStoreBase):
pass
tcaswell@xf23id1-srv2:~/bnl_source/conda-prescriptions$ conda create -n dl_test matplotlib=1.3.1
Fetching package metadata: /home/tcaswell/mc3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py:266: SubjectAltNameWarning: Certificate for pergamon.cs.nsls2.local has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
SubjectAltNameWarning
....
Solving package specifications: ....................
Package plan for installation in environment /home/tcaswell/mc3/envs/dl_test:
The following packages will be downloaded:
package | build
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tacaswell
tacaswell / install-mongodb.sh
Created April 29, 2016 13:17 — forked from w0rldart/install-mongodb.sh
Installing MongoDB on Ubuntu 15.04
#!/bin/sh
##
## Bash install script for mongo 3.2 for Ubuntu 15.04, because of
## the replacement of upstart with systemd
##
## - AUTHOR: Alexandru Budurovici <https://w0rldart.com>
## - VERSION: 1.0
##
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.