Blog 1

Random Talk on Random Thoughts

GNU ddrescue—A Powerful Data Recovery Tool

| 0 Comments |

3 days ago, I encountered an error while moving a folder of about 3 GB from my USB stick to my hard disk using GUI. After 1.2 GB of the files are moved, the progress bar of the program just remained unchanged. I left the seat in front of my computer and did something else. Returning to the seat after half an hour, the situation had NOT been better. The displayed remaining time was still “unknown”.

The I clicked the cancel button to stop the process, but it simply hangs. After terminating the process from the “System Monitor” (another GUI program), the read/write speed of the USB stick became extremely low. Instead of blinking frequently, the light bulb inside the USB stick went on and off slowing during a read/write operation.

In /var/log/syslog.1, it says

[  627.152020] usb 2-1: reset high-speed USB device number 4 using ehci_hcd
[  658.128020] usb 2-1: reset high-speed USB device number 4 using ehci_hcd
[  658.493165] sd 3:0:0:0: [sdf] Unhandled error code
[  658.493169] sd 3:0:0:0: [sdf]  Result: hostbyte=DID_ABORT driverbyte=DRIVER_OK
[  658.493174] sd 3:0:0:0: [sdf] CDB: Write(10): 2a 00 00 54 e9 30 00 00 01 00
[  658.493188] end_request: I/O error, dev sdf, sector 5564720
[  658.494531] quiet_error: 39 callbacks suppressed
[  658.494533] Buffer I/O error on device sdf1, logical block 5564658
[  658.495808] lost page write due to I/O error on sdf1

Giving Up Testing MathJax and Anchors on Blogger

| 0 Comments |

In dynamic view, though the code for dynamic loading of MathJax contents has been pasted into the HTML code for the template, things just work in a strange way: in the class mode, MathJax works the best; in other modes, it may not work or it works partially. For example, in a mode, the dollar sign in the code tag is interpreted, and the script file for MathJax is loaded. But when you click a blog entry for a popup frame containing some MathJax code, then it simply won’t load. Nonetheless, anchors don’t work in a desired way in the dynamic view—after clicking an anchor, I am immediately directed to the destination, which is covered by the header. Finally, to ensure that the contents are correctly interpreted, the best way is to use the tex2jax_ignore class.1 Anyways, if readers are also writers of HTML, LATEX, etc, they’ll know what I intend to write by testing the HTML code, and for the remaining readers, I just apologize for the inconvenience caused and suggest them to right click the article in the default “Sidebar” view and press <F5> to reload for the correctly rendered contents. I’ve forgotten about anchors since toggling between the “Compose” and “HTML” modes while writing a new post will cause some strange change in the <href> attribute of the <a> tag.


Guidelines for Setting a Strong Password

| 0 Comments |

I usually suggest users who refuse to use long passwords (> 10 characters) for their online accounts to look at news on GPU password cracking.1 Setting a sufficiently long password is just the first step. The variety of characters to be chosen is also crucial to increasing the time taken for a brute force attack on the password. This idea is supported by the external URL of this post, which is the main concern here.

The problem is not large if the user has some common sense on how the Internet works. However, as a guide for common end users of online services, the last section “Useful tools” is a little bit misleading. If you know some engineering students, he/she will tell you that making things work is their main goal. They can come up with fancy ways to hide standard errors from users. According to our naked eyes, the so called “random password generator” seems to be able to generate random passwords. However, you don’t actually know the algorithm used.2 Are they random enough? Are there any ways of predicting the output of the online password generators? The Community Ubuntu Documentation provides us a three-pronged reason for not actually using the “secure password generators” listed in the last section of CUHK’s guide.

By saying that those tools “may assist you to set a strong password”, the guide is far from wrong, but also far from good. For a proper introduction to a decent password policy for common users, go to the section titled “Write Your Passwords Down” on the same page on Ubuntu’s community guide.3

P.S. The CUHK’s guide have been writen for a long time. As I’ve mentioned above, a GPU cracks passwords much faster than before, so the figures need to be either updated or simply replaced with a link to a web page introducing recent technology on brute force password attacks.


  1. Hack and / - Password Cracking with GPUs, Part I: the Setup in Linux Journal by Kyle Rankin 

  2. Don’t use online password generators in Ubuntu’s Community Help Wiki 

  3. Write Your Passwords Down in the same page in footnote 2. 

Escaping '$' in MathJax

| 0 Comments |

Anyone who are used to LATEX’s $ character$ for switching to inline math mode would like to use the same command for the same thing on MathJax, which suggests the use of backslashed parentheses to enclose an inline math equation. As a result, in the very first part of MathJax’s official documentation, it contains several lines code for that.

After pasting the code inside the <head> tag, the above problem is solved, but this method creates another problem.

