Skip to content

Instantly share code, notes, and snippets.

View akkunchoi's full-sized avatar

Akiyoshi Tanaka akkunchoi

View GitHub Profile
@akkunchoi
akkunchoi / test.txt
Created October 25, 2012 19:58
git subtree merge test
This is a initial text. Standard edit2 Added on master
@akkunchoi
akkunchoi / jquery.resizer.js
Created October 31, 2012 02:28
jQuery image max-width, max-height
// usage:
// $('img').resizer({maxWidth: 100});
$.fn.resizer = function(options){
this.each(function(k, v){
var d;
var self = $(v);
self.on('load', function(){
if (options.maxWidth){
if (self.width() > options.maxWidth){
@akkunchoi
akkunchoi / VisualizeShell.php
Last active December 12, 2015 07:29
CakePHP2.x visualize console task
<?php
/**
* This script is a edited version for CakePHP2.x to work
* original: http://bakery.cakephp.org/articles/AD7six/2008/01/24/visualize-schema-task
*/
/**
*
* Visualize console task
*
<?php
$options = array('colDelimiter' => ',');
csv('./test.csv', $options, function($row){
var_dump($row);
});
function csv($fp, $options = array(), $callback = null){
if (is_string($fp)){
$fp = fopen($fp, 'r');
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);
@akkunchoi
akkunchoi / HttpBasicAuth.php
Created November 8, 2013 03:36
This is a Slim middleware that provides http basic authentication.
<?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';
@akkunchoi
akkunchoi / hoge.html
Last active February 14, 2017 14:06
php tidy dom xpath
<html>
<section>hoge</section>
</html>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
function index(){
?><!doctype html>
<html>
<head>
<style type="text/css">
</style>
<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');
@akkunchoi
akkunchoi / angular-sample.md
Last active December 30, 2015 06:28
angular test

Angular sample code