Feature toggle (a.k.a Feature Flags) in Ruby and gems to use

> Feature Toggles (often also refered to as Feature Flags) are a powerful technique, allowing teams to modify system behavior without cha...

Wayne

#super_method in Ruby

By calling `super_method`, you can send message to parent class. It could be used to test decorator or protocol. ```rb class ParentClass...

Wayne

String module in Elixir - String.length, String.codepoints and String.graphemes

得了一篇跟 Elixir String module 有關的蠻有趣的[文章 - String Length in Elixir](https://programmingzen.com/string-length-in-elixir/),紀錄一下 對於 special ch...

Wayne

Swift Equatable object

Take exmaple of Post model: ```swift import Foundation struct Post: Identifiable { var id: String } ``` If we don't implement `Equ...

Wayne

Pagination using GraphQL and SwiftUI

簡單來說就是 `List` render 到最後一個 post 的時候(藉由 `onAppear` 來偵測 )就繼續 load 剩下的 posts,這樣就能做到 infinite scroll In view: ```swift import SwiftUI str...

Wayne

System Design 101 - System Design Interviews step by step

System Design interview 通常是 open ended 問題,沒有唯一解,例如「設計一個 Twitter」、「設計一個縮網址服務」等等,所以必須要跟面試官互動,narrow down 問題,focus 在某些部分來解決即可。通常的步驟是: 總結來說...

Wayne

Implement Union Find in Python

UnionFind 是在 Find 的時候才把 set 合併在一起,並且在 union 的時候會 call find ```py class UnionFind: def __init__(self): self.father = {} ...

Wayne

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