Skip to content

Instantly share code, notes, and snippets.

@tkf
tkf / zshrc.sh
Created January 31, 2011 18:08
pythonのワンライナーを使って英単語/熟語から英辞郎とweblioの該当ページを開く
webdict(){
quoted=`python -c "from urllib import quote_plus; print quote_plus('$*')"`
gnome-open http://eow.alc.co.jp/$quoted/UTF-8/ > /dev/null
gnome-open http://ejje.weblio.jp/content/$quoted > /dev/null
}
import numpy
import scipy.constants
def n_by_alpha(rho, U0, C_z_alpha, W, S):
return - 0.5 * rho * U0 ** 2 * C_z_alpha / (W / S)
def cap(omega_nsp, dn_by_dalpha):
return omega_nsp ** 2 / dn_by_dalpha
@tkf
tkf / gdmp.py
Created April 2, 2011 08:02
Command line tool for google-diff-match-patch
#!/usr/bin/env python
"""
Command line tool for google-diff-match-patch
"""
from diff_match_patch import diff_match_patch
HTMLTEMP = '''\
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
zmodload zsh/parameter
function zaw-src-z() {
: ${(A)candidates::=`z 2>&1 | sed -n -e '2,$p' | sed 's/^[0-9\\. ]*//' | tac`}
actions=("zaw-callback-execute" "zaw-callback-replace-buffer" "zaw-callback-append-to-buffer")
act_descriptions=("execute" "replace edit buffer" "append to edit buffer")
}
zaw-register-src -n z zaw-src-z
#!/usr/bin/env python
"""
Plot histogram from list of dates
Usage
=====
Feed newline separated unix time via STDIN.
Ex.1: plot repository activity::
#!/usr/bin/env python
"""
Post list of URLs with tag(s) to Read It Later
"""
import getpass
from readitlater import API
#!/usr/bin/env python
"""
Run command varying its arguments
"""
from subprocess import check_call
from multiprocessing import Pool
from itertools import product
#!/usr/bin/python
"""
A toy example of table generation in docutils
Most of the code is coming from `ListTable.build_table_from_list` in
`docutils.parsers.rst.directives.tables`.
Usage::
python my_table_2x2.py > sample.html

spreadsheet directive for docutils

The spreadsheet directive converts this:

.. spreadsheet:: This is my spread sheet
   :eq: {2} = {0} and {1}
        {3} = not {2}
        {5} = {4}
        {7} = '{6}({5}) = %.2f' % {6}({5})

:setup: from numpy import sin, cos, exp, log