Skip to content

Instantly share code, notes, and snippets.

View samuelandrson's full-sized avatar
💻

Surafel Gudisa samuelandrson

💻
View GitHub Profile
@samuelandrson
samuelandrson / .expo-server-manager.sh
Created October 21, 2025 19:00 — forked from betomoedano/.expo-server-manager.sh
Expo Server Manager - Prompts to kill existing port 8081 process before starting Expo dev server
#!/bin/zsh
# Expo Server Manager - Prompts to kill existing port 8081 process before starting Expo dev server
#
# Setup:
# 1. Save this file to ~/.expo-server-manager.sh
# 2. Add to ~/.zshrc: source ~/.expo-server-manager.sh
# 3. Add aliases:
# alias es='start_expo false'
# alias esc='start_expo true'
@samuelandrson
samuelandrson / proximity-prefetch.tsx
Created April 6, 2025 16:24 — forked from pontusab/proximity-prefetch.tsx
Next.js Proximity Prefetch (PPF)
"use client";
import { useRouter } from "next/navigation";
import type { ReactNode } from "react";
import { useCallback, useEffect, useState } from "react";
interface ProximityPrefetchProps {
children: ReactNode;
threshold?: number;
predictionInterval?: number;
import { AnimatePresence, motion } from "motion/react";
import { useRef, useState } from "react";
type TabValue = "free" | "monthly" | "yearly";
export default function App() {
const [value, setValue] = useState<TabValue>("free");
const code = `
// Wrap the Tab component in a div to control its dimensions
<div className="w-[500px] h-14">
@samuelandrson
samuelandrson / try-catch.ts
Created February 25, 2025 20:40 — forked from t3dotgg/try-catch.ts
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};