Skip to content

Instantly share code, notes, and snippets.

.background {
UnevenRoundedRectangle(topLeadingRadius: 12, bottomTrailingRadius: 12)
}
@paigeshin
paigeshin / file.js
Created October 24, 2023 14:31
gc_function_get_server_notification_and_parse_data.js
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
exports.v2 = functions.https.onRequest(async (req, res) => {
// Ensure the request method is POST
if (req.method !== "POST") {
return res.status(400).send("Only POST requests are accepted");
}
const jwt = require("jsonwebtoken");
const fs = require("fs");
const axios = require("axios");
const privateKey = fs.readFileSync("./AuthKey.p8");
// Production URL : https://api.storekit.itunes.apple.com/inApps/v1/transactions/{transactionId}
// Sandbox URL : https://api.storekit-sandbox.itunes.apple.com/inApps/v1/transactions/{transactionId}
async function getTransaction(token, ID) {
try {
import Foundation
import UserMessagingPlatform
import UIKit
protocol GDPRServiceProtocol {
var consentStatus: UMPConsentStatus { get }
func loadForm(from root: UIViewController) async throws -> UMPConsentStatus
}
final class GDPRService: GDPRServiceProtocol {
import Foundation
import SwiftUI
class DialogPresenter: NSObject, UIViewControllerTransitioningDelegate {
private var transitionStyle: PopupDialogTransitionStyle = .zoomIn
private var popupContentViewController: UIViewController = UIViewController()
private var overlayController: PresentationController?
override init() {
Copy code
import java.security.SecureRandom
import javax.crypto.Cipher
import javax.crypto.KeyGenerator
import javax.crypto.SecretKey
import javax.crypto.spec.IvParameterSpec
fun encrypt(plainText: String, key: SecretKey): Pair<ByteArray, ByteArray> {
val cipher = Cipher.getInstance("AES/CBC/PKCS5Padding")
val iv = ByteArray(16)
// Retrofit API interface
interface MyApiService {
// Example API endpoint that requires an access token
@GET("example_endpoint")
suspend fun getExampleData(@Header("Authorization") authToken: String): Response<ExampleData>
}
// Retrofit API client
class MyApiClient(private val sharedPreferences: SharedPreferences) {
private val apiService = Retrofit.Builder()
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
exports.sendPushMessages = functions.pubsub
.schedule("every 1 hours")
.onRun(async (context) => {
// Retrieve all users from Firestore collection
const usersRef = admin.firestore().collection("users");
const usersSnapshot = await usersRef.get();
@paigeshin
paigeshin / ForegroundTextColor.swift
Created April 2, 2023 03:38 — forked from yannxou/ForegroundTextColor.swift
Foreground text color based on background color #SwiftUI
// Taken from Apple's App Dev Training: https://developer.apple.com/tutorials/app-dev-training/
/// This color is either black or white, whichever is more accessible when viewed against the scrum color.
var accessibleFontColor: Color {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
UIColor(self).getRed(&red, green: &green, blue: &blue, alpha: nil)
return isLightColor(red: red, green: green, blue: blue) ? .black : .white
}
import Foundation
import Combine
let publisher = [1, 2, 3, 4, 5, 6, 7].publisher
publisher
.allSatisfy {
// evaluate values
$0 % 2 == 0 //2, 4, 6
}