Skip to content

Instantly share code, notes, and snippets.

View euxn23's full-sized avatar

yuta.suzuki euxn23

View GitHub Profile
export function parseEnv(env: '1' | '0' | 'true' | 'false' | string | undefined): string | boolean {
if (!env) {
return false;
}
try {
return Boolean(JSON.parse(env));
} catch {
return env;
}
}
@euxn23
euxn23 / .zshrc.env
Last active May 3, 2024 00:03
.zshrc.env
#!/urs/bin/env zsh
export EDITOR=nvim
export XDG_RUNTIME_DIR=/run/user/$(id -u)
# WSL
export BROWSER='pwsh.exe /c start'
alias chrome='/mnt/c/Program\ Files/Google/Chrome/Application/chrome.exe'
alias wezterm=wezterm.exe
alias wezterm-mux-server=wezterm-mux-server.exe
repeat 100 pnpm test -- --ci --silent <test file> &>/dev/null && echo -n "." || echo -n x
@euxn23
euxn23 / eslint.config.js
Last active February 16, 2024 00:28
pnpm i -DE eslint typescript-eslint eslint-plugin-import eslint-plugin-unused-imports eslint-plugin-react eslint-plugin-react-hooks esint-plugin-jsx-a11y
// @ts-check
import typescript from 'typescript-eslint'
import reactPlugin from 'eslint-plugin-react'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'
import importPlugin from 'eslint-plugin-import'
import unusedImportsPlugin from 'eslint-plugin-unused-imports'
import js from '@eslint/js'
import globals from 'globals'
@euxn23
euxn23 / use-behavior-subject.ts
Last active February 15, 2024 23:00
use-behavior-subject.ts
import { BehaviorSubject } from 'rxjs'
import { useSyncExternalStore } from 'react'
export function useSyncBehaviorSubject<T>(subject: BehaviorSubject<T>): T {
return useSyncExternalStore(
(onStoreChange) => {
const subscription = subject.subscribe(onStoreChange)
return () => subscription.unsubscribe()
},
() => subject.value
@euxn23
euxn23 / Center.tsx
Created December 26, 2023 17:57
Radix UI utilities
import { ReactNode } from "react";
import { Flex } from "@radix-ui/themes";
export function Center({ children }: { children: ReactNode }) {
return (
<Flex justify="center" direction="column" align="center" height="100%" width="100%" gap="4">
{children}
</Flex>
);
}
@euxn23
euxn23 / .prettierrc
Last active December 26, 2023 16:27
.prettierrc
{
"singleQuote": true,
"semi": false,
"printWidth": 160
}
@euxn23
euxn23 / eslint.config.js
Last active October 29, 2023 02:42
eslint for vue
import typescriptParser from "@typescript-eslint/parser"
import typescriptPlugin from "@typescript-eslint/eslint-plugin"
import vueParser from 'vue-eslint-parser'
import vuePlugin from 'eslint-plugin-vue'
export default [
{
files: ["src/**/*.{ts,vue}"],
languageOptions: {
parser: vueParser,
@euxn23
euxn23 / wezterm.lua
Created September 16, 2023 07:52
wezterm.lua
local wezterm = require 'wezterm';
local act = wezterm.action
local THEME_ACCENT = '#6d9df1'
local THEME_GRAY_3 = '#262626'
local THEME_GRAY_2 = '#3a3a3a'
local THEME_GRAY_1 = '#626262'
local SOLID_RIGHT_ARROW = utf8.char(0xe0b0)
local SOLID_LEFT_ARROW = utf8.char(0xe0b2)
@euxn23
euxn23 / eslint.config.js
Last active May 1, 2023 19:52
eslint.config.js
import typescriptParser from "@typescript-eslint/parser"
import typescriptPlugin from "@typescript-eslint/eslint-plugin"
import reactPlugin from 'eslint-plugin-react'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y'
export default [
{
files: ["src/**/*.ts{,x}"],
languageOptions: {