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 / bani.js
Created November 21, 2020 10:18
Bani.js | IndexedDB | https://howlerjs.com/
/**
* Fetch Bani API
*/
const pathWrapper = document.getElementById('path'),
audio = document.getElementById('audio'),
previousLink = document.getElementById('prevBtn'),
nextLink = document.getElementById('nextBtn'),
loading = document.querySelector('.loading'),
urlSearchParams = new URLSearchParams(window.location.search),
pauriIndex = parseInt(urlSearchParams.get('i')),
@navdeepsingh
navdeepsingh / contact-details.tsx
Created November 21, 2020 09:57
Contact Details - TypeScript
import React from "react";
import classNames from "classnames";
import A from "@styleguide/components/a";
import { IconBuilding, IconMessage, IconPhone } from "@icons/index";
import css from "./index.scss";
import { CONTACT_US_EMAIL, CONTACT_US_PHONE_NUMBER } from "@lib/staticRoutes";
import {
@navdeepsingh
navdeepsingh / index.tsx
Created November 21, 2020 09:56
Contact Form - Index.tsx
import React from "react";
import PageLayout from "@page-components/page-layout";
import ContactUsFormClipart from "@svg-resources/contact-us-form-clipart";
import ContactForm from "./contact-form";
import ContactDetails from "./contact-details";
import css from "./index.scss";
const ContactUs = () => {
return (
@navdeepsingh
navdeepsingh / contact-form.tsx
Created November 21, 2020 09:54
Contact Form - TypeScript | Formik | Yup
import React from "react";
import { useFormik } from "formik";
import * as Yup from "yup";
import axios from "axios";
import classNames from "classnames";
import Button from "@styleguide/components/button";
import Input from "@styleguide/components/input";
import css from "./index.scss";
@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);
@navdeepsingh
navdeepsingh / commands.md
Last active July 3, 2019 05:52
EC2 SSH Commands

Check Status of file permissions

sudo stat TARGETFOLDER

Change Owner of File/Folder

sudo chown bitnami TARGETFOLDER

Check Status of all services

sudo /opt/bitnami/ctlscript.sh status

Run Apache

@navdeepsingh
navdeepsingh / pagination.php
Created March 29, 2019 11:35
Custom pagination code for shortcode wordpress
function sponsor_pagination($pages = '', $range = 4)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
@navdeepsingh
navdeepsingh / postToOmnisend.js
Last active February 21, 2019 06:07
Post to Omnisend
/*****************/
//@TODO Update Omnisend separately with list id
/*****************/
// An object of options to indicate where to post to
var options = {
"method": "POST",
"protocol": 'https:',
"hostname": 'api.omnisend.com',
"path": '/v3/contacts',
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++) {