This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {createElement, Fragment, isValidElement, ReactElement, ReactNode, useCallback} from 'react'; | |
export interface FcProps<P> { | |
render(props: P): ReactNode | null | void; | |
} | |
function Fc<P extends FcProps<P>>(props: P): ReactElement | null { | |
const v = useCallback(props.render, [])(props); | |
return v === undefined ? null : isValidElement(v) ? v : createElement(Fragment, null, v); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://michalbe.blogspot.com.br/2013/03/javascript-less-known-parts-bitwise.html | |
// http://jsperf.com/bitwise-vs-math-object | |
// http://united-coders.com/christian-harms/results-for-game-for-forfeits-and-the-winner-is/ | |
// https://mudcu.be/journal/2011/11/bitwise-gems-and-other-optimizations/ | |
// https://dreaminginjavascript.wordpress.com/2009/02/09/bitwise-byte-foolish/ | |
// http://jsperf.com/math-min-max-vs-ternary-vs-if/24 | |
"use strict"; | |
var PI = Math.PI; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prints msec in format "[d days ]hh:mm:ss.SSS" | |
function format_duration #(msec=0) | |
{ | |
local t=${1:-0} | |
local days=$((t/60/60/24)) | |
[ $days -gt 0 ] && echo -ne "$days days " | |
printf "%d:%02d:%02d" $((t/60/60%24)) $((t/60%60)) $((t%60)) | |
} | |
# Prints file permissions in decimal mode, ex. 755. |