Pages

Saturday, December 13, 2014

Wordpress-Error:Allowed memory size of 41943040 bytes exhausted

This means that the maximum allowed memory of about 40M has been used and needs to be increased.
As such we write the following command into wp-config.php in order to increase allowed memory. 

In below example we are setting threshold to 64MB

('WP_MEMORY_LIMIT', '64M');

Wordpress-Bypass FTP credientials step for updates(Update on localhost)

If you want to bypass the step where wordpress asks for ftp credentials on update i.e you do not want wordpress to ask for ftp credentials on update specially helpful in updating on localhost

Then in wp-config.php add the following lines to the code
 
define('FS_METHOD','direct');

That's it and this will bypass the ask for ftp credientials

Friday, November 14, 2014

Ubuntu-Connect an Android device using MTP in Ubuntu 14.04 LTS

After Much of Fiddle I was able to connect my ASUS Zenfhone 5 to my ubuntu via MTP Here is How..

1. First we need to install some MTP Apps so run the following command

 sudo apt-get install libmtp-common mtp-tools libmtp-dev libmtp-runtime libmtp9  

Then run

 sudo apt-get dist-upgrade  

2. Then we're going to amend the fuse.conf file. FUSE is an application that aims to provide a secure method for non privileged users to create and mount their own file system implementations.

Run the following command

 sudo nano /etc/fuse.conf  

You will get following lines remove # before last line which allows other users to mount their own file systems

 # /etc/fuse.conf - Configuration file for Filesystem in Userspace (FUSE)  
 # Set the maximum number of FUSE mounts allowed to non-root users.  
 # The default is 1000.  
 #mount_max = 1000  
 # Allow non-root users to specify the allow_other or allow_root mount options.  
 user_allow_other  

3. Now connect your device using MTP option and run following command
 lsusb  
You will get a list as follows
 Bus 002 Device 007: ID 413c:8160 Dell Computer Corp. Wireless 365 Bluetooth  
 Bus 002 Device 005: ID 413c:8162 Dell Computer Corp. Integrated Touchpad [Synaptics]  
 Bus 002 Device 004: ID 413c:8161 Dell Computer Corp. Integrated Keyboard  
 Bus 002 Device 003: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)  
 Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub  
 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  
 Bus 001 Device 006: ID 0b05:5480 ASUSTek Computer, Inc.   
 Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub  
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  

I find the only device connected to my system of name  ASUSTek Computer is my ASUS mobile we need two parts from above line

0b05:5480

Make a note of these and now we will add these to another rules file

4. Run following command

sudo nano /lib/udev/rules.d/69-mtp.rules

Now add the following lines to the file see the idProduct and idVendor we have added change it in accordance with your device

# ASUSTek Computer, Inc.
ATTR{idVendor}=="0b05", ATTR{idProduct}=="5480", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

5. Now we need to add this information to another rules file

sudo nano /etc/udev/rules.d/51-android.rules
 
Now add the following lines to the open file
 ATTR{idVendor}=="0b05", ATTR{idProduct}=="5480", MODE=”0666"  

Remember to add correct idVendor and idProduct

6. Restart the service
 sudo service udev restart  

7. Reboot Device

 sudo reboot

That's It

Wednesday, November 12, 2014

PHP-Localize php.ini configs for any directory

Recently while installing Joomla 3.0 I came across a blocker My Hosting Provider's php.ini said

magic_quotes_gpc = on;

which was hindering my way in installation of Joomla on Hosting Space I had...

I was looking for a work around and here is what I did simply...

1. Created a file called php.ini(or php5.ini-to taste of your php installation) in my local directory and added 

magic_quotes_gpc = off;

2. Secondly I created .htaccess and added following lines of code to the same

 
 <IfModule mod_suphp.c>  
  suPHP_ConfigPath /home/blart/public_html/interiors  
  <Files php.ini>  
   order allow,deny  
   deny from all  
  </Files>  
 </IfModule>  

The following directory contains my php.ini file
/home/blart/public_html/interiors  


That's it and I had my  php.ini localized

Saturday, September 13, 2014

Ubuntu LAMP-Enable Curl and mcrypt

To EnaBLE CURL FIRST WE NEED TO DOWNLOAD AND INSTALL 
Curl Libraries for this enable the following command
 
 sudo apt-get install curl libcurl3 libcurl3-dev php5-curl  
 
To Enable Mcrypt we need to download and Install 
Mcrypt libraries
 
 sudo php5enmod mcrypt  
 
Mcrypt is already there and is just not enabled.
 
If its still not accessible locate "mcrypt.so" if you find the same 
 at a location like 
 
/usr/lib/php5/20121212/mcrypt.so
 
edit its path in mcrypt.ini and then run the command
 
"sudo php5enmod mcrypt"
 
That's it this enables both of these php extensions. 

Sunday, August 24, 2014

Zend-Using ZendX library in Zend

