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 / php-lang-constructs.md
Last active May 19, 2017 01:27
PHP 配列っぽいもの列伝
構文 意味
array 配列リテラル array(1, 2)
die PHPスクリプトの終了 foo() or dir(1);
echo 文字列を標準出力 echo $message, PHP_EOL;
empty 値/変数が「空」または「偽」かの検査 if (empty($v) || empty($a['i']))
eval 文字列をPHPスクリプトとして評価 eval($s)
exit PHPスクリプトの終了 exit(0);
include、include_once PHPスクリプトの読み込み include_once __DIR__ . '/Foo.php';
isset 値/変数が存在するかの検査 $v = isset($a['i']) ? $a['i'] : 's';
@zonuexe
zonuexe / agreements.md
Last active May 18, 2017 13:56
Copyright agreements for BaguettePHP GPL-3.0
@zonuexe
zonuexe / keybase.md
Created May 6, 2017 16:41
Keybase proof

Keybase proof

I hereby claim:

  • I am zonuexe on github.
  • I am tadsan (https://keybase.io/tadsan) on keybase.
  • I have a public key ASBfDNiVJL5ZgMARmLbUlFta8QSry5Nxn1uh2b-Maonhawo

To claim this, I am signing this object:

@zonuexe
zonuexe / tsd.sh
Created April 10, 2017 16:56
TSD
#!/bin/bash
# Copyright (c) 2017 USAMI Kenta <[email protected]>
# @author tadsan
# @license GPL-3.0
# This program comes with ABSOLUTELY NO WARRANTY;
# This is free software, and you are welcome to redistribute it
# under certain conditions; type `tsd version' for details.
@zonuexe
zonuexe / pixelart-pixelated.js
Created April 7, 2017 17:51
pixelart-pixelated.js
var newStyle = document.createElement('style'); newStyle.type = "text/css";
document.getElementsByTagName('head').item(0).appendChild(newStyle);
var css = document.styleSheets.item(0);
css.insertRule(".__pixelart{ image-rendering: pixelated }", 0);
var x = Array.prototype.map.call(document.querySelectorAll('.Item'), function(i){
var t = i.querySelectorAll('.ItemText a');
var isPixelArt = !!Array.prototype.filter.call(t, function(v){ return /ドット|dot|pixel/.test(v.innerText); }).length;
var isIronbeads = !Array.prototype.filter.call(t, function(v){ return /アイロンビーズ/.test(v.innerText); }).length;
if (isPixelArt && !isIronbeads) {
@zonuexe
zonuexe / get_var_name.php
Created March 22, 2017 04:38
get_var_name.php
<?php
include_once getenv('HOME') . '/.composer/vendor/autoload.php';
use PhpParser\Node;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitorAbstract;
use PhpParser\ParserFactory;
use PhpParser\PrettyPrinter;
@zonuexe
zonuexe / fizzbuzz.py
Created February 8, 2017 06:46
FizzBuzz
#-*- coding: utf-8 -*-
def fb(n):
s = ""
if (n % 3 == 0):
s += "Fizz"
if (n % 5 == 0):
s += "Buzz"
if (s == ""):
s = str(n)
@zonuexe
zonuexe / .editorconfig
Created November 30, 2016 06:48
editorconfig
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
@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