Skip to content

Instantly share code, notes, and snippets.

# LogFormat "%h\t%{%Y-%m-%d %H:%M:%S}t\t%r\t%>s\t%b\t%D\t%{User-Agent}i"
cat /path/to/access.log |cut -f6,3 |sed -r 's!^(POST|GET)\s+(.+)\s+HTTP/[0-9]\.[0-9]\s+([0-9]+)$!\3\t\2!' | sort -nr | head -n100
@youhey
youhey / closure_bind_var.js
Created October 24, 2013 02:48
クロージャの参照問題に関するメモ
// クロージャに変数が束縛されている
// 出力
// 10,10,10...
for (var i = 0; i < 10; i++) {
setTimeout(function() {
console.log(i);
}, 1000);
}
// (匿名ラッパーで)変数をコピーして、クロージャが束縛する変数を変更
@youhey
youhey / .htaccess
Created December 6, 2012 09:45
「gist: 4223288」は、たぶん画像リンクが何かしら崩壊したときのURL救済策なんだと思った
# prepare script
php_value auto_prepend_file /var/www/foo/append_subdir.php
@youhey
youhey / .htaccess
Created December 6, 2012 09:41
画像バイナリを出力(かなり冗長な)
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/server-info
RewriteCond %{REQUEST_URI} !^/server-status
RewriteCond %{QUERY_STRING} ^(.*)subdir=(.*)$
RewriteRule ^(.*)$ /rewrite_url.php?rawurl=$1 [QSA,L]
</IfModule>
@youhey
youhey / HTTPResponse.php
Created December 6, 2012 09:20
書き捨てのスクリプトでHTTPレスポンスを、ちょっとだけ操作できる何か
<?php
/**
* HTTPレスポンス
*
* @since 2011-02-10
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
*/
@youhey
youhey / Request.php
Created December 6, 2012 09:18
ウェブアプリケーションからHTTPリクエストを操作する、オレオレF/Wの残骸のような何か
<?php
/**
* HTTPリクエスト
*
* @category tima
* @package tima_Request
* @since tima-beta ver.2007-04-01
* @author IKEDA Youhey <[email protected]>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @copyright 2007 IKEDA Youhey
@youhey
youhey / GoogleAnalytics.php
Created December 6, 2012 09:17
モバイル版のGoogleAnalyticsのHTMLタグを作るために用意したような……
<?php
/**
* GoogleAnalytics - GoogleAnalyticsの解析タグ出力を補助
*
* @since 2010-12-08
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
*/
@youhey
youhey / syncsvn-source2mine.sh
Created December 5, 2012 09:10
SVNサーバ引っ越しのお供に
#!/bin/sh
set -e
set -u
TEMP="/var/svn/tmp"
REPOS="/var/svn/repos"
SOURCE_HOST="svn.example.com"
USERNAME="admin-name"
PASSWORD="admin-pass"
@youhey
youhey / AppModel.php
Created December 5, 2012 09:06
EUC-JPのPostgreSQLデータベースをCakePHP2系から操作するためのAppModel
<?php
/**
* Application model for Cake.
*
* @author IKEDA Youhei <[email protected]>
*/
class AppModel extends Model {
/** encoding */
@youhey
youhey / sjis_output.php
Created December 3, 2012 08:41
CakePHP1.3用のシフトJIS対応のためのヘルパ(afterLayoutでシフトJISに変換)
<?php
/**
* レンダリングの実行結果をシフト JIS に変換
*
* <p>「Layout」が無効だとコールバックされないので変換しません。<br />
* フックが可能な出力処理の終端が「afterLayout」だから。<br />
* また、処理の遷移が「Layout」有効/無効で処理ロジックが異なるため。</p>
*
* @author IKEDA youhei <[email protected]>