Skip to content

Instantly share code, notes, and snippets.

View dinhnhat0401's full-sized avatar
🌾

Nhat Dinh dinhnhat0401

🌾
View GitHub Profile
@dinhnhat0401
dinhnhat0401 / Apple_mobile_device_types.txt
Created March 9, 2022 08:38 — forked from adamawolf/Apple_mobile_device_types.txt
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@dinhnhat0401
dinhnhat0401 / libdispatch-efficiency-tips.md
Created August 29, 2021 06:51 — forked from tclementdev/libdispatch-efficiency-tips.md
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@dinhnhat0401
dinhnhat0401 / System Design.md
Created March 11, 2020 06:47 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
import Foundation
//let queue = DispatchQueue.global()
//let group = DispatchGroup()
//let n = 9
//for i in 0..<n {
// queue.async(group: group) {
// print("\(i): Running async task...")
// sleep(3)
// print("\(i): Async task completed")
@dinhnhat0401
dinhnhat0401 / StateContext.java
Created February 18, 2016 03:26
StatePattern
package com.aiming.link.purchase.model;
import com.aiming.link.purchase.AimingLinkPurchase;
import com.aiming.link.purchase.util.Purchase;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
public class StateContext {