ConTeXt
LaTeXとは別系統のTeXであるConTeXtを試してみた。
ConTeXt WikiのHello World!を参考に、以下のhoge.texを作り、
\definefontsynonym[UnicodeRegular][ipag] \enableregime[utf-8] \mainlanguage[ja] \starttext ほげ ほげら べほげら ほげらが ほげらごん ほげらずん \stoptext
texexec hoge.tex
でコンパイル。
IPAフォントがtex側から見えなかったようなので、
(/usr/share/fonts/ja-ipafonts/ipa{m,g}.otf があることを前提に)
以下のようにリンクを張り、tfmを生成した。
mkdir -p ~/texmf/fonts/{truetype,tfm,pk,map/ttf2pk} cd ~/texmf/fonts/truetype ln -s /usr/share/fonts/ja-ipafonts/*.otf . rename .otf .ttf *.otf cd ~/texmf/fonts/tfm mktexlsr ~/texmf ttf2tfm ipam -q ipam@Unicode@ >> ~/texmf/fonts/map/ttf2pk/ttfonts.map ttf2tfm ipag -q ipag@Unicode@ >> ~/texmf/fonts/map/ttf2pk/ttfonts.map
割と素直に日本語pdfを作れた。
年明け提出のレポートをConTeXtで書いてみるつもり。
LaTeXとの違いに苦労しそう。
xpdf japanese
pdfに埋め込まれたeps中の日本語が,xpdfで表示されなかった.
エラーメッセージはこんなの
Error: Couldn't find 'H' CMap file for 'Adobe-Japan1' collection Error: Unknown CMap 'H' for character collection 'Adobe-Japan1' Error: Unknown font tag 'R9' Error (99516): No font in show/space Error: Couldn't find 'H' CMap file for 'Adobe-Japan1' collection Error: Unknown CMap 'H' for character collection 'Adobe-Japan1' Error: Unknown font tag 'R9' Error (99516): No font in show/space
調べてみると,~/.xpdfrc に
cMapDir Adobe-Japan1 /usr/local/share/xpdf-japanese/CMap
と書かれているのに /usr/local/share/xpdf-japanese/CMap がなかった.
/usr/share/xpdf/japanese/CMap はあるみたいなので,
とりあえず/usr/local/share/xpdf-japanese/CMap から
/usr/share/xpdf/japanese/CMap シンボリックリンクを張ってみたらうまくいった.
xrandr+Dual Display
ノートパソコンを外部ディスプレイやプロジェクタに接続するときに,
接続先によっては解像度の自動選択がうまくできないことがあり,
手動で解像度を選んでやる必要があった.
面倒なので自動化してみた.
xrandr -q で使える解像度一覧が出てくるので,
正規表現で切り出して,画素数(?)順にソート.
大きい順に成功するまで試す.
#! /bin/zsh #旧 #xrandr --output VGA --above LVDS ${1:+"--mode"} ${1:-"--auto"} xrandr -q | sed -n 's/^\s\+\([0-9]\+\)x\([0-9]\+\)\s\+.*$/\1 \2/p' | \ (while read w h do echo $(($w*$h)) $w $h done) | \ sort -nr | uniq | \ (while read r w h do xrandr --output VGA --above LVDS --mode ${w}x${h} > /dev/null && exit done)
cron+slocate+updatedb
ノートパソコン起動時にupdatedbが走って、
起動にとても時間がかかった。
updatedbの入出力の優先度をidleに下げておいた。
/etc/cron.daily/slocate を修正。
--- slocate.orig 2009-10-09 19:49:18.607239291 +0900 +++ slocate 2009-10-09 19:48:26.565745925 +0900 @@ -4,8 +4,8 @@ then if [ -f /etc/updatedb.conf ] then - nice /usr/bin/updatedb + nice ionice -c 3 /usr/bin/updatedb else - nice /usr/bin/updatedb -f proc + nice ionice -c 3 /usr/bin/updatedb -f proc fi fi
MinimalなLinux
ふと思いたってMinimalな構成のLinuxを作ってみた。
# cd /usr/src/linux # make allnoconfig
から始めて、
起動に必要なものと、サイズが小さくなりそうな以下のオプションだけをつけた。
# make menuconfig
General setup ---> Kernel compression mode (LZMA) Initial RAM filesystem and RAM disk (initramfs/initrd) support Support initial ramdisks compressed using LZMA Optimize for size Configure standard kernel features (for small systems) Strip assembler-generated symbols during link Executable file formats / Emulations ---> Kernel support for ELF binaries
あとは普通にコンパイル。
# make -j4
シェルにはbusyboxのallnoconfigを使う。
まずはGentooのemergeで作業領域を残しつつインストールして、
# FEATURES=keepwork emerge -av busybox
作業領域に行ってコンフィグ。
# cd /var/tmp/portage/sys-apps/busybox-*/work/busybox-* # make allnoconfig # make menuconfig
static linkを選択。
Busybox Settings ---> Build Options ---> Build BusyBox as a static binary (no shared libs)
生成物のサイズについて最適化しつつコンパイル。
CFLAGS="-fomit-frame-pointer -Os -pipe" make -j4
生成物を適当なディレクトリに集める。
mkdir /tmp/minimal-linux cp busybox /tmp/minimal-linux/ cd /tmp/minimal-linux cp /usr/src/linux/arch/x86_64/boot/bzImage .
initramfsを作って準備完了。
mv busybox sh echo sh | cpio -o -H newc | lzma -z > initramfs.cpio.lzma rm sh
サイズを見てみるとこんなかんじ。
# ls -l bzImage initramfs.cpio.lzma -rw-r--r-- 1 root root 382576 Sep 16 17:42 bzImage -rw-r--r-- 1 root root 268988 Sep 16 17:53 initramfs.cpio.lzma
合計637KiB。今は亡きフロッピーに収まる大きさにできた。
早速動かしてみる。あらかじめ入れておいたkvmで
# kvm -kernel bzImage -initrd initramfs -append "init=/sh"
と動かすと、無事起動し、busyboxのashのプロンプトが表示された。
BIOSの部分を除けば、起動には一秒かからないくらい。
GCJ (not Java)
Google Code Jam の Qualification Round に参加した。
http://code.google.com/intl/ja/codejam/