Skip to content

Instantly share code, notes, and snippets.

@embray
embray / 01-numpy.py
Created August 12, 2014 14:27
IPython notebook from https://github.com/swcarpentry/bc/blob/master/novice/python/01-numpy.ipynb converted to Python module with nbconvert
# coding: utf-8
### Analyzing Patient Data
# We are studying inflammation in patients who have been given a new treatment for arthritis,
# and need to analyze the first dozen data sets.
# The data sets are stored in [comma-separated values](../../gloss.html#comma-separeted-values) (CSV) format:
# each row holds information for a single patient,
# and the columns represent successive days.
# The first few rows of our first file look like this:
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.
@embray
embray / gist:3dc1dcb0d264bce912fb
Created October 1, 2014 17:20
That time I reimplemented/replaced the raw_input builtin so I could log stdin.
PY3K = sys.version_info[:2] >= (3, 0)
# The global_logging system replaces the raw_input builtin (input on Python 3)
# for two reasons:
#
# 1) It's the easiest way to capture the raw_input prompt and subsequent user
# input to the log.
#
# 2) On Python 2.x raw_input() does not play nicely with GUI toolkits if
# sys.stdout has been replaced by a non-file object (as global_logging
# does). The default raw_input() implementation first checks that
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Mock Version: 1.1.41
ENTER do(['bash', '--login', '-c', 'rpmbuild -bs --target i686 --nodeps builddir/build/SPECS/python-astropy.spec'], False, '/var/lib/mock/fedora-21-i386/root/', None, 0, True, False, 1000, 135, None, False, {'LANG': 'es_ES.utf8', 'TERM': 'vt100', 'SHELL': '/bin/bash', 'CCACHE_DIR': '/tmp/ccache', 'HOSTNAME': 'mock', 'PROMPT_COMMAND': 'echo -n "<mock-chroot>"', 'HOME': '/builddir', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'CCACHE_UMASK': '002'}, logger=<mockbuild.trace_decorator.getLog object at 0x13f9750>)
Executing command: ['bash', '--login', '-c', 'rpmbuild -bs --target i686 --nodeps builddir/build/SPECS/python-astropy.spec'] with env {'LANG': 'es_ES.utf8', 'TERM': 'vt100', 'SHELL': '/bin/bash', 'CCACHE_DIR': '/tmp/ccache', 'HOSTNAME': 'mock', 'PROMPT_COMMAND': 'echo -n "<mock-chroot>"', 'HOME': '/builddir', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'CCACHE_UMASK': '002'}
Construyendo las plataformas de destino: i686
Construyendo para el destino i686
Escrito: /builddir/build/SRPMS/pytho
<HTML>
<TITLE>WebNow 6</TITLE>
<META CONTENT="0" HTTP-EQUIV="expires">
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<LINK href="favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
</HEAD>
<BODY leftmargin="0" marginheight="0" marginwidth="0" style="overflow-x:hidden;overflow-y:hidden" topmargin="0">
<SCRIPT LANGUAGE="JavaScript1.1">document.write('<APPLET archive="webnowapplet.jar" code="com.imagenow.webnow.applet.WebNow" height="100%" width="100%"><PARAM NAME="code" VALUE="com.imagenow.webnow.applet.WebNow"><PARAM NAME="java_version" VALUE="1.6* 1.7*"><PARAM NAME="archive" VALUE="webnowapplet.jar,lang.jar,TimingFramework-1.0.jar,jxlayer.jar,l2fprod-common-all.jar,icebrowser.jar,jniwrap-3.8.4.jar,comfyj-2.10.jar,winpack-3.8.4.jar,slf4j-api-1.5.8.jar,slf4j-simple-1.5.8.jar"><PARAM NAME="cache_archive" VALUE="webnowapplet.jar,lang.jar,TimingFramework-1.0.jar,jxlayer.jar,l2fprod-common-all.jar,icebrowser.jar,jniwrap-3.8.4.jar,comfyj-2.10.jar,winpack-3.8.4.jar,slf4j-api
@embray
embray / setup.cfg
Created September 2, 2011 19:29
A d2to1 example of setup_hooks and pre/post command hooks
$ ./setup.py build
Setting up testproj
running build
running pre_hook testproj.pre_build_hook for command build
Someone is building my project!
running build_py
running post_hook testproj.post_build_hook for command build
Someone built my project!
@embray
embray / long_comment.ipynb
Created December 7, 2012 18:12
update_card_with_long_comment() PyFITS example
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.