dired-quick-sort: Sort Dired Buffers Quickly in Emacs

While Dired is great for browsing the file system, it is often annoying that the buffer is not sorted in the way we want to see. While Dired provides the flexible customizing variable dired-listing-switches, it is still not convenient to switch between different sorting criteria quickly. For this reason, I created the Emacs extension dired-quick-sort to make sorting Dired an easy story.

Project Homepage


How to Save Money When Shopping Online

As the Internet boomed, online shopping has become more and more popular. While it is perfectly fine to visit Amazon or Ebay and simply click on what you want to buy, you can actually make some extra savings by spending a few more minutes. In this post, I will show you how to do it by shopping for the book Surviving AI: The Promise and Peril of Artificial Intelligence by Calum Chace as an example.

Step 1: Check out the Price on Amazon and Ebay

The first thing to do is to have a broad idea of how much it would cost. I would recommend checking out Amazon and Ebay for this purpose. Why? Because they are the biggest online retailers in the world. In the example of the Surviving AI book, the Amazon page shows that the cheapest new book would cost $14.98 by the time this post was written (you need to click on “21 New from $10.99” to reveal the shipping cost and tax).

Surviving AI at AmazonSurviving AI at Amazon

Continue reading

Common Mistakes of Data Backup

Backup is undoubtedly important for most people with digital data. However, individuals often risk data loss by using dangerous strategies. Here, I will show a few false (and dangerous) notions that people often hold for their data backup.

“External Hard Drives are Enough for Backup”

While you may be well aware of the possibility of external hard drive breaking down and make backups on multiple external hard drives, but it is certainly not enough. Usually, when you make backup on external hard drives or optical discs, you typically store them in your home or in the office. But some extreme situations can happen: fire, theft, earthquake, or some magnets that break all the drives. It is usually considered much safer to make remote backup along with these external drives. To make remote backup, you can either use a simple method such as uploading files to cloud storage websites like Dropbox or OneDrive, or use a more sophisticated approach to make frequent backup easier: use incremental backup software such as Areca Backup or Back In Time along with a backup virtual private server (VPS) such as Backupsy.

“File Synchronization Software is a Reliable Backup Tool”

Many people heavily rely on file synchronization software such as Dropbox, Google Drive, Bit Torrent Sync, Syncthing, etc. to back up. I would say they aren’t really reliable: the data can be lost forever in many circumstances. For example, a software bug, or a corruption of your local disk, may well affect the remote copy that you may even not know for a long time. While you can still use these software as convenient “backup” tools, my recommendation is to make sure you make snapshots: you can always go back if you found a certain file is corrupted. In order for it to be easier to make snapshots, you may wanna try some incremental backup software such as Areca Backup on Windows, Time Machine on Mac OS X or Back In Time on GNU/Linux.

“No Need to Back up Things on the Internet”

Anything on the Internet may disappear someday—even this blog post you are reading. People remove articles, videos and other contents on the Internet all the time for various reasons: commercial purpose (e.g., free contents become paid), copyright infringement, or the content owner simply goes bankrupted. If you really don’t want to lose access to some Internet contents, you probably want to make a local copy and make proper backup copies. For example, for YouTube videos, you can download them via sites like savefrom.net or a software like youtube-dl; for an article, you can save the web page as a PDF file; for an image, you can save them to your local disk by right clicking them in your browser.

Security Checks to Do Before Installing an Android App

Android is one of the most popular mobile operating systems. However, some Android apps can cause security issues if not carefully handled. They can be badly written which leaves a lot of security holes for intruders, or itself acts like a malware/virus. Therefore, before installing an Android app, one need to do some checks to make sure it won’t cause security issues.

Continue reading

Manage Passwords for Multiple Accounts with Checksums

It is often hard to manage different passwords across many accounts: complicated passwords are hard to memorize but simple passwords are not safe. A cloud password manager such as LastPass is not a safe option either: cloud password managers often suffer from various security issues. Besides that, it is not cool to expose your passwords to a cloud password manager company. With checksums, the management can be easily done by ourselves, while still maintaining “good” passwords.

Checksums are small-size strings which can be computed from other strings by specific checksum algorithms. Using the most popular checksum algorithms, such as MD5, SHA-1, etc. the checksums usually look very different from the original string, and changing even a single bit of the original string usually leads to very different checksums. For example, the MD5 checksums of the two similar words “bird” and “birds” are completely different (you can use this website to compute the checksum of a string, or use the md5sum or sha1sum command line utility if you are on GNU/Linux or Max OS X):

string MD5 checksum
bird 87d28160e9215b17645c734ba7170ba1
birds ea5f5a5293a7d404e091c04939ba2ad8

Here the basic strategy to manage passwords is to have the password for each account to follow the “prefix+checksum” scheme. The prefix is the same across all accounts and is similar to the usual passwords, e.g., it can be one of your current passwords — this is what you need to memorize. The checksum part is unique for each account: it can be part of the MD5/SHA-1/SHA-2 checksum of something related to the host, such as the domain of the website, or the name of the company which hosts the account, etc. In this way, only one global prefix is needed to memorize which brings easy management, and the checksum part of each account is unique which brings security. For example, as shown in the figure below, for your account at quitter.se, you can use the MD5 checksum of the string “quitter.se”, which is 00b34f415b15dbea2e9d0611d2cc90f8. Then, with a prefix such as my-password, follow the “prefix+checksum” scheme, the password for quitter.se would be my-password00b34f415b15dbea2e9d0611d2cc90f8. If only part of the checksum is used, e.g., the first 10 characters of the checksum, then the password is my-password00b34f415b.

The “prefix+checksum” scheme.

A Collection of Issues about the LaTeX Output in Sphinx and the Solutions

Sphinx is a powerful documentation generation tool, as well as a powerful book writing tool. It can generate multiple output formats, including LaTeX for printable PDF versions. However, the LaTeX output is often more problematic than the html output. In this post, a collection of common issues and their solutions are listed.

Continue reading

Compute the Index of a Permutation in C/C++

I’ve written a C++ code snippet to compute the index of permutation according to this post:

The code was written to be easily adapted into C code. To adapt the code above to C code, simply replace all template types with the type you want and remove all the template declaration.

Configure Proxy Using PAC Files on Firefox for Android

Firefox for Android does not provide a UI option for users to to configure Firefox to use PAC file for proxy settings, but we can use the about:config page to achieve this goal.

Type about:config into your Firefox address bar, and you’ll see a list of options below. In the search box, type proxy to list all options related to proxy. There are two notable options listed here: network.proxy.type and network.proxy.autoconfig_url. Change network.proxy.type to 2 and network.proxy.autoconfig_url to the URL of the PAC file (Tap on the edit box below the configuration option twice to start edit the option). Close the about:config page and now Firefox should use the PAC file for proxy.

To configure the proxy of Firefox on Android using a given proxy server and port, please see this article.