Thursday, June 30, 2016

ImageMagick - Resize and Modify Images

Sometimes we want to reduce the size of an image before to upload it somewhere, or do some adjust in a photo, like to rotate it, however when we have tens, hundreds, thousands of pictures, it may give us a lot of work if we do one by one. 

These small examples may help you when you want to resize more pictures. You can change it according to your needs. The produced image will have the name with the prefix new-.
for i in *.JPG; do convert $i -resize 50% new-$i; done
for i in *.png; do convert $i -resize 50% new-$i; done

For example, if you want to define the dimensions of the new image, you can do like below.
for i in *.JPG; do convert $i -resize 1024x768 new-$i; done
for i in *.png; do convert $i -resize 1024x768 new-$i; done

If you need to rotate several pictures. The script is similar.
for i in *.JPG; do convert $i -rotate 90 new-$i; done
for i in *.png; do convert $i -rotate 90 new-$i; done

For more, you can take a look at:
convert --help
and at their website http://www.imagemagick.org/Usage/

Wednesday, June 29, 2016

SVN - Basic Commands

Clone a remote repository to your computer
svn checkout --username=your_username <url>
svn co --username=your_username <url>

Get the updates from the remote repository to your computer
svn update
svn up

Add files and directories
svn add <file/directory>
svn add *

Remove files and directories
svn rm <file/directory>
svn rm *

See changed files
svn status

See changes in files
svn diff

Send changes to remote repository
svn commit -m "message"
svn ci -m "message"

Tuesday, June 28, 2016

Hello World in GOAL language

A simple Hello World in GOAL will use three files. 

File empty.pl

The first file is an empty Prolog file, that I will name empty.pl. I am going to talk more about this file in the next steps.

File HelloWorld.mod2g

In the second file, I implement the module for printing the Hello World message. 

use empty as knowledge.
exit=always.

module helloWorld {
 if true then print("Hello world").
}
In Line 1, I indicate the reference file for initializing the agent's knowledge. So, I create an empty file, named empty.pl with no content inside. In the current version of GOAL, it is necessary even if it will be an empty file. 

In Line 2, I indicate that the module must execute once and then terminate its execution. At execution time, the main module is called cyclically, so the exit=always is necessary. Change it to exit=never and see what happens.

In Line 3, I define the name of the module.

In Line 4, I define a rule for printing the Hello World message.   

File HelloWorld.mas2g

Finally, in the third file, I configure the system. 

define tom as agent {
 use HelloWorld as main module.
}

launchpolicy {
 launch tom.
}
In the first three lines, I define an agent named tom that uses the module HelloWorld as its main module. In the last three lines, I inform the system to create and execute one agent tom. 

Final Comments

This version of the Hello World in GOAL was implemented using the GOAL 2.0. You can find more about GOAL at http://ii.tudelft.nl/trac/goal

GIT - Basic Commands

Clone a remote repository to your computer
git clone <url>

Get the updates from the remote repository to your computer
git pull

Add files and directories
git add <file/directory>
git add *

Remove files and directories
git rm <file/directory>
git rm *

See changed files
git status

See changes in files
git diff

Send changes to your local repository (not yet to remote repository
git commit -m "message"

Send changes to remote repository
git push

Saturday, June 25, 2016

Searching Word in Files

The command that I bring today is quite useful if you want to search for a specific word or term in several or even thousands of files.
find <directory> | xargs grep -s -a -i <word> | uniq