Posting Source Code on wordpress.com

14/03/2019

While WordPress.com doesn’t allow you to use potentially dangerous code on your blog, there is a way to post source code for viewing. We have created a shortcode you can wrap around source code that preserves its formatting and even provides syntax highlighting for certain languages, like so:

#button {
    font-weight: bold;
    border: 2px solid #fff;
}

To accomplish the above, just wrap your code in these tags:
[code language=”css”]

your code here

[/code]

The language (or lang) parameter controls how the code is syntax highlighted. The following languages are supported:

  • actionscript3
  • bash
  • clojure
  • coldfusion
  • cpp
  • csharp
  • css
  • delphi
  • diff
  • erlang
  • fsharp
  • groovy
  • html
  • java
  • javafx
  • javascript
  • latex (you can also render LaTeX)
  • matlab (keywords only)
  • objc
  • perl
  • php
  • powershell
  • python
  • r
  • ruby
  • scala
  • sql
  • text
  • vb
  • xml

If the language parameter is not set, it will default to “text” (no syntax highlighting).
Code in between the source code tags will automatically be encoded for display, you don’t need to worry about HTML entities or anything.

Source:
https://en.support.wordpress.com/code/posting-source-code/

Advertisements

Backup entire website using ftp

13/03/2019

script (backup_site.sh)
save to /root/backup_site

#!/bin/sh
dt=$(date +'%d-%m-%Y');
tm=$(date +'%H-%M')

#change directory backup site
cd /root/backup_site

#Get all file via ftp
wget --verbose --recursive --level=0 --user=admin --password=3E34aClR=9tOc7v*ZitL ftp://hosting1.com:2131

#Backup database mysql with script backup_db.php
wget --verbose http://hosting1.com/backup_db.php --output-document=backup_db--$dt--$tm.sql

#Copy or Move backup file to other location (alternative)
#cp -f -v /root/backup_site/*.sql /media/database/backup_site/
#mv -f -v /root/backup_site/*.sql /media/database/backup_site/

Backup database mysql script (backup_db.php)

<?php 
    //ENTER THE RELEVANT INFO BELOW
    $mysqlUserName      = "root";
    $mysqlPassword      = "WcfVbkmFp8GzKLlp";
    $mysqlHostName      = "localhost";
    $DbName             = "dbmain";
    $backup_name        = date("d-m-Y H:i:s");;
    $tables             = "wp_main";

   //or add 5th parameter(array) of specific tables:    array("mytable1","mytable2","mytable3") for multiple tables

    Export_Database($mysqlHostName,$mysqlUserName,$mysqlPassword,$DbName,  $tables=false, $backup_name=false );

    function Export_Database($host,$user,$pass,$name,  $tables=false, $backup_name=false )
    {
        $mysqli = new mysqli($host,$user,$pass,$name); 
        $mysqli->select_db($name); 
        $mysqli->query("SET NAMES 'utf8'");

        $queryTables    = $mysqli->query('SHOW TABLES'); 
        while($row = $queryTables->fetch_row()) 
        { 
            $target_tables[] = $row[0]; 
        }   
        if($tables !== false) 
        { 
            $target_tables = array_intersect( $target_tables, $tables); 
        }
        foreach($target_tables as $table)
        {
            $result         =   $mysqli->query('SELECT * FROM '.$table);  
            $fields_amount  =   $result->field_count;  
            $rows_num=$mysqli->affected_rows;     
            $res            =   $mysqli->query('SHOW CREATE TABLE '.$table); 
            $TableMLine     =   $res->fetch_row();
            $content        = (!isset($content) ?  '' : $content) . "\n\n".$TableMLine[1].";\n\n";

            for ($i = 0, $st_counter = 0; $i < $fields_amount;   $i++, $st_counter=0) 
            {
                while($row = $result->fetch_row())  
                { //when started (and every after 100 command cycle):
                    if ($st_counter%100 == 0 || $st_counter == 0 )  
                    {
                            $content .= "\nINSERT INTO ".$table." VALUES";
                    }
                    $content .= "\n(";
                    for($j=0; $j<$fields_amount; $j++)  
                    { 
                        $row[$j] = str_replace("\n","\\n", addslashes($row[$j]) ); 
                        if (isset($row[$j]))
                        {
                            $content .= '"'.$row[$j].'"' ; 
                        }
                        else 
                        {   
                            $content .= '""';
                        }     
                        if ($j<($fields_amount-1))
                        {
                                $content.= ',';
                        }      
                    }
                    $content .=")";
                    //every after 100 command cycle [or at last line] ....p.s. but should be inserted 1 cycle eariler
                    if ( (($st_counter+1)%100==0 && $st_counter!=0) || $st_counter+1==$rows_num) 
                    {   
                        $content .= ";";
                    } 
                    else 
                    {
                        $content .= ",";
                    } 
                    $st_counter=$st_counter+1;
                }
            } $content .="\n\n\n";
        }
        //$backup_name = $backup_name ? $backup_name : $name."___(".date('H-i-s')."_".date('d-m-Y').")__rand".rand(1,11111111).".sql";
        $backup_name = $backup_name ? $backup_name : $name.".sql";
        header('Content-Type: application/octet-stream');   
        header("Content-Transfer-Encoding: Binary"); 
        header("Content-disposition: attachment; filename=\"".$backup_name."\"");  
        echo $content; exit;
    }
