Skip to content

Instantly share code, notes, and snippets.

View Stringsaeed's full-sized avatar
🏗️
building something that matters

Muhammed (Saeed) Ibrahim Stringsaeed

🏗️
building something that matters
View GitHub Profile
import ExpoModulesCore
import SwiftUI
class DraggableProps: ExpoSwiftUI.ViewProps {
@Field var text: String
}
struct DraggableView: ExpoSwiftUI.View {
@EnvironmentObject var props: DraggableProps
var body: some View {
@jpudysz
jpudysz / live-activity-intents.js
Created February 1, 2024 17:48
Add target to any file in Xcode with Expo config plugin
const { withXcodeProject } = require('@expo/config-plugins')
const findFileReferenceByName = (xcodeProject, fileName) => {
const fileReferences = xcodeProject.hash.project.objects['PBXFileReference']
return Object.fromEntries(
Object
.entries(fileReferences)
.filter(([key, value]) => value.name === `"${fileName}"`)
)
@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,
@terrysahaidak
terrysahaidak / Gallery.tsx
Created April 25, 2023 05:09
Control scroll
@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 / viewability-tracker-flatlist.tsx
Last active January 21, 2025 14:01
Viewability tracker with shared values
import { createContext, forwardRef, useCallback, useMemo } from "react";
import { FlatList, FlatListProps, ViewToken } from "react-native";
import Animated, { useSharedValue } from "react-native-reanimated";
const MAX_VIEWABLE_ITEMS = 4;
type ViewabilityItemsContextType = string[];
export const ViewabilityItemsContext = createContext<
Animated.SharedValue<ViewabilityItemsContextType>
@intergalacticspacehighway
intergalacticspacehighway / PinchToZoom.tsx
Last active March 10, 2025 21:02
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,
import * as React from 'react';
import { padStart, eq, isEqual } from 'lodash';
export function useDebugDeps(name: string, deps: unknown[]): void {
const previousDepsRef = React.useRef(deps);
const countRef = React.useRef(0);
printDepsChange(name, deps, previousDepsRef.current, countRef.current);
previousDepsRef.current = deps;
@andywer
andywer / _readme.md
Last active January 8, 2025 04:42
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

@infinityfuture
infinityfuture / textrank_keywords.py
Last active February 15, 2019 16:01
TextRank extract keywords
"""
Reference:
http://www.hankcs.com/nlp/textrank-algorithm-to-extract-the-keywords-java-implementation.html
http://www.hankcs.com/nlp/textrank-algorithm-java-implementation-of-automatic-abstract.html
"""
import numpy as np