Skip to content

Instantly share code, notes, and snippets.

View bockoblur's full-sized avatar

Slobodan Babic bockoblur

  • Novi Sad, Serbia
View GitHub Profile
@bockoblur
bockoblur / abbreviatedNumber.ts
Last active May 16, 2023 19:12 — forked from eugenemtn/abbreviatedNumber.ts
Formatter for abbrevated numbers
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++;
@bockoblur
bockoblur / rgbaToHex.js
Created January 10, 2018 15:07 — forked from phuonghd/rgbaToHex.js
Use JavaScript to Convert RGBA CSS Value to Hexadecimal
#!/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,'');