Skip to content

Instantly share code, notes, and snippets.

View uchida's full-sized avatar

Akihiro Uchida uchida

View GitHub Profile
@uchida
uchida / keyconfig.json
Last active July 1, 2016 20:10
json config file for Chrome Keyconfig
{
"name": "Chrome Keyconfig",
"version": "1.14.0",
"normal_actions": {
"h": {
"name": "scroll left",
"args": []
},
"l": {
"name": "scroll right",
@uchida
uchida / primes.py
Created February 1, 2012 13:44
naive prime numbers generator
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from itertools import count, takewhile, islice
def primes():
yield 2
primes = [2]
for i in count(3, step=2):
if all(i % prime != 0 for prime in primes):
@uchida
uchida / primes.py
Created February 1, 2012 13:45
prime numbers generator
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from itertools import count, takewhile, islice
def primes():
yield 2
yield 3
primes = [2, 3]
for i in count(start=5, step=6):
@uchida
uchida / gist:1759930
Last active September 30, 2015 09:28
latexmkrc sample for Japanese LaTeX documents
# -*- cperl -*-
# ~/.latexmkrc
# setting for pdflatex
$pdflatex = 'pdflatex -8bit -etex -halt-on-error -synctex=1 %O %S';
# setting for Japanese
$latex = 'platex -synctex=1 -halt-on-error %O %S';
$bibtex = 'pbibtex %O %B';
$makeindex = 'mendex %O -o %D %S';
$dvipdf = 'dvipdfmx %O -o %D %S';
# use bibtex as default
@uchida
uchida / gist:1759935
Last active November 12, 2022 06:09
latexmkrc sample for LaTeX documents with pdflatex
# -*- cperl -*-
# latexmkrc
$pdflatex = 'pdflatex -8bit -etex -halt-on-error -synctex=1 %O %S';
$pdf_mode = 1;
$bibtex_use = 1;
$clean_ext = '%R_flymake.aux %R_flymake.dvi %R_flymake.log %R_flymake.out';
$clean_full_ext = 'bbl synctex.gz';
@uchida
uchida / snippet.py
Last active October 1, 2015 09:38
convert snippet file for neosnippet into snippet files for yasnippet
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# convert snippet file for neosnippet into snippet files for yasnippet
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
import argparse
import os.path
import textwrap
YASNIPPET_TEMPLATE = """# -*- mode: snippet -*-
@uchida
uchida / showfonts.py
Created March 3, 2012 11:18
show available font names for matplotlib
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os.path
from matplotlib import get_configdir
import pickle
fpath = os.path.join(get_configdir(), 'fontList.cache')
with open(fpath, 'r') as f:
fontmgr = pickle.load(f)
for fontentry in fontmgr.ttflist:
@uchida
uchida / replicate.bash
Created June 13, 2012 04:01
A replication script for ZFS
#!/usr/bin/env bash
# coding: utf-8
# A replication script for ZFS
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
usage="usage: $(basename $0) [-v] src dst"
die() {
echo "$@" >&2
exit 1
@uchida
uchida / rotate.bash
Last active October 6, 2015 02:47
A ZFS snapshots rotation script
#!/usr/bin/env bash
# A ZFS snapshots rotation script
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
usage="usage: $(basename $0) [-v] filesystem generation"
die() {
echo "$@" >&2
exit 1
}
@uchida
uchida / dlclt.py
Created August 31, 2012 22:22
CUI Downloader of Command Line Tools for Xcode
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# CUI Downloader of "Command Line Tools for Xcode"
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
import sys, os
import urllib, urllib2, cookielib
from getpass import getpass
from HTMLParser import HTMLParser