Skip to content

Instantly share code, notes, and snippets.

View jackyef's full-sized avatar
🧊
Chilling

Jacky Efendi jackyef

🧊
Chilling
View GitHub Profile
@jackyef
jackyef / keyDownAndClicks.js
Created June 9, 2021 08:33
Snippet showing that dispatching keydown events programmatically doesn't trigger click.
button = document.createElement('button')
button.onclick = function() { console.log('you clicked me!') }
button.dispatchEvent(new Event('click'))
button.addEventListener('keydown', e => {
console.log('I received a keydown event', e.key)
})
function aKeyboardEvent() {
const serialCon = (timeArray, maxConcurrency) => {
let activePromiseCount = 0
const times = [...timeArray]
const processNextPromise = () => {
const time = times.shift()
if (!time) return
const newPromise = new Promise((resolve) =>
const serialCon = (timeArray, maxConcurrency) => {
const startedPromises = []
const times = [...timeArray]
const processNextPromise = () => {
const time = times.shift()
if (!time) return
const newPromise = new Promise((resolve) =>
<!DOCTYPE html>
<html lang="id">
<body>
<h1 id="LCP">Heading 1</h1>
<script>
const lcpElement = document.getElementById("LCP");
const rect = lcpElement.getBoundingClientRect();
console.log('initial', JSON.stringify({ rect }, null, 2));
console.log(`Initial size ${rect.width}px + ${rect.height}px`);
'use strict';
module.exports = {
hooks: { readPackage },
};
function readPackage(pkg) {
if (pkg.name === 'antd-table-infinity') {
pkg.peerDependencies = { ...pkg.peerDependencies, antd: '^3.20.0' };
}
@jackyef
jackyef / TaskManager.js
Created November 13, 2019 11:02
Simple TaskManager implementation for NodeJS
const EventEmitter = require('events').EventEmitter;
class Task extends EventEmitter {
constructor(cb, name = 'N/A', type = '') {
super();
this.cb = cb;
this.name = name;
this.type = type; // will be used to determine which queue this task should be enqueued to
this.next = null; // can assign another task to .next for sequencing tasks
this.started = false;
const latestTag = child.execSync('git describe --long').toString('utf-8').split('-')[0];
const output = child
.execSync(`git log ${latestTag}..HEAD --format=%B%H----DELIMITER----`)
.toString("utf-8");
// update package.json
fs.writeFileSync("./package.json", JSON.stringify({ version: String(newVersion) }, null, 2));
// create a new commit
child.execSync('git add .');
child.execSync(`git commit -m "chore: Bump to version ${newVersion}"`);
// tag the commit
child.execSync(`git tag -a -m "Tag for version ${newVersion}" version${newVersion}`);
const child = require("child_process");
const fs = require("fs");
const output = child
.execSync(`git log --format=%B%H----DELIMITER----`)
.toString("utf-8");
const commitsArray = output
.split("----DELIMITER----\n")
.map(commit => {
const child = require('child_process');
const output = child.execSync(`git log --format=%B%H----DELIMITER----`).toString('utf-8');
const commitsArray = output.split('----DELIMITER----\n').map(commit => {
const [message, sha] = commit.split('\n');
return { sha, message };
}).filter(commit => Boolean(commit.sha));