Recently I had to use Jquery UI components in one of my applications.I used ZendX Library to counter the same and I worked upon the same as the same as follows

 In bootstrap.php

       protected function _initJquery() {  
     $view = Zend_Layout::startMvc()->getView();  
     $view->addHelperPath("ZendX/JQuery/View/Helper",  
                 "ZendX_JQuery_View_Helper"  
                );  
     Zend_Controller_Action_HelperBroker::addHelper(  
               new ZendX_JQuery_Controller_Action_Helper_AutoComplete()  
                );  
     $view->jQuery()  
        ->enable()  
        ->setVersion('1.11.0')  
        ->setUiVersion('1.10.4')  
        ->addStylesheet('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css')  
        ->uiEnable();  
   }  

In View

 <?php  
 $this->jQuery()->addJavascriptFile($this->baseUrl().'/assets/js/validation/jquery.validate.min.js');  
 $this->headScript()->prependFile($this->baseUrl().'/assets/js/validation/myvalidation.js');  
 ?>  

Layout

 <?php   
 echo $this->jQuery();  
 echo $this->jQuery()->uiEnable();  
 echo $this->headScript();  
 echo $this->headLink();  
 echo $this->headTitle('My Website');  
 ?>  

ZendX-Use events and properties of jquery-ui widgets in Zend forms

Recently I added a ZendX Date Picker to one of my Zend Applications now I was able to add properties but I was unable to add events so I had to use another Zend magic function
Zend_Json_Expr

As shown in code below

    /*************Order Date From****************************************/     
         $order_date_from = new ZendX_JQuery_Form_Element_DatePicker('order_date_from',  
               array('jQueryParams' => array('dateFormat' => 'yy-mm-dd',  
                 'onClose'=>new Zend_Json_Expr('function( selectedDate ) {$( "#order_date_to" ).datepicker( "option", "minDate", selectedDate );}')  
                 ))  
           );  
         $order_date_from->setAttribs(array('class'=>"",  
             //'id'=>'datepickerfrom'  
         )  
           );  
         $order_date_from->removeDecorator('DtDdWrapper')  
           ->removeDecorator('HtmlTag')  
           ->removeDecorator('Errors')  
           ->removeDecorator('Label');  
         $this->addElement($order_date_from);  
         /*************Order Date From****************************************/  
         /*************Order Date To****************************************/  
         $order_date_to = new ZendX_JQuery_Form_Element_DatePicker('order_date_to',  
               array('jQueryParams' => array(  
                 'onClose'=>new Zend_Json_Expr('function( selectedDate) {$( "#order_date_from" ).datepicker( "option", "maxDate", selectedDate );}'),  
                 'dateFormat' => 'yy-mm-dd'              
                 ))  
           );  
         $order_date_to->setAttribs(array('class'=>"",  
             //'id'=>'datepickerto'  
         )  
           );  
         $order_date_to->removeDecorator('DtDdWrapper')  
           ->removeDecorator('HtmlTag')  
           ->removeDecorator('Errors')  
           ->removeDecorator('Label');  
         $this->addElement($order_date_to);  
         /*************Order Date To****************************************/  

Thursday, June 26, 2014

Fix wordpress image urls in post on migration

Whenever we migrate wordpress from old domain to new domain we seldom encounter url errors where image urls in post do not get updated etc..

To Tackle this out here is a simple sql script

 UPDATE wp_posts SET post_content = REPLACE (  
 post_content,  
 'olddomain.com/wp-content/',  
 'newdomain.com/wp-content/');  

Tuesday, April 29, 2014

Linux-Scrap Website from terminal

Fool the server that we are using mozilla if unable to do via simple way
 $ wget --user-agent="Mozilla 2.0" -m http://www.itfeast.blogspot.com  
The Simple way
 $ wget -m --tries=7 "http://www.itfeast.blogspot.com"  

Sunday, April 27, 2014

Zend 1.12-Render individual form opening and closing tags

Though I am still looking for a workout of the same from zend function's.But still to get best of results I use following manually added code.
 <form action="<?php echo $this->form->getAction() ?>"  
    enctype="<?php echo $this->form->getEnctype() ?>"  
    method="<?php echo $this->form->getMethod() ?>"  
    id="<?php echo $this->form->getId() ?>"  
    class="<?php echo $this->form->getAttrib('class') ?>" >  
 </form>  


Saturday, April 26, 2014

Zend-Option Group in Zend_Form_Element_Multiselect

 $techDoc = new Zend_Form_Element_Multiselect(‘technical_doc’);  
 $techDoc->setLabel(‘Technical Documents’)  
 ->setMultiOptions(array(“Option Group 1″ => array(“option1″,”option2″,”option3″),  
 “Option Group 2″=>array(“option1″,”option2″,”option3″)));  

Tuesday, April 22, 2014

Change default wordpress login URL

Change default Login URL-Wordpress

Add the following line to the end of .htaccess

RewriteRule ^login$ http://YOUR_SITE.com/wp-login.php[NC,L]

Sunday, March 30, 2014

Wordpress-allow login with email address

Wordpress allow login with email address

    function login_with_email_address($username)  
    {  
      $user = get_user_by_email($username);  
      if(!empty($user->user_login))  
          $username = $user->user_login;  
      return $username;  
    }  
    add_action('wp_authenticate','login_with_email_address');  



