Chrome default color picker snippet
function copy(value) {
setTimeout(async()=>console.log(
await window.navigator.clipboard.writeText(value)), 3000);
console.log("Color: " + value);
}
window.colorPicker = () => new EyeDropper().open().then((color)=> copy(color.sRGBHex))
window.colorPicker();
Make dynamic css classes
function cssHandles(...arguments) {
return arguments.reduce((acc, cur) => {
if (typeof cur === 'string') return acc + ` ${cur}`;
if (typeof cur === 'object') {
return Object.keys(cur).map((key) => {
if(cur[key]) return acc + ` ${key}`
return acc
}).filter(Boolean).join('').trim()
}
}, '')
}
cssHandles({ 'button--active': true, 'button--disabled': false, 'primary': true }, { 'is--open': false })
> 'button--active primary'
Show package json infos by terminal
alias pkg="cat package.json"
alias head-pkg="head package.json"
alias tail-pkg="tail package.json"
alias pkg-scripts="pkg | jq .scripts"
alias hgrep="history | grep "