Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env perl
package RangeFile;
use strict;
use warnings;
use 5.10.0;
use Fcntl qw/:seek/;
use parent qw/Exporter/;
package main
func main() {
println([]int("あいうえお")[1] == 'い') // true
println([]byte("あいうえお")[2] == 130) // true
}
==============================================================================
入力支援記法: *hatena_edit_rule*
------------------------------------------------------------------------------
見出し記法
>
*~~
<
日記に見出し(h3)を付けます
@mattn
mattn / twty.log
Created April 28, 2011 10:26
twtyの使い方
# twty -h
Usage of twty:
-f ID: specify favorite ID
-i ID: specify in-reply ID, if not specify text, it will be RT.
-l USER/LIST: show list's timeline (ex: mattn_jp/subtech)
-u USER: show user's timeline
-r: show replies
-v: detail display
# twty
use strict;
use warnings;
use Plack::Request;
use Plack::Response;
use LWP::UserAgent;
use URI;
use JSON;
use Encode;
@riywo
riywo / gist:874011
Created March 17, 2011 08:37
bashでパイプとかでつないでバッファされちゃう時

tail -fみたいに流しながら見たいんだけど、色んなコマンドが出力をバッファしちゃうので、困ったときはそのコマンドにバッファしないオプションが無いか探すのがオヌヌメ。 man command -> bufferとかで検索

grep

   --line-buffered
          Use line buffering, it can be a performance penality.

$ iostat -x 1 | grep --line-buffered 'sda'

awk

@riywo
riywo / gist:870515
Created March 15, 2011 09:46
GNU parallel使って並列でrsyncする&ちゃんとmkdirする
find /path/to/dir/ -type f | time parallel --eta 'rsync -aRz --compress-level=1 {} remote:/'
$ perl -Ilib benchmark/simple.pl http://127.0.0.1/icons/apache_pb.gif
3b5ddd008f7ab078b42c5fbbf1861a715dee8da3
Perl/5.8.8 on i386-linux-thread-multi
Furl/0.21, LWP/5.837, WWW::Curl/4.15, HTTP::Lite/2.3, libcurl[libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5]
--
Connection: close
Date: Thu, 20 Jan 2011 08:57:10 GMT
Accept-Ranges: bytes
ETag: "3803e-916-4c23b600"
Server: Apache/2.2.3 (CentOS)