RSSAll Entries in the "Tutorials" Category

Learn how to work with Contours in Photoshop

Hi friends, this post/tutorial is really very important because in this tutorial I am going to explain the technology or mechanism behind the behaviours of Contours in Photoshop. The main reason why I write this tutorial is because I have seen lots of my friends and students following some trial and error methods in Contours to get their desired output and are unable to achieve it in a single attempt.

First let us see what Gloss Contours are in Photoshop.

Gloss contours is an attribute which controls the application of Photoshop layer styles such as Drop Shadow, Outer Glow, Bevel & Emboss and many more. It is available for you here.

When you click inside the circled area in the previous image the Contour Editor dialog box opens up like this.In the gradient editor dialog box you can see a 45 degree line going from left bottom to right top. You can click and drag this line to produce different outputs of layer styles. The gradient editor has two axis. One is the x-axis and another the y-axis. The x-axis controls the position in the layer style from outside towards center. The y-axis controls the darkness/lightness in that position of the layer style.This is how contours work in Photoshop. Once you understand this concept then you can play around with layer styles and Contours in Photoshop. Ok friends, hope this tutorial was quite useful for you all. Always expect something unexpected from Contours, Photoshop Contours, Photoshop layer styles, Photoshop tutorial


Android ‘“ Detecting Internet Connection

Currently I’m working on an application which involves the network access, and one of the steps to be done is to check the internet connection.

Based on conducted researches, I found that the class responsable for querying the state of network connectivity is the ConnectivityManager. The primary responsibilities of this class are to:

Monitor network connections (Wi-Fi, GPRS, UMTS, etc.)
Send broadcast intents when network connectivity changes
Attempt to ‘fail over’ to another network when connectivity to a network is lost
Provide an API that allows applications to query the coarse-grained or fine-grained state of the available networks

We can get an instance of this class by calling Context.getSystemService(Context.CONNECTIVITY_SERVICE);

Important: Before proceeding to check the internet connection, the ACCESS_NETWORK_STATE permission must be set in the AndroidManifest file, otherwise you’ll get a security exception:

1. android.permission.ACCESS_NETWORK_STATE”

Our method of interest from this class is the getActiveNetworkInfo() method which returns an object of type NetworkInfo, through we can check if we are online or not.

The code for checking the internet connection looks like this:

1 ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
2 NetworkInfo ni = cm.getActiveNetworkInfo();
4 if (ni!=null && ni.isConnected())
5 Log.d(“GREC”, “connected”);
6 else
7 Log.d(“GREC”, “not connected”);

Note that it’s important to check the ni object if it’s not null, otherwise, if the connection is not available an exception is thrown.

And the last thing, in order to properly test the internet connection, disable the internet from the emulator: Settings -> Wireless & Networks -> Mobile Networks -> Data Enabled, not from you computer local area connection. This is because even if you turn off the internet from your computer, but don’t turn it off from emulator, the isConnected() method will return true.

For more information about ConnectivityManager and in general the work with network, consider this link:


Can not include OpenSSL headers files.

Today I had question about “..why since I have OpenSSL installed and working fine with other services, I receive such message(the bellow one) when I am trying to compile something..”

The answer is because the application you are trying to compile manually requires “openssl-devel.x” package installed. It includes files for development of applications which will use OpenSSL.
So according to your OS you should use either yum, apt-get or gpg to install it.
In my example I am trying to compile on CentOS 32 bit, so I will use yum like that:

So the next time when I try to compile my application, Openssl headers files will be there:


Windows server passive port range

Really quick one.

To set Windows server passive port range you should use adsutil.vbs which is one of the administration scripts located usually at: C:>\Inetpub\AdminScripts . I am saying usually as the Windows server installation could be on a different drive.

The issue with the Windows passive port range is that the default firewall (firewall.cpl) does not have option or field to open port range, and often when you setup FTP on your Windows server an try to connect with FTP client it may appear with error similar to this one bellow.


directory listing denied because of missing opened passive port range


As you can see from the log, you can connect to the server using FTP, but when you try to do something like listing directory content or copying files it times our. The reason is because the FTP client is trying to connect trough any opened port above 1024 one. (The usual default range is a big one. For example between 40000 and 45000)

