Skip to content

Instantly share code, notes, and snippets.

パーフェクトRuby読んでて気になったところのメモ

全般

Ruby 1.8 は本書では対象としてないので、ところどころにある「Ruby 1.9 以降では」という記述は要らないと思う。

2章

p.62 「5番目の要素をつくると」は「6番目の要素をつくると」の誤り?

@tmtm
tmtm / make-postfix-git-repos.rb
Last active March 3, 2019 02:14
Postfix の tarball から Git リポジトリを作るスクリプト
# -*- coding: utf-8 -*-
# Postfix はソースが公開されてはいるもののリポジトリが公開されていない
# ので、公開されている tarball から git リポジトリを作るためのスクリプ
# トを作ってみました。
#
# 次の場所から、postfix-*.tar.gz を持ってきて、どっかに置いておきます。
# * ftp://ftp.porcupine.org/mirrors/project-history/postfix/official/
# * ftp://ftp.porcupine.org/mirrors/postfix-release/official/
# tar.gz ファイルの日付の古い順に処理するので、ファイルの日付までコピー
@tmtm
tmtm / gist:a569753ecb5f33640fe6
Created January 30, 2015 01:31
Windows の Rabbit で PDF を表示しようとしたときに出たエラー
DL is deprecated, please use Fiddle
c:/Ruby21/lib/ruby/gems/2.1.0/gems/rabbit-2.1.3/lib/rabbit/parser/pdf.rb: line 29
Poppler-INFO **:Syntax error at position -1: Couldn't find trailer dictionary
c:/Ruby21/lib/ruby/gems/2.1.0/gems/rabbit-2.1.3/lib/rabbit/parser/pdf.rb: line 29
Poppler-INFO **:Syntax error at position -1: Couldn't find trailer dictionary
c:/Ruby21/lib/ruby/gems/2.1.0/gems/rabbit-2.1.3/lib/rabbit/parser/pdf.rb: line 29
Poppler-INFO **:Syntax error at position -1: Couldn't read xref table
c:/Ruby21/lib/ruby/gems/2.1.0/gems/rabbit-2.1.3/lib/rabbit/parser/pdf.rb:29:in `initialize': PDF document is damaged (GLib::Error)
from c:/Ruby21/lib/ruby/gems/2.1.0/gems/rabbit-2.1.3/lib/rabbit/parser/pdf.rb:29:in `new'
from c:/Ruby21/lib/ruby/gems/2.1.0/gems/rabbit-2.1.3/lib/rabbit/parser/pdf.rb:29:in `parse'
'(riece-default-coding-system (quote (utf-8 . utf-8)))
'(riece-default-freeze t)
'(riece-keywords (quote ("hoge" "fuga")))
'(riece-log-coding-system (quote utf-8))
'(riece-server "localhost")
'(riece-startup-channel-list (quote ("#a" "#hoge" "#tmtms" "#hogehoge")))
;; riece
@tmtm
tmtm / trackpoint.sh
Created November 18, 2016 16:19
trackpointの速度を調整して、トラックパッドを無効にする
#!/bin/bash
DIR=/sys/devices/platform/i8042
SPEED=200
SENSITIVITY=200
modprobe -r psmouse
modprobe psmouse proto=any
while :; do
until [ -f $DIR/serio*/serio*/speed -a -f $DIR/serio*/serio*/sensitivity ]; do
sleep 1
@tmtm
tmtm / sjis-cp932-diff.txt
Last active April 24, 2020 05:30
MySQLのsjisとcp932で異なる文字
+------+------+-------+
| code | sjis | cp932 |
+------+------+-------+
| 815F | \ | \ |
| 8160 | 〜 | ~ |
| 8161 | ‖ | ∥ |
| 817C | − | - |
| 8191 | ¢ | ¢ |
| 8192 | £ | £ |
| 81CA | ¬ | ¬ |
@tmtm
tmtm / romantable.txt
Created October 8, 2019 14:46
ローマ字変換テーブル
z1 ○
z! ●
z2 ▽
z@ ▼
z3 △
z# ▲
z4 □
z$ ■
z5 ◇
z% ◆
@tmtm
tmtm / nhk+_toggle_controller.js
Last active December 30, 2020 05:13
NHK+のコントローラー表示をトグルするブックマークレット
javascript:(function(){var e=document.querySelector('.hls-player_controller'); if(e.style.display=='none'){e.style.display=''}else{e.style.display='none'}})();
@tmtm
tmtm / gemdiff.sh
Created November 14, 2021 09:11
gem の差分を見る
#!/bin/bash
dir1=$(mktemp -d)
dir2=$(mktemp -d)
trap "rm -rf $dir1 $dir2" EXIT
cat $1 | (cd $dir1 && tar xf - && tar xf data.tar.gz && gunzip metadata.gz checksums.yaml.gz)
cat $2 | (cd $dir2 && tar xf - && tar xf data.tar.gz && gunzip metadata.gz checksums.yaml.gz)
diff --color=auto -ur $dir1 $dir2
@tmtm
tmtm / win_class_title.rb
Created December 26, 2021 16:47
X のウィンドウのクラスとタイトルを取得する
require 'ffi'
module FFI
typedef :pointer, :Display
typedef :ulong, :XID
typedef :XID, :Window
typedef :int, :Status
typedef :ulong, :Atom
end