Skip to content

Instantly share code, notes, and snippets.

# RewriteMap する前に RewriteEngine on が必要.
# これをやっておかないと,map lookup FAILED というエラーではまる.
# RewriteMap を呼び出す時点で,「RewriteEngine on」してないから使えないよ,というエラーを出してくれれば楽なのに‥‥
RewriteEngine on
RewriteMap mapper prg:/path/to/mapper
<Location /shibboleth-required-area>
AuthType shibboleth
ShibRequestSetting requireSession 1
ShibUserHeaders on
;; MIME part を表示するときに doc-view-mode を利用しないための設定
;; doc-view-mode を使うようになっていると,applicate/pdf な MIME part
;; を表示できずに,単にファイルを保存してしまう.
(setq mailcap-mime-data
(mapcar
(lambda (data)
(cons (car data)
(delq nil
(mapcar
(lambda (pair)
@tsuchm
tsuchm / LSTMLEncoder.py
Created October 12, 2016 01:06
Example of LSTM encoder which ignores labels for padding
import chainer
from chainer import Link, Chain, Function, Variable, cuda
import chainer.functions as F
import chainer.links as L
import numpy as np
class LSTMEncoder(Chain):
def __init__(self, vocab_size, embed_size, hidden_size, ignore_label=-1):
super(LSTMEncoder, self).__init__(
xe = L.EmbedID(vocab_size, embed_size, ignore_label=-1),
@tsuchm
tsuchm / process_jawiki.py
Last active February 4, 2019 06:35
gensim を使って,日本語版 wikipedia ダンプデータをコーパス化するスクリプト(メンテナンスされていません)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# https://github.com/attardi/wikiextractor が使いやすく,かつ,日本語も適切に扱ってくれることが判明しましたので,
# このスクリプトは,今後のメンテナンスの予定はありません.
import argparse
import codecs
import logging
import os.path
from __future__ import print_function
from chainer import cuda
cudnn = cuda.cudnn
libcudnn = cuda.cudnn.cudnn
print(libcudnn.getVersion())
@tsuchm
tsuchm / .bashrc
Created March 5, 2018 07:10
Set LV color mode
# perldoc や man などを参照していて、lv をページャに使っていると、以下のように ESC sequence が
# 表示される症状に悩まされるようになった.いつからかは不明.Debian Stretch 以後?
#
# ESC[1mNAMEESC[0m
# Config::Simple - simple configuration file class
#
# 以下のように、LV 環境変数を明示的に指定すると症状が改善された.
LV=-c
export LV
@tsuchm
tsuchm / base62.pl
Created March 8, 2018 01:48
Perl encode/decoder of base62 format
use constant PRIMITIVES => join( '', 0 .. 9, 'a' .. 'z', 'A' .. 'Z' );
sub encode_base62 {
my( $num ) = @_;
my @c;
do {
push( @c, substr( PRIMITIVES, $num % length(PRIMITIVES), 1 ) );
$num = int( $num / length(PRIMITIVES) );
} while( $num );
join( '', reverse @c );
@tsuchm
tsuchm / remote-sudo.sh
Created May 2, 2018 23:25
Run sudo on remote machines
#!/bin/bash
usage(){
cat <<EOF
Usage: remote-sudo host0 host1 ... hostN -- command arg0 arg1 ... argN
EOF
}
ALLHOSTS=(node0 node1 node2 node3 node4 node5 node6 node7 node8 node9)
DOMAIN=example.jp
@tsuchm
tsuchm / pdfunup.sh
Last active May 23, 2018 12:46
Script which converts the 2-up PDF file into the single page PDF file
#!/bin/sh
usage(){
cat <<EOF
This script converts the 2-up PDF file into the single page PDF file.
For example, http://www.city.yokohama.lg.jp/kankyo/midoriup/jigyo/mori/guidebook.pdf
is a PDF file which consists of A3 16 pages, each A3 page contains 2
A4 pages. In order to print the above PDF as a brochure, do the
following procedure.
@tsuchm
tsuchm / apt_preferences
Last active April 7, 2021 16:22
Ansible Playbook to install nvidia-docker2
Package: libnccl-dev
Pin: version *cuda9.1
Pin-Priority: 999
Package: libnccl-dev
Pin: version *cuda9.0
Pin-Priority: 999
Package: libnccl2
Pin: version *cuda9.1