Hi there 👋

look inside & keep kind

goplay: Embed Go Playground on your Website

This post is introducing a way to run Go snippets on websites. Which leveraged the official Go Playground service at https://go.dev/play/. Demo Let’s take a quick look at the two demos below. You can click the Run button to see the output of the corresponding program. Click Try it yourself or Share button to open the code in the official Go Playground to further edit/test the code on your hand....

May 11, 2022

Postgres ID Generator with Safe JSON Numbers

Before reading this post, I recommend you to read A Better ID Generator For PostgreSQL written by Rob Conery. To recap briefly, their post had discussed: The problem you will face in the rapid grow of your systems if you used GUID as the primary key. How Twitter generating auto-incrementing keys with Snowflake. Create a functional Snowflake equivalent for PostgresSQL. And the third point above will be the focus of discussion in this post....

June 21, 2021

Decode HTTP Query Params into a Struct in Go

Many people use net/http package directly in Go to deal with HTTP requests, including reading URL parameters, HTTP headers, and the request body. It’s straightforward and efficient, though. We can still get bored writing so much tedious code for just reading and parsing the URL params. Especially when we were maintaining a service with hundres of APIs. Let’s see a piece of code for dealing with HTTP requests by using net/http package:...

May 17, 2021

Deploying an AES-128 Encrypted HTTP Live Stream (HLS)

HTTP Live Streaming (HLS) is an HTTP-based adaptive bitrate streaming communications protocol developed by Apple Inc. and released in 2009. Some key points of HLS: Created by Apple. Consists of a playlist/manifest file (e.g. index.m3u8) and segment video files (e.g. index01.ts). H264 codec of video + AAC of audio. Use HTTP, easily leveraging CDN to reach the widest audience without worring about the bandwidth and firewalls. Adaptive streaming, enables changing the quality of the video mid-stream....

May 10, 2021

Open Source Contribution Workflow Best Practice

Generally speaking, as we were using some open-source libraries we will inevitably find that there are some bugs or points that can be improved. And sometimes we even have to develop a brand new feature based on these libraries to satisfy our own needs. Out of respect for sprit of dedication, contributing our code to these opensource libraries is a good way to give back to the community. My Practice When I decided to contribute to a repository, I will first try looking for if there is a contribution guide for it....

January 8, 2019

Reduce Docker Image Size by Using Multi-stage Builds

If you don’t take any optimization measures, docker images can easily get large. And in most cases we just wrapped too many inessential things into the images. So, we should take actions to get rid of it.

October 13, 2018