Skip to content

Instantly share code, notes, and snippets.

View colinfwren's full-sized avatar

Colin Wren colinfwren

View GitHub Profile
@colinfwren
colinfwren / CVPreviewView.swift
Created August 17, 2024 19:17
CV Preview View
import SwiftUI
import PDFKit
import PDFBlocks
struct CVPreviewView: UIViewRepresentable {
var pdfDocument: PDFDocument
init(pdfData pdfDoc: PDFDocument) {
self.pdfDocument = pdfDoc
}
@colinfwren
colinfwren / navigationlinksheet.swift
Created August 9, 2024 21:00
Launching sheet from navigation link
struct ExperienceVersionListView: View {
@Query var experienceVersions: [ExperienceVersion]
@State private var experienceVersionDetailSheet: ExperienceVersion?
var body: some View {
List {
ForEach(experienceVersions) { experienceVersion in
Button(action: { experienceVersionDetailSheet = experienceVersion }) {
NavigationLink(destination: EmptyView()) {
Text(experienceVersion.name)
@colinfwren
colinfwren / reading-values-after-test.ts
Created August 4, 2024 20:17
Reading values from Appwrite after test
async function getRecordDetails(recId: String): Promise<Models.Doc> {
const client = new Client()
.setEndpoint(APPWRITE_URL)
.setProject(APPWRITE_PROJECT)
.setKey(APPWRITE_API_KEY)
const databases = new Databases(client)
return databases.getDocument(DATABASE_ID, COL_ID, recId)
}
@colinfwren
colinfwren / calling-graphql-http.ts
Created August 4, 2024 20:15
Calling GraphQL via HTTP
const graphqlString = `
mutation Something($somethingData: SomethingInput!) {
something(somethingData: $somethingData) {
name
}
}
`
test('something that requires user auth', async () => {
const { jwt } = await getNewUser()
@colinfwren
colinfwren / graphql-hooks.ts
Created August 4, 2024 20:14
Setting up and tearing down Apollo
describe('a feature of the app', () => {
let server, url
beforeAll(async () => {
// assigns the values returned to the variables in the upper scope
({ server, url } = await createApolloServer({ port: 0 }))
})
afterAll(async () => {
await server?.stop()
@colinfwren
colinfwren / getNewUser.ts
Created August 4, 2024 20:13
Getting a JWT for a newly created user
async function getNewUser(): Promise<{ user: Models.User<Models.Preferences>, jwt: string}> {
const client = new Client()
.setEndpoint(APPWRITE_URL)
.setProject(APPWRITE_PROJECT)
.setKey(APPWRITE_API_KEY)
const users = new Users(client)
const userEmail = `test-user-${randomUUID()}@test.com`
const user = await users.create(ID.unique(), userEmail, undefined, NEW_USER_PASSWORD, userEmail)
const agent = request.agent(APPWRITE_URL)
await agent
@colinfwren
colinfwren / appwrite-graphql-server.ts
Created August 4, 2024 20:08
GraphQL context with Appwrite client
import {Account, Client, Databases, Models} from "node-appwrite";
import {ListenOptions} from "node:net";
import {ApolloServer} from "@apollo/server";
import {startStandaloneServer} from "@apollo/server/standalone";
async exampleFunction(databases: Databases, user: Models.User<Models.Preferences>) {
const doc = await databases.createDocument('databaseId', 'colId', user.$id) // do something with a database
}
const resolvers = {
.bag {
/* hoist the item list scroll progress scope to the parent so can be shared */
timeline-scope: --item-list-scroll-timeline;
}
.item-list {
/* make the item lists y-axis scroll progress available as a variable */
scroll-timeline: --item-list-scroll-timeline y;
}
.bag {
/* hoist the item list scroll progress scope to the parent so can be shared */
timeline-scope: --item-list-scroll-timeline;
}
.item-list {
/* make the item lists y-axis scroll progress available as a variable */
scroll-timeline: --item-list-scroll-timeline y;
}
.item-list {
/* make the item lists y-axis scroll progress available as a variable */
scroll-timeline: --item-list-scroll-timeline y;
}
.bag-section-image {
/* The animation(s) to drive using the scroll progress */
animation: item-bag-image linear;
/* Hook up the item lists scroll progress to drive the animation */
animation-timeline: --item-list-scroll-timeline;