how to store and delete s3 image using node js


const s3 = new AWS.S3(
{ accessKeyId: IAM_USER_KEY, /* required */# Put your iam user key
secretAccessKey: IAM_USER_SECRET, /* required */ # Put your iam user secret key
Bucket: BUCKET_NAME /* required */ # Put your bucket name
}
);
s3.deleteObject({
Bucket: MY_BUCKET,
Key: 'some/subfolders/nameofthefile1.extension'
},function (err,data){})

www.codegrepper.com
www.stackoverflow.com

how to sort by data in chart js


const arrayOfObj = chartLabels.map(function (d, i) {
return {
label: d,
data: chartValues[i] || 0,
}
})

const sortedArrayOfObj = arrayOfObj.sort(function (a, b) {
return b.data - a.data
})

let newArrayLabel = []
let newArrayData = []
sortedArrayOfObj.forEach(function (d) {
newArrayLabel.push(d.label)
newArrayData.push(d.data)
})

www.codegrepper.com
www.stackoverflow.com

how to set three js canvas width 100%


body { margin: 0; }
canvas { width: 100vw; height: 100vh; display: block; }

"use strict";

const renderer = new THREE.WebGLRenderer();
document.body.appendChild(renderer.domElement);

// There's no reason to set the aspect here because we're going
// to set it every frame anyway so we'll set it to 2 since 2
// is the the aspect for the canvas default size (300w/150h = 2)
const camera = new THREE.PerspectiveCamera(70, 2, 1, 1000);
camera.position.z = 400;

const scene = new THREE.Scene();
const geometry = new THREE.BoxGeometry(200, 200, 200);
const material = new THREE.MeshPhongMaterial({
color: 0x555555,
specular: 0xffffff,
shininess: 50,
shading: THREE.SmoothShading
});

const mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);

const light1 = new THREE.PointLight(0xff80C0, 2, 0);
light1.position.set(200, 100, 300);
scene.add(light1);

function resizeCanvasToDisplaySize() {
const canvas = renderer.domElement;
const width = canvas.clientWidth;
const height = canvas.clientHeight;
if (canvas.width !== width ||canvas.height !== height) {
// you must pass false here or three.js sadly fights the browser
renderer.setSize(width, height, false);
camera.aspect = width / height;
camera.updateProjectionMatrix();

// set render target sizes here
}
}

function animate(time) {
time *= 0.001; // seconds

resizeCanvasToDisplaySize();

mesh.rotation.x = time * 0.5;
mesh.rotation.y = time * 1;

renderer.render(scene, camera);
requestAnimationFrame(animate);
}

requestAnimationFrame(animate);

www.codegrepper.com
www.stackoverflow.com