Skip to content

Instantly share code, notes, and snippets.

OGURA_Daiki hachibeeDI

Block or report user

Report or block hachibeeDI

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View split-gate.tsx
import * as React from 'react';
import { useMemo, useContext, createContext, ReactNode } from 'react';
import { createPortal } from 'react-dom';
type Context = { portalID: string };
const PortalContext = createContext<Context>({} as any);
export function createSplitGate<T>(render: (arg: T) => ReactNode) {
return {
Zone: (props: Context & { children: ReactNode }) => {


unknown is safe version of any.

We should consider unknowon first then any.

Union types

When would like to take multiple type as argument.

hachibeeDI / listviewthrottle.tsx
Last active Nov 21, 2018
sketch list rendering throttle
View listviewthrottle.tsx
<ListThrottle<string> items={strs}>
{({renderPrevCreatives, renderNextCreatives, throttledItems}) => (
{ => (
def mmp(f):
def _m(x, prev=None):
if prev:
yield from prev
yield f(x)
return _m
def fft(f):
def _m(x, prev=None):
hachibeeDI / withStateToggleHOC.jsx
Created Nov 14, 2017
I guess you should use recompose
View withStateToggleHOC.jsx
const withStateToggle = (name, defaultValue) => ComposedChild => (
class Container extends Component {
constructor (props) {
this.state = {
[name]: defaultValue
this.toggle = this.toggle.bind(this);
hachibeeDI / modal-pattern-hoc.jsx
Created Oct 11, 2017
Considering more readable pattern to implement modal
View modal-pattern-hoc.jsx
import {EventEmitter} from 'events';
import React, {Component} from 'react';
import Modal from 'components/modal';
export default function WithModal (id, title, trigger) {
return (TargetComponent, key, descriptor) => class extends Component {
constructor() {
hachibeeDI / debounced-action-call-middleware.js
Created Apr 28, 2017
View debounced-action-call-middleware.js
import debounce from 'lodash.debounce';
export default function validationDebounceMiddlewareGenerator ({triggerActionTypes, validatorActionType, wait}) {
const createValidateActionDebounced = debounce(
dispatch => dispatch({type: validatorActionType}),
hachibeeDI /
Last active Feb 14, 2018
play around async and future
import asyncio
from time import sleep, time
def blocker(txt):
return 'aaa' + txt
def async_sample(loop):
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
hachibeeDI /
Created Feb 16, 2015
ammount = process.argv[2]
each = process.argv[3]
interest = if process.argv[4] == undefined then 15.0 else process.argv[4]
interest_each_month = (interest / 12) / 100
# console.log interest_each_month
# console.log ammount * interest_each_month
i = 0
ammount = ammount - each
You can’t perform that action at this time.