Skip to content

Instantly share code, notes, and snippets.

View mattfoster's full-sized avatar

Matt Foster mattfoster

View GitHub Profile
@mattfoster
mattfoster / numpy_pil.py
Created August 11, 2008 12:39
Methods for converting between numpy arrays and PIL images. Very useful
import numpy, Image
i = Image.open('lena.jpg')
a = numpy.asarray(i) # a is readonly
i = Image.fromarray(a)
\setlength{\oddsidemargin}{1.4cm}
\setlength{\evensidemargin}{1.4cm}
\setlength{\textwidth}{15cm}
\setlength{\topmargin}{10pt}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}
\setlength{\textheight}{23cm}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
#!/usr/bin/env python
from scipy.io import mio
x = mio.loadmat('test.mat')
lon = x['lon']
lat = x['lat']
# one-liner to read a single variable
lon = mio.loadmat('test.mat')['lon']
export LC_CTYPE=en_US.UTF-8
mkdir -p ~/Library/Application Support/TextMate/Bundles
cd ~/Library/Application Support/TextMate/Bundles
svn co http://macromates.com/svn/Bundles/trunk/Bundles/Matlab.tmbundle
#!/usr/bin/env ruby
# Quick script to create a movie from PNGs.
# Matt Foster
input = ARGV.shift || nil
if input == nil
puts "Usage: #{ARGV[0]} input_image_01.png [output_filename.mov]"
puts "Create a QuickTime Movie from an image sequence."
puts "Uses PNG image compression, and no audio."
\usepackage{fancyhdr} % Go for customized headings
\usepackage{titlesec}
\usepackage{sectsty}
\setlength{\oddsidemargin}{1.4cm}
\setlength{\evensidemargin}{1.4cm}
\setlength{\textwidth}{15cm}
\setlength{\topmargin}{10pt}
% Need these:
\setlength{\oddsidemargin}{1.4cm}
\setlength{\evensidemargin}{1.4cm}
\setlength{\textwidth}{15cm}
\setlength{\topmargin}{15mm}
\addtolength{\voffset}{-1in}
\setlength{\headheight}{14pt}
\setlength{\headsep}{20pt}
\setlength{\textheight}{24cm}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
@mattfoster
mattfoster / gist:8982
Created September 5, 2008 15:49 — forked from defunkt/gist:6443
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.
@mattfoster
mattfoster / gist:12829
Created September 25, 2008 14:34
Create a grid structure from TEC data.
% Given TEC data already resides in Ne....
Grid = setgrid('Rad', Ne.Rad, 'Lat', Ne.Lat, 'Lon', Ne.Lon);
for f (geo*) mv $f $f:s/geo_//