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

Wayne

Latency Numbers Every Programmer Should Know

Copied from https://gist.github.com/jboner/2841832 Latency Comparison Numbers (~2012) ---------------------------------- L1 cache refere...

Wayne

壓力測試的工具 - JMeter

JMeter 是個可以拿來做 performance testing 的工具,可以併發 request 做壓力測試 https://jmeter.apache.org/ ![Screenshot 2020-06-29 18.13.02.png](https://wayn...

Wayne

Library v.s. Framework

終於看到一個簡單明瞭的分類方試 會 call 你的 method 的叫 framework, 只有你會 call 他的 method 的叫 library >- Framework: If you have code in a jar that you import a...

Wayne

How OTR (Off-the-Record) Messaging works

OTR stands for Off-the-Record Messaging, the OTR protocol was designed by cryptographers Ian Goldberg and Nikita Borisov and released on ...

Wayne

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

Wayne

Fix timestamp precision problem in CI

用 Timecop freeze 時間時,會因為作業系統不同的關係導致 RSpec test 在 compare timestamp 時出現誤差值,導致在 local 能 pass 的 test case 在 CI 卻會 failed,以下提供看似正常但會出錯的 Test ...

Wayne

血淋淋的鍵盤設定之路 - Vortexgear Tab75

## Spec - 鍵盤:Vortexgear Tab75 - MacOS: 10.15.4 - Karabiner-Elements: 12.0.9 ## 鍵盤配置: `[ L1 ][ L2 ][ L3 ][ Space ][ R1 ][ R2 ][ R3 ]` ...

Wayne

Git 把分支的分支的改動轉移到 master 上

看到一個發文有附圖的[好文](https://medium.com/@glasses618/不要再-cherry-pick-了-e079d67404d6) 以下引用原文 如果今天有三支 branch:master、staging、feature/b。本來你在開發中的 ...

Wayne

Readable feature test with RSpec

可以用更語意的 method 來寫 spec,with `given`, `when`, `and`, `then` keywords Example: ```rb feature 'Enrolment' do scenario 'Enrolling in a c...

Wayne

各種數學相關的英文

叫我英文小廢柴~科科 數學符號的英文 - 乘法 (Multiply): a * b => a multiply by b - 除法 (Divide): a / b => a aivided by b - 分母:fraction - 分子:denominator ...

Wayne

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

Wayne

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

Wayne

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

Wayne

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

Wayne

Swift Equatable object

Take exmaple of Post model: ```swift import Foundation struct Post: Identifiable { var id: String } ``` If we don't implement `Equ...

Wayne

Pagination using GraphQL and SwiftUI

簡單來說就是 `List` render 到最後一個 post 的時候(藉由 `onAppear` 來偵測 )就繼續 load 剩下的 posts,這樣就能做到 infinite scroll In view: ```swift import SwiftUI str...

Wayne

System Design 101 - System Design Interviews step by step

System Design interview 通常是 open ended 問題,沒有唯一解,例如「設計一個 Twitter」、「設計一個縮網址服務」等等,所以必須要跟面試官互動,narrow down 問題,focus 在某些部分來解決即可。通常的步驟是: 總結來說...

Wayne

Implement Union Find in Python

UnionFind 是在 Find 的時候才把 set 合併在一起,並且在 union 的時候會 call find ```py class UnionFind: def __init__(self): self.father = {} ...

Wayne

System Design 101 - Polling vs Long-Polling vs WebSockets vs Server-Sent Events

### Polling client 持續不斷的 send http request to server,server 持續不斷的回傳 response 給 client ex: 每秒都 call API 問 server 有沒有新的 notification ##...

Wayne

System Design 101 - Consistent Hashing

在 [System Design 101 - Sharding or Data Partitioning](/posts/426-system-design-101-sharding-or-data-partitioning) 的 Partitioning Criteri...

Wayne

System Design 101 - SQL and NoSQL

### SQL and NoSQL **SQL** => Relational databases store data in rows and columns. 就是有 tables, row, columns 的 database **NoSQL** => 泛指不是 ...

Wayne

System Design 101 - Caching

Cache 就是把常用的資料先 copy 起來,有人需要的時候就直接把 copy 拿給他、節省時間的方式 ## Cache 的種類 ### 1. Appplication server cache request 打到 web server 的時後從 web ser...

Wayne

System Design 101 - Sharding or Data Partitioning

> Data partitioning (also known as sharding) is a technique to break up a big database (DB) into many smaller parts. Sharding 就是把 DB 切成...

Wayne

How an iOS share extension communicate with containing app

> ven though an app extension bundle is nested within its containing app’s bundle, the running app extension and containing app have no ...

Wayne