Skip to content

Instantly share code, notes, and snippets.

View bluerabbit's full-sized avatar
🤠
spark joy

Akira Kusumoto bluerabbit

🤠
spark joy
View GitHub Profile
@bluerabbit
bluerabbit / gist:4688711
Created February 1, 2013 02:30
ExceptionのStackTraceを文字列で取得する
public static String getStackTrace(Throwable e) {
StringWriter sw = null;
PrintWriter pw = null;
try {
sw = new StringWriter();
pw = new PrintWriter(sw);
e.printStackTrace(pw);
return sw.toString();
} finally {
try {
@bluerabbit
bluerabbit / .my.cnf
Created February 7, 2013 11:18
MySQLでslow_query_logを出す
[mysqld]
long_query_time=1
slow_query_log=1
slow-query-log-file=~/mysqld-slow-query.log
log-queries-not-using-indexes
@bluerabbit
bluerabbit / gist:4951546
Created February 14, 2013 09:27
sedを利用して範囲データを取得する
sed -n '開始行,終了行p' ファイル名
%cat hoge.txt
1
2
3
4
5
%sed -n '3,4p' hoge.txt
@bluerabbit
bluerabbit / gist:5044478
Created February 27, 2013 02:30
gem install pre-commit便利やな https://github.com/jish/pre-commit
% gem install pre-commit
% mkdir work
% cd work
% git init
% pre-commit install
% git config "pre-commit.checks" "jshint"
% echo "var x = 1" > error.js
% git add .
% git commit -m "add error.js"
@bluerabbit
bluerabbit / gist:5044866
Created February 27, 2013 03:44
node jshintを使う
$ curl https://raw.github.com/hokaccha/nodebrew/master/nodebrew | perl - setup
$ nodebrew install latest
$ nodebrew use v0.9.10
$ node -v
$ npm install -g jshint
$ echo "var x = 1" > error.js
$ jshint error.js
@bluerabbit
bluerabbit / String#colorize.rb
Created February 27, 2013 03:59
rubyで標準出力に色付けるやつ
class String
def colorize(color_code); "\e[#{color_code}m#{self}\e[0m"; end
def red; colorize(31); end
def yellow; colorize(33); end
def pink; colorize(35); end
end
@bluerabbit
bluerabbit / gist:5046843
Created February 27, 2013 10:10
MySQL Serverを最初に起動した時に実行すべきコマンド:mysql_secure_installation
%mysql_secure_installation
Change the root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
  • rootパスワードを設定する
@bluerabbit
bluerabbit / gist:5053253
Created February 28, 2013 00:44
git-nowの使い方

install

brew install --zsh-completion git-now

step 1

% git init
@bluerabbit
bluerabbit / gist:5053282
Last active December 14, 2015 07:49
拡張grepとしてのawk。awkを使ってログを抽出する

3番目の値と等価な行のみを抽出

%cat development.log | awk '$3=="OK"'
Completed 200 OK in 3412ms (Views: 3411.8ms | ActiveRecord: 0.0ms)
Completed 200 OK in 17ms (Views: 16.6ms | ActiveRecord: 0.0ms)
@bluerabbit
bluerabbit / gist:5053412
Last active December 14, 2015 07:48
sedで置換

1

%echo 1140003 | sed 's/.../〒&-/'
〒114-0003