Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cpelley
cpelley / gist:7785812
Created December 4, 2013 11:02
Partial datetime benchmark
import timeit
import numpy as np
import iris
from iris.pdatetime import PartialDateTime
def _ret_cube():
cube = iris.cube.Cube(np.arange(4))
@cpelley
cpelley / .screenrc
Last active January 8, 2016 23:00
screenrc settings
# Turn off audible bell
vbell off
# Turn off startup message
startup_message off
hardstatus off
caption always "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%<"
@cpelley
cpelley / gist:7097521
Created October 22, 2013 09:11
esmf + ESMPy install
# Specify tag release
export ESMPY='620_01b'
# Download archive if not done already
archive=ESMPy_${ESMPY}.tar.bz2
if [ ! -f ${archive} ]; then
echo 'Downoading archive'
wget http://www.earthsystemmodeling.org/python_releases/ESMPy_${ESMPY}/${archive}
fi
#!/usr/bin/env python
import sys
import re
def main(fnme):
with open(fnme, 'r') as fh:
lines = fh.readlines()
@cpelley
cpelley / Pyflakes monkeypatch
Last active December 22, 2015 14:09
Pyflakes monkey-patch to give appropriately formatted syntax error for vim
#!/usr/bin/env python
import sys
import pyflakes.reporter as reporter
from pyflakes.scripts.pyflakes import main
# Monkey patch syntax error method for suitability with vim
def vimhappy_syntaxError(self, filename, msg, lineno, offset, text):
line = text.splitlines()[-1]
@cpelley
cpelley / python.vim
Last active February 2, 2016 21:09
" setup wrapping
setlocal textwidth=79 " width of document
setlocal nowrap " don't automatically wrap on load
setlocal fo-=t " don't automatically wrap text when typing
" Colour column at 80char
if exists('+colorcolumn')
setlocal colorcolumn=80
else
autocmd BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
@cpelley
cpelley / .vimrc
Last active December 22, 2015 00:59
" ENABLE FILETYPE SPECIFIC VIM SETTINGS FILES
filetype plugin on
" language-dependent indenting.
filetype plugin indent on
" SET COLOUR
" mkdir -p ~/.vim/colors && cd ~/.vim/colors
" wget -O wombat256mod.vim http://www.vim.org/scripts/download_script.php?src_id=13400
set t_Co=256
@cpelley
cpelley / gist:6377893
Last active December 21, 2015 22:49
Custom matplotlib colormap using an existing one
import copy
import matplotlib
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
def plot_colormap(cmapname='jet'):
"""