Skip to content

Instantly share code, notes, and snippets.

View zonuexe's full-sized avatar
🤓
PHP is a Lisp. Emacs is Web.

USAMI Kenta zonuexe

🤓
PHP is a Lisp. Emacs is Web.
View GitHub Profile
@zonuexe
zonuexe / pcntl_signal_sample.php
Last active September 23, 2016 08:38
ticksを使ってみたサンプル
<?php
var_dump(PHP_SAPI);
pcntl_signal(SIGALRM, function () {
var_dump("おしまい", time()); exit;
});
// 2秒後にセット
pcntl_alarm(2);
$i = 0;
@zonuexe
zonuexe / htmlsprintf.php
Last active January 22, 2019 10:55
どうしてもPHPからHTMLを出力せざるを得なくなったときにご利用ください
<?php
/**
* printf is template engine
*
* @license WTFPL http://www.wtfpl.net/
* @author USAMI Kenta <[email protected]>
* @param string $format
* @param string|int|float $args...
* @return string
@zonuexe
zonuexe / abcxyz.el
Last active November 16, 2016 10:53
疑り深い人のためのダイナミックスコープ
(defvar foo-list '(a b c x y z))
(defun foo-func ()
foo-list)
(foo-func) ;=> (a b c x y z)
(defvar abc)
(defvar xyz)
@zonuexe
zonuexe / zaregoto.dic
Created May 10, 2016 15:02
戯言だけどね
あいかわじゅん 哀川潤
あいかわじゅんや 藍川純哉
あおいいみここ 葵井巫女子
あおいろさう゛ぁん 青色サヴァン
あかがみ 赤神
あかがみいりあ 赤神イリア
あかがみおでっと 赤神オデット
あかきせいさい 《赤き征裁》
あくとうびた 悪刀・鐚
あさのみいこ 浅野みいこ
@zonuexe
zonuexe / guzzle_bench.php
Last active March 21, 2016 14:35
Guzzle vs stream wrapper
<?php
/**
* @author USAMI Kenta <[email protected]>
* @copyright WTFPL
*/
require getenv('HOME') . '/.composer/vendor/autoload.php';
echo 'Test for stream wrapper', PHP_EOL;
@zonuexe
zonuexe / functions.json
Last active December 24, 2015 17:31
php functions
This file has been truncated, but you can view the full file.
{
"PHP 4": {
"debug_backtrace": {
"id": "function.debug-backtrace",
"purpose": "Generates a backtrace",
"prototype": "array debug_backtrace([int $options = DEBUG_BACKTRACE_PROVIDE_OBJECT [, int $limit = '']])",
"return": "<p class=\"para\"> Returns an array of associative <span class=\"type\">array<\/span>s. The possible returned elements are as follows: <\/p> <p class=\"para\"> <table class=\"doctable table\"> <caption><strong>Possible returned elements from <span class=\"function\">debug_backtrace<\/span><\/strong><\/caption> <thead> <tr> <th>Name<\/th> <th>Type<\/th> <th>Description<\/th> <\/tr> <\/thead> <tbody class=\"tbody\"> <tr> <td>function<\/td> <td><span class=\"type\">string<\/span><\/td> <td> The current function name. See also <a href=\"language.constants.predefined.html\" class=\"link\">__FUNCTION__<\/a>. <\/td> <\/tr> <tr>
@zonuexe
zonuexe / functions-all.json
Last active December 24, 2015 17:32
php functions
This file has been truncated, but you can view the full file.
{
"PECL apc": {
"apc_add": {
"id": "function.apc-add",
"purpose": "Cache a new variable in the data store",
"prototype": "array apc_add(string $key, mixed $var [, int $ttl = '', array $values [, mixed $unused = null]])",
"return": "<p class=\"para\"> Returns TRUE if something has effectively been added into the cache, FALSE otherwise. Second syntax returns array with error keys. <\/p>"
},
"apc_bin_dump": {
"id": "function.apc-bin-dump",
PHP 5 <= 5.0.5, PECL ingres >= 1.0.0
0.0.1
0.2.0
None
PECL CUBRID >= 8.3.0
PECL CUBRID >= 8.3.1
PECL CUBRID >= 8.4.0
PECL CUBRID >= 8.4.1
PECL CUBRID >=8.3.0
PECL OAuth >= 0.99.1
@zonuexe
zonuexe / AppRunnerSample.php
Last active December 21, 2015 01:22
PHP AppRunner
<?php
/**
* @copyright 2015 pixiv Inc.
* @license http://creativecommons.org/publicdomain/zero/1.0/legalcode CC0-1.0
*/
final class AppRunnerSample
{
public static function execute(ControllerTypeBInterface $controller)
{
@zonuexe
zonuexe / phpnet_version_parse.php
Last active December 24, 2015 17:33
php.netのバージョン表記をパースするやつ
#!/usr/bin/env php
<?php
/**
* phpnet_version_parse.php
*
* @author USAMI Kenta <[email protected]>
* @copyright 2015 USAMI Kenta
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache-2.0
*/