Zedboard – Setting up a ARM development environment in Linux

Post moved to: Zedboard – Setting up a ARM development environment in Linux


Move files by date into different directory using CLI

A while back I was unfortunate in such a way that my HDD that I primarily use as photo archive started having mechanical issues, and before It died on my arms I had the opportunity to backup most of my pictures, however most of them were truncated and had to be discarded and the ones I could recover their filenames where overwritten with random filenames and ascii codes.

For over a while I have neglected my pictures and they just piled up in a single and nameless directory, until I took it against myself to clean them up.

And one of the benefits of using Linux OS is the scripting features.

for i in *; 
do d=$(exiftool $i | grep 'Date/Time Original' | cut -f 17 -d ' '); 
newd=`echo ${d//:/-}`; 
echo $i ${newd} ;
mkdir -p ${newd}; 
mv -- ${i} ${newd}; 
  1. write this script to a file named mvByDate.sh in your old directory.
  2. replace the /your/new/directory with your new directory’s path
  3. make this file executable with chmod +x mvByDate.sh
  4. then execute this file by ./mvByDate.sh
  5. voila

Install and configure NFS server on Ubuntu for serving files

When it comes to serving media content within your local network, a NFS share is way better than Samba/CIFS share in terms of speed and resource usage. If you have a XBMC box to watch TV shows and movies from a central server then a Network File System (NFS) share should be the choice for a media source. It only takes a few minutes to install and configure NFS server in Ubuntu, and it is a must have item on my server.

Setup NFS Server on Ubuntu

If you do not have NFS yet, you will have to install NFS server first using the following commands:

sudo apt-get install nfs-kernel-server

That’s the easiest part. It requires just bit more effort to configure NFS server to share files with right permissions.

Configure NFS Server

After installation you can configure NFS server by editing the /etc/exports file. First make a backup copy of the default NFS configuration file:

sudo cp -a /etc/exports /etc/exports.backup

Then open the /etc/exports file using the following command:

sudo nano /etc/exports

Edit and comment out all existing lines by adding a “#” in front the line. Next, setup NFS share for each folder you want to make available to the client devices as shown below.

Setup NFS Share for Media

One of the primary purposes I configure NFS server on Ubuntu server is to share my media to all my Xbian Raspberry Pi HTPC. As I said before, for sharing within a network the performance of NFS is better than SAMBA. If you a media folder on your central Ubuntu server, then add the following line to line to /etc/exports to setup NFS share for it.

#Export media to all IP address under 192.168.1.X

This will make your media folder located under /home/user available to every device in your local network. The options within parenthesis are specifically chosen to improve performance. We are sharing “non-critical” media files and we are making them available only to devices in your home network (192.168.1.X). So we can afford to go lower on security to improve speed and performance.

rw – allows read/write if you want to be able to delete or rename files from XBMC or other devices. On XBMC you write permission to download subtitles.
async – Increases read/write performance. Only to be used for non-critical files.
insecure – Does not mean the files are insecure but rather this setting allow clients (eg. Mac OS X) to use non-reserved ports connect to a NFS server.
no_subtree_check – Improves speed and reliability by eliminating permission checks on parent directories.
nohide – This option allows the client device to see multiple file systems but only works on one host. Since this is rare, you may choose to omit this option as it can potentially cause problems in some cases.

Starting, Stopping, and Restarting NFS Server

Once you have setup NFS server, you can start NFS share using the following command:

sudo exportfs -ra

Any time you make changes to /etc/exports I recommend that you restart your NFS server using the following command:

sudo service nfs-kernel-server restart

On your XBMC just choose Network Filesystem (NFS) when you select the source. Note that NFS does not work on Windows clients but they should work on all Linux-based OSes that run XBMC. For Windows, you will still have to Setup Samba as the file server.

Setup NFS Client on Ubuntu

If you would like to connect to the NFS server on your local computer running Linux – prefferably Ubuntu, Do the following:

sudo apt-get install nfs-common


Check to see if everything works
You should try and mount it now. The basic template you will use is:

sudo mount ServerIP:/folder/already/setup/to/be/shared /home/username/folder/in/your/local/computer

so for example:

sudo mount /home/nerd/music

Mount at startup

Add the following lines in your fstab to mount NFS directories automatically after system reboot.

sudo nano /etc/fstab

This will mount directories on start up after the server reboots.

Server_IP:/home/music /home/nerd/music  /mnt/music   nfs   auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0

NFS provides a quick and easy way to access remote systems over a network. However, the protocol itself is not encrypted. If you are using this in a production environment, consider routing NFS over SSH or a VPN connection to create a more secure experience.

setting up python-simplegui library

CodeSkulptor is a web-based python compiler/interpreter, That I have been using for the Interactive Python course offered on Coursera .
And being were I am now, which is in Marion Island – our internet can be so slow at times so I resulted on running my python codes on my local machine not needing to go to CodeSkulptor.

I had troubles importing simplegui library, So after vigorous google searches I finally found a way to run codes needing simplegui library

1. Install

 sudo apt-get install python-dev ipython python-numpy python-matplotlib python-scipy python-pygame python-pip python.h python-setuptools

2. Download and install

wget https://pypi.python.org/packages/source/S/SimpleGUICS2Pygame/SimpleGUICS2Pygame-01.07.00.tar.gz
tar xzvf SimpleGUICS2Pygame-01.07.00.tar.gz
sudo python setup.py install

3. run python on CLI

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui

then test it.

import SimpleGUICS2Pygame.simpleguics2pygame as simplegui
message = "Welcome!"

# Handler for mouse click
def click():
global message
message = "Good job!"

# Handler to draw on canvas
def draw(canvas):
canvas.draw_text(message, [50,112], 48, "Red")

# Create a frame and assign callbacks to event handlers
frame = simplegui.create_frame("Home", 300, 200)
frame.add_button("Click me", click)

# Start the frame animation

How to install Gummi(LaTex) on ubuntu

How to install Gummi on ubuntu
This post is trivial since Gummi has recently released an PPA (Personal Package Archive) for Ubuntu.
btw, there are only 3 commands needed to get Gummi up and running:
1- First, add the PPA to your repository:
$sudo add-apt-repository ppa:gummi/gummi

2- Then, update your repository to reflect the new changes:
$sudo apt-get update

3- Everything is now ready to install Gummi:
$sudo apt-get install gummi