Skip to content

Instantly share code, notes, and snippets.

View yccheok's full-sized avatar

Yan Cheng Cheok yccheok

View GitHub Profile
import SwiftUI
struct SpeechBubble: View {
var count: Int
var body: some View {
HStack(spacing: 0) {
Rectangle()
.fill(.red)
.rotationEffect(.degrees(45))
@globalActor actor MyGlobalActor : GlobalActor {
static let shared = MyGlobalActor()
}
extension MoveNoteViewController: UISearchBarDelegate {
@MyGlobalActor
private func filterNotes(_ text: String) async -> [Note] {
if text.isEmpty {
return await notes
func isInActiveCanceledTrial() async throws -> Bool {
let currentDate = Date()
for await verificationResult in Transaction.currentEntitlements {
guard case .verified(let transaction) = verificationResult else { continue }
guard let expirationDate = transaction.expirationDate else { continue }
// Check if it's an active trial
if transaction.offer?.type == .introductory {
private void xxx() {
Log.i("CHEOK", "xxx");
GetGoogleIdOption googleIdOption = new GetGoogleIdOption.Builder()
.setFilterByAuthorizedAccounts(true)
.setAutoSelectEnabled(true)
.setServerClientId(Constants.WENOTE_CLOUD_STORAGE_CLIENT_ID)
.setNonce("NONCE")
.build();
androidx.credentials.GetCredentialRequest request = new androidx.credentials.GetCredentialRequest.Builder()
1. Attempt to perform the silent sign-in:
Task<GoogleSignInAccount> task = googleSignInClient.silentSignIn();
2. If step 1 succeeds, we can pass the GoogleSignInAccount to the Google Drive service.
3. If step 1 fails, prompt the user to sign in using:
startActivityForResult(Utils.buildGoogleSignInClient().getSignInIntent(), ...)
class GradientView: UIView {
override class var layerClass: AnyClass { CAGradientLayer.self }
override init(frame: CGRect) {
super.init(frame: frame)
isOpaque = false
if let gradient = self.layer as? CAGradientLayer {
gradient.startPoint = .init(x: 0.5, y: 0)
gradient.endPoint = .init(x: 0.5, y: 1)
//gradient.colors = [UIColor.red.cgColor, UIColor.black.cgColor]
class OnboardingViewControllerTemplate: UIViewController {
@IBOutlet weak var demoImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidLayoutSubviews() {
class ShareViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// Get the all encompasing object that holds whatever was shared. If not, dismiss view.
guard let extensionItem = extensionContext?.inputItems.first as? NSExtensionItem else {
self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)
return
}
(venv) yccheok@Yans-MacBook-Pro functions % export PUBSUB_PROJECT_ID="YYY";
export PUBSUB_EMULATOR_HOST="localhost:8085";
export GOOGLE_APPLICATION_CREDENTIALS="/Users/yccheok/yocto/ZZZ/firebase/functions/YYY.json";
firebase emulators:start
(node:4337) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
i emulators: Starting emulators: auth, functions, firestore, pubsub, storage
⚠ emulators: It seems that you are running multiple instances of the emulator suite for project YYY. This may result in unexpected behavior.
⚠ functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: database, hosting, dataconnect
⚠ functions: Your GOOGLE_APPLICATION_CREDENTIALS environment variable points to /Users/yccheok/yocto/ZZZ/firebase/functions/YYY.json. Non-emulated services will access production using these credentials
static func generateDocId() -> String {
let db = Firestore.firestore()
// Any collection name will do. This function is not supposed to perform any read/write
// operations on Firestore.
return db.collection("sandbox").document().documentID
}