Skip to content

Instantly share code, notes, and snippets.

View acro5piano's full-sized avatar
🏠
Working from home

Kay Gosho acro5piano

🏠
Working from home
View GitHub Profile
@acro5piano
acro5piano / file0.txt
Last active December 11, 2015 01:51
Mechanizeでgetする時にhttp://を省略してはまった件 ref: http://qiita.com/acro5piano/items/32fe7d2735d2f350c5a0
irb(main):004:0> require 'mechanize'
irb(main):005:0> agent = Mechanize.new
irb(main):006:0> p agent.get('google.co.jp')
ArgumentError: absolute URL needed (not google.co.jp)
from /home/hogeuser/.rbenv/versions/2.2.0-rc1/lib/ruby/gems/2.2.0/gems/mechanize-2.7.3/lib/mechanize/http/agent.rb:651:in `resolve'
from /home/hogeuser/.rbenv/versions/2.2.0-rc1/lib/ruby/gems/2.2.0/gems/mechanize-2.7.3/lib/mechanize/http/agent.rb:223:in `fetch'
from /home/hogeuser/.rbenv/versions/2.2.0-rc1/lib/ruby/gems/2.2.0/gems/mechanize-2.7.3/lib/mechanize.rb:440:in `get'
from (irb):6
from /home/hogeuser/.rbenv/versions/2.2.0-rc1/bin/irb:11:in `<main>'
@acro5piano
acro5piano / file0.sh
Last active June 25, 2016 08:09
CSVファイルから特定の列を取り出す自作関数 ref: http://qiita.com/acro5piano/items/26c4926b243e615a2d77
cat <<EOF > test.txt
a b c
d e f
EOF
# cutを使う場合
cat test.txt | cut -d ' ' -f 1,3
#=> a c
#=> d f
@acro5piano
acro5piano / file0.sh
Last active July 12, 2016 02:16
テキストファイルの1行目以降を出力 ref: http://qiita.com/acro5piano/items/3639c7f70c17f110b532
k-gosho@kgosho-ubuntu ~ % cat languages.txt
id,name
1,"Ruby"
2,"Perl"
3,"PHP"
@acro5piano
acro5piano / active_record.rb
Last active September 6, 2016 16:38
has_secure_passwordでauthenticateメソッドが追加される仕組み ref: http://qiita.com/acro5piano/items/416c08a808c850e0477e
require_relative './secure_password'
class ActiveRecord
extend SecurePassword
end
@acro5piano
acro5piano / Gemfile
Last active September 6, 2016 16:44
Sinatra + Thin + NginxでWEBアプリケーション運用 ref: http://qiita.com/acro5piano/items/1b63615a10e0ca4a67d7
gem 'sinatra' , '1.4.6'
group :production do
gem 'thin'
end
@acro5piano
acro5piano / file0.sh
Created September 8, 2016 01:41
「精神と時の部屋」コマンドを作った ref: http://qiita.com/acro5piano/items/d18114b34f6ebc7a0d8b
mkdir /tmp/a
cd /tmp/a
@acro5piano
acro5piano / file0.sh
Last active September 11, 2016 11:30
Bashにアラーム機能を搭載する ref: http://qiita.com/acro5piano/items/5008584c0458354a797e
# この関数を~/.bash_aliasesなどに書いておく
alarm(){
echo "echo $1 | cowsay | wall" | at $2
}
@acro5piano
acro5piano / .bash_aliases
Last active September 11, 2016 11:35
Bashにアラーム機能を搭載する(改) ref: http://qiita.com/acro5piano/items/12c829da344464134f37
alarm(){
echo "tmux detach-client; sleep 2; cowsay_to_single_pts $1" | at $2
}
@acro5piano
acro5piano / file0.sh
Created September 14, 2016 01:13
markdown-stylesとinotify-toolsで、最高のドキュメント執筆環境を整えた ref: http://qiita.com/acro5piano/items/0b781d301571025cf168
sudo npm install -g markdown-styles
@acro5piano
acro5piano / file0.sh
Last active September 21, 2016 07:13
Bashでテンプレートエンジンっぽいものを作った ref: http://qiita.com/acro5piano/items/26de28485142eeac37b1
# Render a template file
#
# $ cat template.txt
# ==========================
# Hello, I'm {{ name }}.
# It's {{ wheather }} wheather today.
# ==========================
#
# $ util::render_template template.txt 'name=bashist&wheather=good'
# ==========================