Skip to content

Instantly share code, notes, and snippets.

View tobimori's full-sized avatar

Tobias Möritz tobimori

View GitHub Profile
@pontusab
pontusab / proximity-prefetch.tsx
Created April 6, 2025 06:43
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;
@AlemTuzlak
AlemTuzlak / index.ts
Last active August 9, 2024 09:56
Hono auto-infer app context
// Your app load context function that generates the remix context object
const generateAppLoadContext = async (c: Context, build: ServerBuild) => {
// example with i18n
const locale = i18next.getLocale(c);
const t = await i18next.getFixedT(c);
return {
appVersion: "v1.0",
lang: locale,
t,
@lukaskleinschmidt
lukaskleinschmidt / Menu.php
Last active March 1, 2024 15:57
Kirby 4 Panel Menu
<?php
namespace App;
use Closure;
use Kirby\Cms\App;
class Menu
{
public static array $pages = [];
@richardscarrott
richardscarrott / worker.ts
Last active March 12, 2025 17:22
Cloudflare Workers / Pages `stale-while-revalidate`
import { parse } from 'cache-control-parser';
export default {
async fetch(request: Request, env: {}, ctx: ExecutionContext): Promise<Response> {
try {
const cache = await caches.default;
const cachedResponse = await cache.match(request);
if (cachedResponse) {
console.log('Cache: HIT');
if (shouldRevalidate(cachedResponse)) {
@lukaskleinschmidt
lukaskleinschmidt / LICENSE.md
Last active April 14, 2024 14:26
Kirby 3 Synced Structure

MIT License

Copyright (c) 2023 Lukas Kleinschmidt

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT

@rphlmr
rphlmr / clear-db.ts
Last active April 15, 2025 02:09
Drizzle snippets
// Credits to Louistiti from Drizzle Discord: https://discord.com/channels/1043890932593987624/1130802621750448160/1143083373535973406
import { sql } from "drizzle-orm";
const clearDb = async (): Promise<void> => {
const query = sql<string>`SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_type = 'BASE TABLE';
`;
@jordienr
jordienr / Gradient.js
Created September 12, 2021 00:23
Stripe Mesh Gradient WebGL
/*
* Stripe WebGl Gradient Animation
* All Credits to Stripe.com
* ScrollObserver functionality to disable animation when not scrolled into view has been disabled and
* commented out for now.
* https://kevinhufnagl.com
*/
export { mergeServerSideProps } from './merge-server-side-props'
export { mergeStaticProps } from './merge-static-props'
@bradley
bradley / RefreshableScrollView.swift
Last active November 28, 2021 00:46
Pull-to-Refresh: SwiftUI, UIKit-Backed, Actually-Usable
//
// RefreshableScrollView.swift
// --
//
// Created by Bradley on 3/24/21.
//
import Combine
import SwiftUI
import UIKit
@mattdanielbrown
mattdanielbrown / index.html
Created February 22, 2021 17:56
Infinite Scrolling Cards with GSAP and ScrollTrigger (smooth)
<div class="gallery">
<ul class="cards">
<li>0</li>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>