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...
Implement Union Find in Python
UnionFind 是在 Find 的時候才把 set 合併在一起,並且在 union 的時候會 call find ```py class UnionFind: def __init__(self): self.father = {} ...
System Design 101 - Consistent Hashing
在 [System Design 101 - Sharding or Data Partitioning](/posts/426-system-design-101-sharding-or-data-partitioning) 的 Partitioning Criteri...
LRU Cache
Least Recently Used (LRU) cache Least recently use 簡單的說就是:最近最少使用 像是 CPU 釋放 memory 時就會使用 LRU Cache 來刪除最近最少使用的東西。 概念沒什麼大不了的,重點是要怎麼實現? B...
複習一下各種排序法,和 Python 實現
搭配題目和講解影片服用: * Lintcode: https://www.lintcode.com/problem/sort-integers * Leetcode: https://leetcode.com/problems/sort-an-array/ * https...
Remove Duplicate Numbers in Array
## Question https://www.lintcode.com/problem/remove-duplicate-numbers-in-array/description https://leetcode.com/problems/remove-duplicat...
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. ...
什么是拓扑排序(Topological Sorting)
直接 copy 過來: 一、什么是拓扑排序 在图论中,拓扑排序(Topological Sorting)是一个有向无环图(DAG, Directed Acyclic Graph)的所有顶点的线性序列。且该序列必须满足下面两个条件: 每个顶点出现且只出现一次。 若存在一...
Graph theory basic - Set and adjacency list

## PKCE 什麼時候適用: 只有手機 App 沒有 Server 的時候 ## Why PKCE? Oauth2 提供很多種 Grant Type https://oauth.net/2/grant-types/ ,就是提供很多種拿到 Token 的方法,最常看...
Sam Altman co-found 的公司 Open AI 在強化學習 (Reinforcement Learning)上有了進展
http://blog.samaltman.com/reinforcement-learning-progress Sam Altman co-found 的公司 Open AI 在強化學習上有了進展,證明專精於特定領域的強化學習演算法可以有效的解決問題,在這篇文章中 D...
bcrypt, devise, and rails secret_key_base
devise 用 secret_key_base 當作產生 token 的依據 devise 用 bcrypt hashify password 然後儲存 rails 的 has_secure_password 也是用 bcrypt 實現 bcrypt() is a h...
DAG - 有向無環圖 - Directed Acyclic Graph
最近想要研究一下 IOTA 在幹嘛,看到有中文翻譯白皮書 : https://hackmd.io/c/rkpoORY4W/https%3A%2F%2Fhackmd.io%2Fs%2FryriSgvAW 裡面提到 DAG 有向無環圖 - Directed Acyclic G...
拓撲排序 - Topological Sorting
上一篇講到 DAG 有向無環圖 - Directed Acyclic Graph 這篇來研究 拓撲排序 - Topological Sorting 這篇文章講得很清楚: https://songlee24.github.io/2015/05/07/topological...
終於在工作中實際用到了紅黑樹 - 交易所配對引擎
首先了解紅黑樹跟一般的二分查找樹的區別可以看下面連結中的漫畫,清楚明瞭: https://mp.weixin.qq.com/s/0RKuO0Pk7R09wGzgyA43mw 簡單來講最大的差別在於 二分查找樹有可能會左右極度不平衡,造成查找時效率變慢 而紅黑樹有自平衡...
摘要算法和對稱加密算法
摘要算法不可逆,對稱加密可逆 所謂對稱加密就是用私鑰(也就是密碼)幫訊息加密,所以只要再用私鑰就能解密,例如 AES 算法 而摘要算法呢?就是沒有私鑰的概念,只要是一樣的字串加密出來的內容就會是一樣的,但是摘要算法會確保加密出來的字串無法(應該說:很難)被逆推回原本的值...
蒙地卡羅演算法
很簡單易懂的介紹,很棒 原理就是產生極多數的樣本,根據樣本的分佈狀態來預估真實狀態 其中交通堵塞的例子真的是很經典,很久以前就聽過但不知道是用蒙地卡羅演算法證明的 [http://mp.weixin.qq.com/s/Ca6-zfA3LzijrMFhJcfnMA]...
B+ tree (B plus tree)
前一篇學習了 什麼是 B- balance tree,立馬再來補習一下 B+ 其實 B+ tree 就是 B- 的升級版 主要的差別在於「子節點有母節點的資訊」,並且「出現在子節點中的母節點元素都是子節點中最大的元素」,不囉唆,看圖:  (b-)
常常看到 postgresql 的 index 都是用 btree 的方式 index,但一直沒時間去研究什麼是 btree,最近發現一個不錯的維信號用漫畫的方式解釋各種演算法相關的東西,剛好看到 b- b+ 的介紹,該是時候學習一下了~ 所謂的 b- 其實唸作 ba...