This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * $textから$start_termと$end_termの間に挟まれた部分を抜き出す関数 | |
| * @param type $text 全文字列 | |
| * @param type $start_term 抜き出しのスタートとなる文字列 | |
| * @param type $end_term 抜き出しの終わりとなる文字列 | |
| * @return type 間に挟まれた文字列 | |
| */ | |
| function cutText($text,$start_term,$end_term) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //既存のクラス | |
| class Banner { | |
| private $string; | |
| public function __construct($text) { | |
| if (is_string($text)) { | |
| $this->string = $text; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| interface MyIterator { | |
| public function hasNext(); | |
| public function next(); | |
| } | |
| class MovieShelf { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * pjax通信かどうか判定する関数。 | |
| * ヘッダーがあるかないかで判定。 | |
| */ | |
| function isPjax() { | |
| $headers = getallheaders(); | |
| //ブラウザごとに送られるヘッダーの大文字小文字が違うので吸収・・・だけどもっといい方法ありそう | |
| if ((isset($headers['X-PJAX']) && $headers['X-PJAX'] === "true") || |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##PJAX通信でHTMLを取得してDOMを書き換える | |
| class PjaxLoader | |
| previousUrl: null | |
| $container: null | |
| $loading: null | |
| constructor: () -> | |
| @previousUrl = location.href | |
| @$container = $('#content_area') ##書き換える対象のDOM | |
| @$loading = $('#loading_image') ##ローディング表示の画像とか | |
| $(window).bind('popstate', @_doPopstate) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * ConsistentHashing法で分散してくれるクラス | |
| */ | |
| class ConsistentHasher { | |
| protected $ring; | |
| protected $keys; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| error_reporting(E_ALL); | |
| require_once '../class/ConsistentHasher.php'; | |
| $start_time = microtime(TRUE); | |
| $nodes = array('1', '2', '3', '4'); | |
| $another_nodes = array('1', '2', '3', '4', '5'); | |
| $ids = range(1, 10000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * simple_xml_loadを使ったXMLパーサー | |
| */ | |
| class XmlLoader { | |
| const DISPLAY_XML_ERROR_LIMIT = 3; //一箇所が不適切なXMLになっていると連鎖的にエラーが大量に出るので。 | |
| /** |