Installing Imagick for php using pecl

If you are dealing with CAPTCHA or some graphics stuff you have definitely come across with Imagick.. it is a nice library that you should check out..
to install.. it is much really easy with pecl
here is the step by step process to install it..

pecl download imagick
tar -zxvf imagick-VERSION.NUMBER.GOES.HERE.tgz
cd imagick-VERSION.NUMBER.GOES.HERE
phpize
./configure --with-imagick=/opt/local
make
make install

Then, on successful make, you will see the path where the “dot so” is saved..
go to you php.ini file and add

extension=imagick.so

then restart you apache and check if the imagic is available on phpinfo()..

DONe!

handling array inputs in zend. Passing inputs that are generated from javascript to zend controller

Hello There,
Was working on a project that is on zend framework. The task involves having having javascript generated input boxes and passing those to the controller.
I have done that before using some other mechanism but they were not somehow natural ways to do it.
It can be done in a much easier way -NATURALLY- though 🙂
lets assume your form has javascript powered email address adding inputboxes. There would be some link you would hit as add emails and it will create input boxes for you..

1. have the input box in your zend form as

		$this->addElement('text', 'emails', array(
			'label'        => 'Emails',
			'isArray'      => TRUE,
			'name'         => 'emails[]'
		));

Or however you are creating the inputbox – or anyother input
2. Then in the javascript where you are creating the input, use the same name as the element’s name

	    var new_email = document.createElement('input');
	    new_email.name = 'emails[]';
	    new_email.type = 'text';
	    new_email.setAttribute('size', 30);

3. yes, you are done!. When the form is submitted, the element with name emails[] would be passed along with the other form elements.
In your controller you would have an array of emails[] and the rest is …

Happy zenjsing

wireless not working on ubuntu 12.04 on dell inspiron

I have a dual boot on my dell inspiron 15. I had an issue with the wireless driver.
Here are the steps I followed to fix it.
Temporary fix
1. go to software resources, you can get it using dash home which is the first icon of the ones listed on the left and type software sources.
2. then select additional drivers menu and select “using broadcom..”

This will fix the problem temporarily but, when you restart the machine you would have to do it again..

Fix.
1. Go to ubuntu software center, you can get it the same way I mentioned on the first part except you would search for “software center” or you can pick it from the unity menu
2. inside the software center, go to the search text box and enter “b43”
3. uninstall/remove the firmware-b43-installer
4. install b43-fwcutter and firmware-b43-lpphy-installer
5. reboot your computer and wireless should show the 🙂 face..

Array Merging in PHP preserving keys. array_merge reindexing arrays

Merging arrays in php keeping the keys

Say you have two arrays with the following values in them:


$array1 = array(13=>'bad luck', 7=>'billion people');
$array2 = array(1=>'number');

And you want the final result to be


$final = (1=>'number', 13=>'billion people', 13=>'bad luck');

But when you merge arrays and using array_merge, u got the indexes being ripped out from the second or first array whose keys are numeric?

The result using array_merge would be

(0 => 'bad luck', 1 => 'billion people', 2 => 'number')

And you don’t want that

Here is a simple way – just use operator overloading of the plus sign

$array1 = array(13=>'bad luck', 7=>'billon population');
$array2 = array(1=>'number');
$merged = $array1 + array2;

Note: This is provided the keys are not overlapping, otherwise, the first array would take ownership of keeping the value.

Do you know how to run single phpunit test

Know who is calling your php script browser or script?

SSH without password not working: mac to ubuntu

if you are doing a lot of server activities, then you are a friend of SSH.
One thing we would do would be to make ssh password-less..
I am trying to log into ubuntu server from mac client. here is the process.

on the MAC,
1. Make sure you have ssh installed. You can check using

which ssh or
ssh -v : this will tell the version

If for some reason it is not installed or if you want to upgrade it, you can install it using mac port – this would be another discussion but the overall stuff would be

$ sudo port -d selfupdate
$ sudo port install openssh

2. Now, create public/private keys using the following command

ssh-keygen -t rsa

you will find these keys in the ~/.ssh folder
This would be much you would do on the client side

On the server (ubuntu server)
1. Create the user on the server using adduser command. Let’s create user macuser

adduser macuser

then follow the instruction to create the user.
2. Go to /etc/ssh/ and update the sshd_config file
Most of the settings of this file would be responsible for the famous problem of asking the password all the time..
3. in the sshd_config file update the following:

StrictModes no
RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication yes

AuthorizedKeysFile      %h/.ssh/authorized_keys

After this restart the ssh using

sudo service ssh restart

Now go back to the mac client and copy the public keys to the server as follows

ssh-copy-id macuser@ubuntuServerOrIP-goes-here

here you will be asked for your password. Give the password you assigned while creating the user on the server.

Then log into the server using

ssh macuser@ubuntuServerOrIP-goes-here

if it is still asking for the password check the following

1. on the ubuntu server go to the ~/.ssh/authorized_keys and see if the public key of mac is registered
2. Check the folder’s permission level is 700 and that of autorized_keys is 600
3. Check the above setting of sshd_config file are saved and restart the ssh on the server

jQuery bind/unbind not working on firefox or in some other browsers

So, your jQuery bind is working OK on all browsers and not in firefox?

At least in my case, it worked on chrome and not on FF.

Let me put it using example:

let’s say we want to assign click event to some item with id = ‘bindable’


$('#bindable').bind('click', function(){
      alert ('From the truth and search of truth, I would prefer the later..');
});

this snippet works fine in chrome and others. but in firefox it is NOT.

The culprit is in passing the ‘event’


$('#bindable').bind('click', function(event){//look mom, i pass the event here..
      alert ('From the truth and search of truth, I would prefer the later..');
});

See mode javascript stuffs

URL encoding in XSLT and php

want to url encode the value you are having in the xsl? do the follwoing two liner and you are done.

1. add the name space xmlns:php=”http://php.net/xsl on the xsl part first
2. then use php:functionString(‘urlencode’, “the text/node/orwhatever to be encoded here”);

DONE

Changes made in new revision of SVN. How to see changes in revision in SVN

Working on SVN? I am sure these days we are on the era of DVCS ( Decentralized Version Control System ) like that of git and mercurial but still, we will be using svn..

To see the changes you made on the current revision vs the previous one, use:

svn diff -r PREV:COMITTED file_name_goes_here

or if you have specific revision numbers then plug them in place of the prev and committed above and it will list the changes you made on that file.