Understand the Token Bucket Algorithm in 15 Lines of Python Code

When transmitting data over a network, to prevent network congestion, it’s necessary to limit the outgoing traffic so that data is sent out at a relatively uniform speed. The token bucket algorithm achieves this functionality by controlling the number of data packets sent to the network and allowing for burst data transmission. What is a Token? From the name “token bucket,” it seems to be a bucket filled with tokens. So, what exactly is a token? ...

March 20, 2018 · 3 min · Zhiya

The Person Who Loves You the Most Will Help You Understand Blockchain Without Breaking a Sweat

Blockchain is a hot topic these days. You can hear people talking about blockchain or trading cryptocurrencies in any office building elevator. Through this article, I hope to give you a comprehensive understanding of the concept of blockchain. After grasping the concept, the next article will demonstrate how to implement a blockchain network with approximately 300 lines of Python code. Blocks and Chains A block is, well, a block (what else could it be?), and when you link these blocks together one by one, like a chain, it’s called a blockchain (hold your thoughts, keep reading). ...

March 14, 2018 · 4 min · Zhiya

No More Fear in Interviews: Understand the LRU Algorithm with 20 Lines of Python Code

The LRU algorithm is a common topic in backend engineer interviews. This article will help you understand the LRU algorithm and ultimately implement a cache based on the LRU algorithm using Python with ease. What is a Cache Let’s look at a diagram: when we visit a webpage, the browser sends a request to the server, which processes it and returns the page to the browser. When multiple browsers access simultaneously, multiple requests are initiated in a short time, and the server has to perform the same series of operations for each request. This repetitive work not only wastes resources but can also slow down response times. ...

March 6, 2018 · 4 min · Zhiya

Convert PDF to Word Using 60 Lines of Python Code with Multithreading

In the workplace, we often encounter situations where we need to extract text from PDF files. For a single PDF, copying and pasting doesn’t take much time, but what if you need to convert a large number of PDFs to Word documents? Today, I’ll teach you how to use 60 lines of code to achieve multithreaded batch PDF to Word conversion. If you’re not interested in the detailed process, you can skip to the end for the code. ...

March 3, 2018 · 3 min · Zhiya

Attempting to Hack Scores in 'Snake Battle'

Yesterday, a classmate recommended a popular game called “Snake Battle,” which has recently climbed to the second spot on the App Store’s overall rankings. Whenever I had some free time over the past couple of days, I’d pull out my phone to play a few rounds. However, I hit a bottleneck in the endless mode around 3000 points, so I decided to take a closer look at the game’s API purely out of curiosity… ...

August 28, 2016 · 3 min · Zhiya