Skip to content

Instantly share code, notes, and snippets.

View nkzsdy's full-sized avatar

Ryota Sakurai nkzsdy

View GitHub Profile
@nkzsdy
nkzsdy / gpeco.fish
Created February 27, 2019 12:19
gitのブランチ一覧からインタラクティブに選択してcheckoutする
function gpeco
if [ -e .git ]
git checkout (git branch | peco | tr -d " ")
else
echo "[ERROR]: .git is not found."
end
end
@nkzsdy
nkzsdy / raket.fish
Created February 27, 2019 11:57
Rakeタスクをインタラクティブに選択できるfish function
function raket
if test -f Gemfile -o -f .bundle/
set task (bundle exec rake -T | peco | cut -d " " -f 2)
if [ -n "$task" ]
bundle exec rake $task
else
echo "Task execution was interrupted."
end
else
echo "[ERROR]: $pwd maybe not Rails directory."
@nkzsdy
nkzsdy / scrape_from_mdn.rb
Created February 16, 2019 05:32
Scraping from MDN HTTP response status codes
require 'open-uri'
require 'nokogiri'
base_url = 'https://developer.mozilla.org'
doc = Nokogiri::HTML(open("#{base_url}/ja/docs/Web/HTTP/Status"))
target_nodes = doc.xpath('//*[@id="wikiArticle"]/dl')
all_results = []
target_nodes.each do |node|
node.children.css('dt').each do |item|