Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ItsWendell's full-sized avatar

Wendell Misiedjan ItsWendell

View GitHub Profile
@ItsWendell
ItsWendell / algolia-places-component.js
Last active February 26, 2020 20:10
React Hooks: Algolia Places component with custom input field and support for initial value. (places.js)
import React, { useRef, useEffect } from 'react';
import places from 'places.js';
// Custom component for React implementation with Hooks for Places.js
const AlgoliaPlaces = ({
inputComponent = input,
placeholder,
options,
initialValue,
@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;
@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 / 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 / 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 / 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 / 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 / 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,
>(