Dan's Blog


Programming Language Theory • System Programming

164 Posts

Phoenix with svelte

1 min read • 1/20/2022, 4:46:02 PM

install in run modify modify create Add into view template

Cocoa in Racket

2 min read • 1/20/2022, 3:18:32 AM

Racket provides Objective-C bindings, so the best part here is that we can use Cocoa in Racket to build a GUI. In fact, on macOS is based…

quick sort: pivot selection

1 min read • 1/20/2022, 3:05:03 AM

The most famous quick sort in the functional world is from Haskell. To simplify the problem, all elements in given list are unique. It works…

NOTE: arm64 print number by use svc

1 min read • 1/19/2022, 12:42:08 PM

NOTE: A problem is single digit print with trailing 0

church number in racket

1 min read • 1/19/2022, 10:47:57 AM

Start Play with it

setup libraries for chez scheme

1 min read • 1/14/2022, 1:00:39 PM

Since I finally figure out how to set up these, I record them and provide some convenience common setup. It's all about environment variable…

zig: show list of files in a directory

1 min read • 1/12/2022, 6:46:34 AM

A usage of list files, is building existed C libraries, listing all C files is annoying.

Arduino zig: seven segment display

3 min read • 1/9/2022, 7:43:00 PM

seven segment display is a form of electronic display device for displaying decimal numerals, the following picture shows how to build it up…

Forth in Arm64

1 min read • 1/8/2022, 1:13:25 AM

我們知道 forth 是一個 stack-based 的連接語言,極度簡單的概念讓它非常容易被 port 到各種機器上,並且不需要太多的 runtime 支援。下面我就來介紹怎麼在 arm64(aarch64) 的 macOS 下寫出對應的 forth 指令。 Integer…

NOTE: useful nix commands

1 min read • 1/6/2022, 5:57:34 AM

NOTE: Phoenix and TimescaleDB

1 min read • 1/6/2022, 5:19:04 AM

TimescaleDB is a postgres compatible DB with time series extension Container for development To run up an instance: Modification in Phoenix…

Arduino zig: blink

3 min read • 1/4/2022, 6:14:01 AM

