Skip to content

Instantly share code, notes, and snippets.

View gouf's full-sized avatar
😇
I don't know how my life work with.

Go Furuya gouf

😇
I don't know how my life work with.
View GitHub Profile
@gouf
gouf / wishlist_whole_price.js
Created December 8, 2018 16:56
Amazon の欲しいものリストから総額を取得 (簡易版)
(new Intl.NumberFormat('ja-JP', {
style: 'currency',
currency: 'JPY'
})).format(
Array.from(document.querySelectorAll('span.a-price-whole').values())
.map(function(v) { return v.innerText })
.map(function(v) { return parseInt(v.split(',').join('')) })
.reduce(function(ret, v) { return ret + v })
)
#
# 変数の宣言
#
variable "vpc_id" {
type = "string"
default = "vpc-0a84e4b7d165f8525"
}
variable "vpc_subnet_id" {
type = "string"
@gouf
gouf / zundoko.rb
Last active March 26, 2018 09:32
Yet Another Zundoko
# frozen_string_literal: true
# Ref: <https://en.wikipedia.org/wiki/Kiyoshi_Hikawa>
# Ref: <https://twitter.com/kumiromilk/status/707437861881180160>
# See also: <https://qiita.com/shunsugai@github/items/971a15461de29563bf90>
# 「ズン」「ドコ」のいずれかをランダムで出力し続けて
# 「ズン」「ズン」「ズン」「ズン」「ドコ」の配列が出たら
# 「キ・ヨ・シ!」って出力して終了
class Zundoko
WORD_PAIR = %w[ズン ドコ]
@gouf
gouf / rerun_yard.sh
Created March 24, 2018 14:17
Wach directory/files and run command repeatedly
#!/bin/sh
# About rerun: [alexch/rerun: Restarts an app when the filesystem changes. Uses growl and FSEventStream if on OS X.](https://github.com/alexch/rerun/)
# About yard: [YARD - A Ruby Documentation Tool](https://yardoc.org/)
# Note: specify `-d [directory where not same directory level of .yard]` option to avoid endless loop
rerun -d app -c "rm -rf .yard && yard doc && ./yard_server.sh restart"
@gouf
gouf / web-servers.md
Created February 3, 2018 19:13 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@gouf
gouf / calendar_table_helper.rb
Created January 30, 2018 15:38
<table/> タグを用いてカレンダーを生成する
# Ref: * [Railsで今月のカレンダーを生成するerbコード - Qiita](https://qiita.com/nnabeyang/items/8b54a28551983d9cdb32)
# put into... app/helpers/calendar_table_helper.rb
# <table/> タグを用いてカレンダーを生成する
module CalendarTableHelper
def calendar_table_tag(today = Date.today)
tag.table do
calendar_caption(today) +
calendar_header +
calendar_body(today)
end
@gouf
gouf / login-and-logout.md
Created December 5, 2017 12:19
Ref: [ログイン・ログアウトのテスト - ShouldBeeドキュメント](http://docs.shouldbee.at/examples/login-and-logout/)

テスト仕様書

ログインする

「/login」に移動する
「username」フィールドに「admin」と入力する
@gouf
gouf / compare_url.rb
Created December 2, 2017 12:55
「今日のローカルでの作業(コミット)」を、GitHub Compare URL 形式に加工する(※コミットは要 push)
#!/home/gouf/.anyenv/envs/rbenv/shims/ruby
# vim: ft=ruby
Dir.chdir(Dir.pwd)
#
# リポジトリ/ユーザ名の抽出
#
origin = %x(git remote -v)
@gouf
gouf / memo.md
Last active November 19, 2017 08:42
各バージョンでrails new する
@gouf
gouf / pokemon.rb
Last active October 31, 2017 16:05
自回答の転記 Ref: [Ruby - Rubyで次の仕様を満たすPokemonクラスを持つプログラム... (98411)|teratail](https://teratail.com/questions/98411)
# 2体のポケモンを戦わせる
class PokemonBattle
def initialize(pokemon_a, pokemon_b)
@turn_count = 0
@players = [pokemon_a, pokemon_b]
end
def game_start!
print_initial_situation
loop do