Skip to content

Instantly share code, notes, and snippets.

View trys's full-sized avatar
🤓
🚀

Trys Mudford trys

🤓
🚀
View GitHub Profile
@dutchcelt
dutchcelt / convertToTShirtSize.js
Last active February 28, 2024 07:17
Convert a step value to a corresponding T-shirt size
/**
* Converts a step value to a corresponding T-shirt size.
* The default value '0' is equal to 'm'.
* @param {number} step - The step value to convert into a T-shirt size.
* @returns {string} The T-shirt size corresponding to the given step value.
*/
const convertToTShirtSize = (step = 0) => {
const times = Math.max(0, Math.abs(step) - 1);
const index = Math.sign(step) + 1;
return 'x'.repeat(times) + ['s','m','l'][index];
@paulirish
paulirish / bling.js
Last active May 10, 2025 11:02
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };