# What to Debug when You Are Debugging

Debugging is probably the first task for most of us in practice: Day 1 when you joined the team, someone senior called you to his desk and gave you a defect description, "go and figure out what goes wrong, young boy".

Tablets, smart phones, smart watches...

By making the computing units even smaller, we are trying to bring these intelligent devices much closer to its master, the human beings. From PC to laptops to smart phones, the pioneers have made billions of dollars from their customers, who happily give up the greens for those latest fancy toys.

Now some are trying to replicate the success by offering a smaller accessory: the watch. Samsung is on its way, and there would be a number of well-known names getting on board, too. I am not sure how people would react to the next-gen watches, but I know I am not quite into the thing.

I think smart watch is going to fail...

# Repeat in Vim

There are many ways to repeat something in Vim. Knowing how and when to repeat would greatly save your time with Vim.

Get Started

Natively Vim provides some basic methods to repeat:

• the '.' will repeat the latest operation: if you 'dd' to delete a line, '.' will continue deleting another
• the 'p' pastes contents copied (or in the Vim language, yanked) before. Combined with the use of registers, one can keep multiple copies of different content and pastes them into other places.

Be More Powerful

Besides the basic toys, Vim enables much powerful repeat technique with its record feature, the q command allows to repeat a series of Vim operations, which, when nested or with numbers of repeated operations specified, could be extremely efficient. A life changing feature.

Example: When analyzing logs it is sometimes required to remove the time stamps and compare two logs. There are many ways to remove time stamps in a log file, using the recording feature is one of them. In the example below, I first go into the recording mode, remove the timestamp of the first line, go into the next line, and end recording. The remove-time-stamp operation has been recorded and stored into register 'q'. Because there are still 48 lines to be processed, I simply type '48@q' to repeat the same operation for 48 times and the whole log is cleaned.

Not everyone would think of it but regular expression is another technique that could be used to repeat operations in Vim. And when you used to it, you will give up anything to be able to do regexp in Vim =) There are many resources available for using regular expression (Google is your best friend...), there is even a [website](vimregex.com) just for this topic! I think it would not be very interesting for me to 'repeat' here...

Make Extra Steps

Besides the native support provided by Vim, there are many plugins available out there to further improve your efficiency. Marvim being one of them, makes it easier to store your frequently-used-and-complicated operations and even easier to repeat them.

Marvim allows saving operation macros by name and groups the stored macros by namespace. On the other hand Marvim provides searching the operations by name: especially helpful when you have a lot of operations saved. A simple but illustrative example is shown below for those who are interested.

# Minimal Setup for Remote Access Linux from Windows with X

When accessing a Linux machine remotely in Windows, many might use VNC or similar remote desktop tools. Some might simply use Putty. Both are not quite satisfying: VNC and the like ask for too much network bandwidth when transferring graphical data, while Putty doesn't support X and limits your use to only in the console.

Some might suggest using Cygwin, which will give you access to the X environment without sacrificing much bandwidth (it transfers the graphical parameters instead of pixel value). But still installing Cygwin is a pain, not to metion its huge size, which could be over 1G easily.

Recently I just realize there is a way to get to work remotely from Windows with X setup, and here is you could do it:

• Download a Putty client (I would recommend KiTTY, give it a try)
• Start XMing and then run your Putty client. Enable "Enable X11 forwarding" in Category->Connection->SSH->X11.
• Start a Putty session and try "xclock"

YES! It works! Even better, with minimal space and setup =)

# 开关

9点到了。 “老婆，去洗碗吧” “嗯……你也去洗澡吧。”很明显，她还是趴在网上，没有要去洗碗的意思。看来真的有什么吸引到她了。 哟，敌不动我不动？有点意思。

9点15分。我忽然把视频的声音关掉。 整个房间马上安静了下来。 大概感觉到我要去洗澡了，虽然没有回头看我，但是她挪了挪身子准备起来。 在她的背后，我继续测试，忽然又把视频声音打开。 “嗯……”伸了个懒腰，她又挪回到原来的姿势，继续趴网。 再次把声音关掉，眼前的这个家伙又开始挪动准备去洗碗。 “哈哈” 我忍不住笑出来，结束了我的测试。 “果真是我不动你也不动哦！”全盘托出我的试验之后，她也没忍住，不停的笑骂我的心机太重。

# Hello Octopress

This weekend I decided to migrate this blog from Wordpress to Octopress, because of many reasons searchable in google, and because with Octopress now I can write posts anywhere with Vim and Git. To help those who are now exploring Octopress (and myself sometime later), I've made some notes on the obstacles that I've seen as well as the solutions:

Migration from Wordpress to Octopress

