Skip to content

Instantly share code, notes, and snippets.

Avatar
✂️
Yak Shaving

Tatsuya Itakura itkrt2y

✂️
Yak Shaving
View GitHub Profile
@itkrt2y
itkrt2y / NumberInput.tsx
Last active Apr 19, 2022
react-hook-form + ChakraUI NumberInput
View NumberInput.tsx
import {
NumberDecrementStepper,
NumberIncrementStepper,
NumberInput,
NumberInputField,
NumberInputStepper,
} from "@chakra-ui/react";
import { Controller } from "react-hook-form";
<Controller
@itkrt2y
itkrt2y / page.rb
Last active Aug 1, 2022 — forked from rmosolgo/page_example.rb
Generic page number / per-page pagination with GraphQL-Ruby
View page.rb
class Page
DEFAULT_PAGE_SIZE = 20
def initialize(all_nodes, page:, per_page:)
@all_nodes = all_nodes
# Normalize pagination arguments
@page = if page.nil? || page < 1
1
else
page
@itkrt2y
itkrt2y / association.rb
Last active Dec 1, 2022
Association dataloader with graphql-ruby
View association.rb
# official docs: https://graphql-ruby.org/dataloader/sources.html
# app/graphql/sources/association.rb
class Sources::Association < ::GraphQL::Dataloader::Source
def initialize(association_name, scope = nil)
@association_name = association_name
@scope = scope
end
def fetch(records)
@itkrt2y
itkrt2y / get-width-of-text-in-browser.js
Last active Sep 26, 2021
Get width of text in browser
View get-width-of-text-in-browser.js
document.createElement("canvas")
.getContext("2d")
.measureText("Hello こんにちは 😀")
.width;
@itkrt2y
itkrt2y / file-base-routing-with-preact-vite-wouter.tsx
Last active Apr 27, 2022
File based routing for vite, preact and wouter
View file-base-routing-with-preact-vite-wouter.tsx
import { Route, Switch } from "wouter-preact";
const pageFiles = import.meta.globEager("./pages/**/*.tsx");
const pages = Object.keys(pageFiles)
.sort()
.reverse() // Ensure the order of page file names. Put `:<filename>` to the end of the array.
.map((filePath) => {
const path = filePath.slice(8, -4).replace(/\/?index$/, "");
const { Page } = pageFiles[filePath];
@itkrt2y
itkrt2y / docker-compose.yml
Created Dec 4, 2019
Docker / MySQL (utf8mb4)
View docker-compose.yml
version: "3"
services:
db:
image: mysql:5.7
container_name: sample-db
ports:
- 3344:3306
volumes:
- ./db/mysql:/var/lib/mysql
@itkrt2y
itkrt2y / open-pull-request
Created Nov 29, 2019
Open Pull Request associated with a commit id
View open-pull-request
#!/bin/sh
# Required: hub, jq
commit=$1
pr=$(hub api graphql -F query="
{
repository(name: \"{repo}\", owner: \"{owner}\") {
commit: object(expression: \"$commit\") {
... on Commit {
@itkrt2y
itkrt2y / .eslintrc.js
Last active Feb 22, 2021
VSCode + TypeScript + ESLint + Prettier + React
View .eslintrc.js
/** @type import("eslint").Linter.Config */
module.exports = {
env: { browser: true, node: true },
parser: '@typescript-eslint/parser',
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:react/recommended",
@itkrt2y
itkrt2y / manjaro-gnome.md
Last active Aug 24, 2022
Setup Manjaro Linux (Gnome)
View manjaro-gnome.md

Firewall

Open 'Firewall Configuration' app and enable firewall.

CPU undervolt

yay -S intel-undervolt
sudo vim /etc/intel-undevolt.conf
# CPU / CPU Cache =&gt; -90
View gnome-terminal-profile.dconf
[/]
audible-bell=false
background-color='rgb(15,15,15)'
bold-is-bright=false
default-size-columns=80
default-size-rows=50
palette=['rgb(0,0,0)', 'rgb(205,0,0)', 'rgb(0,205,0)', 'rgb(205,205,0)', 'rgb(30,144,255)', 'rgb(205,0,205)', 'rgb(0,205,205)', 'rgb(229,229,229)', 'rgb(127,127,127)', 'rgb(255,0,0)', 'rgb(0,255,0)', 'rgb(255,255,0)', 'rgb(72,111,213)', 'rgb(255,0,255)', 'rgb(0,255,255)', 'rgb(255,255,255)']
visible-name='manjaro-custom'