Programming

Moving completed downloads to a different directory in aria2

By default, aria2 does not move completed downloads to a different directory than the one where downloads started. However, this behavior can be customized through the aria2 event hooks.

"Directory index forbidden by Options directive" in Phusion Passenger 5

You may get a 403 Forbidden error code for a Rails 2.3 application under Phusion Passenger 5. And the corresponding error message in the log is similar to Directory index forbidden by Options directive: /webapps/xxxxxx/current/public/. Well, the cause of this error may be totally unrelated to the Options directive in httpd.conf.

Reading Java SE 8 for the Really Impatient by Cay S. Horstmann, Addison-Wesley (2014)

Eagerly anticipated by millions of programmers, Java SE 8 is the most important Java update in many years. The addition of lambda expressions (closures) and streams represents the biggest change to Java programming since the introduction of generics and annotations.

Now, with Java SE 8 for the Really Impatient , internationally renowned Java author Cay S. Horstmann concisely introduces Java 8’s most valuable new features (plus a few Java 7 innovations that haven’t gotten the attention they deserve). ...

Check if two integer iterators have the maximum distance of one

Given the interface IntIterator defined in the following, implement the method isDistanceZeroOrOne(IntIterator a, IntIterator b) to return if the distance between a and b is at most one, where the distance is defined as the minimum number of modifications to make them equal to each other. Modifications can be: 1) change an int in a. 2) insert an int to a. 3) remove an int from a. For example, the method should return true for 1, 2, 2 and 1, 3, 2, 2.

Implement an H() method and an O() method to produce a water molecular

Both methods are to be called by multiple threads. Each thread calling either method becomes blocking and when one thread finds that there are already at least two threads calling H() and at least one thread calling O(), let two threads calling H() and one thread calling O() resume from blocking in order to produce a water molecular.

Paint a row of houses with the minimum cost

There are a row of houses. Each house can be painted with three colors: red, blue and green. The cost of painting each house with a certain color is different. No two adjacent houses have the same color. Paint the houses with the minimum cost.

Fixing Toyota RAV4 2010 engine under cover

It was snowing and I wanted to check if I could get out of the accumulated snow around my car without plowing. Then I noticed that the plastic cover under my car had one corner loose and was hanging half way to the ground. I had no experience fixing any car issue, but I eventually did not want to take to a dealer to be charged an arm and a leg for such a small and obvious problem.

Seagate Backup Plus 5TB USB 3.0 desktop external hard drive disassembly

For some untold reasons, a hard drive with enclosure is much cheaper than a bare hard drive. That was why I needed a bare drive but I ordered this 5TB enclosure and had decided to take out the drive as soon as it arrived.

Implementing "press any key to continue" in Java

Well, strictly speaking, it is "press ENTER to continue".

Sums of every n rows in a column in Excel

Suppose there is a column of data points. We want a new column of data points which consists of the sums of every n data points in the old column continuously. For example, if there are 1000 data points in the old column, and we want every 5 data points to be summed up to a new data point, there will be 200 data points in the new column.