blink is like hello world on Arduino, and here I will show how to do it in zig. First, you need to create a zig project: Blink(programming…


1 min read • 12/31/2021, 3:38:27 PM

在 2021 的最後一天,要為各位介紹偉大的 errlang,顧名思義,就是更會回傳 err 的語言。典型的 errlang 程式如下 我們有 err,從來也不檢查 err 的型別總是讓人懷疑 我們有時會讓 err 接地 接多了就會接地泣 然而最重要的,還是用 err…

tree command on macOS

1 min read • 12/11/2021, 6:17:39 PM

One can get command on macOS by using A sample is for racket project. It produces

Julia MacroTools

1 min read • 12/10/2021, 5:15:27 PM

是 Julia 的一個程式庫,可以大幅簡化編寫 macro 的難度。 上面的程式裡面寫了 ,意思是 這段會去比對 跟右邊的 pattern…


2 min read • 10/8/2021, 4:27:16 PM


2 min read • 10/8/2021, 1:48:04 PM

idris2 FFI

1 min read • 9/26/2021, 11:18:32 PM

Idris has a simple FFI, the following code is an example. To avoid duplicate typing, we usually would write Then we would like to wrap as…

syntax-property 與 local-expand 的實際運用

1 min read • 8/19/2021, 11:10:37 AM

可以用來把資訊存入 syntax 中,這可以用在各種有趣的 macro 擴展系統之中。一個我比較熟悉的案例是 type-system,比如我們可以寫下 來表示 其中 可以用 來取得型別。 這是因為有一個常見的問題:marco…

不要誤用 with

1 min read • 7/16/2021, 9:02:22 PM

身為一個多條件過濾器,許多人會像下面那樣誤用它。 然而正確的寫法應該是下面這樣。 其中的關鍵就在 會安心的吞掉錯誤,我們沒辦法判斷沒有拿到 究竟是因為沒有 或是 沒有通過驗證。第二種寫法就避開了這個問題,如果 比對失敗也會留下顯眼的紀錄,並且自動從錯誤中恢復。

Run Postgres on GitHub Action

1 min read • 7/15/2021, 7:11:19 PM

For some projects, like Phoenix project, we need a database for testing. Good news is setting it up is simple: This is all we need.

Phoenix with React

1 min read • 7/6/2021, 3:08:18 PM

Phoenix is a great framework, but sometimes we want to use frontend framework like React. In this article, you will learn how to use them…

Elixir, Phoenix, and GraphQL(Absinthe)

2 min read • 7/6/2021, 12:44:39 AM

Long time ago, I play Elixir and write down an article about Phoenix. Time has passed, now I'm really working with Elixir XD. Today, I want…

find max subsequence

1 min read • 7/3/2021, 7:23:30 AM

The following code shows how to find max subsequence

VSCode remote developing

1 min read • 6/18/2021, 2:24:38 AM

First step, install remote pack. Now, at the left-button of your vscode should have a button. After clicked it, there will show some…

Racket: Lexer and Parser

4 min read • 6/4/2021, 3:29:45 AM

This article ports lexer from Go implementation and ports parser from Rust implementation to Racket. Lexer First, we need some structures…

S-expression, macro and develop

8 min read • 5/10/2021, 11:03:09 PM

這篇文章是從我在 Clojure Taiwan 的分享 clojure isn't lisp enough 改編而來的。由於演講與文章的差異,編排會略有不同,但主旨仍然是 macro 系統與開發方式之間的交互影響。 這篇文章前段的兩大主角分別是 Racket 和 Clojure…


1 min read • 5/3/2021, 7:21:05 PM

css secrets 不用大量細節灌爆你的腦袋,卻在一個個可以直接撿來用的案例中教會你怎麼把 css 的技巧套用到真實世界中 黑暗元素 這部應該不需要介紹了吧 lol 非虛構寫作指南(on writing well…

strictly positive check

4 min read • 5/2/2021, 10:24:48 AM

Why? strictly positive 是 data type 中對 constructor 的一種特殊要求形成的屬性,這是因為如果一個語言可以定義出不是 strictly positive 的 data type,就可以在 type as logic…

NOTE: Deploy Racket Bot r16 on Heroku

1 min read • 4/22/2021, 3:49:57 PM

How to deploy r16 bot on Heroku.

NOTE: Racket CI(GitHub Action) cache

1 min read • 3/31/2021, 7:29:38 AM

Add the following code helps GitHub Action caches installed packages. If you install packages via command like: Then add :

delimited/undelimited continuation

1 min read • 3/13/2021, 1:50:55 PM

Continuation is the future of the program, for example What is the continuation of ? We can get the result by replacing with a hole: By…

Unit sphere is convex

1 min read • 3/10/2021, 9:15:16 AM

When we say "A is convex", means for any two points in , the line in (each point on the line in ). To prove the title "Is the unit sphere…

NOTE: Racket GUI 避免重複開啟視窗

1 min read • 3/6/2021, 2:54:50 PM

首先用 往 附加一些額外的控制程式碼 接著設計一個只有當 flag 被設定好時才會開啟視窗()的函數 最後就可以得到重複觸發也不會重複開啟的視窗啦!

NOTE: Nix home-manager 基本設定

1 min read • 2/12/2021, 10:21:53 AM

home-manager 會讀取 並套用裡面的設定(config),所以我們可以用一個 git repository 管理並用 把設定掛到 home-manager 讀取的位置。一個基本的設定檔內容如下: 當然,不是任意字串都可以寫進去,套件是否存在可以到 nixos…

NOTE: 安裝 NixOS

1 min read • 2/4/2021, 4:46:25 AM

先到 Download Page 下載 Gnome, 64bit 這個 iso,在 macos 上可以用以下指令找出並把 iso image 弄進 USB 要記得把 換成正確的值, 的檔名也要改對。完成之後把 USB 插到要安裝的電腦並調整開機選項讓 USB…

12-1 月總結

1 min read • 1/29/2021, 1:08:56 PM

拿 racket 寫了幾個 nanopass 跟 compiler 的教學 從 frontend(compiler) 到 nanopass 用 nanopass 做簡單的類型檢查 完善了一下 reporter 的報告收集機制跟文件 大幅改動 sauron 的方向,v0.4.…

Lean 4, Idris 2 安裝

1 min read • 1/19/2021, 1:41:55 PM

Lean 4(nightly) Editor VSCode Idris 2 Editor vim emacs

termination checking(終止檢查)

4 min read • 1/13/2021, 6:08:05 AM

在 dependent type 裡面,我們可以寫下如 這樣的函數, 展開得到 、 展開得到 。而我們可以把它用在定義裡面,因此以下程式是合法的 因為 type checker…

subtle racket macro

3 min read • 1/7/2021, 7:38:58 AM

Racket macro is a powerful and great tool to create a new syntax form for existing language. Most of the time it just works as expected, but…


5 min read • 12/21/2020, 10:37:17 PM

循序式語意對程式初學者而言其實很不自然,最主要的原因就是因為它的常見實作語言是 C 語言家族,而 C 語言的 assign 符號跟數學的等於是同一個符號(都是 )。當然改個符號就能解決辨識問題,事實上另一個曾經的主流循序式語言家族 Pascal…

12 月推書

1 min read • 12/20/2020, 2:41:38 PM

無限的力量 這本是我最近看過最好的數學科普書籍 XD…

A wrong question: Is a Square a Rectangle?

2 min read • 11/16/2020, 11:52:00 PM

Overview what is Subtyping? what is Liskov Substitution Principle? what's the problem? how to solve this mistake of type system What is…

9-11 月總結

1 min read • 11/16/2020, 1:06:53 PM

拿 racket 寫了 raytracer 加了 Version Control Panel 跟 REPL 到 sauron 裡 inductive 實驗失敗(incr 會改掉問題部分) 做完延宕幾百年的 tiny kubernetes 網路實現 寫了 macro…

廢到有剩 Macro: comment

1 min read • 10/7/2020, 12:00:00 AM

我發現真正重要的內容通常需要長時間修改、反覆拿出來閱讀,所以目前的形式越來越不適合。因此以後 blog 這邊會逐漸廢人化,只有無聊透頂的技術相關或是日常才會發這裡 www。舉例: 這在 racket 裡定義了一個什麼也不會做的語法,可以充當註釋

NOTE: Lambda Cube

1 min read • 9/17/2020, 12:00:00 AM

First we have UTLC(untyped lambda calculus) to STLC(simply typed lambda calculus), by adding arrow type(): Lambda cube Lambda cube starts…

NOTE: scribble and xelatex

1 min read • 9/1/2020, 12:00:00 AM

scribble is a useful tool to create nice documents, however, with Chinese(any unicode character) it might produce some weird empty box for…

[racket macro] define/where

1 min read • 8/23/2020, 12:00:00 AM

In Racket, we know using form( represents ignore) is better than form However, the benefit of defining helper in target procedure can be see…

NOTE: Coq tactics

2 min read • 8/19/2020, 12:00:00 AM

Quickly note some Coq. introduces variable from environment, here introduce bound from . would try to reduce both sides of equation, in…

Infinite, how big?

3 min read • 8/7/2020, 12:00:00 AM

Counting is a useful skill, we count in many places, money, cars, weight. We develop awesome ways to count number by hands, if we mark thumb…

NOTE: how to setup a julia project

1 min read • 8/7/2020, 12:00:00 AM

Tape in shell, after getting into the interactive environment of Julia, tape to get into pkg mode: In this mode tape: In the current…

NOTE: represent type by s-exp when doing inference

1 min read • 8/1/2020, 12:00:00 AM

Compare with old implementation, this version improves by using s-exp to represent type, therefore, can reduce size a lot.

NOTE: Bad Idea, put Haskell in S expression?

1 min read • 7/31/2020, 12:00:00 AM

Just record a bad idea www. The major challenge would be can be repeated. Therefore, have to record each binding and convert to a pattern…

NOTE: Racket GUI framework and editor component

1 min read • 7/30/2020, 12:00:00 AM

framework based on racket/gui and provides some helpful components. This note is about , more precisely racket:text%. Whole GUI system based…

How to find mk fixed point

3 min read • 7/26/2020, 12:00:00 AM

This article is about how to get a fixed point in lambda calculus(utlc) system, if you didn't familiar with it, you can read NOTE: what is…

Why Logic Programming?

1 min read • 7/15/2020, 12:00:00 AM

Why? Always a good question, to understand logic programming, need to realize what we gain from it. Normally, if we want to solve a…

NOTE: Algebra Structure

1 min read • 7/12/2020, 12:00:00 AM

Magma: A set equipped with a single binary operation that must be closed by definition. Definition: a set matched with an operation . magma…


1 min read • 7/3/2020, 12:00:00 AM

優質國度絕對是精彩的超乎預期的小說,甚至無需過多介紹。來看簡介就知道有多棒: 優質國度知道你會喜歡這本書 超過 630,000 讀者跟你一樣喜歡這本書 2…

NOTE: 演算法的量級

2 min read • 6/20/2020, 12:00:00 AM

估算演算法的執行時間對寫出有效率的程式非常重要,而基於兩個假設我們採用了量級作為估算方式: 求精確複雜度很難 係數通常不重要 當可以求精確複雜度時,當然應該用更好的工具,並以實驗佐證。 定義 O(big O) 給定複雜度函數 f(n),O(f(n)) 為複雜度函數 g(n…


1 min read • 6/17/2020, 12:00:00 AM

材料(一人份) 沒講數量的是因為亂加就好了 高麗菜 顆 培根 2 片 油 低筋麵粉 4 匙 起司粉 黑胡椒 雞蛋…

NOTE: lambda 2

1 min read • 6/12/2020, 12:00:00 AM

(Second order typed lambda calculus) Consider identity function: There are many identity functions, one per type, but their definitions are…


2 min read • 6/11/2020, 12:00:00 AM

ZFC(Zermelo-Fraenkel set theory with the axiom of choice) is an axiomatic system used to formally define set theory. More precisely, ZFC is…

正確實作 substitution 有多難

2 min read • 6/4/2020, 12:00:00 AM

lambda calculus 有所謂的 substitution,具體來說就是 會變成 ,但正確實作這個行為到底有多麻煩呢?為什麼我寫這篇廢文: 因為我寫錯了... 一切都由簡單的 macro 開始搞, 的目標是簡化 term…

NOTE: 樸素集合論三大悖論

3 min read • 5/31/2020, 12:00:00 AM

樸素集合論(Naive set theory)只有兩條公理: 外延公理(axiom of extensionality):給定兩集合 ,若 , 概括公理(axiom of unrestricted comprehension…


1 min read • 5/31/2020, 12:00:00 AM

我只是寫 continuation 寫一寫非常不滿意,果然先寫個廢文好了,這篇只是一個把 racket 改成 currying 的 macro 說明: 先把 macro 寫好,現在來思考一下所謂 currying 到底做了什麼,簡單來說它就是 λ…

Hindley-Milner type system: Incrementally build way & Make new language in Racket

15 min read • 5/24/2020, 12:00:00 AM

Hindley-Milner (HM) type system is a classical type system for lambda calculus with parametric polymorphism. Its most notable property is it…

De Bruijn index: why and how

5 min read • 5/16/2020, 12:00:00 AM

At the beginning of learning PLT, everyone could be confused by program that didn't have a variable! Will, I mean they didn't use , or…

Programming 生涯回顧

7 min read • 5/13/2020, 12:00:00 AM

很久以前就曾經想過要不要寫下這種經驗文,這念頭出現到現在轉眼就過了兩年了 XD…

NOTE: 演算法的各種時間複雜度

3 min read • 5/12/2020, 12:00:00 AM


1 min read • 5/10/2020, 12:00:00 AM

材料 筆管麵 奶油塊 牛奶 50ml 鹽 開水 沙拉油 洋蔥 蒜 可選 培根 蘑菇 流程 1. 備料 切蒜碎 切洋蔥絲 2-1. 麵 開水煮沸後加入 2 匙鹽(或是罐裝轉 6 次) 計時 12 分鐘,放入筆管麵,時間到關火 2-2. 白醬(煮麵時間約剩…

A beautiful proof: There have infinite primes

1 min read • 5/9/2020, 12:00:00 AM

A long long time ago, we found natural numbers can be useful in our life, and some of them seem special. These numbers' multiplication can…

How to parse expression with the parser combinator

3 min read • 5/3/2020, 12:00:00 AM

Writing parser is a boring and massive job, therefore, people create many ways like parser generators to reduce costs. One of them called…


6 min read • 4/25/2020, 12:00:00 AM

在上一篇教學裡我們只花費了心思在如何建立核心概念的程式上,然而寫好地程式碼沒有讓人操作的介面也就只是一團垃圾而已,這次我們就來看看怎麼樣逐步開發操作用的介面吧! Racket 本身就提供了相當方便的內建 GUI,而這次我們就是要使用這些 API…

NOTE: how to install Nix package manager on MacOS Catalina

1 min read • 4/17/2020, 12:00:00 AM

Since MacOS Catalina adds some new rules, root path cannot be used by applicatin now, caused Nix package manager cannot work! The problem is…

NOTE: class member initialization order in C++

1 min read • 4/13/2020, 12:00:00 AM

There are some trap when using class in C++. One of them is the initialization order of members. This can be annoying, therefore, I want to…

From Functor to Applicative

3 min read • 4/11/2020, 12:00:00 AM

Last time we introduce Functor, a Functor is a container which provide a function can help another function operating the Functor. This…

NOTE: Seven Bridges of Königsberg and Eulerian graph

2 min read • 4/3/2020, 12:00:00 AM

Seven Bridges of Königsberg The seven bridges of Königsberg is a notable problem in mathematics. The following picture shows the actual…


3 min read • 4/1/2020, 12:00:00 AM

大約是在去年 8 月左右我在書店發現了天防者第一集,身為布蘭登.山德森的腦粉,怎麼能夠錯過大大的新書呢? 當下就買了英文版回來閱讀,不過當時公司相當忙碌也就只看了一兩章就放到一旁。過了一陣子「又」看到中文版的出現,看著封面設計這麼讚,當即也買下了它(敗書真的很棒 www…

Binary Encoding of Integer

4 min read • 3/21/2020, 12:00:00 AM

contains positive and negative numbers, but nowdays Computer system based on binary. There only have and can be used. A simple solution is…

NOTE: simply typed lambda calculus

2 min read • 3/8/2020, 12:00:00 AM

Last time I introduce lambda calculus. Lambda calculus is powerful enough for computation. But it's not good enough for people, compare with…

A Racket macro tutorial -- get HTTP parameters easier

6 min read • 2/16/2020, 12:00:00 AM

A few days ago, I post this answer to respond to a question about Racket's web framework. When researching on which frameworks could be used…


3 min read • 2/6/2020, 12:00:00 AM

一如標題這篇是介紹程式語言的文章,比較特殊的是分類語言的方式主要是以能學到什麼觀念為重點。因此我不會去比較它們的範式(如 OOP, FP…

不會騎 Gogoro 的兩個鄉巴佬

2 min read • 1/31/2020, 12:00:00 AM

晚上跟老同學出去吃飯之後去買 sim 卡(對方要出國),我們又想說好像沒試過 goshare 不然試看看啊,於是在捷運上開始弄 app:掃描文件跟臉部完成手續!不試還好,一試就變成現在這篇文章的內容啦 www 一開始的 goshare…

NOTE: C++ optional

1 min read • 1/26/2020, 12:00:00 AM

Optional type was introduced since C++17, we could include header to have it. I supply a few examples to explain this good abstraction. A…

NOTE: a little bit Z3 solver

1 min read • 1/24/2020, 12:00:00 AM

Satisfiability Modulo Theories(SMT) problem is a decision problem for logical formulas with respect to combinations of background theories…

NOTE: bounded polymorphism

1 min read • 1/24/2020, 12:00:00 AM

Bounded polymorphism refers to existential quantifiers(), restricted to range over types of bound type. To understand it only needs a few…

最後一次抱怨 Go

11 min read • 1/19/2020, 12:00:00 AM

一如標題這是我最後一次去寫對 Go 的公開抱怨,而這不是因為我終於能夠接受它了,而是對其設計與文化感到徹底的失望。有些人可能知道我對這門語言曾經抱持的過度熱愛,我甚至寫過數個盡情發揮 meta programming 技巧的程式庫與多篇包含模式、concurrency…

Type as Constraint: Why we need more type?

3 min read • 1/16/2020, 12:00:00 AM

For me, programming was about how to map my mind to the world; from this view, it probably shows why I tend to use statically typed language…

TDD is not silver bullet

1 min read • 1/11/2020, 12:00:00 AM

For the decade, people like to say TDD can solve problems faster, and I'm going to claim this was not the truth. We could solve the problem…

Reflection on Working effectively with legacy code --- chapter 20 to 23

3 min read • 1/4/2020, 12:00:00 AM

Chapter 20: This Class Is Too Big and I Don’t Want It to Get Any Bigger Chapter 21: I’m Changing the Same Code All Over the Place Chapter 2…

Reflection on Working effectively with legacy code --- chapter 11 to 19

5 min read • 1/3/2020, 12:00:00 AM

At ch6-10 we know why adding test is so hard, and how to get over it. As usual, we overview what is going to be mentioned in this article…

NOTE: What is lambda calculus

6 min read • 1/1/2020, 12:00:00 AM

What is lambda-calculus? Or, more specific, what is untyped/pure lambda-calculus? To answer this, I wrote the note for myself. Lambda…

Interaction with C in Zig

7 min read • 12/22/2019, 12:00:00 AM

From 1972, C became more and more important in the underlying world. Many projects are based on C, including the famous operating system…

NOTE: get labels from Pod

2 min read • 12/20/2019, 12:00:00 AM

This week our company wants to improve one of our projects which is based on Istio, exchanging weight in different checker instances, make…

How to test in Haskell: HSpec setup

1 min read • 12/14/2019, 12:00:00 AM

Before you start to read, ensure you're using Cabal >= 3.0 to manage your project. For a Haskell project, I usually use Cabal, do not have…

From Infinite Type to Functor

4 min read • 12/13/2019, 12:00:00 AM

At infinite type I mention a way(recursive abstract data type) to make we use just like . However, such modeling is not enough. Consider…

NOTE: If we write kubernetes client in Rust

1 min read • 12/13/2019, 12:00:00 AM

First, we can make in cluster config became more evident. Then we can mix get/list by providing type parameters:

Haskell quick start

7 min read • 12/8/2019, 12:00:00 AM

Haskell resource is a little bit outdated and if you take a look at https://www.haskell.org/documentation/ you would found there are several…

Infinite Type

3 min read • 12/8/2019, 12:00:00 AM

Infinite type sounds not good since we have no idea how much space would it take. Consider this: At here, the type of was after the first…

Reflection on Working effectively with legacy code --- chapter 6 to 10

8 min read • 12/7/2019, 12:00:00 AM

At part I we basically understand why we need to test, how to test legacy code and what tools can we use. Chapter 6 to 10 mentions more…

Mergeable replicated data types

4 min read • 11/30/2019, 12:00:00 AM

Mergeable replicated data types Kaki et al., OOPSLA’19 First, we need to know the context we need mergeable replicated data types(MRDT). In…

Reflection on Working effectively with legacy code --- Part I

3 min read • 11/24/2019, 12:00:00 AM

Preface author defines: what is legacy code? The code which lack of tests. Keep going on, at chapter 1 author compares reasons we update the…

Algebra data type vs Class

1 min read • 11/19/2019, 12:00:00 AM

I have a long time thought that algebra data type(ADT) is must need. In , ADT looks like this: And let's see how to do the same thing in…


7 min read • 11/9/2019, 12:00:00 AM

這是一篇重看 2017 年發的系列文 (這裡是第一篇 routedan.blogspot.com/2017/02/atm-ps.html) 之後決定重寫的文章 之所以決定重來,是因為以現在我的角度來看,當初寫得太過 Java Spec…

How to use .gitignore

1 min read • 11/8/2019, 12:00:00 AM

So what's wrong with me, write down an article for . Because this answer makes me reconsider how to use . The answer tell us it have a…

Weird behavior in Go: encoding/gob

1 min read • 10/31/2019, 12:00:00 AM

Consider the following program: This is quite usual in Go. But we want to make it more expressive. So we have: p.s. Replace and others…

DPDK usertools: devbind

1 min read • 10/19/2019, 12:00:00 AM

After compiling DPDK, load module and start our process. A common problem is we have no idea where is the NIC going :). And DPDK actually…

DPDK -- EAL Input/output error

1 min read • 10/18/2019, 12:00:00 AM

Last week I'm trying to reproduce a bug happened in our customer environment, so we create a minimal example for this: https://github.com…

Why not a big script

1 min read • 10/5/2019, 12:00:00 AM

I believe no one likes a big script, and I don’t like it either. A big script means a buggy script. A big script can cause no one can…

nix report

4 min read • 9/12/2019, 12:00:00 AM

This article is created as a record of the feedback of the usage of nix, also stand for learning how to use nix in daily developing life…

Privileged Pod -- Debug kubernetes node

1 min read • 9/1/2019, 12:00:00 AM

Just a record. At most of time, if we want to get into a node of kubernetes cluster, we can just using . Or we would have a master node has…

cgo can be a trouble

2 min read • 8/15/2019, 12:00:00 AM

This week, I have to upgrade nff-go from v0.7.0 to v0.8.1, so I change the version first. However, I found the whole package move to , and…

Notes: Ruby Conf Taiwan 2019

6 min read • 8/13/2019, 12:00:00 AM

Get start This article is the note and thought I get from the conference. I would mention the following topics: type checker for Ruby(steep…

How trait with lifetime can be a trouble and how to fix it

2 min read • 7/31/2019, 12:00:00 AM

In my case, I have a trait called for deserialize from bytes. Now I want to reuse a struct called for others so I write done: Because…

tcpdump cheat sheet

2 min read • 6/25/2019, 12:00:00 AM

tcpdump? A command line tool for analyzing network packets. How to get packets? Using option, , you would get the packet through NIC…

A simple way to ensure interface won't be implemented accidently

1 min read • 6/18/2019, 12:00:00 AM

Sample code is quite easy: Now, let’s create a structure type: Now, if you add , you won’t be a car accidently! What if you want to embed…

The Go concurrency bug I made

3 min read • 5/25/2019, 12:00:00 AM

There is a saying: I never had a slice of bread particularly large and wide that did not fall upon the floor and always on the buttered side…

Kubernetes Networking: concept and overview from underlying perspective

17 min read • 5/18/2019, 12:00:00 AM

Kubernetes was built to run distributed systems on a cluster of nodes. Understanding the concept of kubernetes networking could help you…

HugePages on Kubernetes

3 min read • 5/4/2019, 12:00:00 AM

What is Huge Page? When a process using some memory, CPU marking the RAM used by the process. For efficiently, CPU allocate by chunks by 4K…

5 tools for file transfer

3 min read • 4/27/2019, 12:00:00 AM

We usually have to transfer files between two computers, such as config, log, image. There are a lot of tools that could do it, but if we…

gRPC proxy: approach & pain

3 min read • 4/13/2019, 12:00:00 AM

A few weeks ago, we re-discuss the config setup issue; we found generating a new, valid config is too hard for anyone. You must remember all…

Write a hashmap in Go

2 min read • 4/4/2019, 12:00:00 AM

Just a note Hash map is a data structure that helps you associate a key type to a value type. For example, a string map to the boolean value…

Introduction of LLDB

3 min read • 3/17/2019, 12:00:00 AM

Seriously, I'm not a big fan of the debugger since I never have a try at before. But this time I take a few hours to work with it and the…

Make googletest-like test framework from scratch

5 min read • 3/3/2019, 12:00:00 AM

Back to 2016, I learned googletest how improving my C++ project. From that, I always want to know how it. Let's take a look at some basic…


3 min read • 3/1/2019, 12:00:00 AM

Tracing source code of Kubernetes client-go

8 min read • 1/25/2019, 12:00:00 AM

Whole thing is started from Ingress this feature of Kubernetes. But today I'm not going to talk too much about it, basically just I have to…

How to compare Go benchmark in TravisCI

1 min read • 12/28/2018, 12:00:00 AM

Although the article is for Go, but you still can use concept part for others language. Frist we create a script called : Then I usually…

Should I learn?

2 min read • 12/22/2018, 12:00:00 AM

A typical problem is someone, maybe your friend, your teacher, your co-worker, tell you that you must learn the freshest, incredible new XXX…

Kubernetes context

4 min read • 12/9/2018, 12:00:00 AM

Before you beginning You should already install this command line tool. And knowing what is Kubernetes. Knowing why we need to separate the…

fun networking: tcp close

1 min read • 11/30/2018, 12:00:00 AM

Recently we are working on a new feature is about filter packets by HTTP header for our router. This is the concept, we read the header by…

XDP some note

3 min read • 11/30/2018, 12:00:00 AM

What is XDP? XDP is eXpress Data Path, it's a technology about putting a BPF code virtual machine on the NIC(network interface controller…

Testing in Go

4 min read • 11/17/2018, 12:00:00 AM

Just list some testing way in Go. Basically we use this built-in lib to testing To start your first test with Go is an easy task. Example…

Kubernetes 從 Pod 開始

5 min read • 10/27/2018, 12:00:00 AM

欲閱讀本篇文章至少需要知道何為 container,由於範例將採用 Docker 為例,所以也預設讀者已經具備操作 Docker 的能力;且讀過 kubernetes 的基礎概念只是還沒開始用而已 Kubernetes 最小部署的單位為 Pod,一個 Pod 是 1 至 N…

Test LLVM Go binding in travis

2 min read • 10/6/2018, 12:00:00 AM

Basically, the problem is because I use Go binding of LLVM, then it hard to use preinstalled LLVM. This article is about how I solve the…

Go quick start

5 min read • 9/23/2018, 12:00:00 AM

I am going to show you enough knowledge to getting start with Go. Are you ready? Variables In Go, we have , & short declaration…

Use httpexpect to test server

1 min read • 9/16/2018, 12:00:00 AM

Use builtin functionality to test a Go server is a panicful experience. The problem is because we have to handle too many error and get so…

Mark Sweep GC

1 min read • 9/3/2018, 12:00:00 AM

Mark-Sweep is a classic GC algorithm, it's combined with two parts, and . Mark pseudo code would like: And Sweep pseudo code would like…

gRPC quick start in Go

2 min read • 8/16/2018, 12:00:00 AM

What is RPC? RPC means "remote procedure call". The concept is call remote function as local function. Then gRPC? It is a framework that…

Practical issue about DNS -- EDNS0

2 min read • 8/7/2018, 12:00:00 AM

I have to create a checker for our DNS server. Our DNS server will return it's config via . Code would like: But our config stream is too…

Reflection in Go: create a stack[T]

2 min read • 7/22/2018, 12:00:00 AM

Do you know what can Go's package do? Whatever you had use it or not. Understanding it is not a bad thing. A well known thing is Go don't…

Magic in redux-go v2.1: package rematch

6 min read • 7/4/2018, 12:00:00 AM

A few days ago, I release the redux-go v2.1. The purpose is: create reducer & action then manage relationships between them is pretty hard…

Error is Value

3 min read • 6/22/2018, 12:00:00 AM

I think most Gopher had read error-handling-and-go. Has anyone had watched Go Lift? Let's getting start from Go Lift! The point of Go Lift…

How to get start with Rust

3 min read • 5/26/2018, 12:00:00 AM

Rust is a strange language. Moving First point is move semantic. What do you expect? & is ? No! says: This error tell you why you got a…

Design of Redux-go v2

4 min read • 5/17/2018, 12:00:00 AM

Redux is a single flow state manager. I porting it from JS to Go at last year. However, there had one thing make me can't familiar with it…

Some thinking from Elixir X Ruby Conf

2 min read • 5/1/2018, 12:00:00 AM

Although title contains Ruby, but I won't talk too much on it, because I did not learn it. This conf is my first conf. I learn something at…

Go Channels 入門

5 min read • 4/23/2018, 12:00:00 AM

閱讀此篇之前,我假設讀者已具備 知識,一點 CS 常識,和一些讓子彈飛的技巧(師爺?師爺?) 說起 的 ,要從CSP(Communicating Sequential Process)模型說起 在電腦科學中,CSP 是一種形式語言,描述非同步系統中各種interaction…

Nginx 安裝與啟動

2 min read • 4/2/2018, 12:00:00 AM

這篇只是隨便紀錄一下好不容易終於弄懂的 Nginx ,首先各個平台安裝方式應該直接上網查詢 官網下載頁 最基本的啟動方式通常是 ,不過各平台可能有差異,應以實際位置為主 指令 設定流程 把設定檔放在 下,請根據系統到 Nginx 的設定檔目錄中尋找這個目錄 p.s…

Phoneix 安裝與啟動

1 min read • 3/31/2018, 12:00:00 AM

這幾天好不容易有機會試玩 Elixir 的神奇框架 Phoenix 首先要用 mix 下載 phoenix 另外也需要 node, npm 等相依 預設使用 postgreSQL 作為資料庫 Phoenix 與 Rails…

How to disable Go test caching

1 min read • 3/17/2018, 12:00:00 AM

Go 的測試有一個很討厭的行為,那就是 test caching,它會儲存測試的結果然後導致失敗沒有被發覺 如果你的 Go 版本是 1.9,你可以嘗試用命令執行測試 參數會取消 test caching 你還有其他選擇,例如,這也會取消 test caching…

Introduction Of Char Recognizing -- Lexer Tech

4 min read • 2/25/2018, 12:00:00 AM

此篇使用 Rust 作為演示實際程式碼的語言 說到 Lexer 技術,大家應該都會想到正規表達式,但是為什麼是正規表達式呢? 所以我們要介紹整個掃描並辨識字詞的技術與原理 最簡單的辨識單字技術是大家都能直接想出來的方法,就是 character-by-character…

Create a WaitGroup by yourself

2 min read • 2/15/2018, 12:00:00 AM

If you had written any concurrency code in Go, I think you could seem before. Today's we will focus on create a wait group by channel trick…

Sort by interface in Go

2 min read • 2/14/2018, 12:00:00 AM

Sort is an operation very often to use. Although a isn't too long. We still don't want to create it again and again. It also doesn't have…

The best practice of Singleton in Golang

1 min read • 2/12/2018, 12:00:00 AM

How to implement singleton in Go? It's really a problem at there. And worth to think about it. Start Let's consider how to create a…

You should know about `this`

4 min read • 2/9/2018, 12:00:00 AM

scope rule is one of the hardest problem in JS. Let's start it. Ok! Now we know the truth: is dynamic. However, we still need to send us…

OpenCV introduction

1 min read • 2/8/2018, 12:00:00 AM

Install(Unix Like system) ffmpeg Download Page OpenCV Download Page Introduction Show Image Compile & Run it.

Erlang Quick Start

4 min read • 1/5/2018, 12:00:00 AM

那麼今天就來介紹說很久但是一直沒有寫的 Erlang 吧! Erlang 是一隻很有趣的語言,它絕對跟你看過的主流語言有巨大的差異,無論是語法上還是思想上皆是如此 首先我們需要安裝環境,請參考官方的 Downloads 接著我們就從 erl 開始吧 輸入指令啟動 Erlang…

Type driven development in C++

1 min read • 12/23/2017, 12:00:00 AM

Let's start from some code. And seems will be only code in this article. Ok, some code be there, why I want to talk about these code? Few…

llvm Go bindings

1 min read • 12/4/2017, 12:00:00 AM

Use command to get llvm project Then Then Then go back to dir go/llvm I had installed Ninja, then build script use it to build system. I…

Vim replace

1 min read • 10/24/2017, 12:00:00 AM

在 Vim 中 找出文字並修改不是一件複雜的事 你只需要 是進入命令模式 和都是行號的代號,你可以用數字 1, 2,…

Extension hack

4 min read • 9/29/2017, 12:00:00 AM

好吧,上一篇說了這麼多,其實幾乎就只是把屬性定義在類別外罷了,沒什麼啊 這樣並沒有比強到哪裡 所以,讓我們來看看吧! hack 1: extension from a temporary protocol…

Swift --extension概念入門

3 min read • 9/29/2017, 12:00:00 AM

雖然 apple 在的文件中註記了 NOTE If you define an extension to add new functionality to an existing type, the new functionality will be available on…

ANTLR v4--introduction

3 min read • 9/3/2017, 12:00:00 AM

今天我想介紹一個強大有趣的工具--ANTLR 這個工具根據我們定義的文法產生處理原始碼的 parser,當然不只是處理程式語言,你也可以用來處理其他資料 安裝 之後會用到的通常是這支程式 因為它用來產生 parser 開始 我們需要建立一個檔案叫,而裡頭的 grammar…

lexer 原理解釋

3 min read • 7/8/2017, 12:00:00 AM

因為 Elz 實在是一個遠超我一開始的預想的語言(最開始只是想了解編譯器,乾脆就開始設計新語言了) 打造花了我很多心思,Elz 採用先從原始碼中取得詞素,再分析詞素的設計 這樣一來兩邊都可以降低實作的複雜度 分成與兩大主軸工作之後,考慮到效能,我沒有採用 lex…

C++ thread 基礎

4 min read • 6/26/2017, 12:00:00 AM

使用標準庫的 thread 非常容易 1.引入標頭檔 2.宣告函式 3.建構一個物件…

©2022 dannypsnl(林子篆)