Skip to content

Instantly share code, notes, and snippets.

View maxam2017's full-sized avatar
🦕

Hong-Kuan Wu maxam2017

🦕
View GitHub Profile
@maxam2017
maxam2017 / debounce.js
Created September 27, 2023 17:36
Debounce & Throttle
function debounce(fn, wait) {
let timerId;
return function debounced(...args) {
clearTimeout(timerId);
const that = this;
timerId = setTimeout(() => fn.apply(that, args), wait);
};
}
@maxam2017
maxam2017 / machine.js
Created January 13, 2022 02:07
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@maxam2017
maxam2017 / js-trick.md
Created January 8, 2021 15:26
JavaScript is awesome

Logo

JavaScript Trick

umm...

  1. casting
🌞 Morning 254 commits ████████▍░░░░░░░░░░░░ 40.1%
🌆 Daytime 124 commits ████░░░░░░░░░░░░░░░░░ 19.6%
🌃 Evening 105 commits ███▍░░░░░░░░░░░░░░░░░ 16.6%
🌙 Night 151 commits █████░░░░░░░░░░░░░░░░ 23.8%
🌞 Morning 84 commits ███▋░░░░░░░░░░░░░░░░░ 17.8%
🌆 Daytime 186 commits ████████▎░░░░░░░░░░░░ 39.3%
🌃 Evening 152 commits ██████▋░░░░░░░░░░░░░░ 32.1%
🌙 Night 51 commits ██▎░░░░░░░░░░░░░░░░░░ 10.8%
TypeScript 4 hrs 24 mins ███████████████▍░░░░░ 73.3%
Docker 41 mins ██▍░░░░░░░░░░░░░░░░░░ 11.4%
JSON 21 mins █▎░░░░░░░░░░░░░░░░░░░ 6.0%
Other 13 mins ▊░░░░░░░░░░░░░░░░░░░░ 3.7%
Diff 10 mins ▌░░░░░░░░░░░░░░░░░░░░ 3.0%
import RPi.GPIO as GPIO
import os
import time
import logging
import bluetooth
import subprocess
import requests
import base64
'''
<layout>
@maxam2017
maxam2017 / segmentrouting.py
Last active July 17, 2019 04:10
Segment Routing with flexible N*M leaf-spine topology
import argparse
import logging
import json
import subprocess
from requests import post, delete
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.cli import CLI
from mininet.node import RemoteController, Host, OVSSwitch