Category Archives: FOSS

Free and open source software

Raspberry Pi – Video loop

Here is a nice week-end project, useful for automatic presentations, restaurant menus and waiting room video entertainment/marketing/information (my case).

I used a 32″ TV with a Raspberry Pi B (512 Mb RAM), a Wifi Adapter and a 64 Gb SD card (40 $CND at Costco) to create a simple video looping device.

My goal is simple, I want to use SFTP to upload videos in a folder, and have a simple Debian service loop and play each video file one by one.

Since I am not always here to restart the service, a simple reboot of the Pi (by unplugging) should restart the whole thing. No technical knowledge required !

Here is how I done it:

  1. Create nice corporate information slide deck
    • I suggest creating a visually interesting Powerpoint Presentation, with FULLY automated transitions and animation.
    • Test the presentation in Powerpoint.
    • Once it is perfectly tuned, export the Powerpoint to a MP4 video (sadly, only possible on Windows, not MAC OS)
  2. Setup the system
    • Install Raspbian with NOOBS on my 64Gb SD Card
    • Log-in with the pi user
    • If needed, setup wifi
      • type : startx
      • In LXDE, use the “Wifi” tool to setup the network
      • Exit LXDE
      • Reboot (sudo shutdown -r 0)
    • As a principle, I always upgrade the debian package and install vim (both are optional)
      • sudo aptitude upgrade
      • sudo aptitude install vim ctags
    • As we will use the CLI based Raspberry Pi Video player, omxplayer, there is no need for other software.
  3. Create the looping “application” (2 scripts and a folder)
    • Create a /home/pi/movies folder
    • Use your favorite SFTP client (ex: Mozilla) to push the corporate and other movie files to the Pi
    • Create the loop script (mine is named ~/declicTV/
  4. mkdir /home/pi/declicTV
    cd /home/pi/declicTV

The code is greatly inspired from here.
I have made a few improvements:

#first version from

# set here the path to the directory containing your videos

# you can normally leave this alone
SERVICE_OPTS="-o hdmi -n 3 -b"

# now for our infinite loop!
while true; do
        if ps ax | grep -v grep | grep $SERVICE > /dev/null
        sleep 1;
        for file in $VIDEOPATH/*
                echo $SERVICE $SERVICE_OPTS "$file"
                #Display Files
                $SERVICE $SERVICE_OPTS "$file"
  • Then, it is a simple matter of adding a script to init.d, just like explained here.
    • Don’t forget the update-rc.d part.
    • Here is my init.d declicTV script:
#! /bin/sh
# /etc/init.d/declicTV
# taken from

# Some things that run always
touch /var/lock/declicTV

# Carry out specific functions when asked to by the system
case "$1" in
    echo "Starting script declicTV "
    nohup /home/pi/declicTV/ > /home/pi/declicTV/videoplayer.log &
    echo "Stopping script declicTV"
    killall -9 -r
    echo "Usage: /etc/init.d/declicTV {start|stop}"
    exit 1

exit 0

I hope this will be helpful to you !

CentOS and VirtualBox NAT Port Forwarding

In my recent experiments, and while preparing for my next post, I stumbled on problems when trying to forward ports of my CentOS Guest VM to my Mac OS based browser. For some reason, even if Port forwarding was properly configured, like so :

Virtual Box Port NAT port forwarding on CentOS
Virtual Box Port NAT port forwarding on CentOS

…my Host system browser could not connect to services on my VM, with the exception of SSH. The solution was simple, CentOS comes with default netfilters rules built-in. These rules allow outgoing trafic, and incoming SSH requests only. The firewall configuration needed to be changed. The simplest way to do so is to disable the firewall completely:

# Run as root !
# Flush (discard) all rules
iptables -F
# Save configuration permanently
/sbin/service iptables save

While this may be very good for VM usage, I don’t like to disable a whole firewall (I feel unclean afterwards when I do). Here is a more sensible solution, that could be a starting point for a more solid security setup :

#Again... as root !
#See config
iptables -L
#save config
iptables-save > /root/iptables-save.txt
#edit config (see below for example)
vim /root/iptable-save.txt
# flush + load config
iptables-restore < /root/iptables-save.txt
# Validate
iptables -L
# Save for good
/sbin/service iptables save

For reference, here is my iptable-save.txt file:

# Generated by iptables-save v1.4.7 on Thu Jul 24 08:28:03 2014
:OUTPUT ACCEPT [471:1082248]
-A INPUT -p icmp -j ACCEPT 
-A INPUT -i lo -j ACCEPT 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 7222 -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 8777 -j ACCEPT 
-A INPUT -j REJECT --reject-with icmp-host-prohibited 
-A FORWARD -j REJECT --reject-with icmp-host-prohibited 
# Completed on Thu Jul 24 08:28:03 2014

It should work immediately, but to test the “iptables-restore”, you should reboot. Main reference:

Favorite Crunchbang admin commands

I found this script and made a menu shortcut to shutdown my netbook screen and fix the resolution for my external monitor. Here are both commands:

# Close my netbook screen and adjust resolution of ext. monitor
# Labels can be taken from "grandr" command
xrandr --output LVDS1 --off &
xrandr --output VGA1 --mode "1680x1050" &

Also, I often need to administrate the network connections as root (ex : to add a permanent static configuration to the wired card).

sudo nm-connection-editor

Display personal goals as QR Poster

I recently had this idea to display my life goals as a poster in my home office underground lair. The design is composed of 4 life goals and 16 proverbs, and displayed in a frame.
Here is the final result:

Please don't scan :-)

The project was relatively simple:

  • I used the QRStuff site to generate codes in both colors.
  • And then used Inkscape and it’s alignment features to create a .pdf
  • My local printing shop was kind enough to print it so it would fit in my Ikea frame

Map a USB drive to one specific location and solve the “S to Skip” bug

… in a few steps ! (On Debian based distros)

1 – Use disk-manager or manually add a line like this one to your /etc/fstab file

UUID=8d7548c6-a4c3-49b1-9c08-82c9b90cdc98 /media/BLUELINE ext3 defaults 0 2

2 – (optional) In my case, the hardrive is slow to boot compared to the computer. I need to replace this special line in /etc/defaults/grub. The “rootdelay” option leaves 15 seconds more to the system before trying to mount devices

GRUB_CMDLINE_LINUX_DEFAULT="rootdelay=15 quiet"

then run


3 – Reboot

4 – Enjoy ! (Was this simple or what ?)

Upgrade to SSD without reinstalling Windows

It used to be that my first suggestion for a computer upgrade was “Bigger Screen” or “More RAM”.

Not anymore ! I announce that SSD is the next thing ! (If you can tolerate the craziness)

I just got a new Dell XPS 17 with a i7 Processor and 12 Gigs of RAM. I’m planing to use it for testing memory-hungry programs. Since I will use virtualization a lot, I figured I would need to give these SSD drive a try. Dell upgrade hard-drives prices were ludicrous for “no-name” SSDs, so I decided to buy a OCZ Vertex 3 120G drive from a local store.

For the record : SSDs rocks.

But since I forgot/did not bother to ask for a real Windows CD from Dell… I have a problem.

How can I upgrade my classic 500G HD to a 120G SSD without losing the OS ?

First, make sure you have this available:

  • A usb key/CD with Clonezilla installed (CZ)
  • A usbkey/CD with SystemRescueCD installed (SRCD)
  • A “self-made” Windows Repair CD (either 32 or 64 bits) (WRCD)
  • I assume you have access to 2 classic SATA hard-drives. I my case, I also had the good luck to have two SATA drives slots on a laptop. If that is not your case, try to use a USB external drive adapter or enclosure.
  • I assume you are replacing the first drive of a two hard drives system.
    • The main drive is going to be replaced by the new drive;
    • The second drive will remain in place at the end of the process.

Here are the simple, not-at-all-excessive-steps list to follow:

  • CZ: Before booting the system the first time, backup the main drive to the second drive
  • Figure out witch is the main drive (apart from the second drive) (In my case, Dell documentation was helpful)
  • Boot one time using the original main drive
  • SRCD: Resize the main drive so that the partition would fit on the (smaller) SSD drive
  • Reboot Again : Windows will react by a drive test (this is required or the next steps will fail)
  • CZ: Backup one more time (optional)
  • Remove 2nd drive
  • Move main drive to 2nd drive former socket
  • Install SSD drive in first socket
  • CZ: Clone form main drive to SSd drive
  • Remove main drive, and store in safe place (from now on, this will be your backup)
  • Install second drive in second socket
  • Reboot, again . Windows should react by a drive check
    • At this point. you witness your quickest. reboot. EVER.
  • Optional cleanup steps
    • SRCD: Delete “special” and “recovery” partitions
    • SRCD: Resize main partition to maximum size (all disk)
    • SRCD: Set boot flag on remaining “main” partition
    • WRCD: Boot with Windows Repair CD twice
      • First time will trigger an auto-repair feature
      • At second time, ask for “Repair startup” option to repair the OS
  • Reboot, cleanup again
  • CZ: Backup one last time.
  • Done.

You, hour by hour

From the “Crontab-entry-that-is-actually-a-social-sciences-experiment” dept,
today we tinker an easy experiment with the integrated webcam of your [Note/Net]Book.

I stumbled upon this nice CLI utility : fswebcam !

Installation is easy on Debian/Ubuntu (don’t forget su or sudo) :

aptitude install fswebcam

Now that we have the program, let’s try a simple command:

fswebcam -D 5 /some/place/nice/somefile.jpeg

This command does 3 things :

  • Start the webcam
  • Wait 5 seconds
  • Take one picture and save it at the designated location

The second step is a little weirder (and maybe a little narcissist). Imagine we take a picture EVERY hour. For this purpose, we simply create a cron entry:

crontab -e

will bring your favorite editor, and allow you to edit the current user cron settings
Just add a line like this one, and ensure the destination directory exists:

# 0 * * * * fswebcam -D 5 /dest/dir/$(date +\%Y-\%m-\%d-\%H\%M\%S).jpeg

This line will trigger every day of every month, every day of the week at every hour and 0 minutes. The $(date +\%Y-\%m-\%d-\%H\%M\%S) part creates a different filename each time.

The results are very interesting. They allow you to observe yourself.

Webcam capture results
“Best” of me of the past 4 months

So far, I was able to observe:

  • The hours I look tired
  • The days I seem to work more
  • When I look more happy
  • How I position myself while working (strangely holding my head with my bent arm)

I can only assume the results are very personal, so I guess you would observe other traits yourselves.

Happy spying on yourself !

Simple Debian/Gmail configuration for sending mail from CLI

Sometimes we need to use the mail command (instead of a rich MUA) . A central mail server is not always available and there may be a need for simpler solutions. This article demonstrate a direct link from exim4 (Debian/Squeeze) to Gmail.


  • On a newly installed Debian, type :
    # dpkg-reconfigure exim4-config
  • Choose “mail sent by smarthost; no local mail
  • Choose all default values until the “smarthost” configuration
  • “Smarthost” is
  • Edit the password file:
    # vim /etc/exim4/passwd.client
  • Add a line like this one:
  • Run : # update-exim4.conf
  • Test the mail command


Debian wiki
Debian documentation
Another guide on the subject