Skip to content

Instantly share code, notes, and snippets.

View fzn0x's full-sized avatar
🌓
Nocturnal / Diurnal (Hybrid)

fzn0x fzn0x

🌓
Nocturnal / Diurnal (Hybrid)
View GitHub Profile
@r17x
r17x / OSX.md
Created February 24, 2022 18:31
MacOS common tools

Common Tools for development in Mac

xcode-select

  • version
xcode-select --version
// xcode-select version 2392.
  • Install
@fzn0x
fzn0x / web3js-realtime-balance.js
Last active July 20, 2023 13:43
Get Realtime Balance in web3.js | author using v1.3.6.rc-x, vue composition api. FREE TO MODIFY FOR YOUR OWN USE.
/*
* Author : Muhammad Fauzan | fauzan121002
* Web3.js v1.3.6
*
* No License Used, Free to modify, commercial use and distribute.
*/
import { defineComponent, useAsync, ref } from '@nuxtjs/composition-api'
export const useGetUserBalance = async () => {
/**
* Example `FizzBuzz` with JavaScript (Pattern-Matching Like????????????) λ_(ツ)_/¯
* I Love this tweet
* @see https://twitter.com/cajuinaoverflow/status/1395022027204005889
* JavaScript will make You Crazy (Trust Me!)
*/
const FizzBuzz = n => ({
true: n,
[ n % 5 === 0]: "Buzz",
[ n % 3 === 0]: "Fizz",
@fzn0x
fzn0x / fifo.js
Created May 19, 2021 15:28
FIFO Algorithm in Javascript
// define the queue class
class Queue {
constructor(...elements) {
// set array as value of construct args
this.elements = [...elements];
}
push(...args) {
// push arguments to this.elements
return this.elements.push(...args);
@broofa
broofa / checkForUndefinedCSSClasses.js
Last active January 21, 2024 17:22
ES module for detecting undefined CSS classes (uses mutation observer to monitor DOM changes). `console.warn()`s undefined classes.
/**
* Sets up a DOM MutationObserver that watches for elements using undefined CSS
* class names. Performance should be pretty good, but it's probably best to
* avoid using this in production.
*
* Usage:
*
* import cssCheck from './checkForUndefinedCSSClasses.js'
*
* // Call before DOM renders (e.g. in <HEAD> or prior to React.render())
@nfantone
nfantone / before-shutdown.js
Created September 23, 2020 13:00
Node.js graceful shutdown handler
'use strict';
/**
* @callback BeforeShutdownListener
* @param {string} [signalOrEvent] The exit signal or event name received on the process.
*/
/**
* System signals the app will listen to initiate shutdown.
* @const {string[]}
@fzn0x
fzn0x / divideAndSort.js
Last active August 16, 2020 04:50
Divide And Sort Javascript
function divideAndSort(value){
const division = value.toString().split("0");
for(let num in division){
if(division[num] == "") {
division.splice(num,1);
}else{
division[num] = division[num].split("").sort().join().replace(/,/g,"");
@Cynosphere
Cynosphere / gameslist.json
Created March 6, 2019 01:48
Discord Verified Games List
This file has been truncated, but you can view the full file.
[
{
"id": "259392830932254721",
"name": "SpeedRunners",
"icon": "cb48279ea90e86fb4f71c709d3236395",
"splash": "94e91cac9509fee1eb80a69b9503878a",
"overlay": false,
"overlayWarn": false,
"overlayCompatibilityHook": false,
"aliases": [],
@mpgn
mpgn / SubtleCrypto.js
Last active May 6, 2024 03:25
SubtleCrypto javascript example
// exemple based on https://github.com/diafygi/webcrypto-examples#rsa-oaep
function importKey() {
return window.crypto.subtle.importKey(
"jwk", //can be "jwk" or "raw"
{ //this is an example jwk key, "raw" would be an ArrayBuffer
kty: "oct",
k: "Y0zt37HgOx-BY7SQjYVmrqhPkO44Ii2Jcb9yydUDPfE",
alg: "A256GCM",
ext: true,
@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active May 2, 2024 19:03
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem