D3 sample
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
var EventEmitter = (function(){ | |
var EventEmitter = function(){ | |
this.listeners = {}; | |
}; | |
EventEmitter.prototype.emit = function(eventName){ | |
var args = Array.prototype.slice.apply(arguments, [1]); | |
console.log(args); | |
if (this.listeners[eventName]){ | |
for (var i = 0; i < this.listeners[eventName].length; i++){ | |
this.listeners[eventName][i].apply(this, args); |
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 | |
// UTF-8文字列をUnicodeエスケープする。ただし英数字と記号はエスケープしない。 | |
function unicode_encode($str) { | |
return preg_replace_callback("/((?:[^\x09\x0A\x0D\x20-\x7E]{3})+)/", "encode_callback", $str); | |
} | |
function encode_callback($matches) { | |
$char = mb_convert_encoding($matches[1], "UTF-16", "UTF-8"); | |
$escaped = ""; | |
for ($i = 0, $l = strlen($char); $i < $l; $i += 2) { |
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
# coding: utf-8 | |
# | |
require 'nkf' | |
p "a a".split(/\s+/) # ムリ | |
# 以下utf8の場合 | |
# ref http://www.kkaneko.com/rinkou/ruby/hankaku.html | |
p NKF::nkf('-WwXm0', "アイウエオガギグゲゴ") # アイウエオガギグゲゴ | |
p NKF::nkf( '-Wwxm0Z0', "123" ) # 123 |
Angular sample code
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
<html><head><meta charset="UTF-8" /></head><body> | |
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> | |
<a href="#" class="s">Success</a> | |
<a href="#" class="f">Fail</a> | |
<script> | |
var df = jQuery.Deferred(); | |
df.then(function(){ | |
alert('then'); |
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); | |
ini_set('display_errors', 'On'); | |
function index(){ | |
?><!doctype html> | |
<html> | |
<head> | |
<style type="text/css"> | |
</style> |
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
<html> | |
<section>hoge</section> | |
</html> |
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 | |
/** | |
* This is a Slim middleware that provides http basic authentication. | |
* | |
* usage: | |
* | |
* $app->add(new HttpBasicAuth(array( | |
* 'users' => array('username' => 'password'), | |
* 'when' => function(\Slim\Http\Request $req, $res){ | |
* return $req->getPathInfo() === '/admin'; |
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
class CsvFileIterator implements \Iterator{ | |
protected $in; | |
protected $fp; | |
protected $index; | |
protected $current; | |
public function __construct($in, $options = array()) { | |
$this->in = $in; | |
$this->options = array_merge(array( | |
'column_separator' => ',' | |
), $options); |