How to install/uninstall libreoffice using terminal on ubuntu 16.04

On windows I was comfortable using GUI to install and uninstall software but in Ubuntu I am more comfortable using terminal. Please fine below steps to Uninstall LibreOffice from Ubuntu 16.04.

sudo apt-get remove --purge libreoffice*  
sudo apt-get clean  
sudo apt-get autoremove  

Steps to install LibreOffice on Ubuntu using terminal

sudo add-apt-repository ppa:libreoffice/ppa  
sudo apt-get update  
sudo apt-get install libreoffice  

Using .deb file
1. Download .deb file from https://www.libreoffice.org/download/download/. Current latest version is
LibreOffice5.4.2Linuxx86-64rpm.tar.gz
There might be a new version when you are reading this. Please use latest version.
2. Run following commands

tar -xvzf LibreOffice_5.4.2_Linux_x86-64_deb.tar.gz  
cd LibreOffice_5.4.2_Linux_x86-64_deb/DEBS/  
dpkg -i *.deb  

Ubuntu Quick Reference

change folder ownership

sudo chown -R $USER /var/www  

Rename folder

mv CodeIgniter-3.1.6/ codeignitor316  

Copy Folder (Please make sure folder path is from root directory and not the relative path)

sudo cp -r /var/www/mediawiki /var/www/mediawiki  

Copy File

sudo cp filename1.py /var/www/filename2.py  

unfiz tar file

tar xzf file.tar.gz  

List of installed softwares. Second command will save this list in text file.

apt list --installed  
dpkg --get-selections > list.txt  

Uninstall app

sudo apt remove <app_name>

NGINX start and stop

sudo ln -s /etc/nginx/sites-available/techtrekking.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
# Error log
tail -f /var/log/nginx/error.log

Update local host file

sudo -i gedit /etc/hosts

 

Upgrade sublime text

sudo apt-get install --only-upgrade sublime-text

Some useful commands

Activity command
start
sudo service postgresql start
stop
sudo service postgresql stop
restart
sudo service postgresql restart
Update Host file
sudo nano /etc/hosts
Reboot
sudo reboot

Getting started with PHP

Your PHP code goes inside the

<?php  
code here  
?>

To display text in HTML output page

echo "this is output";  

Make sure to end your line of PHP code with a semicolon

;
String Manipulations
<?php  
$name = "Luke Perry";
echo strlen($name); // 10  
echo substr($name, 0, 3); // Luk  
echo strtoupper($name); // LUKE PERRY  
echo strpos($name, "e Perry"); // 3  
// concatenation
echo "hello" . "user";  
?>
Variables

All variable names in PHP start with a dollar sign

$temp
Comment

comment is started with either of following code

//

or

#
Operators
> Greater than
< Less than  
<= Less than or equal to  
>= Greater than or equal to
== Equal to
!= Not equal to
Conditional Sentence
    if ( 2 > 10) {
        echo " ok";
        }
    else if ( 2 == 33 ) {
        echo "ccc";
        }
    else if ( 3 == 34) {
        echo "this is 3";
    }
    else {
        echo "nothing mathcn";
        }
switch
    switch (2) {
        case 0:
            echo 'The value is 0';
            break;
        case 1:
            echo 'The value is 1';
            break;
        case 2:
            echo 'The value is 2';
            break;
        default:
            echo "The value isn't 0, 1 or 2";
    }

Using or clause with switch

    switch ($i) {
        case 0:
            echo '$i is 0.';
            break;
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
            echo '$i is somewhere between 1 and 5.';
            break;
        case 6:
        case 7:
            echo '$i is either 6 or 7.';
            break;
        default:
            echo "I don't know how much $i is.";
    }
Working with Array

defining array and adding new element

      <?php
        // Add your array elements after
        // "Beans" and before the final ")"
        $array = array("Egg", "Tomato", "Beans" );        
      ?>
<?php  
$states = array();
$array = array_push($states, "Montana");
$array = array_push($states, "North Carolina");
$array = array_push($states, "California");
echo $array; // returns 3  
var_dump($states);  
?>

Pushing multiple elements together

<?php  
$states = array(); // target array
$array = array_push($states, 
"Montana", 
"North Carolina", 
"California");
echo $array; // returns 3  
var_dump($games);  
?>

Print array

<?php  
echo $tens[2];  
echo $tens{2};  
?>

Modify and delete array element

$languages[1] = "green";
unset($array[2]);  
unset($array);  
Loop
        foreach($languages as $lang) {
          print "<p>$lang</p>";
        }

another example

      <?php
        // Echoes the first five even numbers
        for ($i = 2; $i < 11; $i = $i + 2) {
          echo $i;
        }
      ?>

fuzzywuzzy : string matching Python

Many times while dealing with text analytics, we need to compare text. There are multiple algorithms and approaches to do the job. Lets have a look at fuzzywuzzy library.

fuzzywuzzy
Installation
pip install fuzzywuzzy  
pip install python-Levenshtein  

fuzzywuzzy will work even if you dont install python-Levenshtein but installing it will enhance performance.

Using fuzz.ratio

This is basic comparison and output is as below

>>> from fuzzywuzzy import fuzz
>>> from fuzzywuzzy import process
>>> fuzz.ratio("ABCD", "ABCD")
100  
>>> fuzz.ratio("ABCD", "ABCDE")
89  
>>> fuzz.ratio("ABCD", "ABCDEF")
80  
>>> fuzz.ratio("ABCD", "ABCDEFG")
73  
>>> fuzz.ratio("ABCD", "ABCDEFGH")
67  
>>> fuzz.ratio("ABCD", "ABCDEFGHI")
62  
>>> fuzz.ratio("ABCD", "ABCDEFGHIJ")
57  
Using partial_ratio

ratio is very simple comparison, you can use partial_ratio to do sub-string mapping.

>>> fuzz.partial_ratio("ABCD", "ABCDEFGHIJ")
100  

But evening partial ration fails when words are scarmbled.

>>> fuzz.partial_ratio("India Vs Aus","Aus Vs India")
42  
Using tokensortratio

Basically “India Vs Aus” and “Aus Vs India” are same thing but people can use either ways and both are valid. In cases of words where sequence might be different,you can use tokensortratio

>>> fuzz.token_sort_ratio("India Vs Aus","Aus Vs India")
100  
>>> fuzz.token_sort_ratio("India cricket team Vs Aus cricket team","Aus Vs India")
48  

Now lets add further complication, if I add ‘cricket team’ in one of the word, match does not work.

fuzz.tokensetratio

In such cases, using tokensetration might help you.

>>> fuzz.token_set_ratio("India cricket team Vs Aus cricket team","Aus Vs India")
100  
Which matching algorithm to use ?

Well, just because fuzz.tokensetratio works even with extra words, it might not be suitable for your application. Ultimately, it will boils down to what you want ti compare and how is use data.

You can take a look at other libraries such as jellyfish if you are looking for alternative approaches.