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 / 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
@gouf
gouf / memo.md
Created October 8, 2017 05:35
1対1、少人数で誰かに教えるときの「お品書き」テンプレート、とメモ

環境

ノートPC を持ち寄って、対面で教える/教わることを想定

(デスクトップ画面共有 + WebCam による顔出し が実現できるならばリモートでも可)

テンプレートを使うにあたって esa.io あるいはその他ドキュメント管理サービスの利用を想定

また、その場で参考URL やコード片を渡すなどするので、Slack やその他コミュニケーション サービスの利用を想定

@gouf
gouf / rank_label.rb
Created October 5, 2017 10:22
同順を含む順位ラベルを付加する(Ruby 版)
# Ref: [PHP - タイ順位を表示させたい(95165)|teratail](https://teratail.com/questions/95165)
target = [[100] * 2, [97] * 3, [90] * 5].flatten
# => [100, 100, 97, 97, 97, 90, 90, 90, 90, 90]
def combine_rank_label(desc_sorted_list)
rank_index = 1
rank_value_cache, *target = desc_sorted_list
// Define functions
upDownCycleNumber = function(cycleLength) {
// Setup function
// Create an array like:
// [0, 1, 2, 3, 4, 5, 4, 3, 2, 1]
createUpDownCyclesArray = function(cycleLength) {
// Create an array like:
// [0, 1, 2, 3, 4, 5]
incrementalArray =
Array.apply(null, Array(cycleLength + 1))