Skip to content

Instantly share code, notes, and snippets.

View alexrudy's full-sized avatar

Alex Rudy alexrudy

View GitHub Profile
@alexrudy
alexrudy / ipydb.py
Created September 20, 2015 20:17
IPython Debugger
# -*- coding: utf-8 -*-
import sys
import warnings
_ipydb_active = False
def ipydb():
"""Try to use the iPython debugger on program failures."""
global _ipydb_active
@alexrudy
alexrudy / telemetry.rst
Last active November 4, 2015 18:05
Telemetry for ShaneAO Documentation

Telemetry recorder tools.

The interface for the telemetry recorder is only available in the ShaneAO command line interface for now. Please use the box next to the >>> symbol in ShaneAO to enter telemetry commands.

The telemetry recorder will:

  • Only record closed loop telemetry when the system appears settled.
  • Only start once the user calls telemetry.start().
@alexrudy
alexrudy / matplotlib-fonts-osx.md
Last active July 12, 2022 13:16
Adding custom fonts to Matplotlib on OS X

How to add custom (or system) fonts to matplotlib on OS X

Matplotlib expects to find .ttf fonts on your system. Newer versions of OS X use .dfont files. Converting them is easy, and putting them in a proper font path is also easy. The user font path on OS X is ~/Library/Fonts/, and matplotlib will find fonts here.

  1. First, install what you'll need:
  • matplotlib
  • fondu (port install fondu, or brew install fondu)
  1. Then find your desired font file. For system font files, the easiest way to do this is in the FontBook application. You can open FontBook in your utlities folder. Then select your font of choice, right click on it, and select "Show in Finder". You'll need to know where it is. Many system fonts are in places like /System/Library/Fonts/...
  2. Move to your user's font directory ~/Library/Fonts/.
  3. Use fondu to convert the OS-X specific font file (ends with .dfont) to .ttf.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function setup_OSIRIS {
export OSIRIS_ROOT=$1
export OSIRIS_WROOT=${2:-$OSIRIS_ROOT}
# Location of data files
export OSIRIS_DRP_DATA_PATH=$OSIRIS_WROOT/data/
# Set the queue directory for any pipelines started by this user
export DRF_QUEUE_DIR=$OSIRIS_WROOT/drf_queue
def resample_spectrum(source_wavelength, source_spectrum, destination_wavelengths, destination_resolution):
"""Resample a spectrum to a new wavelength grid, possibly degrading the spectrum's resoltuion.
:param source_wavelength: The source wavelength array.
:param source_spectrum: The source spectrum array.
:param destination_wavelengths: The destination wavelength array.
:param destination_resolution: The destination resolution.
:returns: The resampled spectrum.
This function is definitely valid for making a spectrum worse. Doing anything else is questionable.
@alexrudy
alexrudy / things.applescript
Last active July 21, 2017 13:37
Things.app basic CLI
@alexrudy
alexrudy / pushover.py
Last active November 5, 2023 14:45
Send yourself a notification via pushover.
#!/usr/bin/env python
#
# pushover.py
# Send yourself notifications via https://pushover.net
# Just set your pushover user ID to PUSHOVER_USER_ID
# and your application API token to PUSHOVER_API_TOKEN
# then call this script with the message you want to
# send::
#
# $ make test; pushover.py "make test finished!"
@alexrudy
alexrudy / stripkeys.py
Created August 21, 2017 18:57
Quick python command to strip and insert AWS keys into SQL files.
#!/usr/bin/env python
import click
import re
import os
import contextlib
@contextlib.contextmanager
def backup_file(file, mode='w', replace=False):
"""Open a backup file for writing"""