Skip to content

Instantly share code, notes, and snippets.

View koba04's full-sized avatar

Toru Kobayashi koba04

View GitHub Profile
@koba04
koba04 / topological-sort.js
Last active August 10, 2023 00:49
Topological Sort
const topologicalSort = (tree) => {
const answers = [];
const entryTimesMap = new Map();
// calc entry times
tree.forEach(node => {
if (!entryTimesMap.has(node.val)) {
entryTimesMap.set(node.val, 0);
}
node.deps.forEach(dep => {
import PropTypes from 'prop-types';
import React from 'react';
import type { ReactElement } from 'react';
import ReactDOM from 'react-dom';
import TransitionGroup from './TransitionGroup';
import type { Props as TransitionProps } from './Transition';
type Props = Omit<TransitionProps, 'children'> & {
children: [ReactElement<TransitionProps>, ReactElement<TransitionProps>];
};
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()
}

#voyagebook

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

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

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

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

@koba04
koba04 / server.js
Last active April 20, 2020 09:37 — forked from shisama/proxy_server.js
Node.js Proxy Server with Basic Auth Sample
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 &&
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 February 17, 2019 07:04
Approaches to normalize Redux Store
interface User {
id: number;
name: string;
todoIds: number[];
}
interface Todo {
id: number;
body: string;
memoIds: number[];
@koba04
koba04 / NavigationTiming.js
Last active July 20, 2018 05:02
Web Perf snippets
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`,
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'));