Skip to content

Instantly share code, notes, and snippets.

View r7kamura's full-sized avatar

Ryo Nakamura r7kamura

View GitHub Profile
@r7kamura
r7kamura / pomodoro-time-change-description.diff
Last active June 19, 2024 00:27
How to modify pomodoro-time.html.
diff --git a/docs/pomodoro-timer.html b/docs/pomodoro-timer.html
index fcc18c3..047c024 100644
--- a/docs/pomodoro-timer.html
+++ b/docs/pomodoro-timer.html
@@ -124,11 +124,7 @@
const interval = parameters.work + parameters.break;
const minutesInInterval = minutes % interval;
const sessionNumber = (date.getHours() - 5) % 24;
- if (minutesInInterval < parameters.work) {
- return `POMODORO#${sessionNumber}`;
@r7kamura
r7kamura / rspec-match_pattern.rb
Last active November 11, 2023 06:09
RSpec matcher with pattern-matching.
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rspec'
end
require 'rspec/autorun'
@r7kamura
r7kamura / rubocop-todo-corrector.yml
Last active July 31, 2022 01:19
Example of .github/workflows/rubocop-todo-corrector.yml with label
name: rubocop-todo-corrector
on:
pull_request:
types:
- closed
workflow_dispatch:
inputs:
cop_name:
description: Pass cop name if you want to pick a specific cop.
@r7kamura
r7kamura / Redirector.json
Created May 5, 2022 22:43
Example Redirector settings to redirect JA to EN on docs.github.com.
{
"createdBy": "Redirector v3.5.3",
"createdAt": "2022-05-05T22:35:21.668Z",
"redirects": [
{
"description": "GitHub Docs ja to en",
"exampleUrl": "https://docs.github.com/ja/repositories/creating-and-managing-repositories/creating-a-template-repository",
"exampleResult": "https://docs.github.com/en//repositories/creating-and-managing-repositories/creating-a-template-repository",
"error": null,
"includePattern": "https://docs.github.com/ja($|/.*)",
@r7kamura
r7kamura / gcloud_oidc_setup.sh
Last active May 12, 2022 14:15
Create a GCP project and some resources for OIDC.
#!/bin/bash
set -eu
set -o pipefail
# Set these 2 variables.
PROJECT_ID="godolog-example-15" # e.g. godolog-example
GITHUB_REPO="r7kamura/godolog-example" # e.g. r7kamura/godolog-example
SERVICE_ACCOUNT_ID="google-drive-reader"
SERVICE_ACCOUNT_EMAIL="${SERVICE_ACCOUNT_ID}@${PROJECT_ID}.iam.gserviceaccount.com"
@r7kamura
r7kamura / get_json_then_convert_it_to_xml.rb
Last active November 24, 2020 00:50
Ruby script to GET JSON then convert it to XML.
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'activesupport'
gem 'builder'
gem 'faraday'
gem 'faraday_middleware'
end
@r7kamura
r7kamura / convert_json_to_xml.rb
Last active November 23, 2020 07:14
Ruby script to convert JSON to XML.
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'activesupport'
gem 'builder'
end
require 'active_support/core_ext/array/conversions'
@r7kamura
r7kamura / factory_bot_factories_spec.rb
Last active November 13, 2020 05:33
Example to lint FactoryBot factories with RSpec.
require 'rails_helper'
RSpec.describe 'FactoryBot factory' do
FactoryBot.factories.each do |factory|
describe factory.name.inspect do
it 'creates valid record' do
expect { FactoryBot::Linter.new([factory]).lint! }.not_to raise_error
end
end
end
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'activerecord', '6.0.3.4'
gem 'sqlite3'
end
@r7kamura
r7kamura / i18n_symbol_reference_feature_example.rb
Last active November 5, 2020 07:45
An example of how to reuse other values by symbol translation key value on i18n gem.
require 'i18n'
require 'yaml'
I18n.backend.store_translations(
:en,
YAML.load(<<-YAML)
activerecord:
attributes:
user:
status: