write ahead log

ロールフォワード用

gitのfirst commitをビルドする

興味わいたのでやってみたけど意外とうまくいかなかったのでメモ.

ソース自体はgithubにミラーがあって, ここから手に入る.

ubuntu trustyの64bit環境でやった.

そのまま素直にビルドしようとすると以下のエラーが出た.

vagrant@vagrant-ubuntu-trusty-64:~/repo/git$ make
gcc -g   -c -o update-cache.o update-cache.c
In file included from update-cache.c:1:0:
cache.h:13:25: fatal error: openssl/sha.h: No such file or directory
 #include <openssl/sha.h>
                         ^
compilation terminated.
make: *** [update-cache.o] Error 1

libssl-devが入ってなくて怒られているっぽいので入れる.

vagrant@vagrant-ubuntu-trusty-64:~/repo/git$ sudo apt-get install libssl-dev

それでも怒られたのでMakefileを編集.

-lcryptoが無いとopenssl関連のビルドが通らず, -lzが無いとzlib関連が通らなかった.

LIBS= -lssl -lcrypto -lz

これでmakeすると(warnningがいっぱい出るが)ビルドできた.

minttyのロケールを設定する

msys2を入れてフォントや透過度を変えて満足して使っていたが, svnをコマンドで使うとロケールがおかしいと怒られた.

$ svn update
svn: warning: cannot set LC_CTYPE locale
svn: warning: environment variable LANG is ja
svn: warning: please check that your locale name is correct

あー, そういや気にした事なかったわー.

と思いつつ設定した.

LANGの設定

まず, ~/.bash_profileへ以下を追記.

LANG=ja_JP.utf8

minttyの設定

~/.minttyrcへLocaleとCharset設定を追加する.

BoldAsFont=no
Transparency=high
CursorType=block
Font=Ricty Diminished Discord
FontHeight=11
Locale=ja_JP     #ここ
Charset=UTF-8    #ここ

これでminttyを再起動すればいい感じに動いた.

両方合わせる必要があるのがポイントっぽい.

SVNで証明書を使う

今更SVNを使う事になったので.

証明書ファイルのパスは絶対パスじゃないと動作しなかった. typoなのか, msys2環境だからなのかはよーわからん.

~/.subversion/serversを以下の通り編集.

ssl-client-cert-file = [証明書ファイルのパス]
ssl-client-cert-password = [証明書ファイルのパスワード]

ubuntuでタイムゾーンの変更

ちょっと古いけど, バージョンは以下でやった.

vagrant@vagrant-ubuntu-trusty-64:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"

現在のタイムゾーンを確認する.

$ timedatectl

設定できるタイムゾーンを調べる.

$ timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
...

設定.何となくニューヨークへ.

$ sudo timedatectl set-timezone America/New_York

Apple Musicへのリクエスト方法

技術ネタじゃないけど.

Apple Musicを使ってるんだけど, 欲しい曲が無い時にリクエストの出し先がわからなくて困ってた.

やっと見つけたので.

iTunes Store Requests

どんどん曲数増えればいいなぁ.

goでbrainfuckを書いた

こんな面白そうな記事があったので作ってみた.

github.com

全ての最適化を実装するのはちょっとしんどかったので(というか途中で飽き始めた)2段階目まで作った.

実行速度を見ると元記事通り, 明らかに差が出るのが面白い.

試行回数1だけど.

$ go test -bench .
BenchmarkFactorSimpleRun-4                     1        56483572100 ns/op
BenchmarkMandelbrotSimpleRun-4                 1        202497152900 ns/op
BenchmarkFactorOptimizedRun-4                  1        24686566000 ns/op
BenchmarkMandelbrotOptimizedRun-4              1        79534122700 ns/op
BenchmarkFactorOptimized2Run-4                 1        13370674300 ns/op
BenchmarkMandelbrotOptimized2Run-4             1        41272916900 ns/op
PASS
ok      _/C_/msys64/home/IMAI/dropbox/lab/gobrainfuck   418.021s

Optimize2段階目時点で5倍くらい早い.

いやー, 面白い.

参考

JITコンパイルでの冒険

Goでベンチマーク - Block Rockin’ Codes

CentOS6にOracle 11g XEを入れる

vagrantでCentOS6.7を入れて試している. (CentOS7はちょっと今回スルーで....)

1. ダウンロード

ここからライセンス同意すればダウンロードできる.

RPMで配布されている.

何気にアカウント登録を求められるのがめんどい...

64bit版しかないけど, 今時32bitもなかろう.

2. インストール

2.1. zipを解凍して中身を確認

とりあえずzipを解凍

[vagrant@localhost ~] unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip

Disk1ディレクトリが出来る.

中身はこんな感じ.

[vagrant@localhost ~]$ cd Disk1/
[vagrant@localhost Disk1]$ ls
oracle-xe-11.2.0-1.0.x86_64.rpm  response  upgrade

2.2. 依存パッケージのインストール

一度試すとbcが要るといわれたので入れる.

[vagrant@localhost Disk1]$ sudo yum install bc

2.3. [番外編]vagrantのswapが足りないといわれたので増やす

[vagrant@localhost Disk1]sudo swapon -s
[vagrant@localhost Disk1]df
[vagrant@localhost Disk1]sudo dd if=/dev/zero of=/swapfile bs=1M count=2500
[vagrant@localhost Disk1]sudo mkswap /swapfile
[vagrant@localhost Disk1]sudo swapon /swapfile

2.4. rpmでインストール

[vagrant@localhost Disk1]$ sudo rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
Preparing...                ########################################### [100%]
   1:oracle-xe              ########################################### [100%]
   Executing post-install steps...
   You must run '/etc/init.d/oracle-xe configure' as the root user to configure the
    database.

2.5. configureを実行

[vagrant@localhost ~]$ sudo /etc/init.d/oracle-xe configure

Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g Express
Edition.  The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts.  Press <Enter> to accept the defaults.
Ctrl-C will abort.

Specify the HTTP port that will be used for Oracle Application Express [8080]:  #[デフォルトで良いのでEnter]

Specify a port that will be used for the database listener [1521]: #[デフォルトで良いのでEnter]

Specify a password to be used for database accounts.  Note that the same
password will be used for SYS and SYSTEM.  Oracle recommends the use of
different passwords for each database account.  This can be done after
initial configuration: #[passwordとか適当に]
Confirm the password:  #[passwordとか適当に]

Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]:y

Starting Oracle Net Listener...Done
Configuring database...Done
Starting Oracle Database 11g Express Edition instance...Done
Installation completed successfully.

3. 接続確認

3.1. SQLPlusの設定

下記を実行すれば環境変数はいい感じにしてくれるらしい.

[vagrant@localhost ~]$ . /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh

~/.bashrcに環境変数設定用シェルスクリプトの呼び出しを追加.

[vagrant@localhost ~]$ vi ~/.bashrc
# User specific aliases and functions
. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh

3.2. SQLPlusで確認

いい感じ.

[vagrant@localhost ~]$ sqlplus system

SQL*Plus: Release 11.2.0.2.0 Production on Thu Oct 12 03:07:33 2017

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Enter password:

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL>

参考

Linux(CentOS) 64bit版へOracle XE(Express Edition)をインストール

Oracle XEをVagrantで入れようとしたらswapが足りなかった