Skip to content

Instantly share code, notes, and snippets.

View starkdmi's full-sized avatar

Dmitry Starkov starkdmi

View GitHub Profile
@starkdmi
starkdmi / firebase_verify_jwt.dart
Last active September 5, 2024 03:48
Verify JWT token of authenticated Firebase user
import 'package:dio/dio.dart'; // default `http` package can be used as well
import 'package:jose/jose.dart'; // BSD-3-Clause, use `dart_jsonwebtoken` package in case of MIT license
const firebaseProjectId = "FIREBASE_PROJECT_ID";
Map<String, String> googleSecureTokens = {}; // { "KeyId": "PublicKey" } from public Google website
DateTime? googleTokensExpirationDate;
// Verify Firebase JWT token
// https://firebase.google.com/docs/auth/admin/verify-id-tokens#verify_id_tokens_using_a_third-party_jwt_library
Future<bool> validateToken(String token) async {
@starkdmi
starkdmi / firebase_app_check.dart
Last active March 13, 2022 15:44
Verify Firebase App Check token
import 'package:collection/collection.dart' show ListEquality;
import 'package:jose/jose.dart'; // BSD-3-Clause, use `dart_jsonwebtoken` package in case of MIT license
import 'package:dio/dio.dart'; // default `http` package can be used as well
const firebaseProjectId = "FIREBASE_PROJECT_ID";
const firebaseProjectNumber = "FIREBASE_PROJECT_NUMBER";
const firebaseAppIds = [
"FIREBASE_IOS_APP_ID",
"FIREBASE_ANDROID_APP_ID",
"FIREBASE_WEB_APP_ID"
@starkdmi
starkdmi / SwiftLosslessCut.swift
Last active June 11, 2023 13:00
Lossless Video Cut using AVAssetWriter
let source = URL(fileURLWithPath: "input.mov")
let destination = URL(fileURLWithPath: "output.mov")
try? FileManager.default.removeItem(at: destination)
let asset = AVAsset(url: source)
let reader = try! AVAssetReader(asset: asset)
let writer = try! AVAssetWriter(outputURL: destination, fileType: .mov)
let videoTrack = await asset.getFirstTrack(withMediaType: .video)
@starkdmi
starkdmi / ROCm Installation on AMD Ryzen 7 PRO 8700GE.md
Created November 2, 2024 09:41
Installing and verifying ROCm 6.2 and PyTorch 2.6 on AMD Ryzen 7 PRO 8700GE running Ubuntu