vagrant(for windows)
# vagrantのインストール
Vagrant_1.3.5.msiをインストール(2013/11/20現在)
にインストールされます
# CentOS64bit版をインストール
$ vagrant box add {title} {url}
C:\Users\a9b\>C:\HashiCorp\Vagrant\bin\vagrant box add lucid64 http://files.vagrantup.com/lucid64.box
他のBoxに関しては、下記にあります
# 実際にVirtualBoxで起動します
$ vagrant init {BOX名}
$ vagrant up
C:\Users\a9b\>mkdir lucid64
C:\Users\a9b\>cd lucid64
C:\Users\a9b\lucid64 >C:\HashiCorp\Vagrant\bin\vagrant init lucid64
C:\Users\a9b\>cd lucid64
C:\Users\a9b\lucid64 >C:\HashiCorp\Vagrant\bin\vagrant init lucid64
C:\Users\a9b\lucid64 >C:\HashiCorp\Vagrant\bin\vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'lucid64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Mounting shared folders...
[default] -- /vagrant
[default] Importing base box 'lucid64'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Mounting shared folders...
[default] -- /vagrant
C:\Users\a9b\lucid64 >dir
C:\Users\seki\cent64 のディレクトリ
2013/11/20 15:27 <DIR> .
2013/11/20 15:27 <DIR> ..
2013/11/20 15:27 <DIR> .vagrant
2013/11/20 15:27 4,730 Vagrantfile
2013/11/20 15:27 <DIR> .
2013/11/20 15:27 <DIR> ..
2013/11/20 15:27 <DIR> .vagrant
2013/11/20 15:27 4,730 Vagrantfile
となっているはずです
# sshでログイン
$ vagrant ssh
C:\Users\a9b\cent64>C:\HashiCorp\Vagrant\bin\vagrant ssh
`ssh` executable not found in any directories in the %PATH% variable. Is an
SSH client installed? Try installing Cygwin, MinGW or Git, all of which
contain an SSH client. Or use the PuTTY SSH client with the following
authentication information shown below:
Host: 127.0.0.1
Port: 2222
Username: vagrant
Private key: C:/Users/a9b/.vagrant.d/insecure_private_key
`ssh` executable not found in any directories in the %PATH% variable. Is an
SSH client installed? Try installing Cygwin, MinGW or Git, all of which
contain an SSH client. Or use the PuTTY SSH client with the following
authentication information shown below:
Host: 127.0.0.1
Port: 2222
Username: vagrant
Private key: C:/Users/a9b/.vagrant.d/insecure_private_key
puttyから上記のアクセス情報でアクセスするとログインできます。
# 参考URL
しましまにする
しましまにしたいセルを全て選択して条件付き書式の設定画面を開き、以下の条件を設定します。
数式が "=AND(MOD(ROW(),2)=1)"
tmux.conf
# キーバインドの変更 unbind-key C-b set-option -g prefix C-j bind C-j send-prefix bind-key k confirm-before -p "kill-pane #P? (y/n)" kill-pane bind-key K kill-pane bind-key h select-pane -t :.- bind-key l select-pane -t :.+ bind-key v split-window -h bind-key s split-window bind-key o new-window bind-key b choose-window bind-key M switch-client -l bind-key H previous-window bind-key L next-window # ステータスライン set-window-option -g utf8 on set-window-option -g mode-keys vi set-window-option -g automatic-rename off set-window-option -g status-interval 5 set -g status-left-length 30 set -g status-left '#[fg=white,bg=black]#[default]' set -g status-right '#[fg=white,bg=black,bold]#H#][#S#[fg=white]][%Y-%m-%d(%a) %H:%M]#[default]' # window-status-current setw -g window-status-current-fg black setw -g window-status-current-bg cyan setw -g window-status-current-attr bold#,underscore # pane-active-border set -g pane-active-border-fg black set -g pane-active-border-bg cyan # color set-option -g status-bg black set-option -g status-fg cyan set-option -g history-limit 100000 # マウス設定 #set-option -g mouse-select-pane on #set-option -g mouse-select-window on #set-option -g mouse-resize-pane on #set-option -g mode-mouse on # PuTTYを使う場合は、下記の設定はoffを推奨(コメントを参照してください) set-option -g mouse-utf8 off bind S run "tmux capture-pane -S -10000; tmux show-buffer | /usr/sbin/sendmail seki@banex.jp"
array_multisortで配列の中身でソート
array_multisortが優秀すぎた。
http://jp2.php.net/manual/ja/function.array-multisort.php
<?php $data[] = array('volume' => 67, 'edition' => 2); $data[] = array('volume' => 86, 'edition' => 1); $data[] = array('volume' => 85, 'edition' => 6); $data[] = array('volume' => 98, 'edition' => 2); $data[] = array('volume' => 86, 'edition' => 6); $data[] = array('volume' => 67, 'edition' => 7); // 列方向の配列を得る foreach ($data as $key => $row) { $volume[$key] = $row['volume']; $edition[$key] = $row['edition']; } ?>
データを volume の降順、edition の昇順にソートする。
$data を最後のパラメータとして渡し、同じキーでソートする。
<?php array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data); ?>
cakePHPでmysqlのCOUNT
cakePHPでmysqlのCOUNT(*)の処理をする際に
下記のように配列が望んでいる形で返ってこない場合の対処
(※cakePHP1.2系)
$f = array("COUNT(`Model`.`field`) as `count_result`,"field_1","field_2");
array(1) { [0]=> array(2) { [0]=> array(1) { ["count_result"]=> string(1) "0" } ["Model"]=> array(3) { ["field_1"]=> NULL ["field_2"]=> NULL } } }
\\cake\libs\model\datasources\dbo_source.php
<?php function fetchResult() { if ($row = mysql_fetch_row($this->results)) { $resultRow = array(); $i = 0; foreach ($row as $index => $field) { list($table, $column) = $this->map[$index]; $resultRow[$table][$column] = $row[$index]; $i++; } return $resultRow; } else { return false; } } ?>
\\cake\libs\model\datasources\dbo_source.php
<?php function fetchResult() { if ($row = mysql_fetch_row($this->results)) { $resultRow = array(); $i = 0; # editer a9b $t_table = 0; foreach ($row as $index => $field) { list($table, $column) = $this->map[$index]; # editer a9b if(empty($table)){ $table = $t_table; }else{ $t_table = $table; } $resultRow[$table][$column] = $row[$index]; $i++; } return $resultRow; } else { return false; } } ?>
また、上記の修正ではフィールド指定の順序を持ってきたいフィールドの後ろに置かないと動きません。
$f = array("field_1","field_2","COUNT(`Model`.`field`) as `count_result`");
array(1) { [0]=> array(1) { ["Model"]=> array(4) { ["field_1"]=> NULL ["field_2"]=> NULL ["count_result"]=> string(1) "0" } } }