Skip to content

Instantly share code, notes, and snippets.

@tkf
tkf / mplonflask.py
Created October 19, 2011 21:04
matplotlib on Flask
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot
import numpy
from flask import Flask, send_file
from cStringIO import StringIO
app = Flask(__name__)
@tkf
tkf / mplfillregion.py
Created October 24, 2011 22:02
Fill *multiple* regions using matplotlib
import numpy
from matplotlib import pyplot
from matplotlib.colors import ListedColormap
def genemesh(x0, x1, y0, y1, **kwds):
return numpy.meshgrid(
numpy.linspace(x0, x1, **kwds),
numpy.linspace(y0, y1, **kwds),
)
@tkf
tkf / xmonad.hs
Created November 6, 2011 15:19
My absolute coordinate version of doFloat
import XMonad
import qualified XMonad.StackSet as W
main :: IO ()
main = xmonad defaultConfig
{ manageHook = composeAll
[ className =? "XTerm" --> doFloatAbsRect 0 0 600 300 ]
}
doFloatAbsRect :: Rational -> Rational -> Rational -> Rational -> ManageHook
@tkf
tkf / mplcolors.sty
Created November 7, 2011 19:17
Use matplotlib color scheme in LaTeX!
% [[[cog
% import cog
% from matplotlib.colors import cnames, hex2color
% cog.outl('\n'.join(
% r'\definecolor{mpl%s}{rgb}{%s}' % (n, '%s,%s,%s'% hex2color(cnames[n]))
% for n in sorted(cnames)))
% ]]]
\definecolor{mplaliceblue}{rgb}{0.941176470588,0.972549019608,1.0}
\definecolor{mplantiquewhite}{rgb}{0.980392156863,0.921568627451,0.843137254902}
\definecolor{mplaqua}{rgb}{0.0,1.0,1.0}
@tkf
tkf / ido-completing-read-with-anything.el
Created December 1, 2011 15:24
An advice to use `ido-completing-read' even if `anything' is installed
(defadvice ido-completing-read
(around ido-completing-read-with-anything
(prompt choices &optional predicate require-match initial-input hist def)
activate)
"An advice to use `ido-completing-read' even if `anything' is installed.
As `anything-read-string-mode' overrides `completing-read', this advice
deactivate/activate before/after the execution of `ido-completing-read'."
(let ((arsm anything-read-string-mode)
(inhibit-quit t)
from matplotlib import pyplot, ticker
import numpy
pyplot.clf()
ax = pyplot.axes()
for axis in [ax.get_xaxis(), ax.get_yaxis()]:
axis.set_major_locator(ticker.MaxNLocator(nbins=4, steps=[1, 2, 5, 10]))
x = numpy.linspace(0, 11)
ax.plot(x, numpy.sin(x) * 0.1 + 0.01)
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--action', '-a', action='append', nargs="+")
parser.add_argument('--begin', '-b', action='append')
parser.add_argument('--files', '-f', nargs="*")
print parser.parse_args()

Quick profile of lexical-let memory leak

do-collect.el:

http://farm8.staticflickr.com/7162/6788480891_0851c27cf7_b.jpg

do-collect-with-gc.el:

(require 'e2wm)
(require 'e2wm-vcs)
;;; My commands
(defun e2wm:my-toggle-sub (&optional move-buffer)
"Toggle on/off of e2wm sub window.
See also: http://d.hatena.ne.jp/kiwanami/20100528/1275038929
If the universal prefix argument is given, the current buffer
@tkf
tkf / .loaddefs.el
Created March 24, 2012 17:35
bookmark-extensions' autoloads
;;;### (autoloads (image-bookmark-jump bmkext-bmenu-delicious bmkext-bmenu-refresh-delicious
;;;;;; bmkext-bmenu-list-only-firefox-bookmarks bmkext-export-addressbook
;;;;;; bmkext-addressbook-send-to-marked bmkext-addressbook-set-mail-buffer-and-cc
;;;;;; bmkext-addressbook-set-mail-buffer bmkext-bmenu-toggle-marks
;;;;;; bmkext-bmenu-hide-unmarked bmkext-bmenu-hide-marked bmkext-bmenu-regexp-mark
;;;;;; bmkext-bmenu-unmark-all-2 bmkext-bmenu-unmark-all bmkext-bmenu-unmark-all-non-deletion-flags
;;;;;; bmkext-bmenu-unmark-all-deletion-flags bmkext-bmenu-mark-all-bookmarks
;;;;;; bmkext-bmenu-show-all-bookmarks bmkext-bmenu-list-only-last-org-bookmarks
;;;;;; bmkext-bmenu-list-only-woman-man-bookmarks bmkext-bmenu-list-only-gnus-bookmarks