Skip to content

Instantly share code, notes, and snippets.

@kanonji
kanonji / time.js
Created April 20, 2011 16:27
Class to handle time for JavaScript.
var Time = function( time, type ){
this.hour = 0;
this.minute = 0;
this.second = 0;
this.millisecond = 0;
var HOURS = 60 * 60 * 1000;
var MINUTES = 60 * 1000;
var SECONDS = 1000;
this._HOUR = function(){ return HOURS };
this._MINUTE = function(){ return MINUTES };
@kanonji
kanonji / remove-characters-for-filename.php
Created April 7, 2011 19:59
Remove ASCII unavailable for filename
<?php
/**
* \x00-\x1f\x7f: Controll Characters
* \x22 "
* \x2a *
* \x2f /
* \x3a :
* \x3c <
* \x3e >
* \x3f ?
@kanonji
kanonji / file_exists-is-not-binary-safe.txt
Created April 4, 2011 19:09
test for file_exists() is binary safe or not.
If you see that this file is exist, file_exists() is not binary safe.
<?php
/**
* Extended HtmlHelper
* @author kanonji
*/
class ExHtmlHelper extends HtmlHelper {
/**
* $.webroot() for jQuery
*
* To get webroot path when using jQuery.
<h1>Look see when Undefined variable/offset notice occurs with isset() is_null() empty() if()</h1>
<h2>$foo;</h2>
<?php $foo;?>
<h3>isset($foo)</h3>
<p>
<?php var_dump(isset($foo)); ?>
</p>
<h3>is_null($foo)</h3>
<p>
<?php var_dump(is_null($foo)); ?>
/**
* Extended HtmlHelper
* @author kanonji
*/
class ExHtmlHelper extends HtmlHelper {
/**
* Extended HtmlHelper->link() to understand the url is current or not.
*
* $options['current'] is additional option key.
* If no value set, 'current' is set as default.
<?php
class Foo{
public function call($call){
call_user_func(array($this, $call));
}
static public function publicmethod(){
echo __METHOD__;
}
static protected function protectedmethod(){
echo __METHOD__;