Skip to content

Instantly share code, notes, and snippets.

View adeelibr's full-sized avatar
🥋
doing bat shit crazy stuff with code

Adeel Imran adeelibr

🥋
doing bat shit crazy stuff with code
View GitHub Profile
@adeelibr
adeelibr / Abort Controller In Axios
Last active April 20, 2024 00:50
Abort Controllers In Axios
import React, { Component } from 'react';
import axios from 'axios';
class Example extends Component {
signal = axios.CancelToken.source();
state = {
isLoading: false,
user: {},
}
@adeelibr
adeelibr / rebase.md
Created April 5, 2024 10:30
rebase-guide
@comment helps massively in doing a proper rebase

git config --global rerere.enabled true

@comment be on your dev branch

git pull origin main git rebase main

@comment now fix conflicts manually only once, since git rerere will record your chosen conflict resolutions
@comment publish your changes with --force parameter

git push -f

@adeelibr
adeelibr / Java Hangman
Created August 25, 2017 20:33
A simple command line game of Hangman made in Java
package Hangman;
import java.util.Scanner;
import java.util.Random;
public class Built {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
Random random = new Random();
@adeelibr
adeelibr / feature.flag.js
Created April 24, 2023 18:08
Proposal for feature flags
// BE does the feature flags for users for A/B testing
<FeatureFlag isEnabled={flagValue}>
// Content for a specific feature flag
</FeatureFlag>
const FeatureFlag = ({ isEnabled, children }) => {
return isEnabled ? children : null;
}
@adeelibr
adeelibr / useReducerExample.js
Created November 4, 2018 12:14
React Hooks useReducer
import React, { useReducer } from 'react';
const initialState = {
loading: false,
count: 0,
};
const reducer = (state, action) => {
switch (action.type) {
case 'increment': {
@adeelibr
adeelibr / cypress-persist-user.js
Created November 26, 2019 12:22
Persist Login Between Tests In Cypress
before(() => {
cy.clearInfo();
cy.login();
});
after(() => {
cy.contains('Logout').click();
cy.contains('Login');
});
beforeEach(() => {
@adeelibr
adeelibr / magic.js
Created June 30, 2020 20:35
require.cache
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 June 22, 2020 19:54
How to install Node via NPM

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 / createPdf.js
Last active June 15, 2020 08:53
createPdf.js script for NodeJS FS & Puppeteer
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 / closure-example.js
Created November 25, 2019 23:04
Closure video example youtube
// 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';