2012/07/10

CakePHPのモデルキャッシュ

新しくカラムを追加した場合、本番環境でのみ更新されないということがある。debug=0では999日間モデルキャッシュが効いてるので削除してあげましょうというお話。

http://pplace.jp/2011/06/158/

2012/07/09

CakePHPでQdmailを使う場合の修正

エラー文

Fatal error: Call to undefined method View::renderElement() in /***/app/controllers/components/qdmail.php on line 3823

エラー分の該当箇所を下記に修正



$content = $view->element( $this->view_dir . DS . $type . DS . $this->template , 
  array('content' => $content ) , true );



http://www.msng.info/archives/2011/01/using-qdmail-component-on-cakephp-1-3.php

JqueryのCDNが落ちてた場合の対処法

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>!window.jQuery && document.write('<script src="/サーバーURL/jquery.js"><\/script>')</script>


こんな感じで対処できる

iOSでデフォルトで動いてるプロセスリスト

Launchd: takes over many tasks from cron, xinetd, mach_init, and init, which are UNIX programs that traditionally have handled system initialization, called systems scripts, run startup items, and generally prepared the system for the user. (do not close)
TQServer: Net Long Company PC Suit daemon (recommend not to close it)
BTServer: Bluetooth Service (BlueTooth) (in my environment with the dock, turn it off iphone not responding)
CommCenter: Communications Center (phone system) (do not close)
configd: to automatically configure and maintain the network (do not close)
cron: regularly scheduled command or script execution (alarm clock might use it, recommend not to close it)
mDNSResponder: Multicast-DNS Responder daemon. (Do not turn off)
lockdownd: so that iPhone can use other SIM card (do not close)
ptpd: the process of connecting itunes (do not close)
fitx: WeFIT Input Method (not recommended to be closed)
mediaserverd: (system sounds) (do not close)
notifyd: inter-process communication (do not close)
SpringBoard: Springboard is no better explanation in English, if you used the installer or ibrickr install a third-party software, you will find the middle of the screen there is a circular symbol loader, and then immediately return to the standby screen iPhone , then this is a Springboard restart the process (do not close)
MobilePhone: I need not explain this right (do not close)
sshd: ssh daemon (you can close it)
crashreporterd: test application crashes the daemon. (Recommend to close)
dock: dock the software process (you decide to use or not)
iapd: ipod is the iphone and other Apple products using a communication protocol, the purpose is to allow other third-party devices such as communication equipment and iphone. (Recommended closure)
syslogd: recording system error logs and status messages (recommend to close)
: time to refresh the file system cache to prevent data loss caused by system crash (recommend to close). If you want to manually sync the file system cache, in text mode (ssh to connect to the iphone), implementation of the sync command.

VirtualBoxのCentOSでCPU使用率が上がる問題

/etc/grub.conf を下記のように編集


title CentOS (2.6.18-194.3.1.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-194.3.1.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet divider=10
        initrd /initrd-2.6.18-194.3.1.el5.img


http://digitalbox.jp/happy-go-lucky-computing/centos/howto-decrease-cpu-utilization-of-centos-on-virtualbox/

CakePHP1.3.10のテストのエラー対応


# /cake/tests/lib/reporter/cake_html_reporter.php
function CakeHtmlReporter($charset = 'utf-8', $params = array()) {
-    $params = array_map(array($this, '_htmlEntities'), $params);
-    $this->CakeBaseReporter($charset, $params);
+    $this->CakeBaseReporter($charset, $params);
+    $params = array_map(array($this, '_htmlEntities'), $params);
}


1.3.7では修正されたみたいだけど1.3.10ではまた戻っていたので対応

http://blog.longkey1.net/archive/931

Apacheがログローテートのときに落ちる問題

restartをreloadに変更して対処


vi /etc/logrotate.d/httpd/var/log/httpd/*log
{
 missingok
 notifempty
 sharedscripts
 postrotate
  #/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
  /sbin/service httpd reload > /dev/null 2>/dev/null || true
 endscript
}

http://life1204.blogspot.jp/2008/11/httpdlogrotatehttpd.html

HTML5のcanvasで画像データの読み書き


Canvasからbase64エンコーディングされた画像データを取得する方法
var canvas = document.getElementById("myCanvas"); 
var base64 = canvas.toDataURL(); 

// LocalStorageに保存する 

window.localStorage.setItem("saveKey", base64);
LocalStorageに保存したデータをCanvasに読み込む方法
// LocalStroageからデータを取得する
var base64 = window.localStorage.getItem("saveKey");

// Imageオブジェクトを作成し、src属性にデータを設定する
var image = new Image();
image.src = base64;
image.onload = function(){

  // 画像の読み込みが終わったら、Canvasに画像を反映する。
  canvas.drawImage(image, 0, 0);
}

herokuで独自ドメインを使う

Custom Domain Add Onを入れてドメインを指定

DNSサイドでは下記を登録する

75.101.163.44
75.101.145.87
174.129.212.2
https://devcenter.heroku.com/articles/custom-domains#dns_setup

rvmとcapistranoを同時に使う時のメモ

Gemfileに追加


gem 'rvm-capistrano'

deproy.rbに追加
set :rvm_ruby_string, 'ree@rails3'                     # Or:
#set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") # Read from local system

require "rvm/capistrano"                               # Load RVM's capistrano plugin.

https://rvm.io/integration/capistrano/