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

Wayne

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

Wayne

Rails 用 webpacker 時 compile 很慢而且很吃 memory?You're probably a over-packer lol

長話短說,就是 webpacker 會 compile **所有** 在 `japascripts/packs` 資料夾底下的東西,所以只要沒有要在 layout 裡面 include 的 file 就不要放在 packs 下面,這樣就會變快了。 Copy paste f...

Wayne

Ruby 2.7 懶人點點點語法

`...` 成為最新最潮的 arguments forwarding syntax ```rb def bar(*args, **kws, &block) block.call(args, kws) end ``` 可以寫成 ```rb def foo(...)...

Wayne

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

Wayne

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

Wayne

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

Wayne

10 個 ActiveRecord 的新功能

快速看看,有印象就好 https://hint.io/blog/10-New-Things-in-Active-Record

Wayne

Redefine comparator in Python and Ruby

## Python In python, there are several magic functions for comparing: * `__eq__(self, other)` 定義了等號的行為` ==` 。 * `__ne__(self, other)` ...

Wayne

Rails 6 ActiveStorage updates

工作上有用到 ActiveStorage,然後我又手癢想升級 Rails,所以先記錄一下 https://blog.saeloun.com/2019/11/04/rails-6-active-storage-updates.html

Wayne

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

Wayne

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

Wayne

Ruby multiline string

## With indention version ```rb indented = <<-EOS Hello This is an example. I have to write this multiline string outside the we...

Wayne

uniq list in Python

```py list(set([1,2,2,3])) # => [1,2,3] ``` functional style

Wayne

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

Wayne

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

Wayne

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

Wayne

Keyword argument in Ruby 3

https://blog.saeloun.com/2019/10/07/ruby-2-7-keyword-arguments-redesign.html

Wayne

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

Wayne

給高中沒學好或是已經忘記的同學的 CS 基礎知識 cheatsheet

https://youtu.be/TOsMcgIK95k

Wayne

複習一下各種排序法,和 Python 實現

搭配題目和講解影片服用: * Lintcode: https://www.lintcode.com/problem/sort-integers * Leetcode: https://leetcode.com/problems/sort-an-array/ * https...

Wayne

Remove Duplicate Numbers in Array

## Question https://www.lintcode.com/problem/remove-duplicate-numbers-in-array/description https://leetcode.com/problems/remove-duplicat...

Wayne

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

Wayne

什么是拓扑排序(Topological Sorting)

直接 copy 過來: 一、什么是拓扑排序 在图论中,拓扑排序(Topological Sorting)是一个有向无环图(DAG, Directed Acyclic Graph)的所有顶点的线性序列。且该序列必须满足下面两个条件: 每个顶点出现且只出现一次。 若存在一...

Wayne

rspec 3 composable matchers

http://rspec.info/blog/2014/01/new-in-rspec-3-composable-matchers/

Wayne