A Beautiful Linear Time Python Regex Matcher via NFA

NFA_demo

I came across a problem on leetcode a few days ago. It asked me to implement a simple regex (regular expression) matcher which supports both ‘.’ and ‘*’ qualifiers. A brute force algorithm for this simple case alone could end up an exponential time efficiency, not to mention if it were to support all basic regex operators, i.e.…

Fix Python graph-tool “couldn’t recognise svg” Problem

After I had installed graph-tool and gtk+3 via homebrew and tried to run a graph-tool demo, I came across the following problem:

I then did a little bit Googling and found out that this was caused by a lack of SVG lib ‘librsvg’ for homebrew’s gtk installation. However, a simple homebrew installation of that lib didn’t fix…

How to Set a Key Binding in Sublime Text Based on the File Type the Command Is Running on

In my Sublime Text 3, I use JsFormat to format my javascript source code. Its key binding follows:

I have noticed that the JsFormat used the selector context operand to make sure that the js_format command would only run on file types “.js”, “.json” or “.html”. This is to avoid key clashes with other…

Universal Keyboard Shortcuts for Text Editing

shortcuts

When editing text, the following list of keyboard shortcuts should work universally across applications and operating systems. For example, in Microsoft Word, in Internet browsers, in Unix-like system’s terminal, or in those text editors. They will work if they are not conflicting with existing application specific shortcuts. They should become your muscle memory to enable…

Alfred Workflow: Skype Call 2.0

An Alfred workflow to make Skype phone call to the phone number selected by Alfred’s Contacts feature. If the Skype hasn’t been opened yet, this workflow will open it and ensure it is online before starting the phone call. When making a phone call, this workflow won’t change your Skype online status, and no annoying confirmation dialog…

Fix Mac OS X Mountain Lion Laggy/Choppy Animations

This choppy animation problem has been keeping bothering me since I upgraded from Lion several months ago. However, I don’t want to apply the classic Windows remedy, i.e. to reinstall everything from scratch, as I love my 4 years old Mac OS X very much. I did some research in Google and found the following…

Patches for Tw2other 1.0 by cluries on github

Cluries‘ Tw2other is a PHP program that allows you to broadcast your Twitter tweets to popular Chinese social networks, such as 人人网 and 新浪微博. However, as in version 1.0, the author decided to completely rewrite the codes of previous versions, and it’s in an incomplete state at the moment. If you try to run the…