Skip to content

Instantly share code, notes, and snippets.

@kuzuha
kuzuha / gist:2232677
Created March 29, 2012 02:38
php interface declaration duplication.
<?php
interface Foo {
function test();
}
interface Bar {
function test();
}
@kuzuha
kuzuha / gist:1386352
Created November 22, 2011 17:48
array filter on php 5.4
$it = new CallbackFilterIterator(
new ArrayIterator(range(1, 10)),
function($v){ return $v % 2 == 1;}
);
foreach($it as $value) {
var_dump($value);
}
@kuzuha
kuzuha / gist:1300778
Created October 20, 2011 09:47
add SERVER_PROTOCOL to cli_server
Index: sapi/cli/php_cli_server.c
===================================================================
--- sapi/cli/php_cli_server.c (revision 318210)
+++ sapi/cli/php_cli_server.c (working copy)
@@ -571,6 +571,12 @@
sapi_cli_server_register_variable(track_vars_array, "SERVER_SOFTWARE", tmp TSRMLS_CC);
efree(tmp);
}
+ {
+ char *tmp;
use 5.12.1;
use warnings;
use Plack::Request;
use Router::Simple;
use FindBin;
use AnyEvent::Util qw(run_cmd);
my $router = Router::Simple->new();
my @tap = ();
my $builder = "/Library/Application Support/Titanium/mobilesdk/osx/1.6.2/iphone/
Ti.include 'qunit/qunit.js'
Ti.include 'qunit/qunit-tap.js'
qunitTap QUnit, (message) ->
Ti.API.info message
xhr = Ti.Network.createHTTPClient()
xhr.open 'POST', 'http://192.168.3.2:5000/tap', false
xhr.send tap : message
, noPlan: true
@kuzuha
kuzuha / gist:8cc5d70a31b9619e2938
Last active August 29, 2015 14:14
PHP といえば、Facebook の Hack はどうなったんだろう
ideサポート
intellijのideであるphpstormがサポートをしようとしている。
https://youtrack.jetbrains.com/issue/WI-21737
fix versiosには9.0が付いているので、うまくいけば2015年末にリリースされるであろうphpstorm 9.0に含まれる。
hhvm 3.3からxdebugが含まれるようになったことも含め、今後のide対応に期待が高まる。
async/await サポート
http://hhvm.com/blog/7091/async-cooperative-multitasking-for-hack
便利そう(小並感)
php -r '$a=[]; $a["1.1"]=1; $a[1.1]=2; var_dump($a);'
array(2) {
'1.1' =>
int(1)
[1] =>
int(2)
}
php -r '$a="0x12"; $a++; var_dump($a);'
int(19)
php -r '$a="012"; $a++; var_dump($a);'
<?php
trait AbstractSpeak
{
abstract protected function speak($string);
}
trait PrintSpeak
{
protected function speak($string)