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
const noop = () => { | |
/* do nothing */ | |
}; | |
// ---------- old version ---------- | |
export function asyncThrottle(func, { interval = 1000, onError = noop } = {}) { | |
if (typeof func !== "function") throw new Error("argument is not function."); | |
let running = false; | |
let lastTime = 0; |
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
version: '3' | |
services: | |
db: | |
image: mysql:latest | |
environment: | |
MYSQL_ROOT_PASSWORD: pass | |
MYSQL_DATABASE: blog | |
MYSQL_USER: user | |
MYSQL_PASSWORD: pass | |
volumes: |
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
abstract class ZodType { | |
abstract _parse(input: ParseInput): ParseReturnType<Output>; | |
parse(data: unknown, params?: Partial<ParseParams>): Output { | |
const result = this.safeParse(data, params); | |
if (result.success) return result.data; | |
throw result.error; | |
} | |
safeParse(data: unknown, params?: Partial<ParseParams>): SafeParseReturnType<Input, Output> { |
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
/** | |
$ node node/reflect-vs-private.js | |
Reflect x 7,297,368 ops/sec ±0.66% (92 runs sampled) | |
Normal x 126,613,750 ops/sec ±0.75% (93 runs sampled) | |
Private x 14,083,334 ops/sec ±0.99% (87 runs sampled) | |
Fastest is Normal | |
*/ | |
const { Benchmark } = require("benchmark"); | |
var suite = new Benchmark.Suite(); |
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
#!/usr/bin/env bash | |
if [ "$#" -ne 2 ]; then | |
echo 'nginx-associate-port-to-domain [port] [domain]' | |
exit 1 | |
fi | |
cat <<EOF > "/etc/nginx/sites-available/$2" | |
server | |
{ |
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 React from 'react' | |
import {render, flushEffects} from 'react-testing-library' | |
export const testHook = hook => (...args) => { | |
let data = null | |
const Component = () => { | |
data = hook(...args) | |
return null | |
} | |
render(<Component />) |
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
color=on | |
color.alternate= | |
color.debug=yellow | |
color.error=red | |
color.footnote= | |
color.header= | |
color.warning=yellow | |
color.summary.background= | |
color.summary.bar= |
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
#!/usr/bin/env bash | |
#--------------------------------------------------------------------------- | |
# Small script to monitor changes of a file or directory. | |
# | |
# -- Requirements | |
# | |
# You need to have git installed on your system because | |
# it is used to compute and show the changes. | |
# |
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
imperative: | |
Duration: 2 ms | |
Memory: 365600 bytes | 0.36 MB approx | |
object-oriented: | |
Duration: 4 ms | |
Memory: 266856 bytes | 0.27 MB approx | |
functional: | |
Duration: 4786 ms |