Skip to content

Instantly share code, notes, and snippets.

View ferreirase's full-sized avatar
🥇
Focusing

Anderson Raphael Ferreira ferreirase

🥇
Focusing
View GitHub Profile
@ntorga
ntorga / humanReadableBytesAdapter.ts
Created April 5, 2024 18:14
A human readable bytes adapter for TypeScript/JavaScript that is actually (and finally) readable.
function humanReadableBytesAdapter(rawBytesQuantity: number): string {
const bytesUnits = ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
let unitSuffixIndex = 0;
const isQuantityNegative = rawBytesQuantity < 0;
const rawBytesQuantityAbsolute = Math.abs(rawBytesQuantity);
let shortestBytesNumeral = rawBytesQuantityAbsolute;
while (shortestBytesNumeral >= 1024 && unitSuffixIndex < bytesUnits.length - 1) {
shortestBytesNumeral /= 1024;
// index.mjs
// nvm use 15 && node index.mjs
{
const getRandomInteger = (max = 100) => {
return Math.floor(Math.random() * max)
}
console.log('Math.random', getRandomInteger())
}
@rxaviers
rxaviers / gist:7360908
Last active June 17, 2024 14:42
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: