Skip to content

Instantly share code, notes, and snippets.

View 1natsu172's full-sized avatar
🤷‍♂️
わかったためしがない

1natsu 1natsu172

🤷‍♂️
わかったためしがない
View GitHub Profile
@1natsu172
1natsu172 / .gitignore
Created October 20, 2017 07:03
wp-attach-dev の .gitignore
.DS_Store
*.sql
npm-debug.log
# local by flywheelプロビジョンデータでいらないものignoreする
conf
logs
app/sql
@1natsu172
1natsu172 / .gitignore
Created October 20, 2017 07:06
VCCW2用の.gitignore
.DS_Store
.bundle
.idea/
.vagrant
Movefile
vendor
node_modules/
*.sql
npm-debug.log
@1natsu172
1natsu172 / PullToRefresh.tsx
Created August 16, 2018 11:16
Reactでpulltorefreshjsを使いたかったので書いたラッパーコンポーネント
import { uniqueId } from 'lodash-es'
import PullToRefreshJS from 'pulltorefreshjs'
import * as React from 'react'
import { findDOMNode } from 'react-dom'
type Props = {
onRefresh: (() => Promise<any>) | (() => void)
children: React.ReactNode
targetComponent?: React.ReactInstance
} & Partial<DefaultProps>
@1natsu172
1natsu172 / file0.txt
Last active November 29, 2018 17:01
react-virtualizedでタイムラインコンポーネントを作ろうとしてハマったときの知見 ref: https://qiita.com/1natsu172/items/f779392eac017cec48a4
<List autoHeight={true} ...{listProps} />
@1natsu172
1natsu172 / file0.txt
Last active April 18, 2020 11:00
https時代のgitアカウントを使い分ける方法 ref: https://qiita.com/1natsu172/items/a4a3357a0481440ec6a5
host github.com-main
HostName github.com
IdentityFile ~/.ssh/id_rsa_github
User git
host github.com-sub
HostName github.com
IdentityFile ~/.ssh/id_rsa_github_sub
User git
@1natsu172
1natsu172 / file0.txt
Last active April 10, 2019 03:34
@foo/barみたいな形式の大量のnpmパッケージをちょっとラクしてインストールする方法 ref: https://qiita.com/1natsu172/items/b9a0e2befcf3122cccc7
$ yarn add -D @types/react-collapsible @types/react-dom @types/react-image-gallery @types/react-modal @types/react-router-dom @types/react-swipeable-views @types/react-virtualized
@1natsu172
1natsu172 / getElementRects.ts
Created February 1, 2019 10:08
dom elementのRectを取って計算して返すくん。paddingを含まない値も欲しくてとりあえず書いたけど、ボツになったので供養
export const getElementRects = (element: HTMLElement) => {
const heightWithPadding = element.getBoundingClientRect().height
const heightWithoutPadding = () => {
if (!getComputedStyle) return 0
const { paddingTop, paddingBottom } = getComputedStyle(element)
const padding =
parseFloat(paddingTop ? paddingTop : '0') +
@1natsu172
1natsu172 / .eslintrc
Last active July 5, 2023 10:23
My airbnb based ESLint config for "typescript-eslint" with React & prettier
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"tsconfigRootDir": "."
},
"env": {
"browser": true,
"jest/globals": true
},
@1natsu172
1natsu172 / useEventCallback.ts
Created March 14, 2019 08:33
custom hooks for event handler.
import { useRef, useCallback, useEffect, useLayoutEffect } from 'react'
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
*
* @description For reference state value on event handler.
* @see https://reactjs.org/docs/hooks-faq.html#how-to-read-an-often-changing-value-from-usecallback
* @see https://github.com/facebook/react/issues/14099
* @todo `unknown` type loos better than `any`. But can't use unknown……Error message "Type 'unknown' is not assignable to type ~" why??
@1natsu172
1natsu172 / HTMLElementEventHandlers.ts
Created March 16, 2019 11:23
The interface of HTMLElement's event type and event handler
/* eslint-disable @typescript-eslint/no-explicit-any */
export type HTMLElementEventHandlers<U extends keyof HTMLElementEventMap> = {
[K in U]: (event: HTMLElementEventMap[K]) => any
}