Skip to content

Instantly share code, notes, and snippets.

View shaneosullivan's full-sized avatar

Shane O'Sullivan shaneosullivan

View GitHub Profile
@shaneosullivan
shaneosullivan / testRepro.js
Created December 23, 2022 18:11
Reproduce issue with Postgres for Node when updating table
/*
This Node script reproduces an issue where, when passing numbers to an
UPDATE SQL query in "pg", it complains that the values are of type
text.
There is an existing open issue at https://github.com/brianc/node-postgres/issues/2159
which is similar but the query is different
*/
const pg = require("pg");
const pgConfig = {
@shaneosullivan
shaneosullivan / forwardEmailWithSendGridAndFormidable.ts
Last active June 20, 2021 06:50
Forward an email with SendGrid and Formidable
import fs from "fs";
// You can use "formidable-serverless" if in a serverless environment like
// AWS Lamba or Google Cloud Functions
import formidable from "formidable";
import sendgridMail from "@sendgrid/mail";
import { AttachmentData } from "@sendgrid/helpers/classes/attachment";
sendgridMail.setApiKey(process.env.SENDGRID_API_KEY);
@shaneosullivan
shaneosullivan / signAndUploadCloudinaryVideo.ts
Last active January 11, 2021 22:24
Example of signing a Cloudinary video upload request and uploading it from a browser
// Run in the browser
// This function takes "someId" as a parameter, as an example that you
// may want to link the video upload to some object in your database.
// This is of course totally optional.
function uploadVideo(
someId: number,
file: File,
listeners: {
onProgress: (perc: number) => void;