Archive for July, 2012

View images in slideshow

July 27, 2012 Leave a comment

You have a collection of images and you want to view them in randomized order. In addition, you want to see them in a slideshow and you want to set the delay between the images.


feh -zsZFD 5 .

It will start displaying the images in the current folder. Installation: “sudo apt-get install feh“. More info: “man feh“.

Send email from command line

July 3, 2012 2 comments

I wanted to send an email notification from command line. I launched a program on my desktop machine at my workplace that would require some days to finish. I want to know when it’s finished and I want to get the result too.

The email will be sent via gmail, it’s the easiest solution. Here, Sid explains nicely how to configure ssmtp on a desktop. Here I repeat the steps:

Step one:
Install ssmtp: “sudo apt-get install ssmtp“.

Step two:
Edit the file /etc/ssmtp/ssmtp.conf and add the following content:

For this purpose, I created a dedicated Gmail account.

Step three:
Test if it works: “ssmtp < filename.txt“.

You can also send emails with the command “mail“:

mail -s "Subject of the mail" < result.txt

Use Case
In the intro I mentioned that I want to get the result of a slow program. Here is how I did it: the program writes the result in a file called “result.txt“. When it’s finished, a shell script is called that sends the content of result.txt to me:

time ./pe_211.d && ./

Where looks like this:

mail -s "PE 211" < result.txt

Related links

Miller-Rabin primality test

A very efficient way for testing if a large number is a prime or not is the Miller-Rabin primality test.

Python code is here.

Wikipedia entry is here.

Categories: math Tags: ,