Terminal Title As Command Do

this is my .bashrc

xterm*|rxvt*|lxterminal*)
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'

    # Show the currently running command in the terminal title:
    # http://www.davidpashley.com/articles/xterm-titles-with-bash.html
    show_command_in_title_bar()
    {
        case "$BASH_COMMAND" in
            *\033]0*)
                # The command is trying to set the title bar as well;
                # this is most likely the execution of $PROMPT_COMMAND.
                # In any case nested escapes confuse the terminal, so don't
                # output them.
                ;;
            *)
                echo -ne "\033]0;${USER}@${HOSTNAME}: ${BASH_COMMAND}\007"
                ;;
        esac
    }
    trap show_command_in_title_bar DEBUG
    ;;
*)
    ;;
esac

Backup Directory (with Exclude Directory) and Rsync Directory

this is the script i wrote

#!/bin/bash

# BACKUP my-app PROD AND my-app_2 PROD

zip -r /var/www/html/backup/my-app/`date +%Y-%m-%d:%H:%M:%S`.zip /var/www/html/my-app -x *log* &> /dev/null
echo "Backup folder my-app ..."
zip -r /var/www/html/backup/my-app_2/`date +%Y-%m-%d:%H:%M:%S`.zip /var/www/html/my-app_2 -x *log* &> /dev/null
echo "Backup folder my-app_2 ..."

# RSYNC my-app DEVEL TO my-app PROD
rsync -Pr /var/www/html/devel/my-app/apppacking/controllers/ /var/www/html/my-app/apppacking/controllers/ &> /dev/null
rsync -Pr /var/www/html/devel/my-app/apppacking/views/ /var/www/html/my-app/apppacking/views/ &> /dev/null
rsync -Pr /var/www/html/devel/my-app/apppacking/libraries/ /var/www/html/my-app/apppacking/libraries/ &> /dev/null
rsync -Pr /var/www/html/devel/my-app/apppacking/models/ /var/www/html/my-app/apppacking/models/ &> /dev/null
rsync -Pr /var/www/html/devel/my-app/assets/ /var/www/html/my-app/assets/ &> /dev/null
echo "Rsync my-app Development ke my-app Production ..."

# RSYNC my-app_2 DEVEL TO my-app_2 PROD
rsync -Pr /var/www/html/devel/my-app_2/apppacking/controllers/ /var/www/html/my-app_2/apppacking/controllers/ &> /dev/null
rsync -Pr /var/www/html/devel/my-app_2/apppacking/views/ /var/www/html/my-app_2/apppacking/views/ &> /dev/null
rsync -Pr /var/www/html/devel/my-app_2/apppacking/libraries/ /var/www/html/my-app_2/apppacking/libraries/ &> /dev/null
rsync -Pr /var/www/html/devel/my-app_2/apppacking/models/ /var/www/html/my-app_2/apppacking/models/ &> /dev/null
rsync -Pr /var/www/html/devel/my-app_2/assets/ /var/www/html/my-app_2/assets/ &> /dev/null
echo "Rsync my-app_2 Development ke my-app_2 Production ..."
echo ""
echo "DONE."

#BACKUP SCRIPT

zip -r /var/www/html/backup/my-app/`date +%Y-%m-%d:%H:%M:%S`.zip /var/www/html/my-app -x *log* &> /dev/null

#RSYNC SCRIPT

rsync -Pr /var/www/html/devel/my-app_2/assets/ /var/www/html/my-app_2/assets/ &> /dev/null

thank you. done.

Fucking Conflict Mariadb with MySQL

oke. today. at this fucking time. i had some fucking problem. when i had installing mariadb then the mysqli modules not work fucking perfectly. then i want revert to mysql. conflict conflic and conflict when the errors output:

mysql blablabla conflict with mariadb blablab

# yum remove mysql-server mysql-libs mysql-devel mysql*
# yum install mysql etc ...

VPN Can’t access local remote network

#VPN IP as client: 192.168.254.112
#VPN Target what we want to telnet is: 192.168.133.100 (where this ip is at the remote local vpn)

in here we use pptp as vpn client (linux centos 6.*)

[root@srv ~]# yum install pptp
[root@srv ~]# cat /etc/ppp/chap-secrets 
# Secrets for authentication using CHAP
# client	server	secret			IP addresses
USERNAME	42.42.42.42	thisispassword	*

[root@srv ~]# cat /etc/ppp/peers/vpn.domain.org 
pty "pptp 42.42.42.42 --nolaunchpppd"
name USERNAME
remotename 42.42.42.42
require-mppe-128
file /etc/ppp/options.pptp
ipparam 42.42.42.42

#NB: uncomment require-mppe-128 in file /etc/ppp/options.pptp

[root@srv ~]# modprobe ppp_mppe
[root@srv ~]# modprobe nf_conntrack_pptp
[root@srv ~]# pppd call vpn.domain.org

#NB: don't forget to routing 