The migration was pretty easy, once you export from Wordpress to an XML file, exitwp generates the markdown files for you with a few key strokes. The only thing lost during the migration is the comment, but your life would made easy if you are going to use Disqus:

To move your comments from Wordpress to Octopress, first install the Disqus plugin on your Wordpress and then export the comments into Discus. It is said that the import might take up to 24 hours but I guess it will be much shorter for many of us. After the import completes, go to [your account].disqus.com/admin/tools/migrate/, build a CSV file following the example and upload the file for URL mapping. That is it for comment migration. Easy~

Customization

The next step is customization. There are not too many themes available for Octopress when I setup this site, and it appears that I have two options if I need something different:

1. follow the instructions @ the official site
2. get the Slash theme

As you could see I am too lazy to hack and therefore just go for option 2.

Localization Support

For bloggers who write posts in Chinese, the current Octopress has a limitation: lack of Chinese category support. There are also two ways out:

1. To name the categories under 'category_dir' in Chinese codings like RFC1738. This method works when I preview the pages locally, but failed after deploying the changes to Github.
2. To name the categories in english, but display the nick names (in Chinese or other localizations). The second method asks for not only changing the category_generator.rb, but also some of the framework files. It works perfectly locally and on the server side. I would recommend this approach.

LaTeX Support

Even though Octopress claims itself as A blogging framework for hackers, LaTeX is not supported by default. To blog with some mathematics, you could try the following to obtain this capability:

1. in _config.yml, change

markdown: rdiscount

to

markdown: kramdown

2. install kramdown by doing

gem install kramdown

in bash

<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

1. try the following

R_{ab} - {textstyle 1 over 2}R,g_{ab} + Lambdag_{ab} = kappa, T_{ab}

and you should see

R_{ab} - {textstyle 1 over 2}R,g_{ab} + Lambdag_{ab} = kappa, T_{ab}

# God Might Be a Supercomputer

This will be a very unique article in the blog: it tries to depict my imagination of God that comes to me when I was coding.

God is a supercomputer, while we are just some little dum devices, some with a 8051, quite a few with MSP430. God designs and creates all of us, giving us the ability to run programs, which also by him.

God writes bug free programs, which are specialized to each device. There is no defect in God's programs, when the programs are correctly run, all little devices do well.

God loves everyone he creates and give them freedom. God loves us so much and gives us the freedom to choose what to run, otherwise we will be puppets that can only run the program downloaded. Therefore each device has the freedom to run whatever it likes, including those not designed by God.

God feels sad when his creation doesn't follow his design. God loves his creations and provide them the best (program). When we do something other than the program offered by God, he will be sad because he knows that is not for us.

The Bible is God's design book, from which one could learn God's design and know what his program is. By reading the bible we know what God's program looks like, and only when we know what is God's design we would be able to tell his program from others.

Knowing God is a supercomputer, we could answer many questions easily:

• Why doesn't God help me even when I pray and ask for his help so badly?

God has designed the best program for you and given you the freedom to run it. He will not help you because if he does he would either have to change the program, or force you to run his program. He will do change the program because God write bug free programs, he has offered the best program. No change is needed, nor possible. He will not force you to run his program because God loves everyone he creates and give them freedom.

• Why do I need to read the Bible?

You don't have to. But if you do, you will have a chance to know what God's design is for you. And you know what is the correct decision to make when you are facing challenges. If you know what is the right thing to do and do it, you make no mistakes and will not regret because you've run the program provided by God. This is because The Bible is God's design book and God write bug free programs.

• I don't see what I am doing is wrong, though people in the Bible study group disagree. Can I just do it?

You can do anything you like because God loves everyone he creates and give them freedom. You have the freedom. But if you choose not to follow God's program you will definitely make mistake and regret because God writes bug free programs. You don't see anything wrong not to follow God's instruction because God is a supercomputerAs little devices we have too simple instruction sets and therefore would not have the capability to understand what can go wrong and how. Simply follow God's program and everything will be fine.

• I know I did something wrong, can I make it up by repenting? I have no time to read the Bible. Other than that, would God help me?

When you did something wrong, your life is off the design by God. Depends on the mistake you made, it might bring you back by repenting. It might also ask for more to correct your mistake. God's help is in the Bible. The best way to correct your mistake is to turn to the bible and to do what it tells you to. Other than that God will not help to do anything, because:

1. God writes bug free programs for you but you choose not to follow.
2. The Bible is God's design book and you choose not to read.
3. God loves everyone he create and gives them freedom so he will not force you to do the correct thing.

I am not sure if the above is truth, as no one could say it is wrong. But I find it logical and helpful to clear many confusions. Hope that helps you, too =)