Skip to content

Instantly share code, notes, and snippets.

🥋
doing bat shit crazy stuff with code

Adeel Imran adeelibr

🥋
doing bat shit crazy stuff with code
Block or report user

Report or block adeelibr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 Apr 29, 2019
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
@adeelibr
adeelibr / data.json
Created Apr 29, 2019
Sample JSON data for NodeJS FS & Puppeteer
View data.json
[
{
"invoiceId": 1,
"createdDate": "3/27/2018",
"dueDate": "5/24/2019",
"address": "28058 Hazelcrest Center",
"companyName": "Eayo",
"invoiceName": "Carbonated Water - Peach",
"price": 376
},
@adeelibr
adeelibr / MyButton.5.jsx
Last active Apr 16, 2019
If/else hell & it's atonement Part 5
View MyButton.5.jsx
const MyButton = ({ theme, rounded, hover, animation, content }) => {
const isThemeDefault = theme === 'default'
const isThemePrimary = theme === 'primary';
const isRounded = rounded === true;
const isHover = hover === true;
const isAnimated = animation === true;
const isPrimaryAnimated = isThemePrimary && isAnimated;
let className = isThemePrimary ? 'primary-btn' : 'default-btn';
@adeelibr
adeelibr / MyButton.4.jsx
Last active Apr 16, 2019
If/else hell & it's atonement Part 4
View MyButton.4.jsx
const MyButton = ({ theme, rounded, hover, animation, content }) => {
let className = '';
if (theme === 'default') {
className = rounded ? 'default-btn rounded' : 'default-btn';
if (hover) {
className = className + ' hover';
}
} else if (theme === 'primary') {
if (rounded) {
if (hover) {
@adeelibr
adeelibr / MyButton.3.jsx
Last active Apr 16, 2019
If/else hell & it's atonement Part 3
View MyButton.3.jsx
const MyButton = ({ theme, rounded, hover, content }) => {
let className = '';
if (theme === 'default') {
className = rounded ? 'default-btn rounded' : 'default-btn';
} else if (theme === 'primary') {
className = rounded ? 'primary-btn rounded' : 'primary-btn';
}
if (hover) {
className = className + ' hover';
@adeelibr
adeelibr / MyButton.2.jsx
Last active Apr 16, 2019
If/else hell & it's atonement Part 2
View MyButton.2.jsx
const MyButton = ({ theme, rounded, content }) => {
let className = '';
if (theme === 'default') {
className = rounded ? 'default-btn rounded' : 'default-btn';
} else if (theme === 'primary') {
className = rounded ? 'primary-btn rounded' : 'primary-btn';
}
return (
<button className={className}>{content}</button>
You can’t perform that action at this time.