[root@srv ~]# route -n
202.52.50.199   103.6.53.113    255.255.255.255 UGH   0      0        0 eth0
192.168.254.253 0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
103.6.53.112    0.0.0.0         255.255.255.252 U     0      0        0 eth0
0.0.0.0         103.6.53.113    0.0.0.0         UG    0      0        0 eth0

#NB: now we routing

[root@srv ~]# route add -host 192.168.133.100 gw 192.168.254.253

#NB: then testing telnet

[root@srv ~]# telnet 192.168.133.100 1337

#NB: 1337 is the port

done. thank you.

Get Percentage with PHP

this is example script

<?php
function get_percentage($value, $tp){
$percent = (($value * 100)/$tp);
$percent = floor($percent);
return $percent ."\n";
}

$value1 = 10;
$value2 = 1;
$value3 = 1;
$tp = $value1 + $value2 + $value3;

echo get_percentage($value1, $tp);
echo get_percentage($value2, $tp);
echo get_percentage($value3, $tp);
?>

doin’ this shit.

Convert (Image, Word File) to PDF File

use this and read description to use it.

#!/bin/bash
# Author: Lihar Sendhi Wijaya
# Twitter: @lsendw
# Sorry if this program not works perfectly. i'm newbie programmer.
# save this to your /usr/local/bin (convert_doc)
# program convert (jpg, jpeg, png, doc, docx) to PDF FILE 
# dependencies libreoffice & imagemagick & pdftk


# DESCRIPTION
# ori_file : original file ex: file.jpeg file.png file.docx
# result: merge file by sequence
# pdf_file: result of file.jpg > file.pdf | file.docx > file.pdf

clear
echo "--------------------------------"
echo "List File & Sequence (will merge) "
echo ""
for listfile in *.*; do
	echo "$listfile"
done
echo "---------------------------------"
echo -n "Do You Want Convert (Y/N) # : "
read CHOOSE
echo "---------------------------------"
if [[ "${CHOOSE,,}"  == "y" ]]; then
	clear
	if [[ -d ori_file ]]; then
		echo "Direktori sudah ada"
	else
				# CREATE DIRECTORY
				mkdir ori_file
			fi

			for f in *.* ; 
			do
				EXT=$(echo $f | cut -d'.' -f3 | tr '[:upper:]' '[:lower:]')
				if [[ "$EXT" == "jpeg" ]]; then
					# CONVERT JPEG TO PDF
					echo "CONVERT JPEG TO PDF"
					convert ./"$f" ./"$f".pdf
					mv "$f" ori_file/
				elif [[ "$EXT" == "jpg" ]]; then
					# CONVERT JPG TO PDF
					echo "CONVERT JPG TO PDF"
					convert ./"$f" ./"$f".pdf
					mv "$f" ori_file/
				elif [[ "$EXT" == "png" ]]; then
					# CONVERT PNG TO PDF
					echo "CONVERT PNG TO PDF"
					convert ./"$f" ./"$f".pdf
					mv "$f" ori_file/
				elif [[ "$EXT" == "doc" ]]; then
					# CONVERT DOC TO PDF
					echo "CONVERT DOC TO PDF"
					soffice --headless --convert-to pdf "$f"
					mv "$f" ori_file/
				elif [[ "$EXT" == "docx" ]]; then
					# CONVERT DOCX TO PDF
					echo "CONVERT DOCX TO PDF"
					soffice --headless --convert-to pdf "$f"
					mv "$f" ori_file/
				fi
			done

			echo -n "Simpan Dengan Nama File: "
			read NAMA_FILE
			if [[ $NAMA_FILE ]]; then
				OUTPUT_NAME="$NAMA_FILE.pdf"
			else
				OUTPUT_NAME="MERGE OUTPUT.pdf"
			fi

			mkdir result
			pdftk *.pdf cat output "$OUTPUT_NAME"
			mv ./"$OUTPUT_NAME" result/

			mkdir pdf_file
			mv *.pdf pdf_file
			echo "---------------------"
			echo "MERGE FILE PDF DONE!"
			echo "NAME FILE: $OUTPUT_NAME"
			echo "IN DIRECTORY: result"
			echo "---------------------"
		elif [[ "${CHOOSE,,}" == "n" ]]; then
			clear
			echo "CANCEL CONVERT"
			exit
		else
			clear
			convert_doc
		fi

thank you. 😀

Howdoi (How Do I Search) Installation

in my love computer, what i install is arch linux & sublime_text. what the function of “howdoi” ? for me in development it make you fast debug. example:

first install howdoi to your fucking love shell like below

$ sudo pip install git+https://github.com/gleitz/howdoi.git#egg=howdoi

then goto your preference sublime text

$ cd /home/sendhi/.config/sublime-text-3/Packages
$ git clone https://github.com/azac/sublime-howdoi-direct-paste
$ sudo ln -s /usr/bin/howdoi /usr/local/bin/howdoi

after installing. use the plugin. open file.ext sublime text then type :

ctrl+shift+h

if can’t do anything with above command try installing package howdoi from install package sublime text

done

source: https://github.com/gleitz/howdoi & https://github.com/azac/sublime-howdoi-direct-paste