Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View congnd's full-sized avatar
🚀
🛡

Cong Nguyen congnd

🚀
🛡
View GitHub Profile
@congnd
congnd / gist:8d78c1e09ecaaf9845f170b6e27a7341
Created November 27, 2023 06:08 — forked from levelsio/gist:5bc87fd1b1ffbf4a705047bebd9b4790
Secret of Monkey Island: Amsterdam (by @levelsio) or how to create your own ChatGPT image+text-based adventure game
2023-11-27 MIT LICENSE
Here's the open source version of my ChatGPT game MonkeyIslandAmsterdam.com.
It's an unofficial image+text-based adventure game edition of Monkey Island in Amsterdam, my home town.
Please use it however you want. It'd be nice to see more ChatGPT-based games appear from this.
It's much easier than you think and you'll be shocked by how relatively well it works with little work.
@congnd
congnd / jwtverify.js
Created October 6, 2023 10:02
Pure JS implementation for verifying Firebase Authentication's JWTs, this can be used on CloudFlare where NodeJS runtime is not fully supported
// refs:
// 1. https://stackoverflow.com/questions/71638739/validating-firebase-auth-tokens-manually
// 2. https://gist.github.com/bcnzer/e6a7265fd368fa22ef960b17b9a76488
// Once it is verified, you should check the payload as described in the Firebase doc:
// https://firebase.google.com/docs/auth/admin/verify-id-tokens#verify_id_tokens_using_a_third-party_jwt_library
async function verify(token) {
const decodedToken = decodeJwt(token)
console.log(JSON.stringify(decodedToken));
CATransaction.begin()
CATransaction.setCompletionBlock {
 // perform cleaning here
}
view.layer.add(animationGroup, forKey: nil)
CATransaction.commit()
animationGroup.duration = duration
let animationGroup = CAAnimationGroup()
animationGroup.animations = [
 // put your sub animations here
]
let animation = CABasicAnimation(keyPath: #keyPath(CALayer.opacity))
animation.toValue = 0
let animation = CABasicAnimation(keyPath: #keyPath(CALayer.transform))
let angle = CGFloat.random(in: ) * CGFloat.pi
let rotation = CATransform3DMakeRotation(angle, 0, 1, 0)
let finalScale = CGFloat.random(in: 2…5)
let transoform = CATransform3DScale(rotation, finalScale, finalScale, 1)
animation.toValue = transoform
let animation = CAKeyframeAnimation(keyPath: #keyPath(CALayer.position))
animation.path = path.cgPath
let path = UIBezierPath()
path.move(to: startPoint)
let endPoint = CGPoint(x: posX + CGFloat.random(in: ), y: 0)
let controlPoint1 = CGPoint(x: , y: )
let controlPoint2 = CGPoint(x: , y: )
path.addCurve(to: endPoint, controlPoint1: controlPoint1, controlPoint2: controlPoint2)
@congnd
congnd / minesweeper.swift
Created February 21, 2020 00:20
Swift solution for minesweeper challenge: https://leetcode.com/problems/minesweeper
class Solution {
func updateBoard(_ board: [[Character]], _ click: [Int]) -> [[Character]] {
let h = board.count
let w = board[0].count
var copied = board
func checkAdjacentPoints(x: Int, y: Int) {
var numberOfBombs = 0