Rails 7 with bootstrap 5
照這個教學 https://jasonfleetwoodboldt.com/courses/stepping-up-rails/rails-7-bootstrap/
How to use Active Record Encryption without Rails credential
This post will teach you how to use Active Record Encryption with Dotenv ### Step 1: generate credential First of all, follow [officia...
Named parameters with flow.js
```js const constructOAuthAPIUrl = ( { path, redirectUri, state, scopes, }: { path: string, redirectUri: str...
React hook use useEffect as useState callback
`useState` doesn't have callback function and it's asynchronous, so if we need to monitor when the state got changed, we need to combine ...
Mac 外接滑鼠移動速度
下這個指令關閉智障的滑鼠移動加速,若沒關閉的話每次滑鼠移到按鈕旁邊就會變慢,有夠智障 ```sh defaults write .GlobalPreferences com.apple.mouse.scaling -1 ``` 聽說調過滑鼠移動速度後這個設定就會重新倍 ...
DHH shares hey.com Gemfile
```rb ruby '2.7.1' gem 'rails', github: 'rails/rails' gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data # Actio...
How to write a good test description
My logic is very similar to this article https://guilhermesimoes.github.io/blog/writing-good-test-descriptions 其實很簡單,就是 test description...
Feature toggle - configuration over code
很久之前的 Post [Feature toggle (a.k.a Feature Flags) in Ruby and gems to use](https://waynechu.cc/posts/441-feature-toggle-a-k-a-feature-fla...
Golang environment variable
1. Built-in `os` package 2. Ruby style `godotenv` https://github.com/joho/godotenv 3. Recommended `viper` https://github.com/spf13/viper ...
Golang version manager
GVM: https://github.com/moovweb/gvm Built-in: https://icanhazdowntime.org/posts/2019-10-11-go-has-a-built-in-go-version-manager/ ## Re...
How to revert git --amend commad?
1. use `git reflog` to see when did the ammend action happend, let's say it happened at HEAD@{4} 2. use `git reset --soft HEAD@{4}` 3. r...
Latency Numbers Every Programmer Should Know
Copied from https://gist.github.com/jboner/2841832 Latency Comparison Numbers (~2012) ---------------------------------- L1 cache refere...
壓力測試的工具 - JMeter
JMeter 是個可以拿來做 performance testing 的工具,可以併發 request 做壓力測試 https://jmeter.apache.org/  Messaging works
OTR stands for Off-the-Record Messaging, the OTR protocol was designed by cryptographers Ian Goldberg and Nikita Borisov and released on ...
Blowfish algorithm (bcrypt)
How to store password in the database using bowfish algorithm to hash (using Python to demostrate) ```py import bcrypt salt = bcrypt.g...
Fix timestamp precision problem in CI
用 Timecop freeze 時間時,會因為作業系統不同的關係導致 RSpec test 在 compare timestamp 時出現誤差值,導致在 local 能 pass 的 test case 在 CI 卻會 failed,以下提供看似正常但會出錯的 Test ...
血淋淋的鍵盤設定之路 - Vortexgear Tab75
## Spec - 鍵盤:Vortexgear Tab75 - MacOS: 10.15.4 - Karabiner-Elements: 12.0.9 ## 鍵盤配置: `[ L1 ][ L2 ][ L3 ][ Space ][ R1 ][ R2 ][ R3 ]` ...
Git 把分支的分支的改動轉移到 master 上
看到一個發文有附圖的[好文](https://medium.com/@glasses618/不要再-cherry-pick-了-e079d67404d6) 以下引用原文 如果今天有三支 branch:master、staging、feature/b。本來你在開發中的 ...
Readable feature test with RSpec
可以用更語意的 method 來寫 spec,with `given`, `when`, `and`, `then` keywords Example: ```rb feature 'Enrolment' do scenario 'Enrolling in a c...
各種數學相關的英文
叫我英文小廢柴~科科 數學符號的英文 - 乘法 (Multiply): a * b => a multiply by b - 除法 (Divide): a / b => a aivided by b - 分母:fraction - 分子:denominator ...
How to sort by an given array in many different ways (in Rails with ActiveRecord with Postgres)
## 1. Use sort_by and prioritized array https://stackoverflow.com/questions/1680627/activerecord-findarray-of-ids-preserving-order/268...
Feature toggle (a.k.a Feature Flags) in Ruby and gems to use
> Feature Toggles (often also refered to as Feature Flags) are a powerful technique, allowing teams to modify system behavior without cha...
#super_method in Ruby
By calling `super_method`, you can send message to parent class. It could be used to test decorator or protocol. ```rb class ParentClass...
String module in Elixir - String.length, String.codepoints and String.graphemes
得了一篇跟 Elixir String module 有關的蠻有趣的[文章 - String Length in Elixir](https://programmingzen.com/string-length-in-elixir/),紀錄一下 對於 special ch...