Archive for January, 2009

Creating a Reverse Sequence of Numbers in Python

Let’s say you want to create a sequence of numbers in reverse order (for example, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1). I tried to do this with the range function, but I couldn’t find a way to do it. But Python has a built-in function called reversed that allows you to [...] Read more »

How to Increase the Priority of a Process in Linux

In Linux, you have the ability to determine which processes are running at a given time on the server. This post explains how to do this using the top command.
Let’s say you have a process that is not getting as much CPU time as you would like, maybe because it is getting beat out by [...] Read more »

Which Linux Operating System Version Are You Running?

Linux comes in many flavors. If you did not perform the installation (or forgot), you may need to find out which flavor is being run on a given box. In Linux, it is pretty easy to do this. Simply type the following command at the command line, and it will give detail about it:

cat /proc/version Read more »

Find the Difference Between Two Dates in Java

Sometimes when you’re writing a program, you want to be able determine the difference in time between two dates. This might be because you want to see how long it took something to run, or you might be processing data and need to find a time span between two events. In searching around the Internet, [...] Read more »

How to Round Numbers (double, float) in Java to Number of Decimal Places

<rant>For some strange reason, Java doesn’t have the ability to round numbers to a given number of decimals. This seems like such an obvious thing to include in any programming language.</rant> Anyway, you can round to the nearest integer, so you have to a little workaround to round to a given number of decimal places. [...] Read more »

Find the Mean/Average of a Number List in Python

To my knowledge, there is no built-in function in Python to find the mean of a list of numbers. You can use statistics packages to do this, such as statpy, but if you just want a lightweight solution to do the trick you can use the function below. Note that on the first line I [...] Read more »