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 / solving_problem.rb
Created July 25, 2024 15:31
Paiza 問題集「STEP: 3 クラスのメンバの更新」 : https://paiza.jp/works/mondai/class_primer/class_primer__change_member/
class Employee
attr_accessor :number, :name
attr_reader :id
def initialize(id:, number:, name:)
@id = id.to_i
@number = number.to_i
@name = name.to_s
end
end
class Employee
attr_reader :number, :name
def initialize(number, name)
@number = number.to_i
@name = name.to_s
end
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<!-- NOTE: JavaScript 側で、自動再生を有効化するには、一度 Play ボタンをクリックする必要がある -->
<div>
@gouf
gouf / fizzbuzz_with_hash.rb
Last active May 22, 2024 19:59
Hash 採用縛りで FizzBuzz
# Hash を用いて FizzBuzz 問題を解くクラス
# 15, 5, 3 の余りを Hash の key として登録しておき、FizzBuzz の解を得る
class FizzBuzz
attr_reader :hash
def initialize
# INFO: Hash instance method Hash#default_proc
# https://docs.ruby-lang.org/ja/latest/method/Hash/i/default_proc.html
hash =
Hash.new do |hash, key|
@gouf
gouf / data.txt
Last active October 28, 2022 09:27
年月 (from, to) のデータから、のべ年数を計算する
20143 20149
20162 20175
20162 20164
20165 20166
20169 201611
20172 20175
20181 20192
20194 20195
20203 20208
202011 20222
@gouf
gouf / .bashrc
Created June 14, 2016 05:16
Switch git author
function switch_git_config () {
name=$1
email=$2
git config --global user.name $name
git config --global user.email $email
echo "Configuration has changed:"
echo "git config user.name: $(git config user.name)"
echo "git config user.email: $(git config user.email)"
}
interface Number {
isFizzBuzz(): boolean
isFizz(): boolean
isBuzz(): boolean
}
Number.prototype.isFizzBuzz = function(): boolean {
return this.isFizz() && this.isBuzz()
}
@gouf
gouf / common.rb
Last active August 16, 2021 12:45
reCAPTCHA (Ruby 側) の煩雑な処理をモジュール化
# 全体の処理
#
# スコアを得るまでの流れ:
#
# View 側:
# 1. reCAPTCHA を設置する (JS 処理)
# 2. ログインフォームの submit に合わせて g-recaptcha-response にデータを乗せる
#
# Rails 側:
# 1. client を生成
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
@gouf
gouf / main.rb
Created November 5, 2019 08:54
Paiza 練習問題 : [翌営業日 - その1](https://paiza.jp/works/mondai/dateset/working_day_1?language_uid=ruby)
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}日"