情弱ログ

参考にならないので当てにしないでください

Emacsで保存時に句読点を全角コンマと全角ピリオドに置換する設定

様式か、風習か、日本語で論文を書くときは「、」や「。」は「,」と「.」に置き換えなくてはいけない。
句読点の設定はだいたいどのIMEにもあるメジャーな設定なのでそこまで困ることではないが、グローバルに変更されると他の文章も全て全角コンマ・ピリオドになるためなかなか使い勝手が悪い。
どうせなのでTeX modeの時は保存時に句読点を全角コンマと全角ピリオドに置換してくれるEmacs Lispを書いた。

(defun replace-dot-comma ()
  "s/。/./g; s/、/,/g;する"
  (interactive)
  (let ((curpos (point)))
    (goto-char (point-min))
    (while (search-forward "。" nil t) (replace-match "."))
    
    (goto-char (point-min))
    (while (search-forward "、" nil t) (replace-match ","))
    (goto-char curpos)
    ))

(add-hook 'tex-mode-hook
          '(lambda ()
             (add-hook 'before-save-hook 'replace-dot-comma nil 'make-it-local)
             ))

これで執筆中は何も考えることなく「、」と「。」を使うことができ、保存時には勝手に「,」と「.」に置換してくれる。

今時Emacs上でTeXで論文書くような人はこんなのよりもっと便利なものを知ってそう

ブート時に途中から画面が真っ暗で表示されなくなる時のtips

ブートローダの選択画面やブートの途中までは画面に映るのに、ある途端から画面が真っ暗になったり、バックグラウンドで処理は行われているのに画面が停止した際の解決法。
nvidiaプロプライエタリドライバを使用していることが前提。

原因はカーネルのオプションの選択ミスで、DRMというカーネルオプションを無効にしてドライバを再コンパイルすると直った。
詳しくはこちら NVidia/nvidia-drivers - Gentoo Wiki

DRMというのはDirect Rendering Managerといい、モダンなビデオカードを扱うためのインタフェースとのこと。
これがLinux kernelのものとドライバのもので競合を起こしていたのが原因の様子。

原因というか、.configファイルを消してしまったのが一番痛い。

セキュキャンに落ちた解答を晒す

んなもん誰が読むんじゃ
まずはセキュリティ・キャンプ合格者のみなさんおめでとうございます。僕は残念ながら落ちてしまいましたが、部内に一人合格者がいたので全滅は免れました。KK君おめでとう&頑張れ。
年齢的に最後のチャンスだったので、落ちた時はかなりへこみましたが、これを期に他の勉強会等にも積極的に参加していきたいです。

今回晒す解答は実際に提出したものをそのまま貼り付けています。
反面教師として来年度以降誰かの参考になったら幸いです。
尚、選択問題2,5,6,9,11に取り組みました。

続きを読む

Gnome3のアプリケーション一覧を汚染された

winetricksでゴニョゴニョといくつかパッケージを入れていたら、Gnomeのアプリケーション一覧(Activities→Show Applications)がバッテン印のアプリケーションに汚染された。
アプリケーション一覧からアプリを起動することはあまりないが、見た目がよろしくない。