You can add several ports manually, but if you have many FTP users, their FTP clients may exceed the port range number and will face the same issue as above. Try using this for testing purposes only (to make sure the issue is because passive port range is not set).

Manual setup of passive port range on windows firewall


To set passive FTP port range on a Windows server the command should be executed via the command line. So go to Start -> Run… type cmd and then:


The result should be similar to this one:

Passive port range sring

Once executed you should not have further issues with Passive mode using your FTP client.

Another method to enable Passive Port Range on Windows 2008 is to execute the following command:

It should return one big ‘OK’, and passive FTP access will be possible.


Set scheduled task Windows 2008

This will be basic tutorial about how to set scheduled task in Windows 2008.

First go to the Administrative Tools – Task Schedule.



Windows 2008 Scheduled tasks location


Once opened, you will see the Task Scheduler window. If it is not something special, you can just create basic task on your Windows 2008. Just click on the link located at right filed under actions.


Create basic task in the task scheduler


The very first step will be to set scheduled task description :


new task description


The next one will be to choose scheduled task trigger :

Scheduled Task Trigger

Windows 2008 Task Scheduler has the following trigger options you can choose from: Daily, Weekly, Monthly, One time, When the computer starts, When I log on, When a specific event is logged. All of them are self-explainable so pick the one you need. In my case the scheduled task will be on daily basis.

windows 2008 scheduled task trigger

Choose the time-frame you want the task to be executed, and then click Next for the scheduled task action:

task action

I will start simple script which will restart IIS using “iisreset” command.Use the browse button to locate the application or the script you want to be scheduled.

execute command scheduled task

The next will be to finish the task setup.

finish task configurationHere you will see the task summary, and will add the task to the Windows 2008 task schedule .


Timestamp in PHP

In this tutorial I will give you example how to add timestamp to file name in PHP .
This is useful when you create similar files like database backups, regular reports, or whatever you are saving in PHP with timestamp in the file name.

Bellow is an example that creates one CSV file with timestamp in the file name:

The part that sets the timestamp in PHP is:

The file created using this method will be like this: testFile.04-10-2011.csv – certainly with different date.
You can modify the PHP date function and use different formats. For example if you need only the current time for timestamp use:

The file name with this timestamp will be like: testFile.06:18:08.csv

For full timestamp including year-month-day-hour-minute-seconds change the code to:

My file appeared with timestamp: testFile.2011-10-04_06:18:08.csv

Certainly you can use different separators for the timestamp, also there are more options available which can be found at PHP date function page.


Generate SSL key and CSR with OpenSSL

It is really easy to generate SSL key and CSR using OpenSSL, and the next several steps will guide you trough the process.

If you are on Linux server, OpenSSL can be downloaded from here: OpenSSL source – or you can use your package management software like YUM install or apt-get. For Windows users, you can use: Win32OpenSSL.

Once you have OpenSSL installed, we can generate SSL certificate key

The following will appear:

The above command will generate SSL key using ‘-rand’ option with few big files for sources and 2048 encryption. The reason of using some big files with ‘-rand’ option is because there are no absolute random generation with computers – but that is different story. Recently the minimum allowed encryption by the SSL issuers is 2048 bits so make sure you will generate your key with this number or with 4096 bit SSL key.

There is another command which can be used :

After executing it, the output will be:

When you generate SSL key with this command will require password, which is good when the key is transported, but once set on a Web Server it will ask for a password every time it is restarted. If you have chosen this method, the next command will remove the SSL key password.

If you open the SSL key file it should be similar to this one:

Now to generate CSR from a key use OpenSSL with this options:

You will be asked few questions for the certificate:

When you are ready with the CSR information, and you open the CSR file, it should look similar to this:

Now provide the CSR to a certificate issuer and wait for the SSL approval message.

Most SSL issuers have service that relies upon the Subscriber or the Subscriber’s authorized administrator to approve all certificate requests for all hosts in the domain. It is important that you will select a correct authorized administrator email. By selecting an authorized administrator, you warrant to the certificate issuer that the individual is authorized to approve the request. The request for SSL server certificate will not be processed beyond this point if you select an incorrect email address.
This part is important and it is a part of the SSL certificate issue process. Its purpose is to avoid someone else to have a certificate issued for your domain.

