Find duplicate files using fdupes

fdupes is a great little tool that can be used to find duplicate files inside one or more directories. It does this by checking the file sizes, MD5 hashes and a byte for byte comparison of the files.

  • To install the tool:
$ sudo apt install fdupes
  • To ask the tool to find and list duplicate files inside a directory foobar:
$ fdupes -r foobar/

Tried with: fdupes 1.6.1 and Ubuntu 18.04

Advertisements

How to negate image using ImageMagick

The ImageMagick convert tool can be used to negate an image using the -negate and +negate options. -negate replaces every grayscale or RGB pixel with its inverted or complementary color. Use +negate when you want to restrict this operation to only work on grayscale pixels.

Example:

$ convert -negate foo.png inverted_foo.png

Tried with: ImageMagick 6.9.7 and Ubuntu 18.04

How to play WRF file

Cisco Webex sessions can be recorded and the recordings can be saved as WRF and ARF files. There does not seem to be any player for the WRF file format on Linux. If you are using Windows or Mac, you can use the Webex Player here to view the files. There is also a Webex Recording Editor that is available on the same webpage that can be used to render a WRF file to a WMV file. I tried the players and editor on Windows, and they seem to be extremely old Windows apps with basic functionality.

Andy Android Emulator

Andy is an Android emulator for Windows that claims to support a lot of features. Downloading and installing its 875MB package was easy. On launch, it shows a default VM and allows you to create more with different configurations. However, the VMs did not launch on my Windows 10 computer. Andy would not show any useful error message either.

Operation move disabled on this server

Problem

I tried to move or rename a file using the p4 move command. The p4 server responded with this error message:

Operation 'move' disabled on this server

Solution

Since the move operation has been disabled by admins on this server, we need to use two operations to simulate a move.

One way to do this is by integrating the old to the new and then deleting the old:

$ p4 integrate old.txt new.txt
$ p4 delete old.txt

Another less recommended way is to copy the old to the new and then deleting the old. In this example, we do that on entire directories:

$ p4 copy old/... new/...
$ p4 delete old/...

How to disable Focused Inbox in MS Outlook

After my email account was moved to Exchange Online, I noticed that my Inbox in MS Outlook client looked different. The All and Unread tabs were replaced with two new tabs: Focused and Other. This was a new feature called Focused Inbox that intelligently was dividing up my Inbox email into these two categories.

After trying it for a few days, I decided I did not need it. To turn it off, go to View → Show Focused Inbox and turn it off.

How to view files over SSH using SimpleHTTPServer

It is convenient to connect to a remote computer using SSH and work at the shell. But viewing images files and other such common files can be a problem. Using a X server might not always be possible. A simple solution that works for me is to use the SimpleHTTPServer module that ships in Python.

  • Change to the directory which holds the files you want to view from a remote computer.
  • Run the SimpleHTTPServer there and provide a port number for the server:
$ python -m SimpleHTTPServer 8901
  • On the local computer, open a browser and connect to the server using the address: http://put-remote-computer-ip-here:8901
  • You can now view image files and other common file types right in the browser.

Tried with: Ubuntu 18.04

Floating point rounding modes in C++11

The standard C library has 4 floating point rounding modes available through cfenv.h. These are now available in C++11 through the header file cfenv.

  • The 4 floating point rounding modes are:
FE_TONEAREST
FE_DOWNWARD
FE_UPWARD
FE_TOWARDZERO
  • FE_TONEAREST rounds to the nearest integer. If the floating point value is exactly midway between two integers, then it does round half to even. The rest of the rounding modes are self explanatory.

  • None of the 4 rounding modes is equivalent to the round half away from zero which the round method does.

  • Anything to do with floating point operations is dependent on the FPU of the processor. So, the availability of these rounding modes and their values are highly dependent on the FPU of your processor.

  • On my x86_64 computer, all the 4 rounding modes were available and the values of these rounding modes were found to be:

#define FE_TONEAREST 0x000
#define FE_DOWNWARD 0x400
#define FE_UPWARD 0x800
#define FE_TOWARDZERO 0xC00
  • The FPU of your processor may support many other rounding modes in addition to these 4 modes.

  • On my x86_64 computer, I found that FE_TONEAREST was the default rounding mode when I used methods like rint and nearbyint to perform rounding.

How to use vimdiff

Vim can be used as a diff and merge tool. While it cannot match the beauty and power of GUI programs like Meld, it is immensely useful to diff and merge over a SSH session.

  • Vim can be invoked in diff mode either using vim -d or as vimdiff. Just pass in the names of the files to compare:
$ vimdiff 1.cpp 2.cpp
$ vim -d 1.cpp 2.cpp 3.cpp
  • Vim in diff mode displays each file in its own window side-by-side showing the diff sections in colors. You can switch between the windows using the normal Vim commands. (I use Ctrl-W-W.) And when you scroll down all the windows scroll down with you because they are locked to each other.

  • To switch to and fro between diffs use the ]-c and [-c commands.

  • To put the diff the cursor is resting on to the next window use the command dp

  • To pull the diff from the next window use the command do

Tried with: Vim 7.4 and Ubuntu 16.04

How to get the C++ standard

The C++ standard is the definitive source for the language. The committee that works on the C++ standard is called the C++ Standards Committee or Working Group 21 or WG21 for short. All information about this committee is shared at the WG21 website.

WG21 regularly reviews changes to the standard and accepts them for addition to the next standard. These commits are available as drafts that the committee shares to the public for free. However, at a certain magical commit, the committee accepts the last few changes on top of a publicly released draft and blesses that as the new standard. However, the official standard is only available through the ISO for a fee.

Historical drafts of the standard that come from WG21 or the latest draft from WG21 are not of interest to most C++ programmers. What is useful for most folks are the official standards. But, those are not free. So, what folks typically do is to grab the last draft before a standard that they are interested in.

For example, assume I have access to only a C++11 compiler and I witness a compilation anomaly. I would be interested in consulting the last draft before the C++11 standard.

WG21 provides a handy redirection service at wg21.link to obtain all sorts of documents are generated by the committee.

Drafts of standards

The redirection links that can be used to download draft PDFs relevant to C++ standards are:

Build draft from source

The latest draft standard can be compiled from its LaTeX source to PDF for free:

  • Install these LaTeX packages:
$ sudo apt-get install latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended
  • Clone the C++ draft standard repository:
$ git clone git@github.com:cplusplus/draft.git
  • Build a PDF of the standard:
$ cd source
$ latexmk -pdf std

If there are too many warnings, you might need to run the above command a second time. The result is a PDF of the C++ standard!