Skip to content

Instantly share code, notes, and snippets.

@sasezaki
sasezaki / auto_prepend_file.php
Created May 3, 2012 16:44
Photozou(photo upload service) API Client - for Multi Access
<?php
set_include_path($_SERVER['HOME'].'/dev/zendframework_zf2/library/');
require_once 'Zend/Loader/StandardAutoloader.php';
$loader = new Zend\Loader\StandardAutoloader;
$loader->registerNamespace('Hasty', $_SERVER['HOME'].'/dev/padraic_hasty/src/Hasty');
$loader->registerNamespace('Symfony', $_SERVER['HOME'].'/dev/symfony_symfony/src/Symfony');
$loader->registerNamespace('Guzzle', $_SERVER['HOME'].'/dev/guzzle_guzzle/src/Guzzle');
$loader->registerNamespace('React', $_SERVER['HOME'].'/dev/react-php_react/src/React');
$loader->register();
@sasezaki
sasezaki / codegenerato.20120502.patch
Created May 2, 2012 13:52
Zend Framework 2 Code component fix
diff --git library/Zend/Code/Generator/ClassGenerator.php library/Zend/Code/Generator/ClassGenerator.php
index 5e633cf..2fa7724 100644
--- library/Zend/Code/Generator/ClassGenerator.php
+++ library/Zend/Code/Generator/ClassGenerator.php
@@ -139,7 +139,8 @@ class ClassGenerator extends AbstractGenerator
$methods = array();
foreach ($classReflection->getMethods() as $reflectionMethod) {
/* @var $reflectionMethod \MethodReflection\Code\Reflection\ReflectionMethod */
- if ($reflectionMethod->getDeclaringClass()->getName() == $cg->getName()) {
+ // @todo should check namespace
@sasezaki
sasezaki / get_binlen_bench.php
Created April 11, 2012 11:34
to get length of binary string in bytes - tiny benchmark
<?php
$count = 100;
$data = "あいうえお";
for ($i= 1; $i < 10; $i++) {
$data .= $data;
}
echo phpversion(), PHP_EOL;
@sasezaki
sasezaki / gist:2301554
Created April 4, 2012 14:22
comment test
I feel require separating target components into 4 or 5 sets
for "Which component should test?"
[a]. ".travis/new-and-upgrading-components"
- Stdlib, EventManager, Cache, Http, Loader, Log, Mail, Session,
Db , Uri, View
Serializer, Markup,
Module, Mvc & Docbook
[b-1]. ".travis/tested-components" (apply namespace & CS from zf1, not
planned updating for zf2)
@sasezaki
sasezaki / 1-Bootstrap.php
Created April 3, 2012 11:00
Zend\Di and bootstrap usage example (Zend\Cache\StorageFactory setting with Zend\Di)
<?php
namespace Miffie;
use Miffie\Runner,
Zend\Config\Config,
Zend\Di\Configuration as DiConfiguration,
Zend\Di\Di;
class Bootstrap
{
@sasezaki
sasezaki / gist:2237956
Created March 29, 2012 14:26
zf2 library - grep -rin "@deprecated"
library/Zend/File/Transfer/Adapter/AbstractAdapter.php:1012: * @deprecated Will be changed to be a filter!!!
library/Zend/Ldap/Exception.php:152: * @deprecated not necessary any more - will be removed
library/Zend/Ldap/Exception.php:165: * @deprecated will be removed
library/Zend/Ldap/Ldap.php:96: * @deprecated will be removed, use {@see Zend_Ldap_Filter_Abstract::escapeValue()}
library/Zend/Ldap/Ldap.php:106: * @deprecated will be removed, use {@see Zend_Ldap_Dn::checkDn()}
library/Zend/Server/AbstractServer.php:39: * @deprecated
library/Zend/Server/AbstractServer.php:97: * @deprecated
library/Zend/Filter/Inflector.php:128: * @deprecated Use setOptions() instead
library/Zend/Validator/ValidatorChain.php:56: * @deprecated Since 1.5.0
library/Zend/Validator/ValidatorChain.php:122: * @deprecated Since 1.5.0
@sasezaki
sasezaki / retry.php
Created March 17, 2012 07:48
php retry by limited goto
<?php
static $retry = 0;
retry:
try {
echo time(), PHP_EOL;
throw new \RuntimeException;
} catch (RuntimeException $e) {
if (++$retry < 3) goto retry;
}
echo 'done';
@sasezaki
sasezaki / gist:2037384
Created March 14, 2012 15:46
scraping hatena keyword
casper = require('casper').create()
ret ={}
casper.start "http://d.hatena.ne.jp/keyword/%BA%B0%CC%EE%A4%A2%A4%B5%C8%FE", ->
ret =
title: @fetchText "div.keyword-container a.title"
url: @evaluate -> document.querySelector("div.keyword-container a.title").getAttribute('href')
furigana: @fetchText "div.keyword-container span.furigana"
@sasezaki
sasezaki / php53result
Created March 9, 2012 18:28
current ZF2 Http StaticTest will fail on PHP5.4.0
$ php ~/tmp/phpunit36/bin/phpunit -c tests/phpunit.xml tests/Zend/Http/Client/StaticTest.php PHPUnit 3.6.10 by Sebastian Bergmann.
Configuration read from /home/sasezaki/zf2/tests/phpunit.xml
.........................string(18) "POST \/ HTTP\/1\.1"
string(15) "POST / HTTP/1.1"
string(18) "Host: example\.com"
string(17) "Host: example.com"
string(17) "Connection: close"
string(17) "Connection: close"
@echo off
REM casperjs
REM
if "%PHANTOMJS_EXECUTABLE%" == "" set
PHANTOMJS_EXECUTABLE=d:\programs\phantomjs\phantomjs.exe
GOTO RUN
:RUN