Imagine that you want to compare the price of a product of different companies. You then typed two prices on the same line.

1
2
3
4
5
6
<p>...</p>
<br />
<p>Nowadays, it costs nearly $500.  In the past, it only costs around
$300.  It's too expensive!</p>
<br />
<p>...</p>

Then the web browser will interpret the contents in this way:

wrong contents

In order to get the problem fixed, I searched “mathjax escape dollar sign” and found a Stack Overflow question very useful. Following the first answer for the question, I managed to get it right. That is, to change the it like this:

1
2
3
4
5
6
7
<p>...</p>
<br />
<p>Nowadays, it costs nearly <span class="tex2jax_ignore">$</span>500.
In the past, it only costs around
<span class="tex2jax_ignore">$</span>300.  It's too expensive!</p>
<br />
<p>...</p>

correct contents

Don't Kill a Fly With a Cannon—Console Creation of GIF Files

| 0 Comments |

As the saying goes, a picture is worth a thousand words. Some netizens believe that if a picture tells the truth.

If you want to take a screenshot in GNU/Linux text mode, you may use fbgrab to get a PNG file (fbcat gives you a PPM file).

If you want to illustrate a process with a series of pictures, then you’ll probably need a GIF file. GIMP provides an easy way of creating GIF files by selecting menu items and clicking a few buttons, but for geeks who are used to CLI, this is not the final answer for them.

If your source PNG files are named as [name]%s.png, then the right command is:1

$ convert $(for ((a=0; a<700; a++)); do printf -- "-delay 10 \
> [name]%s.png" $a; done;) [result].gif
  • -delay 10 means that each image is displayed for 0.1s.
  • [name]: file name of the source PNG files without the ordinal number.
  • %s: the n-th PNG file.
  • [result]: file name of the target GIF file.

Without the whitespace between png and the ending ", things won’t work.

If the GIF animation has not been finished and intermediate files need to be saved, don’t use the GIF format, use MIFF instead.2


  1. Creating a GIF animation from PNG files on Unix & Linux Stack Exchange 

  2. GIF Animations and Animation Meta-data in Examples of ImageMagick Usage (Version 6) 

Don't Remember Keyboard Shortcuts!

| 0 Comments |

Hint: Do not try to learn all shortcuts at once! The human brain isn't made for that kind of stuff, so you will forget almost all of them. Rather, we advise you to learn the 4--5 shortcuts that you find most useful and use them regularly --- learning by doing. Later, you can come back to this chapter to pick up more shortcuts. You will soon find yourself whirling across the command line.

Free Software Foundation Introduction to the Command Line

I’ve found this tips useful. If one can bear this in mind, learning Vim or Emacs will be less discouraging.

My Experience of Using Vim.js

| 0 Comments |

To use Vim in other computers, the official website of PortableApps has already provided users a satisfactory solution. The installation size is about 28 MB (according to the released figure). If you won’t have it installed in a portable device and don’t want to download and install it into a new machine each time, maybe you can try Vim.js. However, I’ve found it slow, when compared to a Vim program.

Vi Key Bindings in Emacs

| 0 Comments |

From Wikipedia’s entry on the Editor’s War, we can see some nicknames of GNU Emacs, such as “EMACS Makes All Computers Slow”, “Esc Meta Alt Ctrl Shift”, etc. I found the second one true. I tried using Viper, but it’s inconvenient to browse info files since the <C-]> button doesn’t work. As a result, I need to toggle Viper using <C-z> all the time. Nevertheless, it’s too inconvenient. Maybe that’s because of my low level of Viper set (level 1), and there are other plug-ins that enables users to use Vi(m)’s key bindings in Emacs, but I’m tired of this sort of tedious work.

After overcoming a steep slope in the very first part of the learning curve of a powerful tool, maybe you’ll find out that there’s some other more productive tool for doing the job. That’s not something new and that’s the reason for so many different tools to come up. For example, Vim is originally intended to be part of the shell, and you’ve spent hours to get a Vim plug-in for GDB integration (e.g. pyclewn). Finally you found out that you forgot that both Emacs and GDB are developed by GNU, and they are the early famous softwares from GNU, so they should work well together. Otherwise, how can GNU encourage users to use free softwares? Therefore, it’s sensible to expect that Emacs has a built-in support for GDB. (And it does!)

Hence, the best way is to be flexible and use suitable tools to do different jobs.

After realising the use of both of the two most famous text editors for *nix users, it’s important for us to get use to them. As a Vim user, reading the official Emacs tutorial available on the homepage of Emacs, I’ve found out that it’s too long if what I need is to do some basic editing work. Some introductory web pages on elementary Emacs commands from some tertiary educational institutions can help some newbies of Emacs, but if you can link up new knowledge with any previously known ideas, it’ll be even better to refer to this post.