Skip to content

Instantly share code, notes, and snippets.

<?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__;
/**
* 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.
<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)); ?>
<?php
/**
* Extended HtmlHelper
* @author kanonji
*/
class ExHtmlHelper extends HtmlHelper {
/**
* $.webroot() for jQuery
*
* To get webroot path when using jQuery.
@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.
@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 / 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 / gist:934093
Created April 21, 2011 10:02
Confirmation code to see in what 'this' is.
var Try = function(){
this.bar = 'bar';
$(window).bind( "load", { self: this }, this.loaded );
};
Try.prototype = {
loaded: function( e ){
console.info('------loaded------');
console.debug(this);
this.foo = 'loaded';
$('body').append( $('<ul>').attr('id', 'foo').append($('<li>')).append($('<li>')) );
@kanonji
kanonji / Bar.pm
Created June 7, 2011 09:49
perl ./once.pl is ok. perl ./twice.pl is not ok. Use 0.20110401 of Number::Phone::JP.
package Bar;
use strict;
use warnings;
use utf8;
use Number::Phone::JP;
sub invoke {
my ( $self ) = @_;
@kanonji
kanonji / client.pl
Created October 3, 2011 08:19
Gearmanの練習
#!/usr/bin/perl
use strict;
use warnings;
use Gearman::Client;
#use Gearman::Task;
use Storable qw/freeze/;
use Getopt::Long qw/GetOptions/;
my %opts = ();