Wednesday, September 28, 2016

Updating PHP 5.5.x with PHP 5.6 or PHP 7.0 in Ubuntu 13.04, 14.04, 15.04

After trying a couple of packages, settings and configuration, finally I seem to have found out a working solution:

1. Update your PPA repository with the  PHP 5.6 package sources:

 sudo add-apt-repository ppa:ondrej/php

Please note the repository is as stated above and not as:

 ppa:ondrej/php5-5.6 because this has been deprecated where the above PPA is a co-installable one, meaning you can install PHP 5.5, PHP 5.6 or PHP 7.0 as per your requirement.

Press enter to confirm. If you come across any error then you will need to install python-software-properties first as shown below:

 sudo apt-get update  
 sudo apt-get install python-software-properties  

2. Update

Once again update your packages:

 sudo apt-get update  

3. Install PHP 5.6 and its relevant mods:

 sudo apt-get install php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml   
 sudo apt-get install php7.0 # for PHP 7.0   
 sudo apt-get install php5.5 # for PHP 5.5   

4. Disable PHP 5.5:

Now this step is very important else you won't be able to use PHP 5.6. Even when you check your PHP version, it will still display as PHP 5.5. Follow the step below to disable PHP 5.5.

 sudo a2dismod php5  

5. Enable PHP 5.6:

 sudo a2enmod php5.6  

6. Restart Apache web server:

 sudo service apache2 restart  

Note: New location of php.ini file in PHP 5.6:

The location of php.ini fie is changed in PHP 5.6 unlike PHP 5.5 where it used to be located at '/etc/php5/apache2/php.ini'; the new location is at '/etc/php/5.6/apache2'

Tuesday, September 20, 2016

[[Solved]] - How to Update Eclipse from Terminal or IDE in Ubuntu 12.04, 14.04, 15.04, 16.04

Since I had installed Eclipse manually under '/opt/eclipse/' directory and not from the Ubuntu Software Centre, I couldn't update it from the terminal. Trying to Update Eclipse from the Terminal or within the IDE was giving me several errors such as these:

 Error 1:  
 An error occurred while uninstalling  
 session context was:(profile=epp.package.cpp, phase=org.eclipse.equinox.internal.p2.engine.phases.Uninstall, operand=[R]org.eclipse.platform_root 4.5.1.v20150904-0015 --> null, action=org.eclipse.equinox.internal.p2.touchpoint.natives.actions.CleanupzipAction).  
 Backup of file /opt/eclipse/.eclipseproduct failed.  
 File that was copied to backup could not be deleted: /opt/eclipse/.eclipseproduct 
 Error 2:  
 An error occurred while uninstalling  
 session context was:(profile=epp.package.cpp, phase=org.eclipse.equinox.internal.p2.engine.phases.Uninstall, operand=[R]org.eclipse.rcp_root 4.5.1.v20150904-0015 --> null, action=org.eclipse.equinox.internal.p2.touchpoint.natives.actions.CleanupzipAction).  
 Backup of file /opt/eclipse/readme/readme_eclipse.html failed.  
 File that was copied to backup could not be deleted: /opt/eclipse/readme/readme_eclipse.html 
 Error 3:  
 An error occurred while uninstalling  
 session context was:(profile=epp.package.cpp, phase=org.eclipse.equinox.internal.p2.engine.phases.Uninstall, operand=[R]org.eclipse.rcp_root 4.5.1.v20150904-0015 --> null, action=org.eclipse.equinox.internal.p2.touchpoint.natives.actions.CleanupzipAction).  
 Backup of file /opt/eclipse/readme failed.  
 Permission denied  

Update Eclipse

Looking at the above errors I figured out one of the possible cause was that Eclipse did not have SU (Super User) privilege. So, I executed Eclipse from the terminal giving it Super User privilege. And once in the IDE ran and update from within it. (Look image below)

To run Eclipse with Super User Permission from within the terminal. Launch your terminal with CTRL + ALT + T:

 cd /opt/eclipse  
 sudo ./eclipse  

Updating Eclipse from IDE

Once in Eclipse go to Help > Check for Updates. Now the Eclipse should be updated without any error.

Sunday, September 18, 2016

JavaScript Equivalent of PHP's number_format() Function

Today while going through JavaScript I came across a float value and then wanted to truncate it by two decimal places. I knew in PHP we have the number_format() function and this is what I found for Javascript:

yourFloatVarHere.toFixed(2);

Example:

Suppose you have a value say: 0.589723, and you would like to truncate this value to two decimal place.
 var divide;  
 var num_format;  
 divide = 33/86;  
 num_format = divide.toFixed(2);  

33/ 8 = 0.38372093
Since we have truncated our answer to two decimal place, the final answer will be: 0.38

Wednesday, September 14, 2016

Understanding the Difference Between isset(), empty(), is_empty() and unset() functions in PHP

isset() function in PHP: 

As the name suggests the isset() function in PHP checks whether the variable 'is set' or not. To be more clear this is what happens when this function is called:
  •  Checks whether the variable is declared or exists or set or not. It returns TRUE or 1 if the variable is not NULL, not an Empty String represented by '' or an Undeclared variable.

empty() function in PHP: 

The empty() function in PHP returns TRUE or 1 in the following cases:
  1. if the variable is undeclared
  2. if the variable is assigned zero. Example $high = 0;
  3.  if the variable is assigned an Empty string or declared NULL. Example: $high= ''; or $high = NULL;

is_null() function in PHP:

As the name suggests, the is_null() function checks whether a variable is NULL or not. This holds TRUE if:
  1. variable is not declared
  2. variable is declared as NULL. Example: $high = NULL;
