Skip to content

Instantly share code, notes, and snippets.

View manhpham90vn's full-sized avatar
😍

Manh Pham Van (Opn VN - Dev Manager) manhpham90vn

😍
View GitHub Profile
@manhpham90vn
manhpham90vn / findRequiredReasonAPIUsage.sh
Created March 19, 2024 06:37 — forked from MarcoEidinger/findRequiredReasonAPIUsage.sh
A shell script to find if any "required reason API" are used in Swift or Objective-C files within that folder or subfolders
#!/bin/bash
# https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api
searchTerms=(
# File timestamp APIs
"creationDate"
"modificationDate"
"fileModificationDate"
"contentModificationDateKey"
"creationDateKey"
@manhpham90vn
manhpham90vn / configure-ec2-wordpress-nginx-php-mariadb.sh
Created October 28, 2023 17:43 — forked from 11808s8/configure-ec2-wordpress-nginx-php-mariadb.sh
Script for setting up an AWS EC2 instance with LEMP + Wordpress. Can be run on the User Data setting while launching an instance.
#!/usr/bin/env bash
# Author: @11808s8 - Adriano
# Email: [email protected]
# Version: 1.1.0 - 07/04/2020
#
# @TODO: Refactor this, breaking parts into modules
# and include more comments/User feedbacks
#
# @TODO: Remove hardcoded credentials
@manhpham90vn
manhpham90vn / axios.refresh_token.1.js
Created October 5, 2023 10:40 — forked from Godofbrowser/axios.refresh_token.1.js
Axios interceptor for refresh token when you have multiple parallel requests. Demo implementation: https://github.com/Godofbrowser/axios-refresh-multiple-request
// for multiple requests
let isRefreshing = false;
let failedQueue = [];
const processQueue = (error, token = null) => {
failedQueue.forEach(prom => {
if (error) {
prom.reject(error);
} else {
prom.resolve(token);
@manhpham90vn
manhpham90vn / channel-example.swift
Created August 30, 2023 04:34 — forked from kainosnoema/channel-example.swift
Golang-like concurrency semantics in Swift
import Foundation
go(println("in a thread"))
// buffered channel
var c = Chan(buffer:20)
// sending routing
go {
while(true) {
@manhpham90vn
manhpham90vn / 200lab_golang_training_food_delivery.sql
Created August 23, 2023 10:25 — forked from viettranx/200lab_golang_training_food_delivery.sql
This is an example DB schema for Food Delivery training project
DROP TABLE IF EXISTS `carts`;
CREATE TABLE `carts` (
`user_id` int NOT NULL,
`food_id` int NOT NULL,
`quantity` int NOT NULL,
`status` int NOT NULL DEFAULT '1',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`user_id`,`food_id`),
@manhpham90vn
manhpham90vn / dealloc-breakpoint.md
Created June 14, 2022 08:55 — forked from eneko/dealloc-breakpoint.md
Xcode UIViewController dealloc breakpoint

Xcode deinit breakpoint for UIViewController

This breakpoint provides an easy way to track view controller deinitialization (deallocation) in UIKit-based applications. This can help finding memory leaks caused by retain cycles preventing view controllers from being deinitialized when dismissed or popped.

From Cédric Luthi's tweet in 2017:

Useful Xcode breakpoint. When you dismiss a controller and you don’t hear the pop sound (or see the log), you probably have a retain cycle.

@manhpham90vn
manhpham90vn / Calendar.swift
Created February 23, 2022 13:57 — forked from mecid/Calendar.swift
SwiftUI Calendar view using LazyVGrid
import SwiftUI
fileprivate extension DateFormatter {
static var month: DateFormatter {
let formatter = DateFormatter()
formatter.dateFormat = "MMMM"
return formatter
}
static var monthAndYear: DateFormatter {
@manhpham90vn
manhpham90vn / AutoRetry.swift
Created December 28, 2021 03:36 — forked from kean/AutoRetry.swift
Smart Auto Retry using RxSwift
// The MIT License (MIT)
//
// Copyright (c) 2017 Alexander Grebenyuk (github.com/kean).
import Foundation
import RxSwift
import RxCocoa
extension ObservableType {
@manhpham90vn
manhpham90vn / AnyObserver+.swift
Created June 28, 2021 08:20 — forked from sgr-ksmt/AnyObserver+.swift
MVVM + RxSwift + Property Wrapper
extension AnyObserver {
static func create<E>(_ relay: PublishRelay<E>) -> AnyObserver<E> {
return .init { event in
guard case let .next(value) = event else { return }
relay.accept(value)
}
}
static func create<E>(_ relay: BehaviorRelay<E>) -> AnyObserver<E> {
return .init { event in