Blog 1

Random Talk on Random Thoughts

Search and Replace in Vim's Visual Mode

| Comments |

If you want to select some lines of text and search for a word to replace in Vim, many users will do it like this:

  1. Use v to do the selection.
  2. Press : to start inputting an editor command.
  3. Use s/<pat>/<text>/g to search and replace text.

Observation: :'<,'>s “applies to whole lines”.1

How about an arbitrary visual selection?

According to a Vim tips found in the footnote, the answer is quite simple—insert the \%V atom at the beginning of the search pattern.


  1. Search and replace in a visual selection—Vim Tips Wiki 

Writing Dollar Signs on Octopress Blogs With MathJax Support

| Comments |

Problem

When I was writing my previous post, I typed three $ in one single paragraph. Although I’d tried adding \ in front of $1, part of the words between $ are still parsed by MathJax.

Solution

According to another page in MathJax’s official documentation, this problem can be solved by surrounding the dollar sign by a span tag with class tex2jax_ignore2, i.e. <span class="tex2jax_ignore">$</span>.


  1. MathJax $\rm \TeX$ and $\rm \LaTeX$ Support— MathJax 2.4 documentation 

  2. The tex2jax Preprocessor—MathJax 2.4 documentation 

NoScript ABE Rules for WLAN Web Portal Login

| Comments |

Objective

To browse the web safely.

Background

To block malicious scripts from running inside the browser ⇒ I installed NoScript plugin in Firefox.1

Problem

Similar to the one described in InformAction Forums: I couldn’t log on to the web portal of a WLAN.

For ordinary netizens who don’t have time to read the post on InformAction Forums, I’ve prepared a screenshot to depict the problem.

fig1

My Git Command List (1)

| Comments |

Since I have poor long-term memory in commands, I’ll write down the Git commands that I know.

This list is written for my reference only. Therefore, I won’t include everything. I’m going to write some basic stuff, so that I can review it if I’ve forgotten it. If you want detailed explanation for a command, find the documentation instead. If you’ve encountered a problem using Git, the best teacher is, in general, a search engine.

Undo an Amendment to a Git Commit

| Comments |

Objective

To undo the command git commit --amend.

Background (TL;DR)

Tonight, I changed something in a Git repository, and wanted to write a Git commit, but I carelessly ran git commit --amend, instead of git commit --all. As a result, I was brought to a Vim buffer which showed the commit message of the latest commit. I quit the editor with :q. Unfortunately, the SHA-1 name of that commit was replaced with another one. The original latest commit had been pushed to GitHub. In other words, I amended a pushed commit—this is an absolutely bad practice!1 Therefore, I need to undo the “amendment” to the commit.

九成人感眼睛疲倦 藍光加快退化

| Comments |

[眼科視光師]黃偉雄指,市民應避免長時間使用電子產品,勿在黑暗中使用電話和電腦,同時應與螢幕保持視距,實行「20-20-20」口訣 (用眼20分鐘,便休息20秒,眺望20呎遠方) 。

AM730

(Last changed on AUG 30, 2014)

Unfortunately, I haven’t find out how to include Octopress’s linklog feature into my Octopress blog. Therefore, I’ve to use blockquotes again, so as to include to link to a news report about the negative impacts on one’s eyes after using looking at the monitor for a long time.

I can now include a linklog in Octopress. See my newer post for details.

常玩手機腦生鏽 14%青年無記性

| Comments |

機不離手會令腦生鏽?美國有研究發現,18至39歲年輕人中有14%記憶力變差,相信與經常使用智能產品有關。本港專家指,20歲後腦部發展踏入衰退期,如過分依賴數碼產品,又無鍛練腦筋,長遠會加速腦退化。

晴報

After reading this piece of news from Sky Post last week, I’m glad that I don’t have to reply any WhatsApp message.

The Chinese article cited a news report in the Daily Mail.1


  1. Technology is turning us absent minded, researchers claim as it’s revealed one in 7 young adults suffer memory lapses in the Daily Mail by Fiona Macrae. (URL

My CSS Settiings for Printing (1)

| Comments |

Objective

To set up a printer-friendly framework for blog posts/pages.

Background

Two months ago, in order to install Clapper’s image popup plugin in this blog1, I studied the source code of his blog on GitHub. In this process, I learnt the roles of /sass\/(custom\/_)?(screen|print).scss/. (To be concise, I write a Perl regex.) Lacking time to learn CSS, I just directly copied Clapper’s CSS settings for printing.

Problems on the printed page

  1. Missing author and date
  2. Screenshots were too large and part of them flowed out of the page.