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.
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
.
When would like to take multiple type as argument.
/* | |
<ListThrottle<string> items={strs}> | |
{({renderPrevCreatives, renderNextCreatives, throttledItems}) => ( | |
<SomeAwesomeComponentSupportsScroll | |
superHandlerCatchOnScrollTop={renderPrevCreatives} | |
superHandlerCatchOnScrollEnd={renderNextCreatives} | |
> | |
<ul> | |
{throttledItems.map(str => ( | |
<li>{str></li> |
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): |
const withStateToggle = (name, defaultValue) => ComposedChild => ( | |
class Container extends Component { | |
constructor (props) { | |
super(props); | |
this.state = { | |
[name]: defaultValue | |
}; | |
this.toggle = this.toggle.bind(this); |
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() { |
import debounce from 'lodash.debounce'; | |
export default function validationDebounceMiddlewareGenerator ({triggerActionTypes, validatorActionType, wait}) { | |
const createValidateActionDebounced = debounce( | |
dispatch => dispatch({type: validatorActionType}), | |
wait | |
); |
import asyncio | |
from time import sleep, time | |
def blocker(txt): | |
sleep(3) | |
return 'aaa' + txt | |
def async_sample(loop): |
<!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> |
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 |