Skip to content

Instantly share code, notes, and snippets.

Avatar
🥋
doing bat shit crazy stuff with code

Adeel Imran adeelibr

🥋
doing bat shit crazy stuff with code
View GitHub Profile
View magic.js
const path = require('path')
const libPath = path.join(require.resolve('./my-library/another'), '..')
// console.log('libPath :: ', libPath)
const anotherPath = path.join(libPath, 'another')
const another = require(anotherPath)
// console.log('anotherPath ::', anotherPath)
// console.log('another ::', another)
@adeelibr
adeelibr / install-node.md
Last active Jun 22, 2020
How to install Node via NPM
View install-node.md

Installation guide for Mac OS & Linux

Open your terminal & type

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Close your terminal & reopen a new one & type

@adeelibr
adeelibr / cypress-persist-user.js
Created Nov 26, 2019
Persist Login Between Tests In Cypress
View cypress-persist-user.js
before(() => {
cy.clearInfo();
cy.login();
});
after(() => {
cy.contains('Logout').click();
cy.contains('Login');
});
beforeEach(() => {
@adeelibr
adeelibr / closure-example.js
Created Nov 25, 2019
Closure video example youtube
View closure-example.js
// ignore this line, this is just here
// to clear console, everytime I hit "Run with JS"
console.clear();
// Comment out each example one by one & play with
// it, happy coding :)
// @example NOT* a closure example
// function person() {
// let name = 'adeel';
View Examples for hoisting for javascript video
// ### EXAMPLE 1
// -- what you type
// var name = 'adeel';
// var profession = 'developer';
// console.log(name + ' ' + profession);
// -- what the machine does
// var name; // undefined
// var profession; // undefined;
// name = 'adeel';
@adeelibr
adeelibr / array-tutorial.js
Created Nov 17, 2019
Understanding javascript array methods like filter, map, some, every, reduce
View array-tutorial.js
// Understanding array methods:-
// - filter
// - map
// - some
// - every
// - reduce
let myOrgArray = [1,2,3, 4, 5, 6, 7, 8, 9, 10];
// Discussing array by reference
@adeelibr
adeelibr / use-scripts-documentation.md
Last active Jul 11, 2019
create-react-app --use-script
View use-scripts-documentation.md

--use-script

How to provide file paths

There are multiple ways, but all of them start from here react-scripts

By default when you do

npx create-react-app my-app

@adeelibr
adeelibr / useIgnore.jsx
Last active Oct 1, 2019
A "hacky" approach to use instead of AbortControllers
View useIgnore.jsx
/**
* @description Hacky implementation for ignoring
* @param {Function} callback
* @param {Array of primitive dependencies} deps, because
* Arrays & Objects don't work in useEffect deps
*/
const useIgnore = (callback, deps) => {
const [{success, error, loading}, setState] = React.useState({
success: null,
error: null,
@adeelibr
adeelibr / createPdf.js
Last active Jun 15, 2020
createPdf.js script for NodeJS FS & Puppeteer
View createPdf.js
const fs = require('fs');
const puppeteer = require('puppeteer');
// Build paths
const { buildPathHtml, buildPathPdf } = require('./buildPaths');
const printPdf = async () => {
console.log('Starting: Generating PDF Process, Kindly wait ..');
/** Launch a headleass browser */
const browser = await puppeteer.launch();
/* 1- Ccreate a newPage() object. It is created in default browser context. */
@adeelibr
adeelibr / createTable.js
Last active Apr 29, 2019
createTable.js script for NodeJS FS & Puppeteer
View createTable.js
const fs = require('fs');
// JSON data
const data = require('./data.json');
// Build paths
const { buildPathHtml } = require('./buildPaths');
/**
* Take an object which has the following model
* @param {Object} item
* @model
You can’t perform that action at this time.