Skip to content

Instantly share code, notes, and snippets.

@amit08255
amit08255 / background.js
Created June 22, 2022 05:35 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@amit08255
amit08255 / intercept.js
Created June 16, 2022 06:26 — forked from suprememoocow/intercept.js
AJAX timing interceptor: this class intercepts all AJAX calls and records the time taken for the HTTP request to complete. These timings are posted back to the server in batches, if there are any to send, about every two seconds. Tested in Firefox, Chrome
(function(XHR) {
"use strict";
var stats = [];
var timeoutId = null;
var open = XHR.prototype.open;
var send = XHR.prototype.send;
@amit08255
amit08255 / powershell.md
Created June 4, 2022 10:22
Resync windows time powershell

Type below commands in admin powershell:

w32tm /unregister

w32tm /register

net stop w32time

net start w32time
@amit08255
amit08255 / nexus_prisma_cheatsheet.md
Last active June 4, 2024 06:19
Nexus + Prisma CheatSheet

Nexus + Prisma CheatSheet

Creating model in Prisma

First create generator and datasource entry in your .prisma file like below:

generator client {
  provider = "prisma-client-js"
}
// company.ts
import { arg, extendType, inputObjectType, intArg, list, nonNull, objectType, stringArg } from "nexus";
export const CompanyInputType = inputObjectType({
name: 'CompanyInputType',
definition(t) {
t.string('name')
t.string('contactPerson')
t.string('bio')
@amit08255
amit08255 / form.md
Last active April 20, 2022 02:16
Get all form fields on submit

Use these event handler on form submit to get all fields

JavaScript

const onSubmit = (e) => {
    const { target } = e;
    e.preventDefault();
    const inputs = Object.fromEntries(new FormData(target).entries());
 console.log(inputs);
@amit08255
amit08255 / js-scroll.md
Created April 19, 2022 10:53
JavaScript Element Scroll and Height Cheats

Get height and width of element

const elmnt = document.getElementById("myDIV");
console.log("height: ", elmnt.offsetHeight);
console.log("width: ", elmnt.offsetWidth);

Get element scroll position

@amit08255
amit08255 / next.config.js.md
Last active April 2, 2025 18:07
NextJS export cache issue fix. Update cache on every build

NextJS export cache issue fix. Update cache on every build

next.config.js file

/* the trick is to build unique build ID on every build and add it to static files on build time.
 * This way the name and URL of static files will change on every build.
 */

/* eslint-disable @typescript-eslint/no-var-requires */
@amit08255
amit08255 / scrollbar.md
Created February 1, 2022 08:49
Custom Scrollbar with CSS
/* Works on Chrome, Edge, and Safari */
::-webkit-scrollbar {
height: 16px !important;
overflow: visible !important;
width: 5px !important;
}

::-webkit-scrollbar-thumb {
background-image: linear-gradient(315deg, #2d3436 0%, #2d3436 74%);
@amit08255
amit08255 / husky-fix.md
Last active February 23, 2022 12:00
Husky hook not install fix

Fix Husky script not install issue

Run below commands:

npm install husky --save-dev
npx husky install
npm install lint-staged --save-dev
npx husky add .husky/pre-commit "node_modules/.bin/lint-staged && npm run test && npm run transpile && npm run build"