Tuesday, March 18, 2014

Zend-Setup on Ubuntu 13.10

To setup zend on ubuntu 13.10(my version)

We need to download its latest framework from
http://www.zend.com/en/company/community/downloads

Zend 1.12.5 is latest as of writing this post

Next unzip and place the same in your home directory and delete all folders except bin and library

Next we need to tell our php to include Zend library so in our php.ini

(found in /etc/php5/apache2/php.ini)

perform following actions

Add
include_path=".:/home/gaurav/ZendFramework-1.12.5/library"
if you find include_path  not used or

Append "/home/gaurav/ZendFramework-1.12.5/library" to current path if include_path is defined (check it's commented by default)

Save and Close

Next move to root and using root privileges(sudo)
 
create a file 
cd /
nano .bashrc
 
and add code 
 
"alias zf=/home/gaurav/ZendFramework-1.12.5/bin/zf.sh"

Save and exit

Next Source .bashrc by following command
 
"source .bashrc"
 
now run zf command
 
If you get an output as follows
 
 An Error Has Occurred                         
 An action and provider is required.                                    

Zend Framework Command Line Console Tool v1.12.4
Usage:
    zf [--global-opts] action-name [--action-opts] provider-name [--provider-opts] [provider parameters ...]
    Note: You may use "?" in any place of the above usage string to ask for more specific help information.
    Example: "zf ? version" will list all available actions for the version provider.

Providers and their actions:
  Version
    zf show version mode[=mini] name-included[=1]
    Note: There are specialties, use zf show version.? to get specific help on them.

  Config
    zf create config
    zf show config
    zf enable config
    Note: There are specialties, use zf enable config.? to get specific help on them.
    zf disable config
    Note: There are specialties, use zf disable config.? to get specific help on them.

  Phpinfo
    zf show phpinfo

  Manifest
    zf show manifest

  Profile
    zf show profile

  Project
    zf create project path name-of-profile file-of-profile
    zf show project
    Note: There are specialties, use zf show project.? to get specific help on them.

  Application
    zf change application.class-name-prefix class-name-prefix

  Model
    zf create model name module

  View
    zf create view controller-name action-name-or-simple-name module

  Controller
    zf create controller name index-action-included[=1] module

  Action
    zf create action name controller-name[=Index] view-included[=1] module

  Module
    zf create module name

  Form
    zf enable form module
    zf create form name module

  Layout
    zf enable layout
    zf disable layout

  DbAdapter
    zf configure db-adapter dsn section-name[=production]

  DbTable
    zf create db-table name actual-table-name module force-overwrite
    Note: There are specialties, use zf create db-table.? to get specific help on them.

  ProjectProvider
    zf create project-provider name actions

Thursday, January 2, 2014

Authorize .Net-Reading Response of Authorize.net api

Reading Error Response
 
AuthorizeNetCIM_Response Object  
 (  
   [xml] => SimpleXMLElement Object  
     (  
       [messages] => SimpleXMLElement Object  
         (  
           [resultCode] => Error  
           [message] => SimpleXMLElement Object  
             (  
               [code] => E00003  
               [text] => The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:cardNumber' element is invalid - The value '668988888888177645' is invalid according to its datatype 'String' - The actual length is greater than the MaxLength value.  
             )  
         )  
     )  
   [response] => ErrorE00003The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:cardNumber' element is invalid - The value '668988888888177645' is invalid according to its datatype 'String' - The actual length is greater than the MaxLength value.  
   [xpath_xml] => SimpleXMLElement Object  
     (  
       [messages] => SimpleXMLElement Object  
         (  
           [resultCode] => Error  
           [message] => SimpleXMLElement Object  
             (  
               [code] => E00003  
               [text] => The 'AnetApi/xml/v1/schema/AnetApiSchema.xsd:cardNumber' element is invalid - The value '668988888888177645' is invalid according to its datatype 'String' - The actual length is greater than the MaxLength value.  
             )  
         )  
     )  
 ) 
 Reading Error Response
 $error = (string)array_pop($response->xpath('messages/message/text'));  

Reading Success Response
 AuthorizeNetCIM_Response Object  
 (  
   [xml] => SimpleXMLElement Object  
     (  
       [messages] => SimpleXMLElement Object  
         (  
           [resultCode] => Ok  
           [message] => SimpleXMLElement Object  
             (  
               [code] => I00001  
               [text] => Successful.  
             )  
         )  
       [customerPaymentProfileId] => 21000823
     )  
   [response] => OkI00001Successful.21000823 
   [xpath_xml] => SimpleXMLElement Object  
     (  
       [messages] => SimpleXMLElement Object  
         (  
           [resultCode] => Ok  
           [message] => SimpleXMLElement Object  
             (  
               [code] => I00001  
               [text] => Successful.  
             )  
         )  
       [customerPaymentProfileId] => 21000844  
     )  
 )
 Reading Authorize .Net Success Object
 if($response->isOk())  

Wordpress-Get Post ID in functions.php

  $url = explode('?', 'http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);  
   $ID = url_to_postid($url[0]);  
   echo $ID;