Skip to content

Instantly share code, notes, and snippets.

@semind
semind / nginx.conf
Created December 30, 2011 02:41
nginx cookbook
##### nginxでリバースプロキシして後段でエラーが発生した場合にnginx側でエラーページの制御をしたい時の設定 #####
proxy_intercept_errors on; # errorをproxy側で肩代わりする設定
error_page 403 404 500 502 503 504 /error.html; # /var/www/html/error.htmlを置いておく
location /error.html {
root /var/www/html/;
}
#### headerの値を参照する ####
$http_フィールド名
@rummelonp
rummelonp / jquery-ujs.sample.md
Created December 13, 2011 02:25
jquery-ujs.js(rails.js)便利だよって話

jquery-ujs.js(rails.js)便利だよって話

自前でやる場合

JavaScript でクリックのイベント処理とか GET 以外ならトークンを含めるとか全部やらないといけないから面倒くさい

HTML

<a href="/some_action" class="some-action">some action</a>
@miyagawa
miyagawa / redis-anyevent-bits.pl
Created November 30, 2011 03:37
Redis get bits
use strict;
use AnyEvent::Redis;
my $r = AnyEvent::Redis->new(host => '127.0.0.1');
my $cv = AE::cv;
$r->del('foo', $cv);
$cv->recv;
for my $bit (1, 3, 4, 7, 8, 13, 16, 22, 24, 31, 32, 33) {
warn "SETBIT $bit 1\n";
=pod
Nyan Cat TAP Formatter
1. Save this file into your PERL5LIB
2. Run prove with option like following:
$ prove --formatter NyanCat
http://www.mattsears.com/articles/2011/11/16/nyan-cat-rspec-formatter
@tily
tily / scaling_isomorphic_javascript_code.ja.markdown
Last active May 1, 2023 09:03
サバクラ両方で動く JavaScript の大規模開発を行うために

サバクラ両方で動く JavaScript の大規模開発を行うために

原文:Scaling Isomorphic Javascript Code (This is just for study, please contact me at tily05 atmark gmail.com if any problem.)

考えてみれば Model-View-Controller とか MVC ってよく聞くよね。実際どんなものか知ってる? 抽象的に言うなら「オブジェクト情報の保持されるグラフィック・システム (つまり、ラスターではないグラフィック。ゲームとか) 上に構築された、表示系を中心としたアプリケーションにおいて、主要な機能どうしの関わりをうまく分離すること」とでも言おうか。もう少し深く考えを押し進めてみれば、これは当然、他のさまざまなアプリケーションにもあてはまる言葉 (bucket term ?) だ。

過去に多くの開発コミュニティが MVC による解決案を提供し、それによってよくあるユースケースにうまく対処し、地位を築くことができた。例をあげるなら、Ruby や Python コミュニティは Rails や Django を作り、MVC アーキテクチャを実現した。

@riywo
riywo / gist:1251364
Created September 29, 2011 17:37
形態素解析した結果を数えるとか

りすこがこんなの書いてて、聞いてみたら名詞だけ抜き出してcountとかやりたいとか。 そういう時はawk使うと便利ですよ(perlでもいいですが)

$ cat filename | awk '$4 ~ /^名詞/{print $1}' | sort | uniq -c | sort -n

4個目のカラムが「品詞」で始まる性質を使ってます。


@nihen
nihen / gist:1196799
Created September 6, 2011 07:00
psgi benchmark
- app.psgi
sub {
return ['200', ['content-type' => 'text/html', 'content-length' => 11], ['hello world']];
}
ab -n 10000 -c 10 -k http://127.0.0.1:8080/
[Plack::Handler::Nginx]
- keepalive_requests 0;
Requests per second: 4777.98 [#/sec] (mean)
@nihen
nihen / Isucon.pm
Created August 30, 2011 18:10
isucon nginx embeded
package Isucon;
use 5.14.1;
use Nginx::Simple;
use Text::Xslate::Util qw/html_escape/;
use POSIX qw/strftime/;
use List::Util qw/first/;
use JSON::XS;
use IO::Handle;
use Encode;
@nihen
nihen / gist:1178857
Created August 29, 2011 17:13
isucon app
use 5.14.1;
use Plack::Request;
use Plack::Builder;
use FindBin;
use Text::Xslate::Util qw/html_escape/;
use POSIX qw/strftime/;
use List::Util qw/first/;
use JSON::XS;
use IO::Handle;
use Encode;
@perusio
perusio / apache_killer.pl
Created August 20, 2011 16:24
Apache Killer by KingCope exploits mod_deflate vulnerability
#Apache httpd Remote Denial of Service (memory exhaustion)
#By Kingcope
#Year 2011
#
# Will result in swapping memory to filesystem on the remote side
# plus killing of processes when running out of swap space.
# Remote System becomes unstable.
#
use IO::Socket;