原创 Golang 設計模式系列5: 橋接模式(Bridge Pattern)
橋接模式(Bridge Pattern):將抽象部分與它的實現部分分離,使它們都可以獨立地變化。它是一種對象結構型模式,又稱爲柄體(Handle and Body)模式或接口(Interface)模式。 在橋接模式結構圖中包含如下
原创 Golang 設計模式系列4: 適配器模式(Adapter design pattern)
適配器模式(Adapter Pattern) :將一個接口轉換成客戶希望的另一個接口,適配器模式使接口不兼容的那些類可以一起工作,其別名爲包裝器(Wrapper)。適配器模式既可以作爲類結構型模式,也可以作爲對象結構型模式。 適配
原创 Golang 設計模式系列1:單例模式 (Singleton Design Pattern)
單例模式(Singleton Design Pattern) 單例模式顧名思義,會提供給用戶一個對象(object)的實例(instance) ,並且保證這個實例全局唯一。 單列模式的應用場景很多,比如: 當你想用同一個鏈接來訪
原创 Golang 設計模式系列3: 組合模式(Composite design pattern)
組合結構包含一下對象: Base Component(基礎組件) - 基礎組件是組合中所有對象的接口,客戶端程序使用基礎組件來處理組合中的對象。 它可以是一個接口或一個抽象類,包含一些對所有對象都是通用的方法。 Leaf(葉子對
原创 SSL Cetificate 生成
首先,理解一下證書的類型。 SSL證書包括: 1,CA證書,也叫根證書或者中間級證書。如果是單向https認證的話,該證書是可選的。不安裝CA證書的話,瀏覽器默認是不安全的。 2,服務器證書,必選項。通過key,證書請求文件c
原创 Single Number 系列
Single Number 系列 Single Number Given an array of integers, every element appears twice except for one. Find that singl
原创 632. Smallest Range
632. Smallest Range You have k lists of sorted integers in ascending order. Find the smallest range that includes at le
原创 552. Student Attendance Record II
552. Student Attendance Record II Given a positive integer n, return the number of all possible attendance records wit
原创 Redis 源碼閱讀筆記1:zmalloc
Redis 源碼閱讀筆記1:zmalloc zmalloc 主要用於Redis的內存管理,實際上它是在tcmalloc和jemalloc以及malloc的基礎上進行了重新封裝,所以並不是全新的內存管理體系。 所有函數如下所列 void *
原创 514. Freedom Trail
514. Freedom Trail In the video game Fallout 4, the quest “Road to Freedom” requires players to reach a metal dial call
原创 629. K Inverse Pairs Array
629. K Inverse Pairs Array Given two integers n and k, find how many different arrays consist of numbers from 1 to n su
原创 564. Find the Closest Palindrome
564. Find the Closest Palindrome Given an integer n, find the closest integer (not including itself), which is a palin
原创 600. Non-negative Integers without Consecutive Ones
600. Non-negative Integers without Consecutive Ones Given a positive integer n, find the number of non-negative integer
原创 python Setuptools
what is setuptools Setuptools is a fully-featured, actively-maintained, and stable library designed to facilitate packa