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 © ...
Database ACID - Atomicity, Consistency, Isolation, and Durability
> ACID,是指資料庫管理系統(DBMS)在寫入或更新資料的過程中,為保證事務(transaction)是正確可靠的,所必須具備的四個特性:原子性(atomicity,或稱不可分割性)、一致性(consistency)、隔離性(isolation,又稱獨立性)、持久性(...
TSDB - Time series database
第一次聽說這種 database,記錄一下: - 數據結構簡單 - 資料量大 - 寫入多於讀取 (95%~99% Write) - 照時間順序寫入,幾乎不會有 update 操作(讀取也是) - bulk delete,通常都直接刪一個區間內的資料,不會刪單一資料(讀取...
How to use SwiftUI with ViewController
[上一篇文章](/posts/412-how-to-make-multiline-textfield-in-swiftui)為了要實現 multiline text field 結果發現 SwiftUI 並沒有所謂 MultilineTextField 這種東西,想要實現就...
How to make multiline TextField in SwiftUI
SwiftUI 根本就是半殘狀態嘛,靠北連個 multiline TextField 都做不到,還得自己用 `UITextView` 客製化,見 https://stackoverflow.com/questions/56471973/how-do-i-create-a-m...
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 ...
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...
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...
Rails nested transaction
TL:DR: Best Practice: 在 nested transaction 內不要手動 `raise ActiveRecord::Rollback`, 一律使用 `save!`, `update!` 等操作,就不會有問題。 1. raise `ActiveRe...
Elixir's interactive shell (IEx) tips
雖然我目前沒有在寫 Elixir,但還滿想玩玩看,通常寫新語言都很需要知道 local 測試語法的方法,剛好看到這個 tips 所以先記錄下來 ## References - https://nts.strzibny.name/elixir-interactive-sh...
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...
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...
Remote tools and tips from ThoughtBot
ThoughBot 跟緊這波疫情 WFH 的潮流發了一篇 remote tips,順便推廣了他們自己的產品 Tuple,還滿想試試看的 另外有個 meeting tip 也不錯,就是舉手的機制,想發言的人要先舉手 再來是被遺忘的 Google Jamboard 可以當快...
How DHH write RESTful controller
常常要貼這個連結給別人但每次都忘記這篇的連結在哪,紀錄一下以後好搜尋 https://gist.github.com/dhh/10022098
Harmless migration file in Rails could be harmeful
討論一個看起來很正常的 migration file 可能造成的問題,ex: ```rb class MyMigration < ActiveRecord::Migration[5.2] def change add_reference :payments, ...
TCP 的三次握手四次揮手
## 三次握手: 連線  cache Least recently use 簡單的說就是:最近最少使用 像是 CPU 釋放 memory 時就會使用 LRU Cache 來刪除最近最少使用的東西。 概念沒什麼大不了的,重點是要怎麼實現? B...
System Design 101 - Introduction to CAP theorem
* 一致性(**C**onsistency) * 可用性(**A**vailability) * 分區容錯性(**P**artition tolerance) CAP 理論就是在說 CAP 只能滿足其中兩者,不可能三者都滿足。 > 在理論計算機科學中,CAP定理(CAP...
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...
How to replace moment.js
Found this repo: https://github.com/you-dont-need/You-Dont-Need-Momentjs Replacement: - [date-fns](https://github.com/date-fns/date-fns...
How to add self-hosted fonts in Gatsby
This note is copied from https://dev.to/iangloude/4-steps-to-self-hosted-fonts-in-gatsby-aj2 1 - place your font files in `src/static/fo...
Weird warning with Ruby 2.7
I kept having this `The called method '…' is defined here` warning from my rails console. Ex: ``` /Users/wayne/.rvm/gems/ruby-2.7.0/gems...
ActiveStorage#attach has different return value between v5 and v6
In activestorage v5 ```rb current_user.images.attach( io: file, filename: file.original_filename, content_type: file.content_type ...
We can change ActiveStorage route_prefix in Rails 6
Usage: ```rb # config/application.rb config.active_storage.routes_prefix = '/files' ``` So instead of having route like `www.example.c...