rm -rf ~/.local/share/desktop-directories/*
rm -rf ~/.local/share/applications/wine*

して一度ログアウトしたら消えた。
wineのアイコンも消えたが、コンソール以外から使うことはないから問題ない。

ちゃんとfind ~ .name .desktopして不要なものを見極めてから消すことをおすすめ。

yosemite上のGentoo/Prefixでmedia-libs/libcanberraのemergeがコケる

誰かバグレポート書いて案件その3。
とりあえず

% emerge libcanberra

すると

canberra-gtk-module.c:28:22: error: gdk/gdkx.h: No such file or directory
canberra-gtk-module.c: In function 'window_get_desktop':
canberra-gtk-module.c:303: error: 'Atom' undeclared (first use in this function)
canberra-gtk-module.c:303: error: (Each undeclared identifier is reported only once
canberra-gtk-module.c:303: error: for each function it appears in.)
canberra-gtk-module.c:303: error: expected ';' before 'type_return'
canberra-gtk-module.c:315: warning: implicit declaration of function 'XGetWindowProperty'
canberra-gtk-module.c:315: warning: implicit declaration of function 'GDK_DISPLAY_XDISPLAY'
canberra-gtk-module.c:315: warning: implicit declaration of function 'GDK_WINDOW_XID'
canberra-gtk-module.c:316: warning: implicit declaration of function 'gdk_x11_get_xatom_by_name_for_display'
canberra-gtk-module.c:317: error: 'False' undeclared (first use in this function)
canberra-gtk-module.c:317: error: expected ')' before numeric constant
canberra-gtk-module.c:317: error: 'type_return' undeclared (first use in this function)
canberra-gtk-module.c:319: error: 'Success' undeclared (first use in this function)
canberra-gtk-module.c:322: error: expected ')' before numeric constant
canberra-gtk-module.c:329: error: 'None' undeclared (first use in this function)
canberra-gtk-module.c:330: warning: implicit declaration of function 'XFree'
canberra-gtk-module.c: In function 'display_get_desktop':
canberra-gtk-module.c:336: error: 'Atom' undeclared (first use in this function)
canberra-gtk-module.c:336: error: expected ';' before 'type_return'
canberra-gtk-module.c:348: warning: implicit declaration of function 'DefaultRootWindow'
canberra-gtk-module.c:350: error: 'False' undeclared (first use in this function)
canberra-gtk-module.c:350: error: expected ')' before numeric constant
canberra-gtk-module.c:350: error: 'type_return' undeclared (first use in this function)
canberra-gtk-module.c:352: error: 'Success' undeclared (first use in this function)
canberra-gtk-module.c:355: error: expected ')' before numeric constant
canberra-gtk-module.c:363: error: 'None' undeclared (first use in this function)
canberra-gtk-module.c: In function 'window_is_xembed':
canberra-gtk-module.c:370: error: 'Atom' undeclared (first use in this function)
canberra-gtk-module.c:370: error: expected ';' before 'type_return'
canberra-gtk-module.c:376: error: expected ';' before 'xembed'
canberra-gtk-module.c:386: error: 'xembed' undeclared (first use in this function)
canberra-gtk-module.c:392: error: 'False' undeclared (first use in this function)
canberra-gtk-module.c:392: error: 'type_return' undeclared (first use in this function)
canberra-gtk-module.c:394: error: 'Success' undeclared (first use in this function)
canberra-gtk-module.c:408: error: 'None' undeclared (first use in this function)

こんなエラーが出てくる。
面倒なので(あと昨日の夜に寝ぼけながらやったせいでほとんど覚えてないので)解決方法だけ乗せると

% LDFLAGS="-L/Users/vicco/Gentoo/usr/lib -L/usr/local/lib" CPPFLAGS="-I/Users/vicco/Gentoo/usr/include -I/usr/local/include/gtk-2.0 -I/usr/local/lib/gtk-2.0/include" CC=clang CXX=clang++ ebuild ~/Gentoo/usr/portage/media-libs/libcanberra/libcanberra-0.30-r4.ebuild unpack
% vim ~/Gentoo/var/tmp/portage/media-libs/libcanberra-0.30-r4/work/libcanberra-0.30/configure.ac

で117行目から

CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
        -Wl,--as-needed \
        -Wl,--gc-sections])

の部分をコメントアウト。clangでは--as-neededと--gc-sectionsはunsupported optionとのこと。
あとは

% LDFLAGS="-L/Users/vicco/Gentoo/usr/lib -L/usr/local/lib" CPPFLAGS="-I/Users/vicco/Gentoo/usr/include -I/usr/local/include/gtk-2.0 -I/usr/local/lib/gtk-2.0/include" CC=clang CXX=clang++ ebuild ~/Gentoo/usr/portage/media-libs/libcanberra/libcanberra-0.30-r4.ebuild configure
% LDFLAGS="-L/Users/vicco/Gentoo/usr/lib -L/usr/local/lib" CPPFLAGS="-I/Users/vicco/Gentoo/usr/include -I/usr/local/include/gtk-2.0 -I/usr/local/lib/gtk-2.0/include" CC=clang CXX=clang++ ebuild ~/Gentoo/usr/portage/media-libs/libcanberra/libcanberra-0.30-r4.ebuild compile
% LDFLAGS="-L/Users/vicco/Gentoo/usr/lib -L/usr/local/lib" CPPFLAGS="-I/Users/vicco/Gentoo/usr/include -I/usr/local/include/gtk-2.0 -I/usr/local/lib/gtk-2.0/include" CC=clang CXX=clang++ ebuild ~/Gentoo/usr/portage/media-libs/libcanberra/libcanberra-0.30-r4.ebuild install
% LDFLAGS="-L/Users/vicco/Gentoo/usr/lib -L/usr/local/lib" CPPFLAGS="-I/Users/vicco/Gentoo/usr/include -I/usr/local/include/gtk-2.0 -I/usr/local/lib/gtk-2.0/include" CC=clang CXX=clang++ ebuild ~/Gentoo/usr/portage/media-libs/libcanberra/libcanberra-0.30-r4.ebuild qmerge

(毎回LDFLAGSとか指定する必要は多分無い)
Gentoo/Prefix上のライブラリとbrewで突っ込んだライブラリを使ったせいでとてもカオス。
今後アップデートがあった時にとても面倒くさそう。