Skip to content

Instantly share code, notes, and snippets.

View morajabi's full-sized avatar
🦀

Mo morajabi

🦀
View GitHub Profile
@morajabi
morajabi / useHover.js
Created August 9, 2021 09:17
Use Hover for react native web
import { useMemo } from 'react'
import { useState } from 'react'
export function useHover() {
const [hovered, setHovered] = useState(false)
let callbacks = useMemo(
() => ({
onMouseEnter: () => {
setHovered(true)
},

Keybase proof

I hereby claim:

  • I am morajabi on github.
  • I am morajabi (https://keybase.io/morajabi) on keybase.
  • I have a public key ASCPpYSKHC9c0nSXk3DPQS6uJsTJHJk5hE49pS0wJ2FPcAo

To claim this, I am signing this object:

{
"version": 2,
"alias": ["there.team"],
"builds": [
{ "src": "web/package.json", "use": "@now/next" },
{
"src": "api/lambda.js",
"use": "@now/node",
"config": {
"includeFiles": [
@morajabi
morajabi / chrome_tabs.osa
Created May 9, 2019 05:25 — forked from samyk/chrome_tabs.osa
applescript to show all url+titles of Chrome tabs along with front window+tab url+title
# shows all url+titles of Chrome along with front window+tab url+title
set titleString to ""
tell application "Google Chrome"
set window_list to every window # get the windows
repeat with the_window in window_list # for every window
set tab_list to every tab in the_window # get the tabs
repeat with the_tab in tab_list # for every tab
@morajabi
morajabi / useRect.js
Created February 18, 2019 14:35
useRect — getBoundingClientRect() React Hook with resize handler
import { useLayoutEffect, useCallback, useState } from 'react'
export const useRect = (ref) => {
const [rect, setRect] = useState(getRect(ref ? ref.current : null))
const handleResize = useCallback(() => {
if (!ref.current) {
return
}
import styled, { css } from 'styled-components'
import { mobile } from '../style/media'
type Props = {
width?: number
height?: number
widthOnMobile?: number
heightOnMobile?: number
fillRow?: boolean
fillColumn?: boolean
@morajabi
morajabi / Link.tsx
Created October 28, 2018 12:46
Smart Gatsby Link
@morajabi
morajabi / ErrorBoundary.js
Last active November 22, 2020 00:46
React 16 Error Boundary component - for electron app (https://there.pm)
import React, { Component } from 'react'
class ErrorBoundary extends Component {
state = {
error: null,
hasError: false,
showError: false,
}
componentDidCatch(e) {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Untitled benchmark</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@morajabi
morajabi / clone-object.js
Created June 22, 2017 13:27
Cloning objects in javascript with Object.assign({}, src)
console.group("Cloning objects");
const firstObject = {
name: 'Mohammad',
};
const clonedObject = Object.assign({}, firstObject);