Note: '' empty string is not NULL.

    unset():  

    You can wipe a variable out of existence using unset().


    Handy Usage: These functions are handy when you need to make sure that the user filled out the appropriate fields in the form.

    Example:

     <?php   
      // Experimenting with isset(), empty() & is_null()   
     // Comment/Uncomment each condition below and test  
      // $high = '';   
      // $high = NULL;   
      // $high = 0;   
      // $high = 'hello';   
      echo '$high = '.$high.'<br />';   
      echo 'isset($high) = '.isset($high).'<br />';   
      echo 'empty($high) = '.empty($high).'<br />';   
      echo 'is_null($high) = '.is_null($high).'<br />';   
      ?>   
    

    Sunday, September 11, 2016

    Install and Run the MIT App Inventor Emulator in Ubuntu 12, 13, 14, 15 & 16



    1. You'll need sudo privileges to do the installation.

    Note: The setup programs are 32-bit software. If you have a 64-bit system you may need to install libraries to allow your machine run 32-bit software. One way to do this is to run the command:

     sudo apt-get install lib32z1  
    

    2. If you have previously installed the App Inventor setup software, you should remove those files before installing the new software:

     sudo rm -rf /usr/google/appinventor  
     sudo rm -rf ~/.appinventor  
    


    3. Download the .deb package for the Emulator from the following link: http://appinv.us/aisetup_linux_deb

    4. Use the GDebi Package Installer to install the .deb Emulator package. If you don't have the GDebi Installer you can get it from the Ubuntu Software Centre at: http://bit.ly/2c1AlRD

    5. The software will be installed under /usr/google/appinventor.

    6. Hit Ctrl+Alt+T and fire up your Terminal and change directory as below:

     cd /usr/google/appinventor/commands-for-Appinventor  
    

    7. Once in the appInventor directory enter the following command to finally Run the Emulator:

     ./aiStarter  
    

    8. Now connect the appInventor to the Emulator as shown in the image below:

    Click Image to Enlarge


    Saturday, September 10, 2016

    फ्री (FREE) VPN: ल्यांटर्णको (Lantern) फ्री (Free) VPN सेवा चलाउनु होश (Qatar, UAE, Saudi Arabia, Oman, Kuwait र Bahrain)

     

    UAE, Qatar, Saudia Arabai, Oman, Bahrain र Kuwait मा बस्नु हुने नेपाली हरुलाई खुसीको खबर!!!

    खाडीमा बस्नुहुने नेपालीहरुलाई VPN सेवाको महत्तव थाहा छ नेै, त्यसमा पनि फ्री VPN सेवा।

    ल्यांटर्ण (Lantern) भन्ने कम्पनीले ८०० MB सम्म फ्री चलाउन मिल्लने एन्डरोइड (Android ) र कम्प्युटर APP निकालेको छ।

    मासिक ८०० MB केवल Viber, Skype चलाउन मज्जाले पुग्छ।

    यो APP चलाउन निक्कै सजिलो छ। बस् डाउनलोड गर्नुहोश, ON गर्नुहोश र पर्योग गर्नुहोश।

    App OFF:


    APP ON:


    APP डाउनलोड (Download) गर्ने लिंक:

    •  एन्डरोइड फोनमा (Android Phone) प्रयोग गर्न यो लिंकमा क्लिक (click) गर्नुहोश: http://bit.ly/2cMVBk3
    • कम्प्युटरमा  प्रयोग गर्न यो लिंक क्लिक गर्नुहोश: http://bit.ly/2cld0yf 

    Lanter App को Icon:



    Connection सफल भएको संकेत:



    Connection बन्द गर्न:



    Sunday, September 4, 2016

    What Should You Use, Kazam, Simple Screen Recorder or Vokoscreen for Screencast in Ubuntu/Linux?

    Top 3 Screen Recorder for Ubuntu/Linux:


    I tried all Kazamm, Simple Screen Recorder and Vokoscreen and this is what I would recommend:

     Kazam

     


    If you would want to go with a simple solution then go for Kazam. You simply install the software and sart using it without having to be bothered about much customizations.

    To Install Kazam: 


    You can install it from the Software Center by checking this link: Download Kazam.

     SimpleScreenRecorder

     

     

    SimpleScreenRecorder has much more features and customization compared to Kazam. For detailed configuration option for SimpleScreenRecorder, you may check my other post: SimpleScreenRecorder Configuration.

    To install SimpleScreenRecorder:


     sudo add-apt-repository ppa:maarten-baert/simplescreenrecorder  
     sudo apt-get update  
     sudo apt-get install simplescreenrecorder  
     # if you want to record 32-bit OpenGL applications on a 64-bit system:  
     sudo apt-get install simplescreenrecorder-lib:i386  
    

    Note for Audio setting: If you are  using a microphone, then please select the option: 'Built-in Audio Analogue Stereo' as shown in the image below.



    Vokoscreen

     



    Vikoscreen has similar features as SimpleScreenRecorder. The one feature it stands out from both of the above screen-recorders is it's Webcam option. If you select the 'Webcam' option then you can enable your webcam and simultaneously record yourself along with your screencast.

    Note for Audio setting: Same as above.

    Install Simple Screen Recorder in Ubuntu 14.04 with Settings Configuration

    Open your terminal by entering CTRL+ALT+T and enter the following commands:

     sudo add-apt-repository ppa:maarten-baert/simplescreenrecorder  
     sudo apt-get update  
     sudo apt-get install simplescreenrecorder  
    

    If you want to record 32-bit OpenGL applications on a 64-bit system:

     sudo apt-get install simplescreenrecorder-lib:i386  
    

    For technical settings and configuration, such as audio/video settings, please watch the video below:

    Top Magento Hosting:

    Top 5 Posts (Weekly)

    Lets Connect: