Skip to content

Instantly share code, notes, and snippets.

Avatar

Toru Kobayashi koba04

View GitHub Profile
View Foo.tsx
const Foo = () => {
const someRef = React.useRef<{ someSetupMethod: () => void; someCleanupMethod: () => void }>(null)
React.useEffect(() => {
if (someRef.current === null) return
someRef.current.someSetupMethod()
return () => {
if (someRef.current === null) return
// react-hooks/exhaustive-deps warns this
someRef.current.someCleanupMethod()
}
View #voyage-book.md

#voyagebook

『Engineers in VOYAGE ― 事業をエンジニアリングする技術者たち』

https://www.lambdanote.com/collections/engineers-in-voyage

以前に技術力評価会に外部評価者として参加させて頂いた縁もあり、本を頂いたので感想を書いてみます。

まず最初に思ったので、こんな本読んだことないなという点です。 企業が自社の技術について書いている本は過去にいくつか読んだことはありますが、そういった本は技術にフォーカスされているのに対して、この本は事業にフォーカスが当てられており、如何に事業をエンジニアリングで発展させていくかという点が中心になっています。まさに本のタイトルの通りですね。

@koba04
koba04 / server.js
Last active Apr 20, 2020 — forked from shisama/proxy_server.js
Node.js Proxy Server with Basic Auth Sample
View server.js
const http = require("http");
const { parse } = require("basic-auth");
const { PROXY_USERNAME, PROXY_PASSWORD } = process.env;
const PROXY_PORT = process.env.PROXY_PORT || 8000;
const check = (credentials) => {
console.log(credentials);
return (
credentials &&
credentials.name === PROXY_USERNAME &&
View safari-samesite-none.md
View use-case-logger.ts
import { Dispatch } from 'redux'
export type Dispatch = Dispatch
export const createUseCase = <T>(name: string, usecase: () => Promise<any>) => async () => {
if (process.env.NODE_ENV === 'development') {
console.groupCollapsed(`%c[UseCase]%c ${name}`, 'color: #00c4cc', '')
console.time(name)
performance.mark(`start:${name}`)
}
@koba04
koba04 / 2.ts
Last active Feb 17, 2019
Approaches to normalize Redux Store
View 2.ts
interface User {
id: number;
name: string;
todoIds: number[];
}
interface Todo {
id: number;
body: string;
memoIds: number[];
@koba04
koba04 / NavigationTiming.js
Last active Jul 20, 2018
Web Perf snippets
View NavigationTiming.js
timing = performance.timing;
console.log(
`Unload: ${timing.unloadEventEnd - timing.unloadEventStart}\n`,
`Redirect: ${timing.redirectEnd - timing.redirectStart}\n`,
`App Cache: ${timing.domainLookupStart - timing.fetchStart}\n`,
`DNS: ${timing.domainLookupEnd - timing.domainLookupStart}\n`,
`TCP: ${timing.connectEnd - timing.connectStart}\n`,
`Request: ${timing.responseStart - timing.requestStart}\n`,
`Response: ${timing.responseEnd - timing.responseStart}\n`,
`Processing: ${timing.domComplete - timing.domLoading}\n`,
View browser.js
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
const initialData = JSON.parse(document.getElementById('initial-data').getAttribute('data-json'));
ReactDOM.hydrate(<App {...initialData} />, document.getElementById('app'));
View server.js
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import express from 'express';
import Html from './Html';
import App from './App';
const app = express();
app.use('/static', express.static('public'));
View Html.js
import React from 'react';
const Html = (props) => {
return (
<html>
<head>
<title>App</title>
</head>
<body>
<div id="app">{props.children}</div>
You can’t perform that action at this time.