In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and
returning the cached result when the same
inputs occur again.
— wikipedia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Layout and Text components are my own utility components. Replace them by your own. */ | |
import { memo, useEffect, useMemo, useState } from "react"; | |
import { ViewStyle } from "react-native"; | |
import { A } from "@mobily/ts-belt"; | |
import mitt from "mitt"; | |
import { v4 as uuid } from "@lukeed/uuid"; | |
import Animated, { | |
Layout as REALayout, | |
Easing, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# exit when any command fails | |
set -e | |
COMMAND=$1 | |
function clean() { | |
printf "🧹 Cleaning.. \n" | |
rm -rf ~/Library/Caches/CocoaPods Pods ~/Library/Developer/Xcode/DerivedData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from "react"; | |
import { AppState, AppStateStatus } from "react-native"; | |
export const useFetchOnAppForeground = () => { | |
const listener = useRef(null); | |
function fetchOnAppForeground(params) { | |
if (AppState.currentState === "active") { | |
return fetch(params); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useMemo, useState } from "react"; | |
import { LayoutChangeEvent, StyleSheet } from "react-native"; | |
import { | |
PinchGestureHandler, | |
PinchGestureHandlerGestureEvent, | |
} from "react-native-gesture-handler"; | |
import Animated, { | |
useAnimatedGestureHandler, | |
useAnimatedStyle, | |
useSharedValue, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react' | |
import { Image, StatusBar, StyleSheet, useWindowDimensions } from 'react-native' | |
import { | |
PanGestureHandler, | |
PinchGestureHandler, | |
PinchGestureHandlerGestureEvent, | |
TapGestureHandler, | |
TapGestureHandlerGestureEvent, | |
} from 'react-native-gesture-handler' | |
import Animated, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// when T is any|unknown, Y is returned, otherwise N | |
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N; | |
// when T is never, Y is returned, otherwise N | |
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N; | |
// when T is a tuple, Y is returned, otherwise N | |
// valid tuples = [string], [string, boolean], | |
// invalid tuples = [], string[], (string | number)[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {View, Dimensions} from 'react-native'; | |
import Animated, { | |
useAnimatedScrollHandler, | |
useAnimatedStyle, | |
useSharedValue, | |
} from 'react-native-reanimated'; | |
const BORDER_RADIUS = 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 2 | |
aliases: | |
- &restore_npm_cache | |
name: 'Restoring node_modules from the cache' | |
key: yarn-v1-{{ checksum "yarn.lock" }}-{{ arch }} | |
- &install_npm_dependencies | |
name: Installing NPM Dependencies | |
command: yarn install | |
- &save_npm_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Title = "Advanced Typescript Types"; | |
const WhoAmI = { | |
name: `Mohamed Shaban`, | |
github: `github.com/drmas`, | |
job: "Software Engineer", | |
company: `Urban Sports Club - Berlin` |
NewerOlder