System Design 101 - Polling vs Long-Polling vs WebSockets vs Server-Sent Events

### Polling client 持續不斷的 send http request to server,server 持續不斷的回傳 response 給 client ex: 每秒都 call API 問 server 有沒有新的 notification ##...

Wayne

System Design 101 - Consistent Hashing

在 [System Design 101 - Sharding or Data Partitioning](/posts/426-system-design-101-sharding-or-data-partitioning) 的 Partitioning Criteri...

Wayne

System Design 101 - SQL and NoSQL

### SQL and NoSQL **SQL** => Relational databases store data in rows and columns. 就是有 tables, row, columns 的 database **NoSQL** => 泛指不是 ...

Wayne

System Design 101 - Caching

Cache 就是把常用的資料先 copy 起來,有人需要的時候就直接把 copy 拿給他、節省時間的方式 ## Cache 的種類 ### 1. Appplication server cache request 打到 web server 的時後從 web ser...

Wayne

System Design 101 - Sharding or Data Partitioning

> Data partitioning (also known as sharding) is a technique to break up a big database (DB) into many smaller parts. Sharding 就是把 DB 切成...

Wayne

How an iOS share extension communicate with containing app

> ven though an app extension bundle is nested within its containing app’s bundle, the running app extension and containing app have no ...

Wayne

Mismatched bundle IDs error when building iOS sharing extension

When I tried to create an share extension and build it, it keeps showing me`Failed to set plugin placeholders`and `failed to create promi...

Wayne

Swift Apollo plugin will cache result by default

I try to call the following code again but it doesn't hit my server because the defailt `cachePolicy` is `.returnCacheDataElseFetch` poli...

Wayne

Set different bundle identifier for different build in Xcode

Like previous post [Use Xcode configuration to store env variables](/posts/419-use-xcode-configuration-to-store-env-variables), we've set...

Wayne

Use Xcode configuration to store env variables

Follow [thoughtbot's article](https://thoughtbot.com/blog/let-s-setup-your-ios-environments) but don't name the class `Environment` bec...

Wayne

Use enum to replace String based key in Swift

Take an exmaple from the `Environment.swift` file which is a simple file access the env variable and return it. Before: ```swift import...

Wayne

Perform mutation with SwiftUI and Apollo client with HTTP token authentication

首先是 Editor View 的部分, Use `@Binding` 關鍵字 ``` // // PostEditor.swift // ios-swift // // Created by Wayne on 2020/3/22. // Copyright © ...

Wayne

Frontend mock API response 的小工具

這篇用來記錄一下有哪些工具可以用,以後持續更新 - https://github.com/miragejs/miragejs

Wayne

Database ACID - Atomicity, Consistency, Isolation, and Durability

> ACID,是指資料庫管理系統(DBMS)在寫入或更新資料的過程中,為保證事務(transaction)是正確可靠的,所必須具備的四個特性:原子性(atomicity,或稱不可分割性)、一致性(consistency)、隔離性(isolation,又稱獨立性)、持久性(...

Wayne

TSDB - Time series database

第一次聽說這種 database,記錄一下: - 數據結構簡單 - 資料量大 - 寫入多於讀取 (95%~99% Write) - 照時間順序寫入,幾乎不會有 update 操作(讀取也是) - bulk delete,通常都直接刪一個區間內的資料,不會刪單一資料(讀取...

Wayne

How to use SwiftUI with ViewController

[上一篇文章](/posts/412-how-to-make-multiline-textfield-in-swiftui)為了要實現 multiline text field 結果發現 SwiftUI 並沒有所謂 MultilineTextField 這種東西,想要實現就...

Wayne

How to make multiline TextField in SwiftUI

SwiftUI 根本就是半殘狀態嘛,靠北連個 multiline TextField 都做不到,還得自己用 `UITextView` 客製化,見 https://stackoverflow.com/questions/56471973/how-do-i-create-a-m...

Wayne

SwiftUI TextField doesn't support String? type binding, how to fix

## Problem Currently SwiftUI doesn't support `String?` type binding for TextField, it only support `String`, so the following code will ...

Wayne

Use Apollo (GraphQL) with SwiftUI

This [apollo-ios plugin](https://github.com/apollographql/apollo-ios) let you able to use apollo client to fetch GraphQL API easily, howe...

Wayne

Disable App Transport Security when developing iOS locally

When you see the following warning: ``` App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure...

Wayne

Rails nested transaction

TL:DR: Best Practice: 在 nested transaction 內不要手動 `raise ActiveRecord::Rollback`, 一律使用 `save!`, `update!` 等操作,就不會有問題。 1. raise `ActiveRe...

Wayne

Elixir's interactive shell (IEx) tips

雖然我目前沒有在寫 Elixir,但還滿想玩玩看,通常寫新語言都很需要知道 local 測試語法的方法,剛好看到這個 tips 所以先記錄下來 ## References - https://nts.strzibny.name/elixir-interactive-sh...

Wayne

How to extend ActiveRecord

Let's have a simple example, I want to implement a `puts_something` callback to `ActiveRecord`, whenever my object get initialzied, I wan...

Wayne

Different behaviour about counter_cache between Rails6.x and Rails5.x

TL;DR: ```rb update!(somthing_id: somthing.id) # => This line will trigger counter_cache in Rails5 but not in Rails6 ``` To make it w...

Wayne

Remote tools and tips from ThoughtBot

ThoughBot 跟緊這波疫情 WFH 的潮流發了一篇 remote tips,順便推廣了他們自己的產品 Tuple,還滿想試試看的 另外有個 meeting tip 也不錯,就是舉手的機制,想發言的人要先舉手 再來是被遺忘的 Google Jamboard 可以當快...

Wayne