Skip to content

Instantly share code, notes, and snippets.

zip -er newZippedFile.zip fileOrFolderToZip
@gn-bcampbell
gn-bcampbell / sortingArray.js
Last active June 14, 2023 19:38
Sorting array of numbers in javascript
// return < 0, A, B (keep order)
// return > 0, A, B (switch order)
// Note that this will mutate the original array!!
// Implement this callback to sort numbers in ASCENDING order
arrayName.sort((a, b) => {
if (a > b) return 1;
if (a < b) return -1;
})
@gn-bcampbell
gn-bcampbell / arrayMethods.js
Created June 19, 2023 07:40
Selecting the correct JS Array Function
let arr = [1,2,3,4,5,6,7]
// IF I WANT...
// ---- Mutate the original array ---- //
// Add to
arr.push() // end
arr.unshift() //start
@gn-bcampbell
gn-bcampbell / notion_types.ts
Created January 26, 2024 09:27
Typscript types for Notion properties
type Post = {
object: string;
id: string;
created_time: Date;
last_edited_time: Date;
created_by: {
object: string;
id: string;
};
last_edited_by: {
@gn-bcampbell
gn-bcampbell / Contact.tsx
Created July 15, 2024 21:33
Using NextJS, Zod, TypeScript, ShadCN and EmailJS to create a contact form
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import emailjs from "@emailjs/browser";
import React, { useRef } from "react";
import { env } from "~/env";
import { Button } from "~/components/ui/button";
import {