Skip to content

Instantly share code, notes, and snippets.

@henryroe
henryroe / talk2subprocess_traitsui.py
Created August 25, 2014 22:40
Demo of launching a traitsui GUI in a separate thread and communicating with it via stdin and stdout
import time
import os
import sys
import pickle
import numpy as np
import subprocess
from threading import Thread
from traits.api import HasTraits, String, Instance, Bool, on_trait_change, Long
from traitsui.api import View, Item, Handler
import psutil
@henryroe
henryroe / bad_idea.py
Created October 3, 2014 00:48
Example of why you shouldn't use a mutable as a default parameter in python
class BadIdea():
def __init__(self, history=[]):
self.history = history
def get_history(self):
return self.history
def append_history(self, input):
self.history.append(input)
@henryroe
henryroe / prepend_and_save.scpt
Created February 14, 2015 12:03
Save mail attachments after pre-pending YYYY-MM-DD_
set outputPath to choose folder
tell application "Mail"
set curMessage to selection
set listAttachments to mail attachment of item 1 of curMessage
set curMessageDate to date received of item 1 of curMessage
set dateStr to (rich text -4 thru -1 of ("0000" & (year of curMessageDate))) & "-" & ¬
(rich text -2 thru -1 of ("00" & ((month of curMessageDate) as integer))) & "-" & ¬
(rich text -2 thru -1 of ("00" & (day of curMessageDate)))
repeat with a from 1 to length of listAttachments
@henryroe
henryroe / Save mail attachments with pre-pended YYYY-MM-DD_.kmmacros
Created February 16, 2015 01:50
Keyboard Maestro macro to take Mail.app attachments, pre-pend YYYY-MM-DD_..., and save to user-selected dir
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>IsActive</key>
<true/>
<key>Macros</key>
@henryroe
henryroe / lessfits
Created July 26, 2016 03:55
lessfits: Command line script for paging through a FITS file's headers
#!/bin/bash
# This script is released under an "MIT License"; see https://opensource.org/licenses/MIT
# The MIT License (MIT)
# Copyright (c) 2016 Henry Roe ([email protected])
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
@henryroe
henryroe / grepfits
Last active July 26, 2016 04:11
grepfits: Command line script for summarizing selected keywords from headers of one or more FITS files
#!/usr/bin/env python
# This script is released under an "MIT License"; see https://opensource.org/licenses/MIT
# The MIT License (MIT)
# Copyright (c) 2016 Henry Roe ([email protected])
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#