Skip to content

Instantly share code, notes, and snippets.

View navdeepsingh's full-sized avatar
🎯
Focusing

Navdeep Singh navdeepsingh

🎯
Focusing
View GitHub Profile
@navdeepsingh
navdeepsingh / awsLambdaSetSecurityHeaders.js
Created September 3, 2020 05:37 — forked from d4gh0s7/awsLambdaSetSecurityHeaders.js
Security Headers with AWS Lambda@Edge
'use strict';
exports.handler = async (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
headers['Strict-Transport-Security'] = [{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload',
}];
@navdeepsingh
navdeepsingh / Random-string
Created July 9, 2019 08:18 — forked from 6174/Random-string
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
let $photoInput = document.getElementById("input");
let fileReader = new FileReader();
let image = new Image();
let $editor = document.getElementById("editor");
let $editorCtx = $editor.getContext("2d");
//This is a performance test
function opacitor(op) {
let imgData = $editorCtx.getImageData(0, 0, $editor.width, $editor.height);
for (let x = 0; x < image.width; x++) {
let $photoInput = document.getElementById("input");
let image = new Image();
let $editor = document.getElementById("editor");
let $editorCtx = $editor.getContext("2d");
function opacitor(op) {
let imgData = $editorCtx.getImageData(0, 0, $editor.width, $editor.height);
for (let x = 0; x < image.width; x++) {
for (let y = 0; y < image.height; y++) {
let index = (x + y * image.width) * 4;