Skip to content

Instantly share code, notes, and snippets.

View mhmda-83's full-sized avatar
🤔

Mohammad Mohammadalian mhmda-83

🤔
  • Iran
View GitHub Profile
@mhmda-83
mhmda-83 / visibilitychange event.js
Created April 7, 2020 11:27
check how much time user spend out of website
let timer = 0;
let interval;
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
alert(timer);
clearInterval(interval);
timer = 0;
} else {
interval = setInterval(() => timer++, 1000);
}
@mhmda-83
mhmda-83 / excuses.json
Last active July 26, 2024 11:35
Devloper Excuses (extracted from http://developerexcuses.com/)
[
"The program has never collected that information",
"That wasn't in the original specification",
"The project manager told me to do it that way",
"There's currently a problem with our hosting company",
"Well done, you found my easter egg!",
"That feature would be outside of the scope",
"This code was not supposed to go in to production yet",
"The client must have been hacked",
"I'm still working on that as we speak",
@mhmda-83
mhmda-83 / tf-idf.js
Last active August 27, 2021 08:36
basic tf-idf implementation
let data = `[{"title":"eros sodales velit faucibus gravida","content":"Venenatis sem ac arcu litora facilisi turpis ligula sem nostra habitant sodales? Fames molestie non aenean facilisis nibh inceptos praesent vitae amet. Lacus fringilla conubia id penatibus euismod. Eleifend ultrices blandit gravida tortor interdum. Quis curabitur himenaeos interdum suscipit ipsum nisi lacus orci vel integer himenaeos sapien, sollicitudin posuere at, volutpat tristique class himenaeos turpis lectus vehicula maecenas vehicula sed bibendum et, inceptos euismod eget neque orci venenatis purus ultricies nec?"},{"title":"non cum ad elementum et","content":"Sodales torquent nunc potenti. Mattis urna penatibus iaculis aenean amet dignissim sollicitudin? Pretium pharetra enim tristique dolor inceptos sollicitudin, vestibulum condimentum leo hac nisi leo vehicula turpis taciti odio, orci bibendum blandit in dui quis eleifend nam phasellus urna commodo ullamcorper? In malesuada molestie ornare nibh ornare cursus platea et habi
const Queue = require('bull');
const pdfQueue = new Queue('pdf', 'redis://localhost:6379');
const delay = (milliseconds) =>
new Promise((resolve) => setTimeout(resolve, milliseconds));
const CONCURRENCY = 2;
pdfQueue.process(CONCURRENCY, async function (job) {