Skip to content

Instantly share code, notes, and snippets.

View ShuvoHabib's full-sized avatar

Habib ShuvoHabib

  • Deriv
  • Dhaka, Bangladesh
View GitHub Profile
@ShuvoHabib
ShuvoHabib / clearStorage.js
Created November 26, 2019 10:53
Clear storge 'localForge'
import storage from 'localforage';
const clearStorage = async () => {
try {
await storage.clear();
await localStorage.clear();
document.cookie.split(';').forEach(function(c) {
document.cookie = c
.replace(/^ +/, '')
.replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/');
@ShuvoHabib
ShuvoHabib / dockerfile
Created February 19, 2019 14:11
Docker for React JS App
FROM node:8.10.0
#Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
@ShuvoHabib
ShuvoHabib / accidentalIdea.md
Last active February 14, 2019 14:05
Remove Accidental .idea folder push in github

The full process would look like this:


$ echo '.idea' >> .gitignore
$ git rm -r --cached .idea
$ git add .gitignore
$ git commit -m '(some message stating you added .idea to ignored entries)'
$ git push
@ShuvoHabib
ShuvoHabib / mutationObserver.js
Created November 19, 2018 15:28
Mutation Observer
var targetNode = document.querySelectorAll('.validation-message'), i;
// Options for the observer (which mutations to observe)
var config = { attributes: true, childList: true, subtree: true };
var callback = function(mutationsList, observer) {
for(var mutation of mutationsList) {
if (mutation.type == 'childList') {
//console.log('mutation.nextElementSibling', mutation.target.nextElementSibling.nextElementSibling);
if(mutation.target.childNodes[0] && mutation.target.childNodes[0].length != 29){
if(mutation.target.nextElementSibling.className == "screen-reader"){
@ShuvoHabib
ShuvoHabib / readyState.js
Created November 18, 2018 22:07
Ready State JS Solution
(function pollFor() {
if (window.jQuery !== undefined && document.readyState === 'complete') {
try {
} catch (err) {
console.log('TRY ERROR: ' + err);
}
} else {
setTimeout(pollFor, 25);
}
@ShuvoHabib
ShuvoHabib / vueJSXHookCounter.js
Created October 27, 2018 08:40
vueJSXHookCounter
import Vue from "vue";
import { withHooks, useState, useEffect } from "vue-hooks";
const CounterAPP = withHooks(h => {
// state
const [count, setCount] = useState(0);
// effect
useEffect(() => {
@ShuvoHabib
ShuvoHabib / vuejsx2counter.js
Created October 27, 2018 08:38
Vue JSX Counter APP
export default {
name: 'app',
data () {
return {
count: 0
}
},
methods: {
handleClick () {
this.count++
@ShuvoHabib
ShuvoHabib / counter-hook.js
Created October 27, 2018 08:26
Counter React Hook
import { useState } from 'react';
function Example() {
// Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>
@ShuvoHabib
ShuvoHabib / counter.js
Created October 27, 2018 08:24
React JS counter APP
class App extends React.Component {
constructor(props) {
this.state = {
count: 0
}
}
onClick(e) {
this.setState({
count: this.state.count + 1
@ShuvoHabib
ShuvoHabib / checkElement.js
Created October 4, 2018 08:13
Check Element
var elementCheck = setInterval(function () {
if(jQuery('#selector').length > 0) {
// Your Code
clearInterval(elementCheck);
}
},1000);