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...
幫衝浪板快速除蠟的神奇技巧
先公布解答:熱水 + 抹布。 以前除蠟都是把衝浪板拿到大台陽底下曬,然後再辛苦的用刮蠟東西把蠟一層一層刮下來,有時候刮到一半蠟又變硬或是底下的蠟還沒被曬溶,就會變得很難除。雖然說可以買除蠟用的 Wax Remover 來讓蠟融掉,但為了除蠟還買化學液體總覺得有點太超過了...
如何 DIY 修理壞掉的衝浪板 Fin Box
## 需要的工具 - 美工刀 - 尖嘴鉗 - 砂紙 (80 grit) - 膠帶 - Q cell - Polyster Resin - MEKP Catalyst - 玻璃纖維布 (fiberglass cloth) - 新的 Fin Box P.S.// 我的板是...
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....
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...
How to communicate with iframes inside WebView
This is an archive of my post from 2017 (revised by [@morhekil](https://twitter.com/morhekil)), original posted in [medium](https://mediu...
Flutter vs ReactNaive
最大的差異應該就在於 ReactNative 依賴於 JavaScript bridge running on run time,且對原生 components 的支援度較低 Flutter 的優勢則在於對原生的支援度高,因為不需要 bridge 就可以 communic...
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/...
寫 Ruby gem 的 best practice
寫 Ruby gem 的 best practice,滿受用的但太長了有空再來看,先記一下,please check the referecne ### Referecne - https://piotrmurach.com/articles/writing-a-rub...
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 ``...
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 是怎麼經過一系列的轉換最後...
Install SElinux
```shell # install sudo apt install policycoreutils selinux-utils selinux-basics # activeate sudo selinux-activate # change to enforci...
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...
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...
Different between TCP and UDP
> 差別在於 TCP是雙向傳輸 UDP是單向.TCP傳送東西.會有封包數據.他可靠性高UDP可靠性低.傳送東西速度快。 在 TCP/ IP 協定家族中﹐傳送層主要有兩個協定﹕TCP 與 UDP。 TCP 提供的是一個連線導向(Connection Oriented)的可...
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] =...
一篇在講 Ruby on Rails 的 ActiveRecord 和 Elixir Phoenix Ecto 差別的文章
一篇在講 Rails 的 ActiveRecord 和 Phoenix Ecto 差別的文章,其實主要就是表達 Model 跟 Schema 脫鉤這樣而已,另外也提到了 Model 沒有 State 所以可以更好 passing around, ex: ```elixir...
Python class method, instance method, and static method
* instance method => 傳 instance 進去的 function,以 self 作為第一個 argument * class method => 傳 class 進去的 function,以 cls (就是 class 的縮寫) 作為第一個 argu...
FactoryBot build_stubbed, build, and create
- Speed `build_stubbed` > `build` > `ceate` - `build` is not persistent object, `build_stubbed` make object looks like persistent - `buil...
how to commit
一直以來我的 commit 方式就是意識流 commit,想到哪就 commit 到哪,呵呵 原因跟我 code review 的習慣有關,我沒有特別講究 commit 的乾淨度所以我在看 code 的時候基本上會忽略 commit message,直接用從票裡得到的 c...
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-...
該寫哪些 test?
https://www.codewithjason.com/kinds-rails-tests-write-kinds-dont/ TL;DR: 1. 每個人對 test 的名稱定義不一樣,有些人叫 acceptance, 有些人叫 end to end, integr...
Ruby API serializer options
這週 Ruby Weekly 剛好兩個人在推自己的 serializer gem,大家都要自己做自己的工具,驗證了別人寫的 code 都是屎,只有自己寫的才是最好的真理,呵呵。 趁機整理一下: - https://github.com/rails-api/active_...
stale while revalidate
stale while revalidate 是 browser 提供的 cache 的機制,我們在很多靜態頁面上都會看到,例如: ``` Cache-Control: max-age=<seconds> Cache-Control: max-stale[=<second...
How Digital Signature works
Key concepst: 1. private key 加密的訊息只可以用 public key 解密 2. public 加密的訊息只可以用 private key 解密 3. 不一樣的內容經過 hash function 後產生的 hash value 不一樣,一樣...