Skip to content

Instantly share code, notes, and snippets.

@karlhorky
karlhorky / README.md
Created April 21, 2024 17:09 — forked from catalinmiron/README.md
Expo app.json Apple Privacy Manifest

About

The privacy details that you may need to add for Apple Privacy Manifest.

This config plugin it's already available from expo >=50.0.17 (Part of this PR by aleqsio)

Tip

Read more about Privacy Manifest File from Apple docs

@karlhorky
karlhorky / express-middleware-disable-gatsby-window-replacestate.ts
Created April 16, 2024 16:32
Express Middleware to Disable Gatsby's window.replaceState()
// Express middleware to disable Gatsby window.replaceState() to
// avoid changing new rewritten URLs back to original URLs
// https://github.com/gatsbyjs/gatsby/blob/c91ed287fd319a345c2f27877e20656826767e92/packages/gatsby/cache-dir/production-app.js#L159-L187
const appJsFilePath = existingGatsbyFiles.find((filePath) =>
/^\/app-[\da-f]+\.js$/.test(filePath),
)!;
const appJsContent = readFileSync(
join(websitePath, 'public', appJsFilePath),
'utf-8',
@karlhorky
karlhorky / Dockerfile
Created April 5, 2024 11:09 — forked from lithdew/Dockerfile
Dockerfile for deploying a Next.js standalone bundle on Fly.io with Bun.
# syntax = docker/dockerfile:1
# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.1.1
FROM oven/bun:${BUN_VERSION}-slim as base
LABEL fly_launch_runtime="Next.js"
# Next.js app lives here
WORKDIR /app
@karlhorky
karlhorky / R2_storage.ts
Created May 1, 2023 05:54 — forked from AndrewIngram/R2_storage.ts
Read/write from Cloudflare R2 in a Vercel edge function w/default
import { AwsClient } from "aws4fetch";
import { deflate } from "pako";
const R2_ACCOUNT_ID = "SOMETHING"
const R2_ACCESS_KEY_ID = "SOMETHING"
const R2_SECRET_ACCESS_KEY ="SOMETHING"
const R2_BUCKET = "SOMETHING"
const R2_URL = `https://${R2_BUCKET}.${R2_ACCOUNT_ID}.r2.cloudflarestorage.com`;
@karlhorky
karlhorky / guests+api.ts
Last active February 23, 2024 11:34
Expo API Routes version of Express Naive Guest List API https://github.com/upleveled/express-guest-list-api-memory-data-store
// guests+api.ts
import { ExpoRequest, ExpoResponse } from 'expo-router/server';
import { guestList, Guest } from './index+api.ts';
export const guestList: Guest[] = [];
export function GET(request: ExpoRequest): ExpoResponse {
return ExpoResponse.json(guestList);
}
@karlhorky
karlhorky / Tailwindcssunreset.scss
Created February 14, 2024 01:19 — forked from swyxio/Tailwindcssunreset.scss
Tailwind CSS Un-Reset - un-reset Tailwind's Preflight CSS Reset so that autogenerated HTML looks consistent with the rest of your Tailwind site. - https://www.swyx.io/writing/tailwind-unreset
.unreset {
a {
@apply text-blue-700 underline;
}
p {
@apply my-4;
}
blockquote,
figure {
@karlhorky
karlhorky / clear-npx-cache.sh
Last active February 7, 2024 05:16
Clear npx cache
# First, remove all the folders in the npx cache location
# https://github.com/npm/cli/issues/1935#issuecomment-745561262
rm -rf $(npm get cache)/_npx/*
@karlhorky
karlhorky / .bashrc
Created September 3, 2019 19:37
Bash Git Aliases
# Git Aliases (sorted alphabetically with some inculsive functions)
# Adapted from oh-my-zsh git alias plugin. "compdef" is a Z shell autocompletion function, disabled throughout where applicable.
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
alias gb='git branch'
@karlhorky
karlhorky / auth-guard-components.tsx
Last active January 21, 2024 13:45
Guard components with auth permissions
// From the comment from @SukkaW here:
// https://github.com/vercel/next.js/pull/60616#issuecomment-1902608289
// Here is what I am doing currently, to authenticate and authorize
// RSC pages and components (like a button or a tooltip)
function GuardedComponent() {
const user = useUser();
// guard() will throw a `NoPermissionError` when the user doesn't have the permission
guard(user, permissionList);