Skip to content

Instantly share code, notes, and snippets.

@kuzuha
kuzuha / gist:5378735
Last active December 16, 2015 04:39
testem android emulator proxy command
#!/bin/sh
URL=`perl -e '$in="'$1'"; $in =~ s/localhost/10.0.2.2/; print $in;'`
$ANDROID_SDK_HOME/platform-tools/adb shell am start -a android.intent.action.VIEW -d $URL
<?php
function array_slide(&$array, $key, $amount) {
if ($amount === 0) {
return;
}
$keys = array_keys($array);
$values = array_values($array);
$target = array($keys[$key] => $values[$key]);
$left = array_slice($array, 0, $key);
@kuzuha
kuzuha / gist:3520393
Created August 29, 2012 23:33
tcpdump filter
#!/usr/bin/env perl
$buf = '';
while(<STDIN>) {
$flag = $_ =~ m/^\s+0x[\da-f]{4}: /;
if (!$flag) {
$buf =~ s/\s//g;
$buf =~ s/[0-9A-Fa-f][0-9A-Fa-f]/pack("C", hex $&)/eg;
$buf = substr($buf, 52);
@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;
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
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/