Skip to content

Instantly share code, notes, and snippets.

View ItsWendell's full-sized avatar

Wendell Misiedjan ItsWendell

View GitHub Profile
@ItsWendell
ItsWendell / wait-until-after.tsx
Created October 29, 2024 15:38
`waitUntil` and `unstable_after` after support for @cloudflare/next-on-pages
import { getOptionalRequestContext } from "@cloudflare/next-on-pages";
import { workAsyncStorage } from "next/dist/server/app-render/work-async-storage.external";
export type AfterTask<T = unknown> = Promise<T> | AfterCallback<T>;
export type AfterCallback<T = unknown> = () => T | Promise<T>;
export function waitUntil(promise: Promise<unknown>) {
const cloudflareCtx = getOptionalRequestContext();
if (!cloudflareCtx) {
@ItsWendell
ItsWendell / Dockerfile
Created October 22, 2023 09:58
Postgres Dockerfile with Custom Extensions using pgxn
## Alternatives: postgres:15-alpine
ARG BASE_IMAGE=postgis/postgis:15-3.4-alpine
## Custom Alpine Postgres docker file with custom extensions
FROM ${BASE_IMAGE} as builder
# Install required dependencies
RUN apk --no-cache add \
python3 \
@ItsWendell
ItsWendell / postgisGeometry.ts
Last active April 5, 2024 08:50
Experimental PostGIS geometry GeoJSON column type for Drizzle ORM
import { sql } from "drizzle-orm";
import { customType, CustomTypeValues } from "drizzle-orm/pg-core";
/**
* Experimental custom type for PostGIS geometry, only supports reads
*/
export const geometry = <
TType extends GeoJSON.Geometry["type"] = GeoJSON.Geometry["type"],
T extends CustomTypeValues = CustomTypeValues,
>(
@ItsWendell
ItsWendell / geometryType.ts
Created October 21, 2023 15:23
Experimental / hacky custom drizzle column for PostGIS geometry (injection method)
export type GeometryTypes = {
Point: GeoJSON.Point;
LineString: GeoJSON.LineString;
Polygon: GeoJSON.Polygon;
MultiPoint: GeoJSON.MultiPoint;
MultiLineString: GeoJSON.MultiLineString;
MultiPolygon: GeoJSON.MultiPolygon;
GeometryCollection: GeoJSON.GeometryCollection;
};
@ItsWendell
ItsWendell / action.yaml
Last active November 19, 2023 17:23
Turbo Summarize Github Actions Action
name: "Summarize Turborepo Output"
description: "Summarize Turborepo output for GitHub Actions"
runs:
using: "composite"
steps:
- shell: bash
name: "Summarize Turborepo Output"
run: |
latest_json=$(ls -t .turbo/runs/*.json | head -1)
@ItsWendell
ItsWendell / expo-runtime.ts
Last active August 25, 2023 08:18
Expo: Runtime Versioning based on pnpm lock
#!/usr/bin/env -S pnpm tsx
import crypto from "crypto";
import fs from "fs";
import path from "path";
import {
createFingerprintAsync,
diffFingerprintChangesAsync,
} from "@expo/fingerprint";
const projectRoot = process.cwd();
@ItsWendell
ItsWendell / with-next-link.ts
Created July 22, 2021 22:15
withNextLink - Higher Order Component for Linkable components to support Next.JS Routing / Links
@ItsWendell
ItsWendell / PLPGSQL-nanoid.sql
Created May 4, 2021 14:07
NanoID Implementation in PL/pgSQL for Postgres.
-- Highly performant NanoID implementation in PL/pgSQL.
--
-- NOTE: This is a concept implementation, hasn't been battle tested.
--
-- Version: 0.1
-- Inspired by https://github.com/Jakeii/nanoid-postgres
-- @author github.com/ItsWendell
CREATE OR REPLACE FUNCTION gen_nanoid(size int DEFAULT 21)
RETURNS text AS $$
@ItsWendell
ItsWendell / segment-analytics.ts
Last active January 30, 2023 10:36
Segment Analytics client for Lambda with Fire & Forget support.
import { merge } from "lodash";
import { request } from "https";
import { v4 as uuidv4 } from "uuid";
export const name = "analytics-lamdba";
export const version = "0.1.2";
export type SegmentMessageTypes =
| "identify"
| "group"
@ItsWendell
ItsWendell / setCacheControl.ts
Created June 14, 2020 23:48
Helper function for setting cache control from HTTP server responses
import { ServerResponse } from "http";
interface CacheControlConfig {
sMaxAge?: number;
maxAge?: number;
staleWhileRevalidate?: boolean | number;
publicCache?: boolean;
privateCache?: boolean;
immutable?: boolean;
noCache?: boolean;