Skip to content

Instantly share code, notes, and snippets.

View jordangarcia's full-sized avatar

Jordan Garcia jordangarcia

View GitHub Profile
// Type for a value that might be a Promise
type MaybePromise<T> = T | Promise<T>;
// Async pipe with proper type inference for up to 10 functions
function asyncPipe<A, B>(
ab: (a: A) => MaybePromise<B>
): (a: A) => Promise<B>;
function asyncPipe<A, B, C>(
ab: (a: A) => MaybePromise<B>,
// Type for a value that might be a Promise
type MaybePromise<T> = T | Promise<T>;
// Async compose with proper type inference for up to 10 functions
function asyncCompose<A, B>(
ab: (a: A) => MaybePromise<B>
): (a: A) => Promise<B>;
function asyncCompose<A, B, C>(
bc: (b: B) => MaybePromise<C>,
import { S3Client, PutObjectCommand, GetObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3';
import { createHash } from 'crypto';
// Types for our chat system
interface ChatMessage {
id: string;
timestamp: number;
role: 'user' | 'assistant';
content: string;
metadata?: Record<string, any>;
/* eslint-disable prefer-promise-reject-errors */
/* eslint-disable compat/compat */
import $ from 'jquery';
import lumin from '../constants/lumin';
const contentType = { 'Content-Type': 'application/json' };
export const ajaxRequest = function (
endpoint = '',
method = 'get',
const promise = new Promise2((resolve, reject) => {
setTimeout(() => {
resolve('hello')
}, 500)
})
promise.then((value) => {
console.log(value)
})

Authentication

Must supply Authorization: Bearer ${token} as a header

Endpoints

GET /user/kv

Returns a mapping of all key values for that user

User Experiment KV API

GET /account/kv

{
  [key]: value
  [key]: value
  [key]: value
  [key]: value

Timer Challenge

Create a timer that counts upwards. Starting at 00:00 and counts up every second.

There should be two buttons when the timer is first rendered

MOCK

00:00