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 => {
/**
* @providesModule ReactVoice
*/
'use strict';
const {spawnSync} = require('child_process');
const ReactDOMFrameScheduling = require('ReactDOMFrameScheduling');
const ReactFiberReconciler = require('ReactFiberReconciler');
const sideEffect = (method, text) => spawnSync('say', ['-v', method, text]);
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>];
};
@koba04
koba04 / path_class_test.pl
Created December 6, 2010 15:33
Path::Class Test Script
#!perl
use 5.010;
use utf8;
use strict;
use warnings;
use Cwd qw/realpath/;
use Encode;
use File::Temp qw/tempdir/;
@koba04
koba04 / api.md
Last active July 19, 2021 10:49
Vue.js note(v0.10.3). not translate. This is draft of https://github.com/koba04/vuejs-book .

API

Class: Vue

  • Vueはvue.jsのコアとなるコンストラクタ
  • インスタンスが作られたときにデータバインディングが開始される
  • オプションを取ることも出来て、DOMやデータやメソッドについて定義出来る
@koba04
koba04 / StaticComponent.js
Created April 16, 2015 01:16
React static component by higher order function.
import React from 'react';
const Static = Component => class extends React.Component {
shouldComponentUpdate() {
return false;
}
render() {
return <Component {...this.props} />;
}
};

#voyagebook

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

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

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

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

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()
}
@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 &&