Skip to content

Instantly share code, notes, and snippets.

// INITAL STATE:
worker = new Person
space = new VeryPrivateSpace
dispenser = new PaperHolder
space.setFixture(dispenser)
//ACTION
worker.transferTo(space)
@dizyart
dizyart / NullChildFixture.php
Created June 29, 2013 22:27
A unit test for CakePHP and null foreign key for belongsTo
<?php
class NullChildFixture extends CakeTestFixture {
public $fields = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
'null_parent_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10),
'name' => array('type' => 'text', 'null' => false, 'default' => NULL, 'collate' => 'utf8_general_ci', 'charset' => 'utf8')
);
@dizyart
dizyart / pageant_add_keys.bat
Last active December 15, 2015 05:59
Add Putty SSH key files (PPK) to Pageant from the command line. Type pageant_add_keys /? or /help for usage.
@echo off
goto script
REM inspired by code in http://jelledepot.blogspot.com/2009/04/putty-pageant-autoload-your-private.html
REM @author DizyArt (https://github.com/dizyart)
REM @copyright 2013 Dizyart
REM licensed under WTFPL (Do What the Fuck You Want to Public License) http://en.wikipedia.org/wiki/WTFPL
@dizyart
dizyart / test.php
Last active December 13, 2015 16:49
Error report for NetBeans + xddebug + php5.4 (mongodb) + apache2.2
<pre>
<?php
$connection = new MongoClient();
$collection = $connection->database->test;
$collection->drop();
$collection->batchInsert([
['a' => 'b'],
['a' => 'b']
]
@dizyart
dizyart / .htaccess_cake_with_subs
Last active January 30, 2019 10:34
.htaccess to allow subdirectory access parallel to a CakePHP app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(?:development|cgi-bin|v1\.5|phpMyAdmin)(?:$|/)
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{REQUEST_URI} !^/(?:development|cgi-bin|v1\.5|phpMyAdmin)(?:$|/.*)
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>