Skip to content

Instantly share code, notes, and snippets.

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 / data.txt
Last active Oct 28, 2022
年月 (from, to) のデータから、のべ年数を計算する
View data.txt
20143 20149
20162 20175
20162 20164
20165 20166
20169 201611
20172 20175
20181 20192
20194 20195
20203 20208
202011 20222
View fizzBuzz.ts
interface Number {
isFizzBuzz(): boolean
isFizz(): boolean
isBuzz(): boolean
}
Number.prototype.isFizzBuzz = function(): boolean {
return this.isFizz() && this.isBuzz()
}
@gouf
gouf / common.rb
Last active Aug 16, 2021
reCAPTCHA (Ruby 側) の煩雑な処理をモジュール化
View common.rb
# 全体の処理
#
# スコアを得るまでの流れ:
#
# View 側:
# 1. reCAPTCHA を設置する (JS 処理)
# 2. ログインフォームの submit に合わせて g-recaptcha-response にデータを乗せる
#
# Rails 側:
# 1. client を生成
View date_duration.rb
require 'active_support'
require 'active_support/core_ext'
#
# 関数の定義
#
def date_duration(base_date, after_date)
duration_parts =
ActiveSupport::Duration.build(after_date.to_i - base_date.to_i).parts
View main.rb
require File.join(__dir__, 'lib', 'workdays')
# eg. 10 1 FRI
# => 10月4日
workday = WorkDay.new(*gets.chomp.split)
month, day = workday.next_workday
puts "#{month}月#{day}日"
@gouf
gouf / janken.rb
Last active Oct 23, 2019
[Rubyでじゃんけんアプリを作ってみた - Qiita](https://qiita.com/hiro-gen/items/85639c0a8f925e31fbbe) を見たので書いてみた
View janken.rb
# frozen_string_literal: true
# じゃんけんゲームで出せる手の種類
module Hands
HANDS = %i[rock scissors paper].freeze
HANDS_LABEL = %w[グー チョキ パー].freeze
private_constant :HANDS, :HANDS_LABEL
end
@gouf
gouf / day_in_month.rb
Created Aug 16, 2019
Paiza レベルアップ問題集: 「月の日数 Ruby編」 - https://paiza.jp/works/mondai/dateset/ruby/days_in_a_month
View day_in_month.rb
require 'date'
def count_day_in_month(date, month:, count: 0)
return count unless month.eql?(date.month)
count_day_in_month(date.succ, month: month, count: count + 1)
end
year, month, day = [*gets.chomp.split, 1].map(&:to_i)
@gouf
gouf / date_format.rb
Created Aug 16, 2019
Paiza レベルアップ問題集: 「日付のフォーマット Ruby編」 - https://paiza.jp/works/mondai/dateset/ruby/date_format
View date_format.rb
class DateFormat
DATE_ORDER = %r{[0-9]{4}/[0-9]{2}/[0-9]{2}}.freeze
MONTH = [*(1..12).map { |n| n.to_s.rjust(2, '0') }].freeze
DAY = [*(1..31).map { |n| n.to_s.rjust(2, '0') }].freeze
class << self
def validate(date_string)
return 'No' unless date_string.match?(DATE_ORDER)
_year, month, day = date_string.split('/')
@gouf
gouf / guru_navi_api.rb
Created Aug 5, 2019
[Ruby - RailsアプリをHerokuへデプロイ後、ぐるなびAPIが検索結果を返さない|teratail](https://teratail.com/questions/203712)
View guru_navi_api.rb
# frozen_string_literal: true
require 'net/http'
require 'uri'
require 'json'
require 'logger'
require 'kaminari'
class GuruNaviApi
API_KEY = ENV['GNAVI_API_KEY']
@gouf
gouf / slack_many_muscle.scpt
Created Jul 6, 2019
Slack 特定のチャンネルに 3x3 の 💪 を入力する AppleScript
View slack_many_muscle.scpt
# Slack の入力欄に :muscle: をたくさん打ち込むスクリプト
# 3x3 に渡ってたくさんの muscle を自動で打ち込む
property channelName : ""
on run argv # TIPS: {"arg1", "arg2"...} と複数設定できる
if (count of argv) > 0 then
set channelName to argv
else
set channelName to "my-rails" # 未指定の場合、この値を設定