Syntax Highlight Command Line Tool

As a software engineer I found myself pretty often in needs of showcasing a piece of code in a document or presentation. While coding, we have IDE and editor tools like VSCode for highlighting the syntax, to make it more readable. However, for the software not designed for developers, usually there’s no such syntax highlighting feature for code. I think explaining your code and idea is critical for software engineering, so syntax highlighting in documents and presentations is as important as for development. With that in mind, I wrote a piece shell script that helps you syntax highlighting code snippets for MacOS:

function shl() {
pbpaste | pygmentize -l \$1 -f html -O style=monokai -O full=True > /tmp/highlighted-code.html
open /tmp/highlighted-code.html
}


To use it, you need to install Pygments first, you can run

...

Boost Productivity with Showcase-driven Development for Mobile or Front-end App

In recent years, I’ve built many React Native mobile apps and React front-end apps. I kinda like the idea of React component, it’s really nice you have a clean interface for UI views and make them pretty predictable and reusable. Besides React, the most exciting thing I’ve learned from the community is actually Storybooks. I think it’s a game changer and the same idea can be also applied to native iOS development and other UI-based apps, and it can boost development productivity greatly and also bring many other great benefits.

...

How UIPushBehavior instantaneous mode works

Today I worked with UIKit Dynamics for implementing some physical based UI effects. It’s the first time I use it, I was really impressed how easy it is to bring awesome physical UI effects in your app. Usually physical engines only available in games, but it’s really cool that Apple brings this kind of technology to iOS environment just for building UI.

While I was using it, there is one thing that confused me. That’s UIPushBehavior’s instantaneous mode. For UIPushBehavior’s another mode continuous, it says very clearly in the document

...

UICollectionView invalid number of items crash problem and solution

Recently, I am working on an iOS project that has an UICollectionView in it. For updating items in the collection, I wrote code like this

collectionView.performBatchUpdates({
switch update {

Basically, whenever the data source updates the items, it runs this piece of code to insert or delete items in the UICollectionView. The code looks pretty straightforward, but sometimes it crashes. The exception looks like this