Flutter vs ReactNaive

最大的差異應該就在於 ReactNative 依賴於 JavaScript bridge running on run time,且對原生 components 的支援度較低 Flutter 的優勢則在於對原生的支援度高,因為不需要 bridge 就可以 communic...

Wayne

Using RabbitMQ and Hutch with RPC call for queue in Rails

This is an example how the author implement the RPC call using Hutch and communicate with RabbitMQ https://karolgalanciak.com/blog/2020/...

Wayne

寫 Ruby gem 的 best practice

寫 Ruby gem 的 best practice,滿受用的但太長了有空再來看,先記一下,please check the referecne ### Referecne - https://piotrmurach.com/articles/writing-a-rub...

Wayne

How to pass arguments to rake task

1. rake way ```rb task :add, [:num1, :num] do |t, args| puts args[:num1].to_i + args[:num].to_i end # rake add\[1,2\] ``` 2. ENV ``...

Wayne

Ruby under a microscope - Chapter 1 - Tokenization and Parsing

This is my reading note about the book `Ruby under a microscope` Chapter 1 - Tokenization and Parsing 第一章在講我們寫的 ruby code 是怎麼經過一系列的轉換最後...

Wayne

Install SElinux

```shell # install sudo apt install policycoreutils selinux-utils selinux-basics # activeate sudo selinux-activate # change to enforci...

Wayne

How to add a new user in kali linux

```shell ec2-user@kali:~$ su root@kali:/home/ec2-user# root@kali:/home/ec2-user# useradd -m wayne root@kali:/home/ec2-user# passwd wayne...

Wayne

Ruby HTTP client options

- The built-in net/http client - Faraday - http.rb (HTTP The Gem) - rest-client - httparty - excon - Typhoeus - Curb For some pros and c...

Wayne

Different between TCP and UDP

> 差別在於 TCP是雙向傳輸 UDP是單向.TCP傳送東西.會有封包數據.他可靠性高UDP可靠性低.傳送東西速度快。 在 TCP/ IP 協定家族中﹐傳送層主要有兩個協定﹕TCP 與 UDP。 TCP 提供的是一個連線導向(Connection Oriented)的可...

Wayne

Python use for loop to generate nested list to avoid weird behavior

如果使用 `[[0] *3] *2` 這樣的方式建立 nested array ` [[0, 0, 0], [0, 0, 0]]`,那第一個 array 跟第二個 array 都是指向同一個記憶體位置,所以當改變 element 的值時,例如: `list[0][0] =...

Wayne

一篇在講 Ruby on Rails 的 ActiveRecord 和 Elixir Phoenix Ecto 差別的文章

一篇在講 Rails 的 ActiveRecord 和 Phoenix Ecto 差別的文章,其實主要就是表達 Model 跟 Schema 脫鉤這樣而已,另外也提到了 Model 沒有 State 所以可以更好 passing around, ex: ```elixir...

Wayne

Python class method, instance method, and static method

* instance method => 傳 instance 進去的 function,以 self 作為第一個 argument * class method => 傳 class 進去的 function,以 cls (就是 class 的縮寫) 作為第一個 argu...

Wayne

FactoryBot build_stubbed, build, and create

- Speed `build_stubbed` > `build` > `ceate` - `build` is not persistent object, `build_stubbed` make object looks like persistent - `buil...

Wayne

how to commit

一直以來我的 commit 方式就是意識流 commit,想到哪就 commit 到哪,呵呵 原因跟我 code review 的習慣有關,我沒有特別講究 commit 的乾淨度所以我在看 code 的時候基本上會忽略 commit message,直接用從票裡得到的 c...

Wayne

ruby lambda and proc

I found this article has a clear explanation of proc and lambda and provides good example of them. https://dev.to/keithrbennett/lambdas-...

Wayne

該寫哪些 test?

https://www.codewithjason.com/kinds-rails-tests-write-kinds-dont/ TL;DR: 1. 每個人對 test 的名稱定義不一樣,有些人叫 acceptance, 有些人叫 end to end, integr...

Wayne

Ruby API serializer options

這週 Ruby Weekly 剛好兩個人在推自己的 serializer gem,大家都要自己做自己的工具,驗證了別人寫的 code 都是屎,只有自己寫的才是最好的真理,呵呵。 趁機整理一下: - https://github.com/rails-api/active_...

Wayne

stale while revalidate

stale while revalidate 是 browser 提供的 cache 的機制,我們在很多靜態頁面上都會看到,例如: ``` Cache-Control: max-age=<seconds> Cache-Control: max-stale[=<second...

Wayne

How Digital Signature works

Key concepst: 1. private key 加密的訊息只可以用 public key 解密 2. public 加密的訊息只可以用 private key 解密 3. 不一樣的內容經過 hash function 後產生的 hash value 不一樣,一樣...

Wayne

Ruby fibrers

簡單來說可以把 Fiber 想成是 Thread 但他們的差別在於 Thread 的運作和停止是由 Operation System 控制,Fiber 則是由 Programmer 控制。丟系安捏。 ` Fiber.yield` 可以 stop Fiber 並把程序...

Wayne

Python3 sorting

https://docs.python.org/3/howto/sorting.html#sortinghowto 這個 doc 講得很清楚。 ## Basic: `list.sort()` => 改變原本的 list,只能用在 list `sorted()`=> 回...

Wayne

Python decimal

Float ```py In [10]: num = 3577 In [11]: while num >= 10: ...: num /= 10 ...: In [12]: num Out[12]: 3.5769999999999995 ```...

Wayne

New features in Ruby 2.7

最令我在意的就是 pattern matching ,但是是 experimental feature,可能還得再等等。 https://www.ruby-lang.org/en/news/2019/12/25/ruby-2-7-0-released/

Wayne

Python reverse list

reverse python list ```py In [1]: [1,2,3,4,5][::-1] Out[1]: [5, 4, 3, 2, 1] ```

Wayne

Python collections.defaultdict

> Returns a new dictionary-like object. defaultdict is a subclass of the built-in dict class. It overrides one method and adds one writab...

Wayne