Skip to content

Instantly share code, notes, and snippets.

@amit08255
amit08255 / linkedList.js
Created November 16, 2021 16:34 — forked from codesections/linkedList.js
A simple linked list implemented in JavaScript
const LinkedList = function() {
this.head = null;
this.tail = null;
};
LinkedList.prototype.addToTail = function(value) {
const newTail = { value, next: null };
if (this.tail) {
this.tail.next = newTail;
@amit08255
amit08255 / locale.md
Created November 30, 2021 03:35
Fix Linux Locale Error

Run below commands:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
sudo locale-gen "en_US.UTF-8"

Restart your computer

@amit08255
amit08255 / download-file.js
Created December 1, 2021 08:59 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@amit08255
amit08255 / nodejs.md
Last active December 20, 2021 16:14
Install NodeJS Windows without Admin
@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"
@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 / 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 / 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 / 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);
// 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')