Readline shortcuts

GNUReadline is the library used to make advanced command-line wizardry convenient and conistent across a multitude of command-line applications. These programs include bash, bc, ftp, gnuplot, gpg, ksh, mysql, psql, python, smbclient, xmllint and zsh.
The cheatsheet at the right contains a summary of many of the useful line editing command shortcuts which are available in all applications that use libreadline.
See the documentation on the Readline website for even more shortcuts with more elaborate descriptions.

среда, 2 октября 2013 г.

Creating new entity (project, environment etc)

Lets assume that we need to create new environment within script

First of all, all new stuff will be applied into database only after step ends. When you create new environment you can't manipulate it, you can only add Properties on it, but you can't add agents or you cant add it into Environment Group, you will get an Exception because environment still not exists in scope of anthill. Same exception will happen if you will try to manipulate newly created project or some other instance. So, remember, if you create something you need to do:

<your_new_entity> = new <Something>;

<you_new_entity>.store();

Finish step.

On next step your new entity will be in database and available for manipulation in anthill, you can add it into server groups, projects etc.

Adding into project's workflows.

Get non-originating workflow like Workflow wf = prj.getWorkflow( nonOrigWFID ) or get an array of workflows Workflow[] wfArray = prj.getNonOriginatingWorkflowArray() and iterate over it.

Add environment into it: wf.addServerGroup( env ) , where env should be instance of ServerGroup

Also you do not need to call .store() method here.

Deleting environment

In first part we have created environment and added it into environment group and workflows. Now if you want to delete it from anthill you need to delete it from all workflows where this environment is used.

четверг, 30 мая 2013 г.

RPM is a Package Manager for popular distribution such as Red Hat,
Suse and many others. It is a powerful command line package management
system for installing uninstalling, verifying, querying, and updating
Linux computer software packages.
You can finding out what
dependencies a rpm file has i.e. it will tell you what you need to
install package with following command:rpm -qpR {.rpm-file} rpm -qR {package-name}

Otherwise you can try to install it end will get error message if some of the deps wouldnot be installed.rpm -ivh {.rpm-file}

вторник, 26 марта 2013 г.

Email PHP errors instead of displaying it

By default, most servers are set to display an error message when an error occured in one of your script. For security reasons, you may want to get an email with the error, instead of displaying it to the public.

";
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Email the error to someone...
error_log($email, 1, 'you@youremail.com', $headers);
// Make sure that you decide how to respond to errors (on the user's side)
// Either echo an error message, or kill the entire project. Up to you...
// The code below ensures that we only "die" if the error was more than
// just a NOTICE.
if ( ($number !== E_NOTICE) && ($number < 2048) ) {
die("There was an error. Please try again later.");
}
}
// We should use our custom function to handle errors.
set_error_handler('nettuts_error_handler');
// Trigger an error... (var doesn't exist)
echo $somevarthatdoesnotexist;

Detect location by IP

Here is an useful code snippet to detect the location of a specific IP. The function below takes one IP as a parameter, and returns the location of the IP. If no location is found,UNKNOWNis returned.