Month: April 2014

Git Tutorial Part 1: Git Configuration

This Git Config Basics Tutorial will help you find out how configuration works and how you can configure your git

Types of Configuration

System Wide:

This configuration file is found at: /etc/gitconfig. This contains the default values for all users on the system.

git config --system

Global/Per User:

Found at: ~/.gitconfig. This is the configuration of a specific user.

git config --global

Project/Repo Specific:

Found at .git/config of each project.

So the configuration process is much like that of apache with the system: httpd.conf

global: mywebsite-vhost.conf
project: .htacess

Configure you Git Identity:

This is the identity data that is stored with every commit you make, o it is good practice to make the email valid and name professional.

git config --global "Number 1"
git config --global

You can use (--system, --global or no argument for project specific config)

Configure your Git Editor:

Configuring your git editor is an important step, as we all have out favourite editors. The default for most system is vim however you change it using the following command:

git config --global core.editor emacs

The same editor can be used as your diff tool and mergetool:

git config --global merge.tool meld
git config --global diff.tool meld

I find that using a graphical merge and diff tool is easier for me.

Checking your Git Settings:

git config --list 1

Git Config Basics Help

git help config
git help <verb>
git <verb> --help
man git-<verb>

Taken from Chapter 1: Pro Git

Zend form Error: String was not found in the haystack

Solution to: Zend Form Error: String was not found in the haystack

Ok So you submit your form with everthing correctly entered and bang...String was not found in the haystack. What does this mean? Well this is actually the best defence of CSFR - Request Forgery that Zend has. This is basically tampering with the $_POST variable posting fake data).

As an example you has a select element created as follows:

$sat = new Zend_Form_Element_Select('satellite_id');
->addMultiOption('0', 'None')

If the data submitted is of the form:

$_POST['satellite_id] = 1;

This will throw the error as the submitted data was not possible based on the options.

However when we use Ajax to populate form elements such as this select, we may indeed add additional options other than those specified in the original form. So to guard against this error, we need to add the following option to the form element to ensure that the InarrayValidator does not fire. The element will look like this:

$sat = new Zend_Form_Element_Select('satellite_id');
->addMultiOption('0', 'None')

When we receive $_POST['satellite_id] = 1, no error will be thrown.

So In actual fact the thing causing the error: String was not found in the haystack, is actually protecting us from illicit users and oblivious attackers.

 Referenced StackOverflow Question

HTML Forms and Submit Button Changing Name

This article explores HTML webforms and specifically the submit button in terms of changing the name, id and value. We explore Submit Button Changing Name Examples.

Example 1: Simple form tags and a frugal submit input


<input type="submit" />


Result 1: Submit label is 'Submit', Default action is to do a Get.

Example 2: Simple form with post method and frugal submit

<form method='post'>
<input type='submit'>

Result 2: Submit label is 'Submit', Does a Post with no form data.

Example 3: Simple Form with Post and submit with id

<form method='post'>
<input type='submit' id='test'>

Result 3:  Submit is still called submit, Does a Post with no form data.

Example 4: Simple Form with Post and Submit with a Name

<form method='post'>
<input type='submit' name='test'>

Result 4:  Submit is still Submit, Does Post that contains form data: $_POST['test'] = 'Submit';

Example 5: Simple Form with Post Submit with a Name and a Value

<form method='post'>
<input type='submit' name='test' value='foo'>

Result 5: Submit is now labelled 'foo', does a post of form data: $_POST['test'] = 'foo';

Example 6: Simple Form with Post Submit with a Value Attribute

<form method='post'>
<input type='submit' value='foo'>

Result 6: Submit labelled foo, but no form data.