View openapi.yaml
This file contains 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
openapi: 3.0.0 | |
info: | |
title: Open-Meteo APIs | |
description: 'Open-Meteo offers free weather forecast APIs for open-source developers and non-commercial use. No API key is required.' | |
version: '1.0' | |
contact: | |
name: Open-Meteo | |
url: https://open-meteo.com | |
email: info@open-meteo.com | |
license: |
View poc.js
This file contains 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
// get current existing video element | |
const video = document.querySelector('video'); | |
// catch seeked event | |
video.addEventListener('seeked', (event) => { | |
// TODO: checking position time seek. | |
// send/broadcast seeking time to websocket | |
console.log('Video found the playback position it was looking for.'); | |
}); |
View hotkey-utilities.js
This file contains 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
export function parseHotkey(hotkey) { | |
const keys = hotkey | |
.toLowerCase() | |
.split('+') | |
.map((part) => part.trim()); | |
const modifiers = { | |
alt: keys.includes('alt'), | |
ctrl: keys.includes('ctrl'), |
View hashchange.js
This file contains 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
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; |
View index.html
This file contains 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
<!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
This file contains 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
// 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)); |
View mutableSet.js
This file contains 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
/** | |
* | |
* @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; |
View whilePromise.js
This file contains 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
export default async function whilePromise(action, condition) { | |
const result = await action(); | |
if (condition(result)) { | |
return whilePromise(action, condition); | |
} | |
} |
View useDelay.js
This file contains 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
export function useDelay(time = 1000) { | |
return React.useCallback(async () => { | |
return await new Promise((resolve) => { | |
setTimeout(resolve, time); | |
}); | |
}, [time]); | |
} | |
//usage | |
export default function App() { |
View useForm.js
This file contains 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 { 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; |
NewerOlder