This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = await Deno.readTextFile("./day2.txt"); | |
const reports = data.split("\n").map((line) => line.split(/\s+/).map(Number)); | |
function checkIsSafe(report: number[], index = 0, dampened = false): boolean { | |
const a = report[index]; | |
const b = report[index + 1]; | |
const diff = b - a; | |
const direction = report[1] - report[0] < 0 ? "dec" : "inc"; | |
const isLast = index + 1 === report.length; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createImageUrlBuilder from '@sanity/image-url'; | |
// import { sanityClient } from 'sanity:client'; | |
import createClient from 'picosanity'; | |
import { z } from 'zod'; | |
const sanityClient = createClient({ | |
dataset: 'production', | |
projectId: 'maa8c2eu', | |
apiVersion: '2024-04-29', | |
useCdn: import.meta.env.PROD, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr1 = [ | |
['name', 'id', 'age', 'weight'], | |
['Susan', '3', '20', '120'], | |
['John', '1', '21', '150'], | |
['Bob', '2', '23', '90'], | |
['Ben', '4', '20', '100'], | |
]; | |
const arr2 = [ | |
['name', 'id', 'height'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineDocument } from 'sanity-typed-queries'; | |
const { section } = defineDocument( | |
'section', | |
{ | |
name: { | |
type: 'string', | |
title: 'Name', | |
validation: (Rule) => Rule.required(), | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
/* An attempt to make the error handling process described on Khalil Stemmler's excellent | |
/* blog a little somewhat simpler. | |
/* https://khalilstemmler.com/articles/enterprise-typescript-nodejs/functional-error-handling/ | |
/** | |
// Left and Right classes, but more specific to error handling. | |
class Failure<L, A = any> { | |
readonly error: L; |