Skip to content

Instantly share code, notes, and snippets.

View uchida's full-sized avatar

Akihiro Uchida uchida

View GitHub Profile
@uchida
uchida / shtidy.el
Created January 18, 2014 18:42
emacs lisp script to tidy shellscript
#!/usr/bin/env emacs --script
(defadvice message (before message-disable activate)
"disable message function to trash stderr message"
(ad-set-args 0 nil))
(defun insert-standard-input ()
"insert contents from standard input"
(condition-case nil
(let (line)
@uchida
uchida / hyphen-num.py
Last active July 14, 2016 15:08
1 3 4 5 7 => 1,3-5,7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from itertools import chain, izip_longest, groupby
def hyphenate(s):
"""
>>> hyphenate("1 2 3")
'1-3'
>>> hyphenate("1 2 3 5 7 8")
@uchida
uchida / aozora_epub.py
Last active December 24, 2015 09:59
青空文庫の「公開中 作家別作品一覧拡充版」から URL を抽出し、テキストファイルを一括取得して、AozoraEpub3 https://github.com/hmdev/AozoraEpub3/ を利用して epub に変換するスクリプト
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
import os.path
import time
import re
import subprocess
import atexit
import cPickle as pickle
@uchida
uchida / mewgrep.py
Last active December 18, 2015 03:58
simple mail search tool for mew-prog-grep
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
import sys, re
import email, email.header
import os.path
import argparse
from locale import getpreferredencoding
@uchida
uchida / menurc
Last active December 16, 2015 00:09
keybind for sylpheed
; sylpheed GtkAccelMap rc-file
; -*- scheme -*-
(gtk_accel_path "<Main>/View/Go to/Other folder..." "g")
(gtk_accel_path "<Main>/View/Go to/Prev message" "k")
(gtk_accel_path "<Main>/View/Go to/Prev unread message" "p")
(gtk_accel_path "<Main>/View/Go to/Next message" "j")
(gtk_accel_path "<Main>/View/Go to/Next unread message" "n")
(gtk_accel_path "<Main>/View/Show or hide/Message view" "v")
(gtk_accel_path "<Main>/View/Update" "<Shift>s")
(gtk_accel_path "<Main>/View/Thread view" "<Shift>t")
@uchida
uchida / pygmentize-console.sh
Created April 9, 2013 11:02
pygmentize LESSCOLORIZER
#!/usr/bin/env bash
if [ "$?" -eq "0" ]; then
pygmentize -g -O "style=native,encoding=$(nkf -g $1)" -f console256 $1 | nkf -w
else
exit 1
fi
@uchida
uchida / lesspipe_utf8.sh
Last active December 15, 2015 23:59
convert anything to UTF-8 for LESSOPEN
#!/usr/bin/env bash
# convert anything to UTF-8 for LESSOPEN
LESSPIPE=lesspipe.sh
conv_utf8() {
if [ -x "$(which nkf 2> /dev/null)" ]; then
nkf -w -Lw "$1"
elif [ -x "$(which ruby 2> /dev/null)" ]; then
ruby -r nkf -pe '$_=NKF.nkf "-w -Lw",$_' "$1"
else
cat "$1"
c = get_config()
c.TerminalInteractiveShell.confirm_exit = False
c.TerminalInteractiveShell.logstart = True
from time import strftime
c.TerminalInteractiveShell.logfile = strftime('ipython-%Y%m%d-%T.py')
@uchida
uchida / uninstall_mactex.sh
Last active March 1, 2018 16:08
MacTeX uninstaller script based on pkgutil command
#!/bin/bash
# MacTeX uninstaller script based on pkgutil command
# by Akihiro Uchida, CC0 dedicated to the public domain
# see http://creativecommons.org/publicdomain/zero/1.0/
IFS=$(echo -en "\n")
for pkg in $(pkgutil --pkgs|grep org.tug.mactex); do
volume="$(pkgutil --pkg-info "$pkg"|grep volume|cut -d' ' -f2-)"
location="$(pkgutil --pkg-info "$pkg"|grep location|cut -d' ' -f2-)"
echo "remove all of the files installed under the $pkg"
for file in $(pkgutil --files "$pkg"); do
@uchida
uchida / Tweaks.rst
Last active January 1, 2021 04:35
Sphinx と LaTeX を使うときの 小技

Sphinx と LaTeX を使うときの 小技

著者

打田 旭宏

ライセンス

CC-BY 3.0

更新日時

Sphinx の LaTeX 出力を利用するときに見栄えを凝るのに知っておくとよいかもしれない小技をまとめました。