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.txt
Last active June 15, 2017 03:48
Chromebookで外付けドライブを使い、DVDを再生、ISOファイルに吸出す ref: http://qiita.com/acro5piano/items/71a29a497acb34d3c0bb
sudo chmod 0664 /dev/sr0
@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.txt
Last active September 30, 2020 16:03
あるディレクトリ以下のファイルツリーをJSONで再帰的に出力する ref: https://qiita.com/acro5piano/items/9ddbc2f330c9084833f9
#!/usr/bin/env python
import os
import json
def json_tree(path):
target_json = []
for item in os.listdir(path):
new_hash = {}
# Python2
import re
str = 'これは漢字を含みます'
re.search('[\xE4B880-\xE98CAC]', str)
@acro5piano
acro5piano / file0.sh
Last active March 27, 2017 16:40
ChromebookでCrouton+Emacs+Mozcで快適日本語入力 ref: http://qiita.com/acro5piano/items/0497d04577bcc3d36065
# Install Emacs
# 面倒であれば、aptから入れても良い
#sudo apt-get install emacs
cd /usr/local/src
sudo wget http://ftp.jaist.ac.jp/pub/GNU/emacs/emacs-24.5.tar.gz
sudo tar xzvf emacs-24.5.tar.gz && sudo rm emacs-24.5.tar.gz
cd emacs-24.5
./configure --with-x-toolkit=no --with-xpm=no --with-jpeg=no --with-gif=no --with-tiff=no
make
sudo make install
@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 / file0.sh
Last active May 24, 2018 06:43
FabricのPython3への対応について ref: https://qiita.com/acro5piano/items/19a5f4c0ae729aae756b
virtualenv -p python3 env
source env/bin/activate
pip3 install fabric3
@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"