Skip to content

Instantly share code, notes, and snippets.

View anastely's full-sized avatar
:octocat:
Focusing

Anas Tely anastely

:octocat:
Focusing
View GitHub Profile
@derekstavis
derekstavis / Toast.tsx
Last active May 16, 2024 14:13
React Native Toast, without Context hell
/* 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,
@pzatorski
pzatorski / react-native-setup-ios.sh
Created May 7, 2022 20:03
Clean a React Native project (iOS)
#!/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
@intergalacticspacehighway
intergalacticspacehighway / use-fetch-on-app-foreground.tsx
Created January 28, 2022 04:10
app fetch request failing in background
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 {
@intergalacticspacehighway
intergalacticspacehighway / PinchToZoom.tsx
Last active April 23, 2024 20:16
Pinch to zoom reanimated + gesture handler
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,
@mrousavy
mrousavy / MEMOIZE.md
Last active May 27, 2024 21:19
Memoize!!! 💾 - a react (native) performance guide
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
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, {
@ClickerMonkey
ClickerMonkey / types.ts
Last active June 18, 2024 17:13
Typescript Helper Types
// 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)[]
import React from 'react';
import {View, Dimensions} from 'react-native';
import Animated, {
useAnimatedScrollHandler,
useAnimatedStyle,
useSharedValue,
} from 'react-native-reanimated';
const BORDER_RADIUS = 10;
@albertogalca
albertogalca / config.yml
Last active January 13, 2023 13:10
Circle CI Config for fastlane
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
@drmas
drmas / presentation.ts
Created March 30, 2020 19:03
EgyptJS Advanced Typescript Types
const Title = "Advanced Typescript Types";
const WhoAmI = {
name: `Mohamed Shaban`,
github: `github.com/drmas`,
job: "Software Engineer",
company: `Urban Sports Club - Berlin`