Skip to content

Instantly share code, notes, and snippets.

View nimahkh's full-sized avatar
🤩
Yo u can do everything you want

Nima Habibkhoda nimahkh

🤩
Yo u can do everything you want
  • Software Engineer
  • The Netherlands
  • X @nimahkh1
View GitHub Profile
@anthowen
anthowen / useOutsideClick.ts
Last active September 20, 2022 09:49
useOutsideClick (TypeScript) - a custom react hook that handles outside click event of certain area. It also ignores click event on browser's scrollbar.
import { useEffect, RefObject } from 'react';
/**
* Hook that handles outside click event of the passed refs
*
* @param refs array of refs
* @param handler a handler function to be called when clicked outside
*/
export default function useOutsideClick(
refs: Array<RefObject<HTMLElement> | undefined>,
// android\gradle.properties
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
// android\app\build.gradle
@nimahkh
nimahkh / App.css
Last active July 10, 2020 03:05
reactjs simple context functions to manage states
.App {
text-align: center;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 40vmin;
pointer-events: none;
}
@SleepWalker
SleepWalker / swipe.js
Created September 30, 2015 04:59
A simple swipe detection on vanilla js
var touchstartX = 0;
var touchstartY = 0;
var touchendX = 0;
var touchendY = 0;
var gesuredZone = document.getElementById('gesuredZone');
gesuredZone.addEventListener('touchstart', function(event) {
touchstartX = event.screenX;
touchstartY = event.screenY;
@kerryChen95
kerryChen95 / currentStackAndLine.js
Last active September 28, 2022 03:17
Get current stack and line number in JavaScript
// For V8:
// Define global variable `__stack__` and `__line`
// for current stack and line
(function(global){
Object.defineProperty(global, '__stack__', {
get: function(){
var orig = Error.prepareStackTrace;
Error.prepareStackTrace = function(_, stack){ return stack; };
var err = new Error;
Error.captureStackTrace(err, arguments.callee);