Skip to content

Instantly share code, notes, and snippets.

Avatar
👀
whoopss

ilhamgusti ilhamgusti

👀
whoopss
View GitHub Profile
@ilhamgusti
ilhamgusti / hotkey-utilities.js
Created Aug 6, 2022
utility to handle hotkeys
View hotkey-utilities.js
export function parseHotkey(hotkey) {
const keys = hotkey
.toLowerCase()
.split('+')
.map((part) => part.trim());
const modifiers = {
alt: keys.includes('alt'),
ctrl: keys.includes('ctrl'),
@ilhamgusti
ilhamgusti / hashchange.js
Created Aug 2, 2022
subscribing hash change
View hashchange.js
if ("onhashchange" in window) {
window.onhashchange = function () {
alert(window.location.hash);
}
}
else {
var prevHash = window.location.hash;
window.setInterval(function () {
if (window.location.hash != prevHash) {
prevHash = window.location.hash;
@ilhamgusti
ilhamgusti / index.html
Last active Jun 14, 2022
html shortener uhuy
View index.html
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Workers - Link Shortener</title>
</head>
<body>
<h1>Workers Link Shortener</h1>
View browserless_get_holiday_indonesia.js
// Full TypeScript support for both puppeteer and the DOM
export default async ({ page }: { page: Page }) => {
// Full puppeteer API is available
const url = 'https://holidayapi.com/countries/id/2025';
await page.goto(url, {waitUntil: 'networkidle0'});
const data = await page.evaluate(()=>{
const query = (selector, context) => Array.from(context.querySelectorAll(selector));
@ilhamgusti
ilhamgusti / mutableSet.js
Created Apr 28, 2022
writing mutable object safely
View mutableSet.js
/**
*
* @param o Object to mutate
* @param ks array of keys, or string of keys
* @param v value to assign
* @param sep custom separator if keys is string. ex: ks:"INIxxADALAHxxKEY", sep is: "xx"
*/
function mutableSet(o, ks, v, sep = '.') {
ks.split && (ks=ks.split(sep));
let i=0, l=ks.length, t=o, x, k;
@ilhamgusti
ilhamgusti / whilePromise.js
Created Jan 24, 2022
while promise with condition
View whilePromise.js
export default async function whilePromise(action, condition) {
const result = await action();
if (condition(result)) {
return whilePromise(action, condition);
}
}
View useDelay.js
export function useDelay(time = 1000) {
return React.useCallback(async () => {
return await new Promise((resolve) => {
setTimeout(resolve, time);
});
}, [time]);
}
//usage
export default function App() {
@ilhamgusti
ilhamgusti / useForm.js
Created Jan 7, 2022
hooks for handle form input
View useForm.js
import { useState } from "react";
function getInputOnChange(setValue) {
return (val) => {
if (!val) {
setValue(val);
} else if (typeof val === "function") {
setValue(val);
} else if (typeof val === "object" && "nativeEvent" in val) {
const { currentTarget } = val;
View docker-compose.yml
version: "3.3"
services:
traefik:
image: traefik
restart: always
container_name: traefik
ports:
- 80:80
- 443:443
@ilhamgusti
ilhamgusti / docker-compose.yml
Created Nov 2, 2021 — forked from Mau5Machine/docker-compose.yml
Traefik Configuration and Setup
View docker-compose.yml
version: "3.3"
services:
################################################
#### Traefik Proxy Setup #####
###############################################
traefik:
image: traefik:v2.0
restart: always