Skip to content

Instantly share code, notes, and snippets.

View fredriccliver's full-sized avatar
🧭
To the north

Fredric Cliver fredriccliver

🧭
To the north
View GitHub Profile
// do this before your work needs an authentication
if (req.headers.authorization && req.headers.authorization.startsWith('Bearer ')) {
console.log('Found "Authorization" header');
// Read the ID Token from the Authorization header.
idToken = req.headers.authorization.split('Bearer ')[1]
const decodedIdToken = await admin.auth().verifyIdToken(idToken)
console.log('ID Token correctly decoded', decodedIdToken)
req.user = decodedIdToken
}else{
// This work with assigning by value
var i = 3
// 3
j = i
// 3
j += 1
// 4
i
// 3
j
<ul id="ul-collections">
<li>
<template id="collection-row-template">
<div class="border border-gray-500 w-64 rounded-3xl cursor-pointer">
<div class="p-4 text-xl font-bold font-serif">The basic english phrase: Greeting; by author Fred.</div>
<div class="p-4">
<span class="font-bold">6</span>
<span class="text-xs">phrases for </span>
<span class="text-sm italic">Beginner</span>
const rowTemplate = document.querySelector<HTMLTemplateElement>('#collection-row-template')!
const ul = document.querySelector<HTMLUListElement>('#ul-collections')!
const li = document.createElement("li") as HTMLLIElement
li.appendChild(rowTemplate.content.cloneNode(true))
ul.append(li)
console.log(`append`)
export class UI {
toastTemplate?: HTMLTemplateElement
constructor(templateSelector: string) {
this.toastTemplate = document.querySelector<HTMLTemplateElement>(
templateSelector
)!
}
showToast() {
let toast = new toastMessage.UI("#toast-message-template")
toast.showToast()
// cf. https://swiftsenpai.com/xcode/asauthorizationappleidbutton-in-storyboard/
import UIKit
import AuthenticationServices
@IBDesignable
class MyAuthorizationAppleIDButton: UIButton {
private var authorizationButton: ASAuthorizationAppleIDButton!
//
// Created by Fredric Cliver on 2020/10/13.
//
import UIKit
import Firebase
import GoogleSignIn
import CryptoKit
import AuthenticationServices
@IBAction func onClickSignOut(_ sender: UIButton) {
let firebaseAuth = Auth.auth()
do {
try firebaseAuth.signOut()
self.view.window?.rootViewController?.dismiss(animated: true, completion: nil)
} catch let signOutError as NSError {
print ("Error signing out: \(signOutError.localizedDescription)")
}
}
export const functionsRegion = () => {
if (location.hostname == "127.0.0.1" || location.hostname == "localhost") {
return undefined
} else {
return "europe-west1"
}
}