Skip to content

Instantly share code, notes, and snippets.

View nsisodiya's full-sized avatar

Narendra Sisodiya nsisodiya

View GitHub Profile
import { css } from 'lit';
var styles = css`
.bg-red {
background: red;
}
`;
const style = document.createElement('style');
style.textContent = styles.toString();
@nsisodiya
nsisodiya / package.json
Created April 28, 2019 19:22
Nodemon ESM and inspect
{
"scripts": {
"start": "nodemon -r esm --inspect-brk --inspect=0.0.0.0:9229 src/server.js",
"test": "echo \"Error: no test specified\" && exit 1"
}
}
@nsisodiya
nsisodiya / delete.sh
Created December 17, 2020 10:48
Delete all remote git branch which are matching a given name
git branch -r | cat | grep sandesh | while read i
do
git push origin --delete $(echo $i | sed 's/\origin\///g')
done
@nsisodiya
nsisodiya / iframe.js
Last active December 16, 2020 14:45
Dynamic IFRAME Using Dynamic Document Fragment when html & css are provided as Strings
var html = '<h1 class="nar">Narendra</div>';
var css = '.nar { color: red; background: url("http://google.com/images/google_favicon_128.png") repeat scroll 0 0 transparent;}';
var nodeWhereToAppend = document.body;
//var nodeWhereToAppend = document.getElementById("container");
function CreateIframe(html, css, nodeWhereToAppend){
var fragment = document.createDocumentFragment();
var iframe = document.createElement('iframe');
iframe.onload = function(){
var doc = this.contentWindow.document;
@nsisodiya
nsisodiya / fix-version-lock.js
Last active September 30, 2020 06:33
./system/npm/fix-version-lock.js
const fs = require('fs');
const YAML = require('yamljs');
const replaceFirstLineOfFile = require('file-firstline-replace');
const pkgJson = require('../../package.json');
var filename = 'Dockerfile';
var newHeader = `FROM node:${pkgJson.nodeVersionLock} as builder\n`;
replaceFirstLineOfFile(filename, newHeader, function (error) {
if (error) {
throw error;
@nsisodiya
nsisodiya / preinstall.js
Created September 30, 2020 06:03
./system/npm/preinstall.js
const pkgJson = require('../../package.json');
const nodeVersion = process.versions.node;
let err = false;
if (pkgJson.nodeVersionLock !== nodeVersion) {
console.error(`Please use node ${pkgJson.nodeVersionLock}. Try
nvm install v${pkgJson.nodeVersionLock}
nvm reinstall-packages v${nodeVersion}
nvm uninstall v${nodeVersion}
@nsisodiya
nsisodiya / genBuildFileSize.js
Created September 23, 2020 06:33
genBuildFileSize.js
const fs = require('fs').promises;
const path = require('path');
const prettyBytes = require('pretty-bytes');
const buildDir = 'build';
const blackListedFiles = ['build/git-log.json'];
const blackListedDirs = ['build/report'];
const isArrayHas = (arr, str) => {
const outOfIndex = -1;
@nsisodiya
nsisodiya / main.js
Created July 27, 2020 09:51
Split String into multiple unique parts
/*
A string s contains only uppercase and lowercase letters.
Break this list into as many parts as possible
so that each letter appears in at most one parts.
Return the list of integers which represent the length of each part.
*/
function findPairs(str) {
var out = [];
type iAdd = (a: number, b: number) => number;
const add: iAdd = (a, b) => a + b;
add(3, 4);
@nsisodiya
nsisodiya / App.tsx
Last active April 25, 2020 08:10
React + Google Sheet demo - Step 1
import React, { useState } from "react";
import "./App.css";
const styles = {
InputBox: {
padding: 4,
},
Error: {
color: "red",
},