Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryo Nakamura r7kamura

View GitHub Profile
@r7kamura
r7kamura / keybindings-to-always-maximize-terminal.json
Created May 17, 2022
Keyboard shortcuts example for VSCode to always open terminal in maximized panel.
View keybindings-to-always-maximize-terminal.json
[
{
"key": "alt+j",
"command": "workbench.action.togglePanel",
"when": "terminalFocus"
},
{
"key": "alt+j",
"command": "workbench.action.toggleMaximizedPanel",
"when": "!terminalFocus"
@r7kamura
r7kamura / obs-script-example.lua
Last active May 10, 2022
An example script for OBS written in Lua.
View obs-script-example.lua
obs = obslua
source_name = ""
function on_second_tick()
update_text()
switch_to_preferred_scene()
end
function calculate_timer_text()
@r7kamura
r7kamura / Redirector.json
Created May 5, 2022
Example Redirector settings to redirect JA to EN on docs.github.com.
View Redirector.json
{
"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
Create a GCP project and some resources for OIDC.
View gcloud_oidc_setup.sh
#!/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 Nov 24, 2020
Ruby script to GET JSON then convert it to XML.
View get_json_then_convert_it_to_xml.rb
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 Nov 23, 2020
Ruby script to convert JSON to XML.
View convert_json_to_xml.rb
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 Nov 13, 2020
Example to lint FactoryBot factories with RSpec.
View factory_bot_factories_spec.rb
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
View active_record_bidirectional_accepts_nested_for_test.rb
# 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 Nov 5, 2020
An example of how to reuse other values by symbol translation key value on i18n gem.
View i18n_symbol_reference_feature_example.rb
require 'i18n'
require 'yaml'
I18n.backend.store_translations(
:en,
YAML.load(<<-YAML)
activerecord:
attributes:
user:
status: