This file contains 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 SwiftUI | |
extension Binding { | |
func onChange(_ handler: @escaping () -> Void) -> Binding<Value> { | |
Binding( | |
get: { self.wrappedValue }, | |
set: { newValue in | |
self.wrappedValue = newValue | |
handler() | |
} |
This file contains 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 SwiftUI | |
struct ScreenLockModifier: ViewModifier { | |
func body(content: Content) -> some View { | |
content | |
.onAppear { | |
UIApplication.shared.isIdleTimerDisabled = true | |
} | |
.onDisappear { | |
UIApplication.shared.isIdleTimerDisabled = false |
This file contains 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
export const dataCy = (value: string) => cy.get(`[data-cy=${value}]`); | |
export const dataCyPath = (...attrs: string[]) => cy.get(attrs.map(attr => `[data-cy=${attr}]`).join(' ')); | |
export const dataCyObject = <T extends readonly string[]>(hostAttr: string, attrs: T) => | |
attrs.reduce((cyObject, attr) => (cyObject[attr] = () => dataCyPath(hostAttr, attr)) && cyObject, {} as Record<T[number], () => Cypress.Chainable<JQuery<HTMLElement>>>); | |
This file contains 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
name: Deploy to Firebase Hosting on PR | |
"on": pull_request | |
jobs: | |
build_and_preview: | |
if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}" | |
runs-on: ubuntu-latest | |
env: | |
IDS: '{ master: "hscheue-workspace", development: "work-development-6804b" }' | |
SA: '{ master: "FIREBASE_SERVICE_ACCOUNT_HSCHEUE_WORKSPACE", development: "FIREBASE_SERVICE_ACCOUNT_WORK_DEVELOPMENT_6804B" }' | |
C: '{ master: "production", development: "development" }' |
This file contains 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
name: Deploy to Firebase Hosting on merge | |
"on": | |
push: | |
branches: | |
- master | |
- development | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
env: |
This file contains 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
function sentInvitation(invitationId) { | |
return exists(/databases/$(database)/documents/accounts/$(request.auth.uid)) | |
&& get(/databases/$(database)/documents/invitations/$(invitationId)).data.invitedBy == /databases/$(database)/documents/accounts/$(request.auth.uid) | |
} | |
// In production, wrapping exists and get in small utilities is worth tradeoff in code readability | |
// chaining this with utility that null-checks auth and auth.uid helps read rule errors in unit tests |
This file contains 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 * as functions from "firebase-functions"; | |
// import type so that lazy import isn't made useless | |
import type * as admin from "firebase-admin"; | |
// global types only | |
type DocumentReference = admin.firestore.DocumentReference; | |
// lazy init admin, not required in pubsub but when paired in functions | |
// file with callables is important. | |
let initialized = false; |
This file contains 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 { MongoClient: driver } = require('mongodb'); | |
const connectionSpread = [ | |
process.env.DB_URL_DEVELOPMENT || 'mongodb://localhost:27017', | |
{ useNewUrlParser: true } | |
]; | |
(async () => { | |
try { | |
const client = await driver.connect(...connectionSpread); |
This file contains 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 handleRequest = async uri => { | |
return new Promise((resolve, reject) => { | |
http.get(uri, async res => { | |
const { statusCode } = res | |
if (statusCode === 302) { // redirect | |
const { location } = res.headers | |
const data = await handleRequest(location) | |
resolve(data) |