Skip to content

Instantly share code, notes, and snippets.

View kazuph's full-sized avatar

Kazuhiro Homma kazuph

View GitHub Profile
@kazuph
kazuph / colorize.pl
Created November 12, 2012 01:28 — forked from Cside/colorize.pl
colorize keywords of logs.
#!/usr/bin/env perl
=head1 Examples
$ tail -f access_log | perl colorize.pl
$ plackup app.psgi 2>&1 | perl colorize.pl
=cut
use strict;
@kazuph
kazuph / rubymotion_run.sh
Last active December 11, 2015 01:29
https://github.com/haraken3/SublimeRubyMotionBuilder/blob/master/rubymotion_run.sh がMac OS X 10.7.5だと正常に動かなかったので自分なりに修正
#!/bin/sh
TERMINAL_ID="RubyMotionBuilder"
PROJECT_DIR="$1"
OPTIONS="$2"
if [ "${PROJECT_DIR}" = "" ]; then
exit 1
fi
package Amon2::Plugin::Model;
use strict;
use warnings;
use Module::Find;
use Try::Tiny;
our $VERSION = '0.01';
sub init {
my ($class, $context_class, $config) = @_;
@kazuph
kazuph / model_bench.pl
Last active December 15, 2015 01:39
Moose vs Mouse vs Moo
#!/usr/bin/env perl
# package ClassBless;
# # 原始的なPerlの書き方
# use strict;
# use warnings;
# use utf8;
# use Data::Dump qw/dump/;
# sub new {
# my $class = shift;
# my %args = @_;
@kazuph
kazuph / atnd.pl
Created March 18, 2013 10:50
WebService::Simple::ATNDのテスト
use strict;
use warnings;
use utf8;
use Encode;
use WebService::Simple::ATND;
my @keywords = qw/東京 perl/;
my @ym = qw/201302 201303 201304/;
my $query = WebService::Simple::ATND->query_events(count => 30);
@kazuph
kazuph / kytprof_add_prof_test.pl
Created March 23, 2013 12:52
Devel::KYTProfの最新版(0.03以降)だとエラーになるソースコード
#!/usr/bin/env perl
use strict;
use warnings;
use Text::Xslate;
use Devel::KYTProf;
use Data::Section::Simple;
Devel::KYTProf->add_prof(
"Text::Xslate",
"render",
@kazuph
kazuph / kytprof_success_test.pl
Created March 23, 2013 12:56
Devel::KYTProfでうまくいくバージョン
#!/usr/bin/env perl
use strict;
use warnings;
use Text::Xslate;
use Devel::KYTProf;
use Data::Section::Simple;
Devel::KYTProf->add_prof(
"Text::Xslate",
"render",
@kazuph
kazuph / _plenv
Last active December 15, 2015 18:09
plenvのzsh補完をするためのScript。zshrcへ追加で使える。
_plenv() {
# cmdsという変数を定義
local -a cmds
# カーソルが現在何番目のコマンドを入力しようとしてるのかがCURRENTに入ってる
# すでにplenvと打っているはずなので補完は2コマンド目から
# 3番目以降のコマンドを入力しようとしているときにはelseへ行く
if (( CURRENT == 2 ));then
compadd init rehash exec which version help global local install list versions list_modules install_cpanm available migrate_modules
@kazuph
kazuph / ff.sh
Created April 6, 2013 05:42
FFのキャラをTerminalに表示させる
curl https://gist.github.com/valvallow/5202862/raw/c21cb0fd0149fbdb9d1c7e0f606fb1408e827060/batz.dat | perl -pe 's{ }{ }g;s{(\d)}{\e[4\1m \e[0m}g;'
curl https://gist.github.com/valvallow/5202862/raw/8943ab5199f78b8b62ef490bcdb2f6ed52cf91f1/galuf.dat | perl -pe 's{ }{ }g;s{(\d)}{\e[4\1m \e[0m}g;'
curl https://gist.github.com/valvallow/5202862/raw/8a3ec94561fec0bd075549d9a7f6bedec1d27fa6/kuromadousi.dat | perl -pe 's{ }{ }g;s{(\d)}{\e[4\1m \e[0m}g;'
curl https://gist.github.com/valvallow/5202862/raw/a16101f89d9f3c24bb6442a6dfa5e4135c5a3c0b/siromadousi.dat | perl -pe 's{ }{ }g;s{(\d)}{\e[4\1m \e[0m}g;'
curl https://gist.github.com/ywatase/5319618/raw/f3aadad2efff5274a1b6e36cdac5090973d9c5e5/akamadousi.dat | perl -pe 's{ }{ }g;s{(\d)}{\e[4\1m \e[0m}g;'
curl https://gist.github.com/ywatase/5319618/raw/13c94fc67f7656b2cd63d6c2a59bf593e0b3de5b/knight.dat | perl -pe 's{ }{ }g;s{(\d)}{\e[4\1m \e[0m}g;'
@kazuph
kazuph / auto_growlnotify.sh
Last active December 15, 2015 21:29 — forked from mirakui/auto_growlnotify.sh
何かのインストールなどの長い処理のときにgrowlで通知してくれるzsh growlが使えるときのみ発動するようにしてみた
# source: http://d.hatena.ne.jp/umezo/20100508/1273332857
local COMMAND=""
local COMMAND_TIME=""
precmd() {
if [ "$COMMAND_TIME" -ne "0" ] ; then
local d=`date +%s`
d=`expr $d - $COMMAND_TIME`
if [ "$d" -ge "30" ] ; then
COMMAND="$COMMAND "