Skip to content

Instantly share code, notes, and snippets.

@AhmedElwerdany
AhmedElwerdany / main.js
Last active October 1, 2022 11:07
getting the text of HTML element excluding children
/*
* <div id='element'>hello world <span>!</span></div>
*
*/
const element = document.querySelector('#element');
let result = '';
element.childNodes.forEach(child => {
@AhmedElwerdany
AhmedElwerdany / round_corners.js
Created October 1, 2022 11:07
round corners (border-radius) with imagemagick
import { execSync } from 'child_process';
import path from 'path';
function roundImage(src_path, dest_path,radius = 15){
const {w,h} = getSize(src_path)
const maskName = `mask.png`
execSync(`convert -size ${w}x${h} xc:none -draw "roundrectangle 0,0,${w},${h},${radius},${radius}" ${maskName}`)
execSync(`convert ${src_path} -matte ${maskName} -compose DstIn -composite ${dest_path}`)
}
@AhmedElwerdany
AhmedElwerdany / script.js
Created October 25, 2022 14:49
watch array in vue.js v2
// https://ahmedelwerdany.github.io/posts/watch-many-in-vue-js/
function watchMany (arrayOfKeys, value) {
const object = {}
for (let i = 0; i < arrayOfKeys.length; i++) {
object[arrayOfKeys[i]] = value
}
return object
}