Be peppered with the following allowed e-mails:
Registered Domain Contacts – This is when the SSL issuer has successfully obtained domain contacts for this domain from the domain registrar. This will be the

Alternate Approval Email Addresses can be used, but you must make sure that such e-mail account has been set up and is available before you provide the CSR, or the approval email will not be delivered.

Level 2 Domain Addresses as bellow are allowed:

Level 3 Domain Addresses as bellow are allowed:

Once you have received and approve the SSL certificate, it will be sent to you and you can install it on your web server.


Incorrect integer value WATCHDOG_ERR

This tutorial is related to issue with Drupal after upgrade, module change or module activation. The error is similar to this one:

“PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: ‘WATCHDOG_ERR’ for column ‘severity’ at row 1: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => file [:db_insert_placeholder_2] => The specified file %file could not be copied to %destination. [:db_insert_placeholder_3] => a:2:{s:5:”%file”;s:22:”temporary://filefCLBmE”;s:12:”%destination”;s:56:”public://ctools/css/818a9e4e3a8a0543c79825df2bf73444.css”;} [:db_insert_placeholder_4] => WATCHDOG_ERR [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => 1317299034 ) in dblog_watchdog() (line 157 of /var/www/vhosts/”

After some search and investigation the issue appeared to be in a file called ‘’ located inside ‘includes’ folder. All the rest variables were WATCHDOG_ERROR, but there was one WATCHDOG_ERR which seams to be not declared anywhere.

The output was :

One of the watchdog lines is not like the rest, and instead of WATCHDOG_ERROR is WATCHDOG_ERR:

So use your preferred editor and just change the variable to WATCHDOG_ERROR and save the file.
Then the issue should be resolved.

PHP relocation error

This will be quick tutorial about how to fix PHP relocation error like this one: php: symbol zlibVersion , version libmysqlclient_16 not defined in in file with link time reference. Instead php: relocation error: php: symbol zlibVersion the error could be php: relocation error: php: symbol crc32.

This is an example and the issue could happen with any shared library not only with .

As per the error message the library version is not matching so we have to check the shared library dependencies. This can be done with tool called ‘ldd’ which prints the shared library dependencies. In this case we will check PHP for “libmysqlclient” so the command should be like this:

Or if for some reason the PHP binary is located elsewhere:

The output should be similar to this one:

Let’s check the file:

In my case this is a symbolic link to the library in the same folder:

Now let’s check if this file exist in another place.

My output is:

So there are two libraries, and now we have to check where is the missing symbol – for example zlibVersion. For that will use ‘nm’ command lists symbols from object files. Let’s try the current linked file:

The output is:

So it seams there are no symbols in this library.

With the other file:

The output is:

Which seams better.

Now I will just remote the current link:

And will create a new one with the library that contains the symbol:

This should resolve the case, and the php: symbol zlibVersion , version libmysqlclient_16 not defined in in file with link time reference error was solved.


Extract certificates from P7B

P7B extract to certificatesThis will be quick tutorial about how to convert P7B to certificate. Actually we will extract certificates from PKCS #7 file using OpenSSL.
Here I have to mention one issue which is really often met and it is with the beginning and the end of the certificate provided. It depends on the OpenSSL version, but for now if the beginning and the end of the certificate are like:
will lead to the following error when you try to extract the SSL certificates:
error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:644:Expecting: PKCS7 .
Let’s examine P7B certificate to see how to avoid such error.


Your certificate could be much longer as digits, but I put […] to shorten the listing on mine. Anyway if your certificate has the same beginning and end, you should change it to:

I have changed:
in order to accommodate the OpenSSL “Expecting: PKCS7

Now we can run the OpenSSL command which will extract PKCS7 certificates from the P7B file .
Note: this command works for both Linux and Windows machines with installed OpenSSL.

The output which prints the stored in the p7b file certificates will be similar to this one:

All this certificates will be stored into the pem.cer file as per the example. The first one is the certificate itself and the following two are CAs signing the certificate.

Another useful option is if you want to merge SSL certificate and key into PFX file