VirtualBoxで4TBの仮想ディスクを作る
GUIでは仮想ディスクのサイズは2TBまでしか指定できませんが、CUIだと2TB以上のサイズを指定することができます。VBoxManage createhdコマンドで仮想ディスクを作ります。
ホストOS、ゲストOSとも2TB以上のディスクが認識できるOSであることが前提です。
C:\Windows\System32> D:\Package\VirtualBox\VBoxManage createhd Usage: VBoxManage createhd --filename <filename> [--size <megabytes>|--sizebyte <bytes>] [--diffparent <uuid>|<filename> [--format VDI|VMDK|VHD] (default: VDI) [--variant Standard,Fixed,Split2G,Stream,ESX]
早速4TBのHDDに仮想ディスクを作ってみました。
サイズはMB指定で、あまりぴったりにするとエラーがでて作れなかったので15GB程余裕を持たせました。
4000340336640 / 1024 / 1024 = 3815021.8359375 → 3800000
(エラー) C:\Windows\System32>D:\Package\VirtualBox\VBoxManage createhd --filename M:\nas_ 4TB_140119.vdi --size 3815021 --format VDI --variant Fixed 0%... Progress state: VBOX_E_FILE_ERROR VBoxManage.exe: error: Failed to create hard disk VBoxManage.exe: error: Could not create the medium storage unit 'M:\nas_4TB_1401 19.vdi'. VBoxManage.exe: error: VDI: disk would overflow creating image 'M:\nas_4TB_14011 9.vdi' (VERR_DISK_FULL) VBoxManage.exe: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component M edium, interface IMedium VBoxManage.exe: error: Context: "int __cdecl handleCreateHardDisk(struct Handler Arg *)" at line 391 of file VBoxManageDisk.cpp (OK) C:\Windows\System32>D:\Package\VirtualBox\VBoxManage createhd --filename M:\nas_ 4TB_140119.vdi --size 3800000 --format VDI --variant Fixed 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Disk image created. UUID: f1b738f9-d6c9-41cd-abf5-f8b206a87634
--variant Fixed を指定して固定サイズにしたので4TBの仮想ディスクを作り終わるまで一晩かかりました。
平均100MB/sで書き込めたとして、10時間くらい見ておけば良いかと思います。
CakePHP2のHtmlHelperでcssを読み込むときにメディアタイプを指定する
普通にstyle.cssを読み込む場合はHtmlHelperでこのように書くとlinkタグに展開されます。
<?php echo $this->Html->css('style'); ?>
<link rel="stylesheet" type="text/css" href="/cakephp2/css/style.css" />
メディアタイプを指定する場合は第3引数にarrayでメディアタイプを指定します。
第2引数は rel 属性の値になります。
<?php echo $this->Html->css('print', 'stylesheet', array('media' => 'print')); ?>
<link rel="stylesheet" type="text/css" href="/cakephp2/css/print.css" media="print" />
PHP5.3以上のときだけDebugKitを読み込む
DebugKitのmasterブランチは2013年7月時点で
となっています。
PHP5.2系で動かすとこんなエラーが出ます。
Parse error: syntax error, unexpected T_FUNCTION in APP/plugins/DebugKit/Controller/Component/ToolbarComponent.php on line 174
ToolbarComponent.php でPHP5.3以降で追加された無名関数が使われているのでPHP5.2以下ではエラーになります。
<?php ... public function implementedEvents() { $before = function ($name) { return function () use ($name) { DebugTimer::start($name, __d('debug_kit', $name)); }; }; $after = function ($name) { return function () use ($name) { DebugTimer::stop($name); }; };
そこでPHP5.3以上のときだけDebugKitを読み込むようにしてみました。
<?php class AppController extends Controller { public $components = array('DebugKit.Toolbar'); ...
としていたのを
<?php class AppController extends Controller { public $components = array(); public function __construct($request = null, $response = null) { parent::__construct($request, $response); if (version_compare(PHP_VERSION, '5.3.0') >= 0) { $this->components['DebugKit.Toolbar'] = array(); } }
これでPHP5.2以下の環境にデプロイしてもエラーは出なくなります。
NEC VL-550WGのLANドライバ
NECのドライバダウンロード一覧に載っていなかったのでボードを眺めてBroadcomチップを見つけて、Broadcomのドライバを入れてみたらビンゴ。
OEMマザーはネットに情報が無くて不便ですわね。
WindowsのRubyで全てのgemをアンインストールする方法
コマンドプロンプトに以下のコマンドを貼り付けると全てのgemをアンインストールできます
ruby -e "`gem list`.split(/$/).each { |line| puts `gem uninstall -Iax #{line.split(' ')[0]}` unless line.empty? }"
RubyInstaller(Ruby 1.9.3-p429) でインストールした場合は初期状態で以下のgemが入っているので、一からやり直したいときはRubyごと再インストールした方がいいかもしれないです
C:\>gem list *** LOCAL GEMS *** bigdecimal (1.1.0) io-console (0.3) json (1.5.5) minitest (2.5.1) rake (0.9.2.2) rdoc (3.9.5)
参考サイト
How to uninstall all ruby gems on windows?
http://stackoverflow.com/questions/6373160/how-to-uninstall-all-ruby-gems-on-windows
singularize, pluralizeで文字列の単数形・複数形変換
ExcelシートからCakePHPのモデルを自動生成するのに単数形・複数形変換が自動でできたら、と思って調べてみたらsingularize, pluralizeを使えばいいということが分かったので試してみました。Win32OLEで簡単にExcelデータが読めるのでRubyで書いています。最近rooに乗り換えました。こちらも簡単にスプレッドシートが読めて OpenOffice, Google spreadsheet, Excel(xls, xlsx) に対応しています。
文字列の後に .singularize .pluralize を付けると複数形・単数形への変換ができます。
singularize.rb
require 'active_support/inflector' p "People".singularize p "Person".pluralize
$ ruby singularize.rb "Person" "People"
require 'active_support' だけだと undefined method `singularize' for "People":String (NoMethodError) になるので require 'active_support/inflector' とします。これでしばらくはまりました。
active_support::inflector にはその他、キャメルケースへの変換(camelize)等便利な関数が用意されています。
http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html
@Ruby 1.9.3