This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Takes an rgba() CSS value and converts it to its 8 digit hexadecimal value. | |
// | |
// Usage: ./rgbaToHex.js "{YOUR_RGBA_STRING}" | |
// | |
// Example: ./rgbaToHex.js "rgba(197, 200, 198, .2)" => #C5C8C633 | |
function trim (str) { | |
return str.replace(/^\s+|\s+$/gm,''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//range: (0..x-1) | |
function rnd(x){ | |
return Math.floor(Math.random()*x); | |
} | |
function shuffleLetters(s){ | |
var res=""; | |
var a=s.split(""); | |
while (a.length>0) | |
res+=a.splice(rnd(a.length),1)[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make sure you include tinycolor library from npm | |
// npm install tinycolor2 | |
const ionPrefix = ".ion-color-"; | |
// | |
// example usage | |
// | |
// addIonColor("myColor", "#123456"); | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getRandomInt = (min = 0, max = 1) => { | |
min = Math.ceil(min); | |
max = Math.floor(max); | |
// The maximum is exclusive and the minimum is inclusive | |
return Math.floor(Math.random() * (max - min) + min); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function abbreviatedNumber(value: number, precision=2): string { | |
if (isNaN(value)) { | |
return ""; | |
} | |
let newValue = value; | |
const suffixes = ["", "K", "M", "B", "T"]; | |
let suffixNum = 0; | |
while (Math.abs(newValue) >= 1000) { | |
newValue /= 1000; | |
suffixNum++; |