Skip to content

Instantly share code, notes, and snippets.

View webNeat's full-sized avatar

Amine Ben hammou webNeat

View GitHub Profile
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;
@webNeat
webNeat / docker-compose.yaml
Created June 22, 2023 15:44
MySQL + adminer on docker-compose
version: '3'
services:
db:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: pass
MYSQL_DATABASE: blog
MYSQL_USER: user
MYSQL_PASSWORD: pass
volumes:
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> {
@webNeat
webNeat / reflect-vs-private.js
Last active January 31, 2022 18:06 — forked from Aschen/reflect.js
Reflect.defineProperty vs #field
/**
$ 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();
#!/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
{
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 />)
@webNeat
webNeat / wn.theme
Last active March 8, 2017 23:00
My Taskwarrior Theme
color=on
color.alternate=
color.debug=yellow
color.error=red
color.footnote=
color.header=
color.warning=yellow
color.summary.background=
color.summary.bar=
@webNeat
webNeat / watcher.sh
Created February 5, 2017 17:58
bash script to monitor changes of a file or directory.
#!/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.
#
@webNeat
webNeat / Results.txt
Last active December 28, 2016 18:43
Comparaison
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