Skip to content

Instantly share code, notes, and snippets.

View phuonghd's full-sized avatar
🏠
Working from home

Phuong Huynh phuonghd

🏠
Working from home
View GitHub Profile
@phuonghd
phuonghd / rgbaToHex.js
Created December 27, 2016 03:05 — forked from whitlockjc/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,'');