This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; |
This file contains 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 ImageResizer { | |
public function resize($path, $width, $height) { | |
if (is_int($width) === FALSE || is_int($height) === FALSE) { | |
throw new Exception('$widthまたは$heightが不正'); | |
} | |
if (is_string($path) && is_file($path)) { | |
$this->resizeImage($path, $width, $height); |
This file contains 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になっていると連鎖的にエラーが大量に出るので。 | |
/** |
This file contains 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 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 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 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 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 { |