How to install ruby-oci8

  1. http://www.oracle.com/technetwork/topics/linuxsoft-082809.html

から

  • instantclient-basic-OS-VERSION.zip
  • instantclient-sdk-OS-VERSION.zip (これ要るかなあ?)
  • instantclient-sqlplus-OS-VERSION.zip

をダウンロードして /opt/oracle に展開する。

  1. 以下を実行
$ cd /opt/oracle/instantclient_11_2
$ sudo ln -s libclntsh.so.11.1 libclntsh.so
$ sudo env ORACLE_HOME=/opt/oracle/instantclient_11_2 LD_LIBRARY_PATH=/opt/oracle/instantclient_11_2 gem install ruby-oci8

参考: http://ruby-oci8.rubyforge.org/en/file.install-instant-client.html

レイアウト

画像のようなレイアウトを組んでいるとき、文字列を中央にするための計算式。
f:id:maangie:20120524092222p:image

  • 文字列のy座標
(let ((top-line-y 90) (bottom-line-y 185) (string-height 18))
  (+ top-line-y (/ (- bottom-line-y top-line-y string-height) 2)))
=> 128
  • 文字列のx座標
(let ((left-line-x 84) (line-width 228.1) (string-width 91))
  (+ left-line-x (/ (- line-width string-width) 2)))
=> 152.55
  • 結果

f:id:maangie:20120524092910p:image

prawn で定義されている用紙サイズを参照する方法

#!/usr/local/bin/ruby
# -*- coding: utf-8 -*-

require 'prawn'
require 'pp'

Prawn::Document::PageGeometry::SIZES.each do |size|
  pp size
end

出力

["4A0", [4767.87, 6740.79]]
["2A0", [3370.39, 4767.87]]
["A0", [2383.94, 3370.39]]
["A1", [1683.78, 2383.94]]
["A2", [1190.55, 1683.78]]
["A3", [841.89, 1190.55]]
["A4", [595.28, 841.89]]
["A5", [419.53, 595.28]]
["A6", [297.64, 419.53]]
["A7", [209.76, 297.64]]
["A8", [147.4, 209.76]]
["A9", [104.88, 147.4]]
["A10", [73.7, 104.88]]
["B0", [2834.65, 4008.19]]
["B1", [2004.09, 2834.65]]
["B2", [1417.32, 2004.09]]
["B3", [1000.63, 1417.32]]
["B4", [708.66, 1000.63]]
["B5", [498.9, 708.66]]
["B6", [354.33, 498.9]]
["B7", [249.45, 354.33]]
["B8", [175.75, 249.45]]
["B9", [124.72, 175.75]]
["B10", [87.87, 124.72]]
["C0", [2599.37, 3676.54]]
["C1", [1836.85, 2599.37]]
["C2", [1298.27, 1836.85]]
["C3", [918.43, 1298.27]]
["C4", [649.13, 918.43]]
["C5", [459.21, 649.13]]
["C6", [323.15, 459.21]]
["C7", [229.61, 323.15]]
["C8", [161.57, 229.61]]
["C9", [113.39, 161.57]]
["C10", [79.37, 113.39]]
["RA0", [2437.8, 3458.27]]
["RA1", [1729.13, 2437.8]]
["RA2", [1218.9, 1729.13]]
["RA3", [864.57, 1218.9]]
["RA4", [609.45, 864.57]]
["SRA0", [2551.18, 3628.35]]
["SRA1", [1814.17, 2551.18]]
["SRA2", [1275.59, 1814.17]]
["SRA3", [907.09, 1275.59]]
["SRA4", [637.8, 907.09]]
["EXECUTIVE", [521.86, 756.0]]
["FOLIO", [612.0, 936.0]]
["LEGAL", [612.0, 1008.0]]
["LETTER", [612.0, 792.0]]
["TABLOID", [792.0, 1224.0]]

テンプレート

<!-- -*- coding: utf-8 -*- -->
<!DOCTYPE
   HTML
   PUBLIC
   "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd"
   >

<html lang="ja">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <LINK REV="MADE" HREF="mailto:foo@example.com">
  <link rel="index" href="./index.html">
  <title>hello</title>
</head>
<body>
  <p>hello, world</p>
</body>
</html>

以下を参照しました。
http://www.kanzaki.com/docs/html/valid-comment.html

cgi で jpeg を送る

#!/usr/bin/ruby
# -*- coding: utf-8 -*-

require "cgi"

# ファイルをメモリに読み込む。
file = open("foo.jpeg", "rb")
image = file.read

# ヘッダ設定
header = {
  "status" => 200, # リソースに対応するエンティティをレスポンスとして送る。

  "type"                => "image/jpeg", # ファイルタイプ指定
  "Content-Disposition" => "inline"      # インライン表示
}

# レスポンスを送る。
CGI.new("html4").out(header) {
  image
}

以下を参照しました。
d:id:haraguroblog:20090823:1251036269
[ruby-list:37233] Re: CGIからファイルをダウンロード
class CGI
[Studying HTTP] HTTP Status Code

ネットワークを有効にする

/etc/sysconfig/network-scripts/ifcfg-eth0 を作成

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
HWADDR=00:00:00:00:00:00
IPADDR=192.168.1.50
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
NETWORK=192.168.1.0
BROADCAST=192.168.1.255

ネットワークを上げる

# ifdown eth0
# ifup eth0

確認

# ifconfig

詳しくは http://www.jitaku-server.net/domain_fix_ip.html