Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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;
})
zip -er newZippedFile.zip fileOrFolderToZip
@gn-bcampbell
gn-bcampbell / removeDuplicates.tsx
Created March 24, 2023 22:49
Loop over response, remove duplicates inside property array of objects
interface SetActivityDetails {
Id: number
Description: string
SetId: number
SetType: string
SetVisitId: number
CostAttributionId?: number
}
export type RequestErrorResponse = Array<{