Skip to content

Instantly share code, notes, and snippets.

View koba04's full-sized avatar

Toru Kobayashi koba04

View GitHub Profile
@koba04
koba04 / git grep pipe sed
Created April 9, 2012 10:22
git grep pipe sed
% git grep --name-only 'Beatles' | xargs sed -i 's/Beatles/Who/g'
@koba04
koba04 / hoge.pl
Created June 20, 2012 09:53
複数条件の長いif文をどうインデントするか
if (
長い条件
||
長い条件
) {
....
}
@koba04
koba04 / forEach.js
Created July 13, 2012 00:59
配列でもオブジェクトでも繰り返ししてくれるforEach ref: http://qiita.com/items/604c308e1b18642da771
var forEach = function(list, callback) {
if ( list instanceof Array ) {
var len = list.length;
for (var i=0; i<len; i++) {
callback.call(list[i], i, list[i]);
}
} else {
for (var key in list ) if ( list.hasOwnProperty(key) ) {
callback.call(list[key], key, list[key]);
}
@koba04
koba04 / advent-calendar-casual-track-2012.pl
Created December 1, 2012 16:21
Sample of Sub::Rate and Data::WeightedRoundRobin.
#!perl
use strict;
use warnings;
use 5.010;
use Data::Dumper;
use Sub::Rate;
use Sub::Rate::NoMaxRate;
use Data::WeightedRoundRobin;
var net = require('net'),
server = net.createServer(),
host = '127.0.0.1',
port = 11111;
server.on('connection', function(socket) {
console.log("server connection");
server.close();
socket.end();
});
@koba04
koba04 / answer
Last active December 12, 2015 02:48
nodejs-dojo vol.3 report
ノードジェイエス大好き!
@koba04
koba04 / jshintrc_memo.md
Last active December 12, 2015 03:29
.jshintrc memo

jshintの設定項目についてのメモ

Enforcing Options

name memo
bitwise ビット演算子を許可しない
camelcase CamelCaseとXXX_YYY_ZZZの形式を許可する
@koba04
koba04 / my_rails_setup
Created April 4, 2013 02:24
setup rails project. use rbenv + bundler you can use like this. % curl -L http://git.io/PyV7dQ | zsh -s - sample_app
#!/bin/zsh
APP=$1
RUBY_VERSION='2.0.0-p0'
RAILS_VERSION='4.0.0.beta1'
echo "ruby version is $RUBY_VERSION"
echo "rails version is $RAILS_VERSION"
echo $RUBY_VERSION > .ruby-version
@koba04
koba04 / try-lite.pl
Last active December 16, 2015 10:08
内側で投げられた例外クラスをキャッチして、それをさらに外側でキャッチしたいけどキャッチ出来ない? 追記:perl 5.14以降だと期待する挙動になる http://perldoc.jp/docs/perl/5.14.0/perl5140delta.pod#Exception32Handling
#!perl
use Carp;
use Try::Lite;
use Exception::Tiny;
use 5.010;
my $code = sub {
try {
say "begin";
@koba04
koba04 / grunt-watch-irc.js
Last active December 17, 2015 12:49
you can "grunt watch" operation by irc private message
#!node
/*
* grunt-watch-irc.js
*
* you can "grunt watch" operation by irc private message
*
* when you run this script, bot join on #grurt
*
* 1. run this script. bot join the #grunt.
*