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

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...

Wayne

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...

Wayne

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...

Wayne

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 ...

Wayne

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...

Wayne

Finally we can disable generated scope from ActiveRecord#enum in Rails 6

Usage: ```rb class Post < ApplicationRecord enum state: { draft: 0, published: 1, personal: 2 }, _scopes: false end ``` PR: https://g...

Wayne

幫衝浪板快速除蠟的神奇技巧

先公布解答:熱水 + 抹布。 以前除蠟都是把衝浪板拿到大台陽底下曬,然後再辛苦的用刮蠟東西把蠟一層一層刮下來,有時候刮到一半蠟又變硬或是底下的蠟還沒被曬溶,就會變得很難除。雖然說可以買除蠟用的 Wax Remover 來讓蠟融掉,但為了除蠟還買化學液體總覺得有點太超過了...

Wayne

如何 DIY 修理壞掉的衝浪板 Fin Box

## 需要的工具 - 美工刀 - 尖嘴鉗 - 砂紙 (80 grit) - 膠帶 - Q cell - Polyster Resin - MEKP Catalyst - 玻璃纖維布 (fiberglass cloth) - 新的 Fin Box P.S.// 我的板是...

Wayne

Ruby 2.7 pattern matching official docs has released

早前一篇文章 [New features in Ruby 2.7](/posts/361-new-features-in-ruby-2-7) 提到了 Ruby 2.7 將要有 pattern matching,現在 [official docs](https://docs....

Wayne

Validate JSON schema in Rails

This is an archive of my post from 2017 (revised by [@morhekil](https://twitter.com/morhekil)), original posted in [medium](https://mediu...

Wayne