Skip to content

Instantly share code, notes, and snippets.

Avatar

Tatsuya Fukata fukata

View GitHub Profile
@fukata
fukata / CodeIgniter1 cache driver patch
Created Mar 19, 2011
"CodeIgniter2" on "Cache Driver" feature "CodeIgniter1" backported patches. Override system directories.
View CodeIgniter1 cache driver patch
diff -Nru /home/tatsuya/DOWNLOAD/php/CodeIgniter_1.7.3/system/libraries/Cache/Cache.php ./system/libraries/Cache/Cache.php
--- /home/tatsuya/DOWNLOAD/php/CodeIgniter_1.7.3/system/libraries/Cache/Cache.php 1970-01-01 08:00:00.000000000 +0800
+++ ./system/libraries/Cache/Cache.php 2011-03-20 06:22:57.267999183 +0800
@@ -0,0 +1,216 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
@fukata
fukata / CodeIgniter1 cache driver patch subclass
Created Mar 19, 2011
"CodeIgniter2" on "Cache Driver" feature "CodeIgniter1" backported patches. Extends Loader.
View CodeIgniter1 cache driver patch subclass
diff -Nru /home/tatsuya/DOWNLOAD/php/CodeIgniter_1.7.3/system/application/libraries/Cache/Cache.php ./system/application/libraries/Cache/Cache.php
--- /home/tatsuya/DOWNLOAD/php/CodeIgniter_1.7.3/system/application/libraries/Cache/Cache.php 1970-01-01 08:00:00.000000000 +0800
+++ ./system/application/libraries/Cache/Cache.php 2011-03-20 07:28:52.003705893 +0800
@@ -0,0 +1,216 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
@fukata
fukata / pretty_date.php
Created Mar 26, 2011
Twitter has been used in such a function to generate a pretty date format string.
View pretty_date.php
<?php
function pretty_date($time) {
$diff = time() - $time;
$day_diff = floor($diff / 86400);
if(is_nan($day_diff)) return '';
if ($day_diff == 0) {
if ($diff < 60) {
return $diff . "second ago";
@fukata
fukata / test_blank.php
Created Mar 27, 2011
PHP variables to be empty string or NULL in making a determination.
View test_blank.php
<?php
// bad example
$v = '0';
if ( empty($v) ) {
echo '$v is blank.';
}
// good example
$v = '0';
if ( strlen($v)==0 ) {
@fukata
fukata / draw_near_data.js
Created Apr 2, 2011
Data to draw within the screen.
View draw_near_data.js
// require jquery
$(function(){
var $w = $(window);
var $h = $('html,body');
var offset = $w.height();
function canDraw($target, info) {
var top = $target.position().top;
if (info.st - offset <= top && top <= info.st + info.wh + offset) {
return true;
}
@fukata
fukata / LoggerAppenderRollingDailyFile.patch
Created Apr 2, 2011
Date format files to rotate log4php appender.
View LoggerAppenderRollingDailyFile.patch
--- log4php-org/Logger.php 2010-07-27 03:21:18.705554189 +0900
+++ log4php/Logger.php 2011-04-02 00:26:13.964032277 +0900
@@ -77,6 +77,7 @@
'LoggerAppenderMailEvent' => '/appenders/LoggerAppenderMailEvent.php',
'LoggerAppenderNull' => '/appenders/LoggerAppenderNull.php',
'LoggerAppenderPhp' => '/appenders/LoggerAppenderPhp.php',
+ 'LoggerAppenderRollingDailyFile' => '/appenders/LoggerAppenderRollingDailyFile.php',
'LoggerAppenderRollingFile' => '/appenders/LoggerAppenderRollingFile.php',
'LoggerAppenderSocket' => '/appenders/LoggerAppenderSocket.php',
'LoggerAppenderSyslog' => '/appenders/LoggerAppenderSyslog.php',
@fukata
fukata / mercurial_pull_parents.txt
Created Apr 6, 2011
Mercurial: Pull parent updates.
View mercurial_pull_parents.txt
$ hg clone parents
$ hg clone child
$ cd child
$ hg pull -u ../parents
$ hg merge
$ hg commit -m 'merge parents'
@fukata
fukata / ci_2.0.1_and_2.0.2.diff
Created Apr 8, 2011
Diff CodeIgniter 2.0.1 and 2.0.2
View ci_2.0.1_and_2.0.2.diff
This file has been truncated, but you can view the full file.
diff -Nru CodeIgniter_2.0.1/application/migrations/001_Create_accounts.php CodeIgniter_2.0.2/application/migrations/001_Create_accounts.php
--- CodeIgniter_2.0.1/application/migrations/001_Create_accounts.php 2011-03-16 02:53:58.000000000 +0800
+++ CodeIgniter_2.0.2/application/migrations/001_Create_accounts.php 1970-01-01 08:00:00.000000000 +0800
@@ -1,32 +0,0 @@
-<?php defined('BASEPATH') OR exit('No direct script access allowed');
-
-class Migration_Create_accounts extends CI_Migration {
-
- function up()
View alias.sh
#alias git
alias gia='git add'
alias gial='git add --all'
alias gic='git commit'
alias gicm='git commit -m'
alias gis='git status'
alias gips='git push'
alias gipl='git pull'
alias gich='git checkout'
alias gib='git branch'
@fukata
fukata / test_intersectes.php
Created Apr 11, 2011
対象データ数に比例しない突き合わせ処理サンプル
View test_intersectes.php
<?php
function test1($masters, $targets) {
$sd = microtime(true);
$intersects = array_uintersect_assoc($targets, $masters, 'compare_key');
$ed = microtime(true);
return $ed-$sd;
}
function compare_key($key1, $key2) {
if ($key2 == $key1->id) {
You can’t perform that action at this time.