Skip to content

Instantly share code, notes, and snippets.

View mindofjonas's full-sized avatar
🎯
Focusing

Jonas Fleur-Aime mindofjonas

🎯
Focusing
View GitHub Profile
@ciiqr
ciiqr / zod-optional-null.ts
Last active November 19, 2024 06:54
zod optional/nullable/nullish differences
// zod schema
z.object({
// valid if string or:
optional: z.string().optional(), // field not provided, or explicitly `undefined`
nullable: z.string().nullable(), // field explicitly `null`
nullish: z.string().nullish(), // field not provided, explicitly `null`, or explicitly `undefined`
});
// type
{
@rphlmr
rphlmr / route.tsx
Last active July 24, 2024 13:02
Remix Supabase Upload
// if you don't plan to upload only images :
/*
async function convertToFile(data: AsyncIterable<Uint8Array>) {
const chunks = [];
for await (const chunk of data) {
chunks.push(chunk);
}
return chunks;
}
@zcaceres
zcaceres / Nested-Routers-Express.md
Last active September 6, 2024 16:45
Child Routers in Express

Nested Routers in Express.js

Express makes it easy to nest routes in your routers. But I always had trouble accessing the request object's .params when you had a long URI with multiple parameters and nested routes.

Let's say you're building routes for a website www.music.com. Music is organized into albums with multiple tracks. Users can click to see a track list. Then they can select a single track and see a sub-page about that specific track.

At our application level, we could first have a Router to handle any requests to our albums.

const express = require('express');
@jonesch
jonesch / exact-target-curl
Created October 5, 2012 18:54
Submitting to Exact Target with cURL
<?php //I am using this for an AJAX call, and checking my responses against the success or failure that it is echoing back.
//create array of data to be posted
$full_name = stripslashes(trim(strip_tags($_POST['full_name'])));
$email_address = stripslashes(trim(strip_tags($_POST['email_address'])));
if(!empty($full_name) && !empty($email_address)){
$post_data['MID'] = "10488043";
$post_data['Full Name'] = $full_name;
$post_data['Email Address'] = $email_address;
$post_data['thx'] = '';