applications


Excel: A few useful functions

count() Counts all cells that contain numbers only.

counta() Counts all cells that contain any content (both numbers and text) a.k.a. are not empty.

countblank() Counts all cells that are empty. 


Ubuntu Linux: How to Resize and add Label to a many picture files 1

Lets say you have a ton of pictures or photos that you want to resize and add a semi-transparent label at the bottom of this bulk of files and even rename them using a pattern based on a unique number.

You can either do this manually or by using imagemagick. If you chose the second way follow these steps:

First of all install it, from bash/terminal call the following:

sudo apt-get install imagemagick

When that command is successfully completed, navigate to the location that the pictures are and once you are there:

In order to resize all pictures then issue the following command (in this example we make all pictures at most 1200px long or 1200px tall and keep the aspect ratio) :

mogrify -resize 1200 *

NOTE: It will affect the original files! So if you want to keep them make sure to copy them elsewhere BEFORE issuing the above command.

After the above is done, you can issue the following set of commands to:

  1. Get each file and find it’s dimensions (which later will be used for the label creation)
  2. Rename all pictures following the number based pattern
  3. Add a semitransparent label containing custom text at the bottom
counter=0; for i in *;
do let counter=counter+1;
width=`identify -format %w "$i"`;
convert -background '#0008' -fill white -gravity center -size ${width}x30 caption:" Some Arbitrary Text " "$i" +swap -gravity south -composite NewFileName.`printf %03d $counter`.jpeg;
done

This command will preserve the original files.
All together with printing the file that is being processed as debuging information:

mogrify -resize 1200 *; counter=0; for i in *; do let counter=counter+1; echo $i; width=`identify -format %w "$i"`; convert -background '#0008' -fill white -gravity center -size ${width}x30 caption:" Some Arbitrary Text " "$i" +swap -gravity south -composite NewFileName.`printf %03d $counter`.jpeg; done

Sample/Result Photos:

 


Ubuntu Linux: How to install Apache2 – MySQL – PHP (LAMP) phpMyAdmin and fix a few installation errors

We won’t give out pretty much any comments/descriptions for this post because we want to keep it small 🙂

First, install a bunch of stuff:

sudo apt-get install apache2
sudo apt-get install mysql-server
sudo apt-get install php5 libapache2-mod-php5 php5-mysql

Later, restart your apache so that it loads all modules (php, etc)

sudo /etc/init.d/apache2 restart

and if you get the following error:
“Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName” resolve it by adding the line:

ServerName localhost

to the file /etc/apache2/httpd.conf and then try restarting again. (You need root access to edit, if you are not familiar with command line text editors line nano, try sudo gedit /etc/apache2/httpd.conf, gedit is usually available with all gnome installations).

After that, to install phpMyAdmin and make it available at http://localhost/phpmyadmin:

sudo apt-get install phpmyadmin
sudo ln -s /usr/share/phpmyadmin /var/www

(The default MySQL login username ‘root’ and the password is the one you entered during installation in the last step).

Happy developing, hope we helped 🙂


Ubuntu: How to compile STAN SPG Planning System (http://planning.cis.strath.ac.uk/STAN/) on Ubuntu 11.10

Recently we tried to compile the STAN SPG Planning System (http://planning.cis.strath.ac.uk/STAN/) under Ubuntu 11.10  Oneiric Ocelot which ended up in a failure.

After reviewing the source code of version 3 (http://planning.cis.strath.ac.uk/code/) we found out that there were many changes needed to be done that had to do with the age of the code itself. We believe that with an OS from1999 and the repsective g++ libraries there should be no problem compiling this application but who has one anyway ? (From the README file: “The code has been built and tested using Linux and UNIX (SunOS) with the g++ compiler.” )

Solution:

We realized that most of the errors are pretty much the same ones and had to do with C++ syntax. Following a synopsis of the changes we did:

    • Replaced
      #include <stream.h>

      with

      #include <iostream>
      using namespace std;

      Note on this, be sure to put using namespace std; after the rest of the includes to avoid conflicts and other issues that might arise.

    • Replaced
      #include <stream.h>

      with

      #include <fstream>
    • Replaced
      #include <new.h>

      with

      #include <new>
    • Added
      #include <cstring>
      #include <stdlib.h>

      wherever there was a call for string manipulation like (strcmp(),strlen(),strcpy(),..) or whenever there were commands like exit().

    • Replaced array assignments like:
      exvec = pl.exvec;

      to

      for(int i = 0;i<EXVECSIZE;i++)  {
        exvec[i] = pl.exvec[i];
      };

      The ranges of these arrays we were able to find them from the respective .h files.

    • In the makefile, we changed:
      pddl.yacc.tab.c: alldefs.h pddl.yacc lex.yy.c
          bison pddl.yacc

      to

      pddl.yacc.tab.c: alldefs.h pddl.yacc lex.yy.c
          bison pddl.yacc -o pddl.yacc.tab.c

      Or else the make will fail as it will not find the file pddl.yacc.tab.c.

In the next section you will find all changes we did to the files extensively (Hopefully we did not forget any or mess them up). The format is as follows (the changes do not necessarily imply that all changes should happen at the same place in file):

in <FILE>
line that was changed/deleted
line that was changed/deleted
-
line that was added
line that was added
line that was added
  1. in Makefile
    pddl.yacc.tab.c: alldefs.h pddl.yacc lex.yy.c
    bison pddl.yacc

    pddl.yacc.tab.c: alldefs.h pddl.yacc lex.yy.c
    bison pddl.yacc -o pddl.yacc.tab.c
  2. in BasicTim.h
    #include <stream.h>

    #include <iostream>
    using namespace std; // make sure it goes right after the includes (I believe it affects stdio.h)
  3. in SymTab.cc
    #include <stream.h>

    #include <iostream>
    #include <cstring>
    #include <stdlib.h>
    using namespace std;
  4. in BasicTim.cc
    #include <fstream.h>

    #include <fstream>
  5. in TimInterface.cc
    #include <fstream.h>

    #include <fstream>
  6. in globals.h
    #include <stream.h>
    #include <fstream.h>

    #include <fstream>
    #include <iostream>
    using namespace std;
  7. in stan.h
    #include <stream.h>

    #include <iostream>
    using namespace std;
  8. in facts.h
    #include “stream.h”

    #include <iostream>
    #include <cstring>
    using namespace std;
  9. in facts.cc
    #include <stream.h>

    #include <iostream>
    using namespace std;
  10. in facts.cc
    exvec = pl.exvec;

    for(int i = 0;i<EXVECSIZE;i++) {
    exvec[i] = pl.exvec[i];
    };
  11. in facts.cc
    domination = pl.domination;

    for(int i = 0;i<EXVECSIZE;i++)  {
    domination[i] = pl.domination[i];
    };
  12. in actions.cc
    exvec = pl.exvec;

    for(int i = 0;i<EXVECSIZE;i++)  {
    exvec[i] = pl.exvec[i];
    };
  13. in instantiation.cc
    #include <stream.h>

    #include <iostream>
    using namespace std;
  14. in candidates.h
    #include <stream.h>

    #include <iostream>
    using namespace std;
  15. in main.cc
    #include <stream.h>
    #include <fstream.h>
    #include <new.h>

    #include <iostream>
    #include <fstream>
    #include <new>
    #include <stdlib.h>
    using namespace std;

Soon we will add the modified version of the source code online that should be able to compile by just issuing make stan.