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 | |
Validator::registerMessages(array( | |
'not-empty'=>'入力してください', | |
'max-length'=>'{1}文字以上', | |
'min-length'=>'{1}文字以内', | |
)); | |
$v = new Validator($post); | |
$v->check('title') |
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 PHPTAL's attribute extension test. | |
* pal:content-nl2br : replaces newline to <br/> | |
* pal:replace-nl2br : replaces newline to <br/> | |
* pal:attr : shorter version of tal:attributes | |
* and adds context variable includes original attributes | |
* named as "attr" inside the tag. | |
*/ | |
require_once 'PHPTAL.php'; |
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 if ( ! defined('BASEPATH')) exit('Direct script access not allowed'); | |
/** | |
* This library bakes related object(s) into object field (or array key) using CI's ActiveRecord. | |
* | |
* @author Hisateru Tanaka | |
* | |
* Annual issue: | |
* Explicit sql programing is too redundant and too difficult to describe about relations. | |
* |
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 | |
// かならずコンテキスト付きで初期化する trait | |
trait InitWithContext { | |
function __construct($context) | |
{ | |
$this->context = $context; | |
} | |
} | |
// オブジェクトのフィールドを直接呼べるようになる trait |
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
app = (require 'express').createServer() | |
#app.get /.*/, (req,res) -> res.render 'maintenance' #メンテナンスモード | |
#app.all /.*/, (req,rep) -> res.send 503 #メンテナンスモード | |
app.get '/', (req,resp)-> | |
resp.send 'Hello World' | |
app.get '/goodbye', (req,resp)-> | |
resp.send 'Goodbye World' |
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 | |
$sortables = Pinoco::newVars(array( | |
'sort_id' =>'id', | |
'sort_author' =>'author', | |
'sort_title' =>'title', | |
'sort_price' =>'price', | |
)); | |
$sql .= ' ORDER BY ' . $sortables->get($_GET['sort'], 'id'); |
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 | |
$sql .= ' ORDER BY ' . Pinoco::newVars(array( | |
'sort_id' =>'id', | |
'sort_author' =>'author', | |
'sort_title' =>'title', | |
'sort_price' =>'price', | |
))->get($_GET['sort'], 'id'); |
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 | |
$sql = Pinoco::newList(); | |
$sql->push('SELECT ...'); // ここでメインのクエリを書く | |
$sql->push(Pinoco::newVars(array( | |
'sort_id' =>'ORDER BY id', | |
'sort_author' =>'ORDER BY author', | |
'sort_title' =>'ORDER BY title', | |
'sort_price' =>'ORDER BY price', |
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
#!/usr/bin/env python | |
#!coding: utf-8 | |
import sys, os, re, shutil | |
from optparse import OptionParser | |
parser = OptionParser(usage= | |
'''%prog [options] <target-dir> | |
Example: |
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 | |
/** | |
* Place this file in CakePHP's root dir and do: | |
* $ php -S localhost:8080 builtin-server.php | |
* with PHP5.4 | |
*/ | |
list($path, $param) = preg_split('/\?/', $_SERVER['REQUEST_URI'], 2); | |
if($path != '/' && (file_exists('app/webroot' . $path))) | |
{ | |
header(sprintf('Location: http://%s/app/webroot%s', |