Skip to content

Instantly share code, notes, and snippets.

View narennaik's full-sized avatar

Naren Naik narennaik

View GitHub Profile
@narennaik
narennaik / index.html
Created April 27, 2015 06:26
Creating Custom Controls in SAPUI5 Demo // source http://jsbin.com/kojisi
<!DOCTYPE html>
<html lang="en">
<head>
<title>Creating Custom Controls in SAPUI5 Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script id="sap-ui-bootstrap" type="text/javascript" src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.ui.commons">
</script>
@narennaik
narennaik / index.html
Created April 27, 2015 09:35
Custom Lightbox Control // source http://jsbin.com/tufeze
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<!--
Created using JS Bin
http://jsbin.com
Copyright (c) 2015 by michadelic (http://jsbin.com/tebef/1/edit)
@narennaik
narennaik / compressGraphqlDocument.js
Created March 15, 2019 11:57 — forked from rybon/compressGraphqlDocument.js
Remove unnecessary whitespace from a GraphQL query / mutation / subscription
const compressGraphqlDocument = graphqlDocument =>
graphqlDocument
.replace(/#.*\n/g, '')
.replace(/[\s|,]*\n+[\s|,]*/g, ' ')
.replace(/:\s/g, ':')
.replace(/,\s/g, ',')
.replace(/\)\s\{/g, '){')
.replace(/\}\s/g, '}')
.replace(/\{\s/g, '{')
.replace(/\s\}/g, '}')
@narennaik
narennaik / settings.json
Created July 12, 2020 20:01
vscode settings
{
"editor.fontFamily": "OperatorMonoSSmLig-Light",
"explorer.confirmDelete": false,
"editor.fontLigatures": true,
"terminal.integrated.fontSize": 13,
"editor.renderIndentGuides": false,
"workbench.activityBar.visible": true,
"editor.lineHeight": 27,
"workbench.editorAssociations": [
{
@narennaik
narennaik / script.ts
Last active August 11, 2020 09:46
Google Recaptcha V2 implementation snippet with typescript, React & node
// Client Side, React component
import { GOOGLE_RECAPTCHA_URL } from '../../../common/constants';
import { INVALID_CAPTCHA_PROVIDED } from '../../utils/constants';
import { MyWindow } from '../../../common/types/global';
import React from 'react';
import { RecaptchaResponse } from '../../../common/types/thirdParty';
import { SignupFormWithCaptcha } from '../../../common/types/signup';
const onRecaptchaScriptLoad = (): void => {
@narennaik
narennaik / todo.js
Created May 27, 2021 07:31
TODO reducer
const todo = (state, action) => {
if (!state) {
return [];
} else if (action.type === "ADD_TODO") {
return [...state, action.payload];
} else {
return state;
}
};
@narennaik
narennaik / action.js
Created May 27, 2021 07:34
Add todo action
const addTodo = { type: 'ADD_TODO', payload: 'Buy a pencil' };
@narennaik
narennaik / store.js
Created May 27, 2021 07:40
create store
const store = (reducer) => {
let state = []; // Can be an object as well
let listeners = [];
const dispatch = (action) => {
state = reducer(state, action);
listeners.forEach((listener) => listener(state));
};
const subscribe = (listener) => {
@narennaik
narennaik / data.js
Last active June 28, 2021 18:10
Data
const domainList = [
{
id: 1,
details: {
name: 'nytimes.com',
valid: true,
},
},
{
id: 2,
@narennaik
narennaik / urlList.js
Created June 28, 2021 18:08
get url list
const urlList = domainList.map((item) => {
const domain = item.details.name;
const httpsUrl = `https://${domain}?callback=true`;
return httpsUrl;
});