Skip to content

Instantly share code, notes, and snippets.

@joezuntz
joezuntz / debug_checklist
Last active December 18, 2015 15:29
Debugging Checklist
1. make clean; make; run
2. check version control for changes you forgot you made
3. check exact command being run
4. check outputs are actually new
5. check inputs are actually what you expect. make plots
6. gdb --args "run_program with_args"
run
7. valgrind run_program with_args
@joezuntz
joezuntz / showpy
Created November 28, 2013 11:45
Short script to open a named python module in your EDITOR
#!/usr/bin/env python
import sys
import imp
import os
def edit_module(module_name):
path = imp.find_module(module_name)[1]
editor = os.environ.get("EDITOR", "emacs -nw")
cmd = "{0} {1}".format(editor, path)
os.system(cmd)
@joezuntz
joezuntz / i3table.py
Last active December 31, 2015 03:48
Example of Table subclass helper for astropy. Uses our I3Table as an example.
import astropy.io.fits
import astropy.table
import astropy.io.registry
class I3Table(astropy.table.Table):
""" Im3shape table class. Same as a standard table except it supports
attribute style column access ("table.e1") and does not try to print itself
out when repr'd interactively.
"""
@joezuntz
joezuntz / plot_im3shape_truth.py
Last active August 29, 2015 13:59
My script for plotting im3shape versus truth in the end-end test
import astropy.table
import numpy as np
import pylab
# Filenames
im3shape_cat = 'im3shape-end2end-v3.fits.gz'
truth_cat = 'end2end-truth.fits.gz'
match_cat = 'match.fits.gz'
#Load in data
@joezuntz
joezuntz / ascii_hist
Created September 29, 2014 13:52
Plot a numpy histogram vertically in text
import numpy as np
def ascii_hist(x, bins):
N,X = np.histogram(x, bins=bins)
total = 1.0*len(x)
width = 50
nmax = N.max()
for (xi, n) in zip(X,N):
bar = '#'*int(n*1.0*width/nmax)
@joezuntz
joezuntz / gist:4c791f9592d1798577da
Created November 14, 2014 14:12
Bayes Lecture 1 Medium Question Answer
{
"metadata": {
"kernelspec": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"display_name": "IPython (Python 2)",
"language": "python",
"name": "python2"
@joezuntz
joezuntz / lmc_cepheids.txt
Created December 4, 2014 12:58
LMC Cepheids
#ID w_magnitude log10_period
OGLE-LMC-CEP-0002 14.525 0.493892755239
OGLE-LMC-CEP-0005 13.4954 0.749122158504
OGLE-LMC-CEP-0012 14.5421 0.424912362695
OGLE-LMC-CEP-0016 12.033 1.02145626261
OGLE-LMC-CEP-0017 14.34215 0.565523888876
OGLE-LMC-CEP-0018 13.93705 0.60722468956
OGLE-LMC-CEP-0021 13.53005 0.737031510245
OGLE-LMC-CEP-0023 15.21055 0.23091500128
OGLE-LMC-CEP-0025 14.0813 0.5721161324
@joezuntz
joezuntz / extragalactic_cepheids.txt
Created December 4, 2014 13:00
Extragalactic Cepheids
#Cepheid Galaxy z log10_period w_magnitude
C5 NGC925 0.001845 1.686 20.7351
C6 NGC925 0.001845 1.635 21.887
C7 NGC925 0.001845 1.624 22.2274
C8 NGC925 0.001845 1.572 22.16795
C9 NGC925 0.001845 1.545 22.4966
C10 NGC925 0.001845 1.514 22.0534
C11 NGC925 0.001845 1.496 22.5698
C12 NGC925 0.001845 1.493 22.40305
C13 NGC925 0.001845 1.483 21.9409
@joezuntz
joezuntz / wz_distance_modulus
Created December 5, 2014 12:04
Distance Modulus w0+wz
{
"metadata": {
"kernelspec": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"display_name": "IPython (Python 2)",
"language": "python",
"name": "python2"
@joezuntz
joezuntz / notes.md
Last active September 29, 2020 09:19
Notes on linking (work in progress)

Fixing problems when compiling programs

Most of us in science learn to write and build computer program in an ad-hoc way, copying bits of Makefile from other people, and using trial and error to change things.

That's fine when everything works, but when stuff starts to go wrong it's useful to have an idea of what different steps are happening during compilation, so you can figure out what's going wrong. In this post I'll talk at a a fairly high level about what happens when you compile code, and in a bit more detail about fixing problems you might see when you doing so.

Interpreted vs Compiled