This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 全体の処理 | |
# | |
# スコアを得るまでの流れ: | |
# | |
# View 側: | |
# 1. reCAPTCHA を設置する (JS 処理) | |
# 2. ログインフォームの submit に合わせて g-recaptcha-response にデータを乗せる | |
# | |
# Rails 側: | |
# 1. client を生成 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}日" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# じゃんけんゲームで出せる手の種類 | |
module Hands | |
HANDS = %i[rock scissors paper].freeze | |
HANDS_LABEL = %w[グー チョキ パー].freeze | |
private_constant :HANDS, :HANDS_LABEL | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" # 未指定の場合、この値を設定 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Alfred Workflow から利用することを想定 | |
# ユーザ指定の検索キーワードがクリップボードにコピーされていることを期待 | |
# NOTE: すでにアプリケーションが起動している必要がある | |
tell application "Evernote" | |
activate | |
delay 0.2 | |
# キーストロークをシステムイベントとして送信 | |
# NOTE: 適宜 delay を入れないと操作が速すぎて 受け付けてもらえない |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run argv # TIPS: {"arg1", "arg2"...} と複数設定できる | |
if (count of argv) > 0 then | |
set searchWord to argv | |
else | |
set searchWord to "test_keystroke" | |
end if | |
# NOTE: すでにアプリケーションが起動している必要がある | |
tell application "Slack" |