0%

Preface

Python can handle precision of floating point numbers

That’s one of the common findings from Google when searching “Precision in Python”.

In one of my company’s projects, I need to either multiply a number or divide a number by 10^8, and return the result in string format. In primary school Math class, we can move the decimal point forward/backward and add/remove zero accordingly along the way. However, when I start doing this task with * or \ directly and apply str() to the result in Python, things began to get really complicated and interesting, results like "0.08353999999999999" (a precision issue) and "1e-08" (a representation issue) are returned.

Read more »

Preface

Python does not have the ability to explicitly specify variable types. All variable types are inferred based on assignment. This may lead to runtime error such as "str" + 1 (this only produces unintended/unexpected result in JavaScript though), it also prevents editor to offer valuable suggestions.

Mypy is a static type checker. In one of my company’s project, I noticed mypy.ini sitting in the project directory, but not being utilised. After some research on mypy, I decided to add its support together with pre-commit. This blog post discusses mypy usage briefly, but focus more on the configurations of files to be checked or excluded in the context of mypy and pre-commit hook configuration.

Read more »

Preface

Sometimes, I might need to insert images into a blog post. The pain point I had earlier is storing image somewhere and copy that path inside the blog post in an organized manner. After some research online, I decided to use an image hosing service (imgur) with a VS Code extension (picGo) to faciliate the upload and link generation process.

Read more »

Preface

Hmm, another article talking about Markdown?

Well, I am not going through the Markdown syntax one by one in this article, I am pretty sure they are quite easy to master after some practices. But instead, I will talk about some hidden parts (at least to me😅) of the Markdown syntax, especially after using markdownlint extension.

If you are looking for a quick Markdown Cheat Sheet, you could refer to Markdown Guide. In summary, all basic syntax are supported for hexo with next theme (I am not sure whether theme matters, but let’s be precise); for the extended syntax, Table, Fenced Code Block, Definition List, Strikethrough and Task List (not sure the purpose of this in a blog article though) are supported. That’s good enough for writting a good blog article with Markdown, hooray🎉.

Read more »

Preface

As I will be writing lots of Markdowns, I spend some time researching VS Code Markdown extensions and creating snippets to enhance the writing experience.

Read more »

Deploy to GitHub Pages

Creating a GitHub Pages site is quite simple. With a GitHub account, a <github-username>.github.io repository could be created.

Once GitHub Pages repository has been successfully created, the next job is to generate static files and deploy them to GitHub Pages reposity to host.

Read more »

Preface

As a new year resolution, I would like to be better than last year. In the technical aspect, I think starting a blog might be a good way (provided I could keep this habit). I used hexo before, however, due to issues with organizing blog articles and the ugly defaul theme, I stopped after a few articles. After organizing all my browser bookmarks last week, I got some inspirations on how to organize things, hence I am starting a new hexo blog again. Let’s see how far this time I could go.

But firstly, I decided to fix some issues I faced before, to keep my interest and form a habbit of good structure with tags and categories.

Read more »