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
export class UI {
toastTemplate?: HTMLTemplateElement
constructor(templateSelector: string) {
this.toastTemplate = document.querySelector<HTMLTemplateElement>(
templateSelector
)!
}
showToast() {
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`)
<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>
// This work with assigning by value
var i = 3
// 3
j = i
// 3
j += 1
// 4
i
// 3
j
// 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{
let option = {}
if (locale) {
let token = await firebase.auth().currentUser?.getIdToken()
option = {
params: { yourParam: valueOfParam },
headers: {
Authorization: `Bearer ${token}`
}
}
}
// Without params and return type
let closureFunc = {
print("Printed from a closure")
}
closureFunc() // Printed from a closure
// With a parameter
let closureWithParams = { (name:String) in
print("My name is \(name)")
}
import UIKit
class PreferencesViewController: UIViewController {
@IBOutlet var usernameLabel: UILabel!
@IBOutlet var profilePic: UIImageView!
@IBOutlet var profileBox: UIView!
@IBOutlet var signOutButton: UIButton!
@IBOutlet var learningLanguageTextField: UITextField!
@IBOutlet var translationTextField: UITextField!
import SwiftUI
import Firebase
@main
struct SpeechApp: App {
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
var body: some Scene {
WindowGroup {
const origData = [
{
uid:123123,
displayName: "user1",
email: null,
emailVerified: false,
isAnonymous: false,
photoURL: "http://gooooooo.com/123123jiji",
nestedData: {