Skip to content

Instantly share code, notes, and snippets.

@dfm
dfm / bengp.ipynb
Last active August 29, 2015 14:27
For ben.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dfm
dfm / ruth.ipynb
Created August 21, 2015 13:35
For ruth
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dfm
dfm / .vimrc
Created April 26, 2011 03:28
Python template
" TEMPLATES
function! LoadTemplate()
" load a template based on the file extension
silent! 0r ~/.vim/skel/tmpl.%:e
" Replace some placeholders
%s/%FILENAME%/\=expand("%:t")/g
%s/%DATE%/\=strftime("%b %d, %Y")/g
" This last one deletes the placeholder
@dfm
dfm / gist:1030052
Created June 16, 2011 19:39
dude.. gist it
double any_op(double, double, std::function<double(double,double)>);
int main()
{
std::function<double(double,double)> add = [](double a, double b) -> double { return a+b; };
std::function<double(double,double)> sub = [](double a, double b) -> double { return a-b; };
printf("5 + 10 = %0.2f\n", any_op(5., 10., add));
printf("5 - 10 = %0.2f\n", any_op(5., 10., sub));
@dfm
dfm / gist:1041170
Created June 22, 2011 20:57
For Aukosh
from numpy import array,sin,cos,cov
import numpy.random as random
def obs_to_xyz(obs):
D,th,phi,vr,vth,vphi = tuple(obs)
sth,cth = sin(th),cos(th)
sphi,cphi = sin(phi),cos(phi)
return [D*sth*cphi,
D*sth*sphi,
D*cth,
@dfm
dfm / .screenrc
Created July 3, 2011 15:27
screen1
shelltitle "$ |bash"
@dfm
dfm / .bashrc
Created July 3, 2011 15:29
screen2
# command prompt... HOLY SHIT MAGIC!
case $TERM in
screen*)
SCREENTITLE='\[\ek\e\\\]\[\ek\W\e\\\]'
;;
*)
SCREENTITLE=''
;;
esac
export PS1="${SCREENTITLE}[\u@\h \W]\$ "
@dfm
dfm / a.py
Created July 6, 2011 14:03
circular imports suck!
import b
def foobag(a_number):
return a_number+1
@dfm
dfm / bash
Created July 13, 2011 17:01
Reusing ssh connections
time ssh hostname ls
@dfm
dfm / combine_sdss_fields.py
Created August 10, 2011 19:20
Combine SDSS fields for Dustin
# encoding: utf-8
"""
A function for combining adjacent SDSS fields into one image.
History
-------
2011-08-10 - Created by Dan Foreman-Mackey
"""