How to test with Salesforce Heroku Connect - Part 2
In my previous post [How to test with Salesforce Heroku Connect ](https://waynechu.cc/posts/290-how-to-test-with-salesforce-heroku-conne...
Fix marked.js and highlight.js
## Story My blog had some highlighting issue when rendering Ruby class. I finally found a time to fix it. The problem is I was useing o...
Rails 用 webpacker 時 compile 很慢而且很吃 memory?You're probably a over-packer lol
長話短說,就是 webpacker 會 compile **所有** 在 `japascripts/packs` 資料夾底下的東西,所以只要沒有要在 layout 裡面 include 的 file 就不要放在 packs 下面,這樣就會變快了。 Copy paste f...
Ruby 2.7 懶人點點點語法
`...` 成為最新最潮的 arguments forwarding syntax ```rb def bar(*args, **kws, &block) block.call(args, kws) end ``` 可以寫成 ```rb def foo(...)...
Faking External Services in Tests with Adapters
Faking External Services in Tests with Adapters https://thoughtbot.com/blog/faking-external-services-in-tests-with-adapters
Unexpected behaviour for ActiveModel::Model validate and valid?
Assume we have an `FakeUser` class looks like below: ```rb class FakeUser include ActiveModel::Model include ActiveModel::Attribute...
There are only 2 hard things in Computer Science
> There are only two hard things in Computer Science: cache invalidation and naming things. > -- Phil Karlton https://martinfowler.com/...
Redefine comparator in Python and Ruby
## Python In python, there are several magic functions for comparing: * `__eq__(self, other)` 定義了等號的行為` ==` 。 * `__ne__(self, other)` ...
Rails 6 ActiveStorage updates
工作上有用到 ActiveStorage,然後我又手癢想升級 Rails,所以先記錄一下 https://blog.saeloun.com/2019/11/04/rails-6-active-storage-updates.html
How Ruby REALLY uses Memory: On the Web and Beyond
好文,強烈建議閱讀全文 => https://www.schneems.com/2019/11/06/how-ruby-really-uses-memory-on-the-web-and-beyond/ ## TL;DR: - Tread 越多 memory usag...
Ruby yield_self and then syntax
## TL;DR: 1. `yield_self` == `then` 2. `yield_self` returns the result of the block ## yield_self Introduced in Ruby v2.5 Difference...
Ruby multiline string
## With indention version ```rb indented = <<-EOS Hello This is an example. I have to write this multiline string outside the we...
How to sort a list in Python
## 1. Object oriented way: ```python list = [4,3,2,1] list.sort() # => return nothing list # => [1,2,3,4] ``` - called from object ...
Finally we have multi env credential in Rails 6
In Rails 6, default credential is for development and staging, they'll store in the same path ``` config/credentials.yml.enc config/mast...
When to use Hash and when to use HashWithIndifferentAccess and why
## TL;DR: * When passing to our class: Both works, because we control everything * When passing to 3rd party library: Hash is better, we...
Keyword argument in Ruby 3
https://blog.saeloun.com/2019/10/07/ruby-2-7-keyword-arguments-redesign.html
Can't find custom headers in Axios response
It's CORS issue, configure CORS setting for browser will fix this. https://stackoverflow.com/questions/37897523/axios-get-access-to-resp...
複習一下各種排序法,和 Python 實現
搭配題目和講解影片服用: * Lintcode: https://www.lintcode.com/problem/sort-integers * Leetcode: https://leetcode.com/problems/sort-an-array/ * https...
Remove Duplicate Numbers in Array
## Question https://www.lintcode.com/problem/remove-duplicate-numbers-in-array/description https://leetcode.com/problems/remove-duplicat...
Classical Binary Search - recursion version
## Question: 457. Classical Binary Search Find any position of a target number in a sorted array. Return -1 if target does not exist. ...
什么是拓扑排序(Topological Sorting)
直接 copy 過來: 一、什么是拓扑排序 在图论中,拓扑排序(Topological Sorting)是一个有向无环图(DAG, Directed Acyclic Graph)的所有顶点的线性序列。且该序列必须满足下面两个条件: 每个顶点出现且只出现一次。 若存在一...