Skip to content

Instantly share code, notes, and snippets.

@sime
sime / schema.php
Created February 26, 2012 15:01
Possible example of using the CakePHP Schema callback `after` to insert content in the database
<?php
// Possible example of using the CakePHP Schema callback `after`
// to insert content in the database.
// Inspiration: https://github.com/majna/schema
// Copy schema.php to app/Config/Schema
// Run: ./Console/cake schema create
App::uses('ClassRegistry', 'Utility');
class AppSchema extends CakeSchema {
@daneko
daneko / PHPUnit_vfsStream_memo.php
Created November 18, 2011 14:34
PHPUnit vfsStreamの使用方法メモ
<?php
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'vfsStream/vfsStream.php';
// require_once 'hoge.php';
/**
* ファイルシステムのテストに関してはURL参照
* とりあえずざっくり使う方法メモ
* @see http://www.phpunit.de/manual/3.6/ja/test-doubles.html#test-doubles.mocking-the-filesystem.examples.ExampleTest.php
@1000k
1000k / encodeco.php
Created September 1, 2011 01:32
PHP+jQuery Encoding/Decoding string form only in 1 file
<?php
if (isset($_POST['input']) && isset($_POST['mode'])) {
ob_start();
// Needs decoding because $_POST is encoded when jQuery.ajax sended the data.
$input = urldecode($_POST['input']);
switch ($_POST['mode']) {
case 'serialize':
$output = serialize($input);
val ahoNum = Array(
"ぜ~ろ", "い~ち", "にぃ~", "さぁ~ん",
"よぉ~ん", "ごぉ~", "ろぉ~く", "ななぁ~",
"はぁ~ち", "きゅ~ぅ", "じゅ~ぅ"
)
class NabeInt(i:Int){
def から(j:Int):List[Int] = (i to j).toList
}
@tony-landis
tony-landis / array-to-texttable.php
Created December 3, 2008 08:00
PHP: Array to Text Table Generation Class
<?php
/**
* Array to Text Table Generation Class
*
* @author Tony Landis <[email protected]>
* @link http://www.tonylandis.com/
* @copyright Copyright (C) 2006-2009 Tony Landis
* @license http://www.opensource.org/licenses/bsd-license.php
*/
class ArrayToTextTable