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 }) => {
View typescript-cheatsheet.md

unknown

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
hachibeeDI / listviewthrottle.tsx
Last active Nov 21, 2018
sketch list rendering throttle
View listviewthrottle.tsx
/*
<ListThrottle<string> items={strs}>
{({renderPrevCreatives, renderNextCreatives, throttledItems}) => (
<SomeAwesomeComponentSupportsScroll
superHandlerCatchOnScrollTop={renderPrevCreatives}
superHandlerCatchOnScrollEnd={renderNextCreatives}
>
<ul>
{throttledItems.map(str => (
<li>{str></li>
View multi-itertool.py
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
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) {
super(props);
this.state = {
[name]: defaultValue
};
this.toggle = this.toggle.bind(this);
@hachibeeDI
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
hachibeeDI / debounced-action-call-middleware.js
Created Apr 28, 2017
debounced-action-call-middleware.js
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}),
wait
);
@hachibeeDI
hachibeeDI / mutiproc_async.py
Last active Feb 14, 2018
play around async and future
View mutiproc_async.py
import asyncio
from time import sleep, time
def blocker(txt):
sleep(3)
return 'aaa' + txt
def async_sample(loop):
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>使い捨てパッド暗号化</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
@hachibeeDI
hachibeeDI / rivo.coffee
Created Feb 16, 2015
リボの手数料の雑な算出
View rivo.coffee
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.