?>

Create cronjob for execute automatically
backup at 23.00 pm, 12.00 am

0 23 * * * /root/backup_site/backup_site.sh
0 12 * * * /root/backup_site/backup_site.sh

Mount Device automatically on Linux Debian Stretch

13/03/2019

File fstab (/etc/fstab)

# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
             
# / was on /dev/sda1 during installation
UUID=c56a5260-3424-48ad-bceb-95de0cd8d172 / ext4 errors=remount-ro 0 1

# swap was on /dev/sda5 during installation
UUID=8c0ad291-a796-4e4d-a10d-7f14c63a32de none swap sw 0 0

#mount CDROM
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0

#Mount untuk hardisk MAXTOR 80GB
#UUID=b757ab7d-61ff-4868-9362-0e48ee108f64 /media/database/MAXTOR ext4 defaults 1 1

#Mount untuk hardisk GOFLEX 1TB USB (external usb drive)
#need install : ntfs-3g
#UUID=14FC428EFC4269D6 /media/database/GOFLEX ntfs-3g defaults 0 0
#UUID=14FC428EFC4269D6 /media/database/GOFLEX ntfs-3g auto,users,permissions 0 0

#Mount untuk windows share
#need install cifs : apt-get install cifs-utils
#pick one if other not working
//10.8.31.14/DATA/"DATA2019" /media/database/O7 cifs #username=admin,password=adminadmin,iocharset=utf8,sec=ntlm,vers=3.0 0 0
#//10.8.31.14/DATA/"DATA2019" /media/database/O7 cifs username=admin,password=adminadmin,vers=2.0 0 0


Install ‘google-drive-ocamlfuse’ on Debian Stretch

12/03/2019

Step by step:

apt install software-properties-common dirmngr gnupg-agent
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AD5F235DF639B041
echo 'deb http://ppa.launchpad.net/alessandro-strada/ppa/ubuntu xenial main' | tee /etc/apt/sources.list.d/alessandro-strada-ubuntu-ppa.list &gt;/dev/null
apt-get update
apt-get install google-drive-ocamlfuse

To automount, create /usr/bin/gdfuse:

#!/bin/bash
su &lt;insert my username&gt; -c "google-drive-ocamlfuse -label $1 $*"
exit 0

… and add this to /etc/fstab:

# cloud shares
gdfuse#me /media/external/cloud/google-drive fuse uid=1000,gid=1000,user 0 0

Source: https://gist.github.com/OneCDOnly/972755c5c5825ddd819cb2729a52b646

Usage
Once installed, run the following command to launch google-drive-ocamlfuse utility from your Terminal:

$ google-drive-ocamlfuse

When you run this first time, the utility will open your web browser and ask your permission to authorize your google drive files. Once you gave authorization, all necessary config files and folders it needs to mount your google drive will be automatically created.

After successful authentication, you will see the following message in your Terminal.

Access token retrieved correctly.
You’re good to go now. Close the web browser and then create a mount point to mount your google drive files.

$ mkdir ~/mygoogledrive

Finally, mount your google drive using command:

$ google-drive-ocamlfuse ~/mygoogledrive

Congratulations! You can access access your files either from Terminal or file manager.

From Terminal:

$ ls ~/mygoogledrive

Source: https://www.ostechnix.com/how-to-mount-google-drive-locally-as-virtual-file-system-in-linux/


How to install TeamViewer on Debian 9 Stretch

08/03/2019

Script for instalation

su
dpkg --add-architecture i386
apt-get update
apt-get install libjpeg62-turbo:i386
wget https://download.teamviewer.com/download/teamviewer_i386.deb
dpkg -i teamviewer_*_i386.deb
apt-get install -f

good luck…

Source:
https://community.teamviewer.com/t5/Knowledge-Base/How-do-I-install-TeamViewer-on-my-Linux-distribution/ta-p/4351#toc-hId-764334519
https://linuxconfig.org/how-to-install-teamviewer-on-debian-9-stretch-linux