How To Revert a Series of Git Commits?

Sometimes, I need to revert a series of commits that I've already pushed, doing a git hard reset (git reset --hard) is not an option, as someone may already have new commits based on mine. For example, assume that I've made a few commits like below: 65a2c62 * commit 10 25cad43 * commit 9 72ad583 * commit 8 ceebf9a * commit 7 acf8a11 * commit 6 28d526f * commit 5 63af1e2 * commit 4 982c71c * commit 3 0fb4c2d * commit 2 acf9da1 * commit 1 b5f9933 * commit 0 For whatever reason, I need to "drop" the changes made by commit 6 to commit 10, that is, go back to "commit 5" without deleting these commits. [Read More]

Generating org-mode Outlines for wikiHow Articles

Recently I found some great articles on wikiHow, then I want to keep notes of them in org-mode files. At first, I manually copied the ToC of articles, but soon I found it's tedious and takes a lot of time. Today I wrote a requests-based Python script to help me extract the ToCs (Table of Content) into org-mode outlines. It takes two arguments, the first one is the URL, the second one is the containing heading's level for the generated ToC in org-mode. [Read More]

Understanding align-regexp of Emacs

Emacs' M-x align-regex is neat when I want to align some similar text, especially when we're coding. I use its trivial version(without prefix arg) regularly on day-to-day programming work before. For example, I can use it to align below code quickly by: Choose the region M-x align-regexp and type = and Enter aaaaaaaaaaaaaa = fields[0] bbb = fields[1] cccccccc = fields[2] It will be aligned to below code, now it's better to read: [Read More]

Fine-tune Curly Braces Style of yasnippet Snippet on the Fly

Yasnippet is a good friend to help us type less and write more, whenever we write some text snippets repeatedly. And there is also an official repository called yasnippet-snippets that contains various snippets for many programming languages(modes), so that we can have many snippets in no time by installing it. But there is a little problem when it comes to conforming to different coding styles. Take the if snippet for example, normally it will generate code like this: [Read More]