This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>|| | |
Caller level 0: | |
{ | |
Bitmask => 'UUUUUUUUUUUUUU', | |
Evaltext => undef, | |
Filename => '/home/yancha/yancha/lib/Yancha/DataStorage/DBI.pm', | |
Hasargs => 1, | |
Hints => 2018, | |
'Line-No' => 284, | |
Package => 'Yancha::DataStorage::DBI', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Yanchaに最短で投稿する手順 | |
# Tokenを取得 | |
# profile_image_urlはオプション | |
curl 'http://yancha.hachiojipm.org/login?nick=fkmt&token_only=1&profile_image_url=http://pyazo.hachiojipm.org/image/OFV5WawlHin4Y80t138408431866687.png' | |
# 返値がTokenになる | |
curl 'http://yancha.hachiojipm.org/api/post?token=取得したtokenをいれる&text=倒壊!!!' | |
# tokenは有効期限があるので、適当に再取得すること。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MarkovController < ApplicationController | |
def keychoice(target) #targetはhash | |
# ハッシュ(target)のキー群の中からの一つのキーStringをランダムに返す | |
puts target.keys.to_s + ">" + target.keys[ rand( target.size ) ].to_s | |
return target.keys[ rand( target.size ) ].to_s | |
end | |
def text | |
@source = ( params[:text].nil? ? nil : params[:text] ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// いらんものを画面にだされては困るので | |
ini_set("display_errors", 0); | |
ini_set("display_startup_errors", 0); | |
// NoticeやDeprecated含めて全部のエラーがほしい | |
error_reporting(E_ALL); | |
// ログファイル設定はmod_phpやBuiltin Serverなどでは設定不要、 | |
// 設定しないとSTDERRに出力される | |
// ini_set("log_errors", 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// strict error bailout | |
set_error_handler(function ($errno, $errstr, $errfile, $errline){ | |
error_log("STRICT: {$errno} {$errstr} {$errfile} {$errline} "); | |
die("get error on: errno:{$errno} file:{$errfile}:{$errline}"); | |
}); | |
echo $a; // undefined value | |
echo "I will die"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"fabpot/goutte": "dev-master" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
基本的にはemlフォーマット(メールのソースである) | |
改行コードはどうやらLFである | |
一行目にメールソースの長さが入る、 | |
つまり後述のXMLが開始するまでのバイト数、ただし先頭の数字(サイズ)の行を除く | |
なので、ボディサイズをいきなりカウントして、 | |
その数字を先頭にいれて、ボディをいれて、XMLをつっこめばよい。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getRemoteIP(){ | |
$_SERVER_UC = array_change_key_case($_SERVER, CASE_UPPER); | |
if(isset($_SERVER_UC['HTTP_CLIENT_IP'])) | |
return $_SERVER_UC['HTTP_CLIENT_IP']; | |
if(isset($_SERVER_UC['HTTP_X_CLUSTER_CLIENT_IP'])) | |
return $_SERVER_UC['HTTP_X_CLUSTER_CLIENT_IP']; | |
if(isset($_SERVER_UC['HTTP_FORWARDED_FOR'])) | |
return $_SERVER_UC['HTTP_FORWARDED_FOR']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$pattern = '/test/:id/'; | |
$regexPattern = preg_replace_callback( | |
'#:([\w]+)#', | |
function($m){ | |
return '(?P<'.$m[1].'>[^/]+)'; | |
}, | |
$pattern | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Mother { | |
static $html = ' | |
<html> | |
<body> | |
{{content}} | |
</body> | |
</html> | |
'; | |
public function __construct($my_name=null, $var=null){ |