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

How DHH write RESTful controller

常常要貼這個連結給別人但每次都忘記這篇的連結在哪,紀錄一下以後好搜尋 https://gist.github.com/dhh/10022098

Wayne

Harmless migration file in Rails could be harmeful

討論一個看起來很正常的 migration file 可能造成的問題,ex: ```rb class MyMigration < ActiveRecord::Migration[5.2] def change add_reference :payments, ...

Wayne

TCP 的三次握手四次揮手

## 三次握手: 連線 ![tcp-connection-made-three-way-handshake.png](https://waynechu.cc/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6Ik...

Wayne

LRU Cache

Least Recently Used (LRU) cache Least recently use 簡單的說就是:最近最少使用 像是 CPU 釋放 memory 時就會使用 LRU Cache 來刪除最近最少使用的東西。 概念沒什麼大不了的,重點是要怎麼實現? B...

Wayne

System Design 101 - Introduction to CAP theorem

* 一致性(**C**onsistency) * 可用性(**A**vailability) * 分區容錯性(**P**artition tolerance) CAP 理論就是在說 CAP 只能滿足其中兩者,不可能三者都滿足。 > 在理論計算機科學中,CAP定理(CAP...

Wayne

How to dynamically create page in Gatsby.js from GraphQL source

1 - Install `gatsby-source-graphql` 2 - Add `gatsby-source-graphql` setting into `gatsby-config.js` ```js { resolve: `gatsby-source-g...

Wayne