Skip to content

Instantly share code, notes, and snippets.

<?php
class TraitSampleTest extends PHPUnit_Framework_TestCase
{
use TraitSampleTrait;
protected function getOne()
{
return 2;
}
}
@ngyuki
ngyuki / LegacyProxyTest.php
Created April 23, 2013 14:43
LegacyProxyTest.php
<?php
namespace ngyuki\example\LegacyProxy;
class LegacyProxy
{
public static function classof()
{
return get_called_class();
}
function phpunit
{
local root="${PWD}"
while [ -n "${root}" ]; do
if [ -x "${root}/vendor/bin/phpunit" ]; then
break
fi
root="${root%/*}"
done
#!/usr/bin/env bash
# example)
# ./phpunit-watch src/ tests/ -c tests/ --colors
set -e
set -u
function usage
{
@ngyuki
ngyuki / fproxy.js
Last active December 31, 2015 00:19
node.js forward proxy example
var httpProxy = require('http-proxy');
var url = require('url');
var net = require('net');
var http = require('http');
process.on('uncaughtException', function (err) {
console.error('! uncaughtException: ' + err.stack);
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script>
$(function(){
$('#aaa').click(function(){
<?php
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
$commands = [];
@ngyuki
ngyuki / symfony-console-single.php
Last active August 29, 2015 14:03
symfony console single
<?php
require __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class MyApplication extends Application
@ngyuki
ngyuki / uopz-di-classes.php
Last active March 6, 2018 12:29
Example of uopz di experimental
<?php
interface SayInterface
{
public function say();
}
class Ore implements SayInterface
{
public function say()
{
<?php
// composer require react/react:\*
require __DIR__ . '/vendor/autoload.php';
use React\EventLoop\Factory;
use React\Socket\Server as SocketServer;
use React\Http\Server as HttpServer;
use React\Http\Request;
use React\Http\Response;