Skip to content

Instantly share code, notes, and snippets.

$ npm install nroongaでエラー

エラーメッセージ

$ npm install nroonga
[Snip]
npm http 304 https://registry.npmjs.org/mkdirp/0.3.0

> [email protected] install /Users/myuser/dev/nrn/node_modules/nroonga
@kanonji
kanonji / Gemfile
Created November 29, 2012 08:22
Gemfile for my heroku env
# A sample Gemfile
source "http://rubygems.org"
path 'vendor/bundle'
gem "heroku"
gem "foreman"
@kanonji
kanonji / 20121206_CakePHP2-tiny-doc.md
Last active May 1, 2017 05:10
My tiny doc for CakePHP2CakePHP

Model

find()

Result data format

find('first')
array(

beforeSave()はModelとBehaviorのどちらが先に呼ばれるか

  public function getEventManager() {
		if (empty($this->_eventManager)) {
			$this->_eventManager = new CakeEventManager();
			$this->_eventManager->attach($this->Behaviors);
			$this->_eventManager->attach($this);
		}
 return $this->_eventManager;

CakeEventManager

CakeEventManagerについて、ソースコードを読んで分かった事を、それでも全部を読み切ってはないので、予想も含めつつまとめます。

まとめ

CakeEventManagerは、アプリケーション全体のイベントを管理する、グローバルマネージャーとしてシングルトン風に生成される。同時に、互いに干渉しない、ローカルマネージャーの生成も行える。 CakePHPのコードをgrepした所、Model, View, Controller, Dispatcherがそれぞれローカルマネージャーを持っていて、互いに干渉しない作りとなっている。ただし、グローバルマネージャーは、どのローカルマネージャーがdispatch()しても、必ずイベントを発火させる。

グローバルマネージャー

@kanonji
kanonji / cheker_for_phptag_and_linebreak.php
Created January 24, 2013 08:46
phpタグが、外側の改行を消す事が有るみたいなので、その動きをチェックする為に作りました。 markdown風のテキストにphpタグを埋め込んでる.phpファイルです。`php cheker_for_phptag_and_linebreak.php`の様に実行すると`php code`と`output`が同じになると思います。
# phpタグと改行
## phpタグ後に文字が有る場合は問題が無い
### php code
<?php echo "PHP"; ?>text
<?php echo "PHP"; ?>
<?php
/**
* Template Task can generate templated output Used in other Tasks
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
#!/usr/bin/perl
use strict;
use warnings;
use Archive::Zip;
use Encode;
if (@ARGV == 0) {
die "usage: $0 ZIPFILE\n";
}
@kanonji
kanonji / .mpdconf
Last active December 17, 2015 22:19
mpd 0.16.3 on serversman
port "6600"
playlist_directory "~/.mpd/playlists"
music_directory "~/.mpd/music"
db_file "~/.mpd/mpd.db"
log_file "~/.mpd/mpd.log"
pid_file "~/.mpd/pid"
state_file "~/.mpd/state"
#bind_to_address "127.0.0.1" #does not work
bind_to_address "0.0.0.0"
#bind_to_address "any" #does not work
@kanonji
kanonji / common_used_perl_module.pl
Last active December 18, 2015 00:19
良く使うPerlモジュール
use feature qw/say/;
use Encode;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); #http://memememomo.hatenablog.com/entry/20100422/1271894685
use XML::Simple;
use Tie::IxHash; #http://blog.dealforest.net/2009/09/xml-parse-in-order/
use Path::Class;
use HTML::TreeBuilder::XPath; #http://blog.64p.org/entry/20100607/1275878274
use HTML::Selector::XPath 'selector_to_xpath';