Skip to content

Instantly share code, notes, and snippets.

View yoshino's full-sized avatar
🌴
On vacation

Taiki Yoshino yoshino

🌴
On vacation
View GitHub Profile
@yoshino
yoshino / ci.yml
Created June 14, 2024 02:14
GitHubActionで別リポジトリにPRを作成する方法
name: 'Push CI'
on: push
jobs:
test-create-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout
@yoshino
yoshino / next.md
Last active June 23, 2021 22:32
Next.js 10 -> Next.11 にアップグレードするついでにNext.js用のeslintを導入する

前提

Next.js 10 で動かしているけど、ESLintを導入していない

方法

1: Next.js 11にアップグレード

Upgrade Guideを参考。

yarn add react@latest react-dom@latest
yarn add next@latest
@yoshino
yoshino / iso8601.ts
Last active May 28, 2021 23:24
Typescript: Iso8601形式を型安全にする
// REF: https://zenn.dev/f_subal/articles/phantom_type_in_typescript
// 「ある関数を通過済みであることを型で保証する」ために下記のような方法を利用する
type Phantomic<T, U extends string> = T & { [key in U]: never };
type Iso8601 = Phantomic<string, "Iso8601">;
const isoPattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
export const iso8601 = (str: String) => {
if (!str.match(isoPattern)) {
throw new Error("not ISO8601");
@yoshino
yoshino / 20210203.md
Created February 3, 2021 13:08
Add support for belongs_to to has_many inversing. #34533

PR

rails/rails#34533

with inverse_of option

class Account < ApplicationRecord
  has_many :users, inverse_of: :account
end
@yoshino
yoshino / #41296.md
Last active February 2, 2021 11:00
Reduce allocations in camelize inflector #41296

REF

rails/rails#41296

condition: destructive method is faster

require 'benchmark_driver'

Benchmark.driver do |x|
  x.rbenv '3.0.0'
@yoshino
yoshino / 20210201.md
Last active February 1, 2021 09:38
Rails 6.x: associatiton( missing and associated )

seed data

account = Account.create(email: 'eiwa@example.com', name: 'eiwa')
user_with_account1 = User.create!(name: 'with_account1', account_id: account.id)
user_with_account2 = User.create!(name: 'with_account2', account_id: account.id)
user_without_account1 = User.create!(name: 'without_account1')
user_without_account2 = User.create!(name: 'without_account2')

missing

@yoshino
yoshino / .rubocop.yml
Last active July 30, 2020 10:56
Rubocopのセットアップ(Rails)
require:
- rubocop-performance
- rubocop-rails
Style/Documentation:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
@yoshino
yoshino / sql.md
Last active May 10, 2020 08:17
SQL関連のチューニング

チューニング

手順

  • 1: 重いクエリランキング、クエリ合計時間ランキング
  • 2: 問題のクエリの実行計画(explain)
  • 3: チューニング

3が終了したら1に戻り改善されているか(ランキングは変わるかを確かめる)

クエリランキング

MySQL(MariaDBでもok)であればmysqldumpslow を使えば事足りそう。

@yoshino
yoshino / vscode_setting.md
Last active May 10, 2020 08:17
VisualCode設定

Popupヒントを表示しない

以下のチェックを外す

Editor › Parameter Hints: Enabled

空白行・空白スペースを削除する

以下のチェックを入れる

@yoshino
yoshino / setup_jumanpp.md
Last active January 8, 2018 21:13
JUMAN++ × Python × Ubuntu17

BOOST (version 1.57 or higher)

sudo apt-get install libboost-all-dev

JUMAN++

$ wget http://lotus.kuee.kyoto-u.ac.jp/nl-resource/jumanpp/jumanpp-1.01.tar.xz
$ tar xJvf jumanpp-1.01.tar.xz