############################################################################## # auth : hi@kesavan.info # date : 2016-06-22 # # Updated version always avail at # 1 - https://github.com/kesavanm/handy-tools/ (quick-commands) and/or # 2 - https://kesavan.info/books.pl ( quick-commands-web-dev.txt ) # # SELFNOTE - Keep this sync with Work & GitHub & ownCloud ############################################################################## VI(M) The following commands could be entered to display the information shown. ========================================================================= :echo @% def/my.txt directory/name of file :echo expand('%:t') my.txt name of file ('tail') :echo expand('%:p') /abc/def/my.txt full path :echo expand('%:p:h') /abc/def directory containing file ('head') :set hlsearch :set incsearch #perform incremental searches as you type :set smartcase :hi! link Comment Comment # Hide the commands :hi! link Comment Ignore # Show the comments :setlocal noautoindent nocindent nosmartindent indentexpr= nonu (:set autoindent) :setlocal nocindent :setlocal nosmartindent :setlocal indentexpr= :diffoff & :diffthis # Turn Off/On Colors during Diff :diffupdate :set tabstop=4 shiftwidth=4 expandtab # Tab to 4 WHITESPACE :retab :set tabstop=4 noexpandtab # 4 WHITESPACE to Tab :%retab! :set syntax=whitespace #show spaces :set listchars=tab:▸\ ,eol:¬ #show tabs,eol :set ts=4 :set et :659,723retab! #tabs to 4spaces from 659 to 723 lines :so % " :source (current file name) or :so $MYVIMRC(currently active .vimrc) vimdiff commands ]c : - next difference [c : - previous difference do - diff obtain dp - diff put zo - open folded text zc - close folded text :diffupdate - re-scan the files for differences syntax off set nohlsearch set t_Co=0 # 7/8 colors , C-W C-W #lets you toggle between the diff columns :set diffopt+=iwhite #To avoid whitespace comparison CTRL+W twice #lets you toggle between the diff columns ctrl-w l ctrl-w h #vim philosipy h-left , l-right Turn-On mouse ============= :set mouse=a <> :set mouse=n <> :set ttymouse=xterm2 Vim-as-IDE ========== ctags -R --languages=php . # Make a tags file ctags -R --links=no --languages=php --exclude=*.html,*.js,*.css . :set tags=$project/tags # Set that in .vimrc Ctrl+] - Goto Definition # Play around Ctrl+t - Back to Code autocmd setlocal tags=/path/to/your/global/c/tags,./tags;/,tags;/ :set foldmethod=indent :set foldlevel=2 # 9 - off ; 0 - class level ; 1,2,3 ... macros ====== to record: q to stop : q to quit apply on lines matching pattern : g/pattern/normal! @a apply on next 100 lines : 100@a apply on from lines 34-65 : 34,65normal! @a apply on all lines : %norm! @a vertical-edit ============= ctrl+shift+v (or ctrl+v) # select the column r to replace highlighted text, d to delete, c to change... etc. shift+i to insert text at the beginning of the column, shift+a to append text ESC #when done. !!!DONT FORGET ME!!! explorer ======== :e ~/path/to/file - Opens the file as a buffer. :sp ~/path/to/file - Opens the file in a new (Window) view port. :Bclose - Close the particular buffer. :q should be avoided unless need. :tabe ~/path/to/file - Opens for edit in a tab. Use :tabclose once done. :Sex ~ or :Sexplore - Opens a quick (split) explorer of the argument (Home dir ~ in this case) :Tex & :Vex - Native vim options beside :Sex C-o # switch to shell <> shell A-s # search pattern, the cursor will jump to the matches sequentially C-\ # directory hotlist search all buffers ================== execute "bufdo vimgrepadd // %" | copen # search & populate cexpr [] # cleanup cclose # close #https://superuser.com/questions/212257/how-do-i-open-a-blank-new-file-in-a-split-in-vim another way is to do a n in normal mode. This will create a new split. You can also do v in normal mode to create a vertical split (the previous one will do a horizontal split. And just to be complete, you move to the different splits by doing with the direction being any h, j, k, or l To close a buffer, do q NeoVIM ====== .\goneovim.exe --nvim=..\..\nvim-win64\nvim-win64\bin\nvim.exe BASH/core-utils Find files (man find ; or link http://en.wikipedia.org/wiki/Find) ================================================================= find /home/tmpdir -type f -name "*string*" -print # f-file d-dir l-link -iname “*.pl” find ~ -name \*.c -print #Instead of doing things this way, you should enclose the pattern in quotes or escape the wildcard # Expressions & RANGES # xtime # x in - data (m)odified ; data+inode+permission (c)hanges ; file read-only (a)ccess # -n - less than n days (RECENT CHANGES) # +n - more than n days (OLDER CHANGES) # n - exactly n days # # ( expr ) Force precedence. # ! expr True if expr is false. # expr1 expr2 And (implied); expr2 is not evaluated if expr1 is false. # expr1 -a expr2 Same as expr1 expr2. # expr1 -o expr2 Or; expr2 is not evaluated if expr1 is true. # find . -ctime n # File's status was last changed n*24 hours ago # (data+inode+permission changes ) find . -mtime -7 # File's data was last modified 7*24 hours ago # finds files changed in the last week find . -mtime -7 -type f # file's data modified less than 7 days ago find www/code/ -mtime 8 -mtime -10 -iname "*.pl" # perl files modified less than 10 days & more than 8 days ago # ie , modified between 8-10 days find ~ -type f -name test.txt -newermt 2014-11-04 ! -newermt 2014-11-04 # files modified between dates find . -type f -name '*.php' -mmin -60 # php files modified in last one hour #find with REGEX - Read more if need : -regextype posix-extended find ~ ! -regex '.*/\..*' -type f # REGEX to filter non-hidden files/directories/links find ~ -regex '^(?!\.)(.*)todo.*' -type f # REGEX to filter *todo* files/directories/links find ~ -type f ! -regex '.*/\..*' -a -regex '.*todo.*' # REGEX to filter non-hidden *todo* files find ~ -type f \( -regex '.*/\..*' \) -regex '.*todo.*' # REGEX to filter hidden *todo* files Find & Grep # list files with patterns =========================================== # Combining find & grep is strongly depreciated ; Just for learning. Go with GNU grep (below) find . -name "*.php" -exec grep -H "some_string" {} \; find / -iname "*checkin*" -exec grep 'Confirm Password' {} \; find . -type f -exec grep -H PATTERN '{}' \; 2>/dev/null #NO SYMB LINK FOLLOW find . -name '*php' -exec grep -ilHn --color=always pattern {} \; -exec grep -n pattern {} \; Grep files with a particular string in the file name ==================================================== grep -rH "string" www/code/ # -r recursive grep -ir -E 'get|wcl' sample.php|tail # -i case-insensitive grep -H ERROR www/log # -H force to print --with-filename; default nature grep -C3 error www/log # -Cn prints n lines before & after the matching lines # -(A)bove (B)elow (C)ombined grep -ir --include \*.php pattern ./* # only particular file type , recursive grep-with-regex =============== ifconfig | grep -E 'inet\W' |awk -F ":" '{print $2}' |awk '{ print "\033[1;34m" $1 "\033[0m" }' #terminal explorer mc # midnight commander #Numbering the occurance perl -ne 'print ++$a." $_" if /pattern/' file.ext #recursive statistics on file types in directory ================================================ find . -type f | sed 's/.*\.//' | sort | uniq -c 16 avi 29 jpg 136 mp3 3 mp4 #fzf - quick find/search for a file updatedb --require-visibility 0 -o ~/.locate.db #indexing locally locate ```bash fzf --preview "[[ $(file --mime {}\) =~ binary ]] && echo {} is a binary file || (highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null | head -500" fzf --preview '[[ $(file --mime {}) =~ binary ]] && echo {} is a binary file || (bat --style=numbers --color=always {} || highlight -O ansi -l {} ||coderay {} ||rougify {} ||cat {}) 2> /dev/null | head -500' --preview-window=right:60% fzf --preview '[[ $(file --mime {}) =~ binary ]] && echo {} is a binary file || (bat --style=numbers --color=always {} || highlight -O ansi -l {} ||coderay {} ||rougify {} ||cat {}) 2> /dev/null | head -500' --preview-window=right:70% fzf --preview '[[ $(file --mime {}) =~ binary ]] && echo {} is a binary file || (highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null | head -500' fzf --preview '[[ $(file --mime {}) =~ binary ]] && echo {} is a binary file || (bat --style=numbers --color=always {} || highlight -O ansi -l {} ||coderay {} ||rougify {} ||bat {}) 2> /dev/null | head -500' --preview-window=right:70% ``` Xargs ===== ll /tmp/*wsdl-bou*|grep 'Jul 24'|awk '{print $9}'|xargs rm # list files of date & remove them ls -a | grep \~ | xargs mv -t tmp+bak+tilde # list files with ~ & move them diff ==== diff --width=$COLUMNS --suppress-common-lines --side-by-side --color=always /tmp/test1.txt /tmp/test2.txt Search for a file for all users with matching pattern: ====================================================== for user in bsatishraj btata gkasim kmuthuvel kthokala ktoufique pdurgaprakash rkema_old smareddy smareddy-old smatte snagotu vgunnam; do for envdb in `find /data/$user -maxdepth 5 -type f -name 'env_db.php'` ; do grep -E 'BE_DB_DATABASE|BE_DB_SLAVE_DATABASE|BE_DB_WEATHER_DATABASE' $envdb|grep 'define(' |awk {'print $2 '}|sort|uniq |xargs echo -e "$user - $envdb \t\t -" ; done; done Explanation ============ kmuthuvel@localhost:atlas:~$ for user in kmuthuvel; > do > for envdb in `find /data/$user -maxdepth 5 -type f -name 'env_db.php'` ; > do > grep -E 'DB_DATABASE|DB_SLAVE_DATABASE|DB_WEATHER_DATABASE' $envdb | > grep 'define(' | > awk {'print $2 '}| > sort| > uniq| > xargs echo -e "$user - $envdb \t\t -" > done; > done kmuthuvel - /data/kmuthuvel/code/core/config/env_db.php - old_db shard01 kmuthuvel - /data/kmuthuvel/code-xyz/core/config/env_db.php - km_db shard01 kmuthuvel - /data/kmuthuvel/archive/code/core/config/env_db.php - km_db newdb shard01 kmuthuvel - /data/kmuthuvel/new/core/config/env_db.php - km_db shard0 kmuthuvel@localhost:atlas:~$ Alias ===== alias ls="ls --color" alias phpk="php -d display_errors=1 -d error_reporting=E_ALL -l" alias phpx="php -d xdebug.profiler_output_dir=$HOME/profile -d xdebug.profiler_enable=On" ln -s for new development env ============================= ln -s /data/kmuthuvel/kmcode /srv/www/b3.com/www/public_html/kmcode #data to public_html ln -s /srv/www/b3.com/www/public_html/kmcode /srv/www/b3.com/www/ #public to www SED / AWk ========= sed -n -e 's/.*\(.*\)<\/name>.*/\1/p' persons.txt #kesavan Mount Disk list =============== sudo lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL sudo fdisk -l sudo cat /etc/fstab # Currently mounted items sudo ls /dev kmuthuvel@localhost:atlas:~$ for user in bsatishraj ktoufique kthokala rkema gkasim snagotu vgunnam pdurgaprakash ; do echo $user `grep km_db /data/$user/code/core/config/env_db.php|wc -l`; done; $ export PS1="\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\$" #TODO ps -elF|head -1;ps -elF| grep listen_for_events_pa ps -elf|head -1;ps -elf| grep listen_for_events_pa rss in ps are resident ; resident set size;the non-swapped physical memory that a task has used (in kiloBytes)(alias rssize, rsz). RES in top ? (may be RSS of ps? . I assume so! htop echo -ne $(cat color-coded-file.txt | sed 's/$/\\n/' | sed 's/ /\\a /g') #read your files with colors shopt -s -o ignoreeof #prevent accidental logout sdiff -w210 -l parameters.yml.dist parameters.yml|cat -n | grep -v -e '($' |grep -v -E 'username|password|mysql:host' Disk Usage ========== du -sch * 2>/dev/null # disk usage by every file/directory du -sch * 2>/dev/null |tail -1 # disk usage by current directory du -sch * 2>/dev/null |sort -hr # disk usage , sort by size du -sh * | sort -hr |head -10 # disk usage , top 10 Permissions: ============ Permissions take a different meaning for directories. read - determines if a user can view the directory's contents, i.e. do ls in it. write - determines if a user can create new files or delete file in the directory. (Note here that this essentially means that a user with write access toa directory can delete files in the directory even if he/she doesn't have write permissions for the file! So be careful with this.) execute - determines if the user can cd into the directory. DIFF diff --old-group-format=$'\e[0;31m%<\e[0m' --new-group-format=$'\e[0;33m%>\e[0m' --unchanged-group-format=$'\e[0;32m%=\e[0m' /home/tmpdir/migrating_active_collections_report.php code/core/goodyear/scripts/migrating_active_collections_report.php diff --old-group-format=$'\e[0;31m%<\e[0m' --new-group-format=$'\e[0;32m%>\e[0m' --unchanged-group-format=$'\e[0;32m%=\e[0m' /home/tmpdir/migrating_active_collections_report.php code/core/goodyear/scripts/migrating_active_collections_report.php diff --old-group-format=$'\e[0;31m%<\e[0m' --new-group-format=$'\e[0;32m%>\e[0m' /home/tmpdir/migrating_active_collections_report.php code/core/goodyear/scripts/migrating_active_collections_report.php MYDIFF diff --new-line-format="%dn%L" --old-line-format="%dn%L" --unchanged-group-format="" --old-group-format=$'\e[0;31m%<\e[0m' --new-group-format=$'\e[0;32m%>\e[0m' /home/tmpdir/migrating_active_collections_report.php code/core/goodyear/scripts/migrating_active_collections_report.php CRONJOBS crontab -l >.crontab ;vi .crontab ; sleep 2 && crontab .crontab # Current cronjobs , saved locally alias crontab="vi ~/.crontab" # Edit cron jobs directly # Refer : http://unix.stackexchange.com/questions/136350/recover-cron-jobs-accidently-removed-with-crontab-r /var/spool/cron/crontabs/* # Backup this regularly BASH ERROR REPORTING err_report() { echo "Error on line $1"; } trap 'err_report $LINENO' ERR WORKING WITH FILES STARTS WITH CHAR '-' ls ./-sample-idotic-file Check who configured what: ========================== for user in `/bin/ls /data/`; do for envdb in `find /data/$user -maxdepth 5 -type f -name 'env_db.php'` ; do grep -E 'DB_DATABASE|DB_SLAVE_DATABASE|DB_WEATHER_DATABASE' $envdb|grep 'define(' |awk {'print $2 '}|sort|uniq |xargs echo -e "$user - $envdb \t\t -" ; done; done TEE === ((main_job|tee /dev/fd/5|job_1 >/dev/fd/4)5>&1|job_2)4>&1 ((main_job|tee /dev/fd/5|(job_2 >/dev/fd/4))5>&1|job_1)4>&1 (( ps -ef | tee /dev/fd/5 |grep wow >/dev/fd/4 ) 5>&1 | grep cmprod)4>&1 cat /tmp/case.out | tee >(grep -E /On.*[\d]{1,9}/ 1>&2) |grep -C1 'Your Current Status' curl https://sdsdsd |tee >(grep -oh 'On.*Number \w.*[0-9]' 1>&2) |grep -C1 'Your Current Status' | tail -1|tr -d "\t" |tr -s " " (R)SYNC rsync --progress -zarvh kesavan@123.456.789.000:/source/at/remote/important /local/kesavan/important.bkup #diff/compare before sync rsync -avzi /home/kesavan/bin/ kesavan@123.456.789.000:/home/kesavan/bin/ thulasi@thulasi-Inspiron-15-356773.166.41.67~2024-04-07 10:40:18 $rsync -avhW --no-compress --progress .cache/thunderbird /media/thulasi/thunderbird/ sending incremental file list sent 223.26K bytes received 68 bytes 148.88K bytes/sec total size is 289.66M speedup is 1,297.03 0 ✓ success ^_^ ________________________________________________________________________________ thulasi@thulasi-Inspiron-15-356773.166.41.67~2024-04-07 10:40:52 $rsync -avhW --no-compress --progress /mnt/16b5a806-1ad0-41fc-8bd6-a16fe6bc0d50/users/kesavan/mozilla/.thunderbird /media/thulasi/thunderbird/ sending incremental file list sent 197.85K bytes received 430 bytes 396.55K bytes/sec total size is 56.23G speedup is 283,618.41 0 ✓ success ^_^ ________________________________________________________________________________ thulasi@thulasi-Inspiron-15-356773.166.41.67~2024-04-07 10:40:55 #better color LS_COLORS=$LS_COLORS:'ow=1;34:' ; export LS_COLORS #release/distro details cat /etc/*-release /etc/*version IRC /nickserv register yourPassword yourEmailAccountName@yourMailProvider /msg nickserv identify kesavan https://wiki.mozilla.org/IRC MySQL -- PROCESSLIST SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST WHERE Command='Query' AND `INFO` LIKE 'SELECT %' ORDER BY STATE ; -- Pager MySQL > PAGER(STDOUT) > STDOUT \P grep -v Sleep -- (\P === pager) -- MySQL > PAGER(grep) > STDOUT pager grep -v Sleep | more; SHOW FULL PROCESSLIST; -- OR whatever SQL \P -- Default pager wasn't set, using stdout. ' -- More on Pager mysql> pager less /** http://www.percona.com/blog/2008/06/23/neat-tricks-for-the-mysql-command-line-pager/ **/ -- Find Column & Tables SELECT DISTINCT TABLE_SCHEMA,TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%order%' AND TABLE_NAME LIKE '%867%' AND TABLE_SCHEMA IN (SELECT DATABASE()); SELECT DISTINCT TABLE_SCHEMA,TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE '%kesavan%' ; -- METADATA -- select table_schema,table_name,create_time from information_schema.tables where table_schema like 'kmuthuvel5' limit 5 ; --REGEXP SELECT id,book_name FROM books WHERE Order_Status REGEXP 'Time|Relativity|Gravity'; --STRING mysql> select customer_id,substring_index(substring_index(xml_log,'',-1),'',1) lob -> from kmuthuvel.orders_xml where order_id = 12345; -- EXTRACTVALUE(xml,'xpath') select oms.order_id,oms.created, oms.market_source_id, ExtractValue(xml,'direct_api/order/market_source_id') actual_msid from orders_market_sources oms join orders_xml oxml on oxml.order_id = oms.order_id where oms.order_id >'6483182' and oms.market_source_id='6' and oms.market_source_id!=ExtractValue(xml,'direct_api/order/market_source_id') -- Copy Table CREATE TABLE km_dup.table1 SELECT * FROM km_orig.table1 -- SQL to fetch latest from same table V1 SELECT * FROM (SELECT id,customer_id,note,date_created FROM customer WHERE customer_id = 123 AND note LIKE 'Customer not happy%' ORDER BY id DESC ) AS LATEST GROUP BY customer_id -- SQL to fetch latest from same table V2 Tuned SELECT ccn.id , ccn.customer_id ,ccn.note , ccn.date_created FROM customer ccn LEFT JOIN customer ccn2 ON (ccn.customer_id = ccn2.customer_id AND ccn.date_created < ccn2.date_created AND ccn.note = ccn2.note ) WHERE ccn2.date_created IS NULL AND ccn.customer_id = 123 AND ccn.note LIKE 'Customer not happy%' ; -- Example V1 SELECT * FROM ( SELECT id,customer_id,note,date FROM customer_log ORDER BY id DESC ) AS LATEST GROUP BY customer_id ORDER BY date DESC ; -- Example V2 SELECT c1.* FROM customer_log c1 LEFT JOIN customer_log c2 ON (c1.customer_id = c2.customer_id AND c1.date < c2.date ) WHERE c2.date IS NULL ; SELECT id,report_id, CONVERT(params USING utf8) params,last_updated ,run_every,notes,active FROM autoreports ORDER BY id DESC LIMIT 5; TRIGGERS ======== mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt -hlocalhost --ukmuthuvel -pXXXXXXXXXXXX my_database > ~/my_database.routines.sql mysql -hlocalhost -ukmuthuvel -pXXXXXXXXXXXX kmuth_new < my_database.routines.sql mysqldump -h -u -p --no-data --no-create-db --no-create-info --skip-opt --triggers > trigger.sql SUB-SQLs ======== LEFT JOIN (a INNER JOIN b ON b.id = a.attr_id AND b.name = 'key_attr' ) ON a.order_id = o.id -- optimal LEFT JOIN a ON a.order_id = o.id AND a.attr_id = (SELECT id from b WHERE name = 'key_attr') -- 6x slow LEFT JOIN a ON a.order_id = o.id AND a.attr_id = 123 -- 2x slow, hardcoded Table Size ========== select table_name as `table`,round((data_length + index_length) / 1024 / 1024) as `size (mb)` from information_schema.tables where table_schema = "db_schema" order by (data_length + index_length) desc; DB Size SELECT table_schema "DB Name", ROUND(SUM(data_length + index_length) / (1024*1024*1024), 1) "Size(GB)" FROM information_schema.tables GROUP BY table_schema; Disable/Enable Strict mode ==================== SELECT @@GLOBAL.sql_mode; SET @@GLOBAL.sql_mode='' SET @@GLOBAL.sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' SET GLOBAL log_bin_trust_function_creators = 1; -- bypass errors related to log_bin_trust dump issue ========== ERROR 1449 (HY000) at line 53175: The user specified as a definer ('boun02sa'@'localhost') does not exist sed -ie 's/ROW_FORMAT=FIXED//g' ~/workspace/db/eo/eo_shard01.sql # clean up the dump before MySQL import mysql -e "GRANT ALL ON *.* TO 'boun02sa'@'%' IDENTIFIED BY 'password';" # add the users mysql -e "FLUSH PRIVILEGES;" # flush mysql -e "DROP DATABASE eo; CREATE DATABASE eo;" # create a fresh db mysql eo < ~/workspace/db/eo/eo_shard01.sql # reimport, it should work PHP ob_start();var_dump(); user_error(ob_get_contents()); ob_get_clean(); debug_print_backtrace() php -d display_errors=1 -d error_reporting=E_ALL -l # define('DEV',0); if(DEV) error_log(date('c')."\t ==>$sql<== with ==> ".var_export($anything,true)."<== \n",3,"/tmp/dev.log"); echo "
";   print_r($_POST);
    echo "
";   var_dump($_POST); exit;

    service php-fpm restart

    

    Try-Catch
    =========

    try{
        $response = $client->ValidateUser("kesavan", "Password1",'DE'); #SERVICE
    }catch (Exception $e) {
        echo "Caught exception:".get_class($e)."\n{$e->getMessage()}\nIn file:{$e->getFile()} at line #{$e->getLine()}\n{$e->getTraceAsString()}\n";
        throw $e;
    }

    Custom Profiler
    ================
    self::profiler('Going to kill me!!! ');
    $total_orders = count($orders); $i =1;$startTime= microtime(true);

    public static function profiler($msg){
        $message = date('Y-m-d H:i:s')." Memory:".round(memory_get_usage()/(1024*1024)).
            "MB MemoryPeak:".round(memory_get_peak_usage()/(1024*1024))."MB  \t".
             number_format(( microtime(true) - $startTime), 4)." Seconds \t".
            .var_export($msg,true)."\n";
        error_log($message,3,'/tmp/sql.log');
    }

    Color'd echo
    ============
    echo " \e[1;34m ". date(c)." \e[35m error-message \e[0m ";

    Included files/functions
    ========================
    var_dump(get_defined_functions());
    var_dump(get_included_files());

    Custom Error Backtracing
    ========================

    $caller =debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,2)[1]['function'];
    $caller2 =debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,3)[2]['function'];
    echo date('c')."\t".__FILE__.__CLASS__. __METHOD__ . __LINE__ . "leaving now \n";
    echo date('c')."\t". __FILE__.__CLASS__."Inside method:". __METHOD__."@ line#" . __LINE__ ."Called by:$caller |  calling getResults \n";
    echo date('c')."\t".__CLASS__."Inside method():".__METHOD__."@ line#".__LINE__."==>".var_export($incFile,1)."<==\n";

    echo date('c')." ".basename(__FILE__)."|". __METHOD__."|".__LINE__.'==>calling:Basic_report->genericAutoReport<=='."\n";
    echo date('c')." ".basename(__FILE__)."|". __METHOD__."|".__LINE__."==>is_auto\n";

    Console-Table foramtted output
    ==============================
    $x = include 'data.php';    # input array

    $mask = "|%5.5s |%-20.20s| %-13.13s |\n";
    printf("+------------------------------------+\n");
    printf($mask,'brand','brand_name','aliases');
    printf("+------------------------------------+\n");
    foreach ($x as $brand => $data)
            list($brand_name,$aliases) = $data;
            printf($mask,$brand,$brand_name,$aliases);
    printf("+-------------------------------------+\n");

    progressBar
    ===========
    function progressBar($done, $total) {
        $perc = floor(($done / $total) * 100);
        $left = 100 - $perc;
        $write = sprintf("\033[0G\033[2K[%'={$perc}s>%-{$left}s] - $perc%% - $done/$total", "", "");
        fwrite(STDERR, $write);
    }

MemCache
    echo 'flush_all' | nc localhost 11211
    sudo service memcached restart

GIT
    Normal Flow
    ===========
        git status                              #Show the current status
        git branch  new_enchancements           #Creates new Branch (Local)
        git checkout    new_enchancements       #Switch to branch (new_enchancements)
        git checkout -b new_enchancements       #Creates & Switch to new_enchancements branch (Local)
        git add file.php                        #Adding new file to git
        git commit -m "Fixed,all files"         #Commit the file
        git push origin new_enchancements       #Send to origin

        git checkout --f new_enchancements      #Switch to branch by force

        git remote -v                           #git remote info

        git reset filename.txt                  #remove a file from the current index, the "about to be committed" area,
                                                #without changing anything else.
        git reset                               #undo `git add .`


        git -c color.ui=always     #force color output

        git ls-remote origin

        
    Branching
    =========
        Always create new branch from `development` only. Else you may conflicts raising from the branch from where you create the new.

        Right-way:
        ==========
                 -------new-feature----------> 5 changes (new feature added )
                /
        -------/--------development----------> 0 changes (upto date with master)
                           \
                            \---hotfix-------> 2 changes (quick hotfix;go by eod )

        0 ---- 1 ---- 2 ---- 3 ---- Time --->


        Avoid:
        =====
                            /---hotfix-------> 7 changes (combines with new feature)
                           /
                 -------new-feature----------> 5 changes (new feature added )
                /
        -------/--------development----------> 0 changes (upto date with master)

        0 ---- 1 ---- 2 ---- 3 ---- Time ---->

    Save changes to temp & goto other branch & come back
    ====================================================

    $git branch                             #list branches                      #10:00 AM
     development
     *my-branch
     master
    $git status                             #current status                     #10:30 AM
     modified:
        abc.txt
    $git stash                              #move changes to temp location      #10:31 AM
    $git checkout very_new_branch           #switch to other branch             #10:40 AM
    $git add new.file.ext                   #work on other branch               #02:30 PM
    $git commmit -m 'Fixed issues;'         #commit the changes                 #02:40 PM
    $git checkout my-branch                 #back to original branch            #03:00 PM
    $git stash pop                          #get the changes from stash         #03:03 PM


    git stash list --format="%gd: %cd - %gs" --date=short
    git stash show --stat

    git stash show -p stash@{1}                 #preview what's inside the stahs 
    git diff  stash@{1} origin/development  --name-only
    git diff stash@{2} origin/development --  app/libraries/Myaccount.php   # compare a file from stash w/ branch

    ## treat stash as local commit # you can checkout , pop single file, git diff

    git diff  stash@{0}  -- file # diff the stash file 
    git checkout stash@{0}  -- checkout the single stash file 
        (git restore --source=stash@{0} -- )
        git show stash@{0}:  >  
        #https://stackoverflow.com/a/15264717/3140741

    git stash push -m page-fix -- file



    Revert to previous commit
    =========================
    git reset --hard  2454tb6
    git push -f origin kmuth-branch

    submodules
    ==========
    git submodule add [-b master --depth 1]  https://github.com/junegunn/fzf.git    # add/init
    git submodule init
    
    git submodule update --init --recursive                                         # update    
    git submodule deinit -f - fzf; rm -rf .git/modules/fzf; git rm -f fzf           # remove/deinit

    Revert To Original/Old - Entire directory (code base)
    =====================================================
        git pull ?
        git stash; git fetch origin; git reset --hard origin/development    #Entire directory to REMOTE_MASTER/REMOTE_BRANCH
        git reset --hard df2bcfac7cabc0fd14d5c5abce22d65589e458a1           #Entire directory to particular version

    Revert To Original/Old version - File level (single file)
    =========================================================
        git checkout -b old_is_gold                                             #Creates & Switch to branch old_is_gold
        git checkout HEAD path/to/file                                          #Single File , from Master
        git checkout d279318b40657be62accea2130ef2fdf9b150b26 -- [full/path]    #Single File , from particular commit

    Revert To Original/Old version - Branch level (From remote into local) (Multiple files)
    =======================================================================================
        git checkout -b old_local_branch            #Creates & Switch to branch old_local_branch
        git merge --no-ff old_remote_gold           #Auto-merging from old_remote_gold to old_local_branch
        git push origin old_local_branch            #Push changes to origin again

    Get changes from master into branch in git
    ============================================
        git rebase master


    Pick & Squash
    =============
        git rebase -pi development      # If nothing shows on squash , try -i only
            pick    f7f3f6d commit 1
            squash  310154e commit 2
            squash  a5f4a0d commit 3
        git push -f origin hot-fix-branch

        git rebase -pi development
            #first on as pick , rest all squash
            >> Refusing to squash a merge: 7daa8381fc40294b9616ebe28466a0cc2aabdca3
        git status
            >>rebase in progress; onto 3f688ad
            >>You are currently editing a commit while rebasing branch 'kmuth-hot-fix' on '3f688ad'

        git rebase --continue
            #removed all the commit messages
            >>Successfully rebased and updated refs/heads/kmuth-hot-fix.
        git push -f origin kmuth-hot-fix
        
        
        #Messed with some other branch stuff ?      
        git branch -D feature_branch
        git checkout developemnt
        git fetch origin && git pull
        git checkout  feature_branch
        git log
        # pick some recent 4-5 old commit
        git rebase -i b223f604  # or git rebase -i HEAD~5
        #pick/drop/squash
        git push -f origin feature_branch

       ### Squash 20 commits from PR
       git rebase -i HEAD~20
       git rebase --continue
       git push origin branch-name --force

        git commit --amend -m "Here goes the final amendment message of all commits to be merged."
    Undo rebase
    ===========
        git reflog  --date=iso branch       #1 of 3 - REFLOG the current branch
        git reset --hard 81ca2476a4         #2 of 3 - RESET to COMMIT before rebase
        git push -f origin branch           #3 of 3 - Just PUSH, nothing to commit/add
    
        Example
        ~~~~~~~
        $git reflog  --date=iso faq2
        5e887715b9 (HEAD -> faq2, origin/faq2) faq2@{2020-03-30 12:45:58 -0500}: rebase -i (finish): refs/heads/faq2 onto 6b1b4c68c24976163da779b1701a9da461882d31
        cb991118aa faq2@{2020-03-30 12:44:27 -0500}: commit: revert of other misc files
        132a17e7d7 faq2@{2020-03-30 12:35:50 -0500}: rebase -i (finish): refs/heads/faq2 onto 6b1b4c68c24976163da779b1701a9da461882d31
        81ca2476a4 faq2@{2020-03-30 12:34:21 -0500}: commit: little tuning
        ba6fcc377c faq2@{2020-03-30 12:02:34 -0500}: branch: Created from refs/remotes/origin/faq2
        0 ✓ success ^_^  ________________________________________________________________________________
        kmuthuvel@L18726(98.198.59.144)|/srv/www/code_de|2020-03-30 13:13:09[faq2]
        $git reset --hard 81ca2476a4
        HEAD is now at 81ca2476a4 little tuning
        0 ✓ success ^_^  ________________________________________________________________________________
        kmuthuvel@L18726(98.198.59.144)|/srv/www/code_de|2020-03-30 13:15:17[faq2]
        $git push -f origin faq2

    Squashing with conflict resolved merges
    =======================================
        git checkout development                        # Move to development
        git branch -D hf_with_5changes_8commits         # Delete  from locally
        git pull origin development                     # Make sure git is upto date
        git checkout -b hf_with_5changes_8commits       # Create & checkout  from development
        git apply ~/5changes.patch.diff                 # Apply the diff (from gitlab) on 
        git push -f origin hf_with_5changes_8commits    # Git push all the final changes


    Patch apply
    ===========
        git apply --stat ~/fix_affleck_upload.patch
        git apply --check ~/fix_affleck_upload.patch
        git apply ~/fix_affleck_upload.patch
        git add
        git commit -m "patch added"
        git push origin 

    Copy branch to branch
    =====================
        git checkout -b new_branch old_branch


        Example
        =======
        git checkout development
            Switched to branch 'development'
            Your branch is up-to-date with 'origin/development'.
        git merge --no-ff heavy_reports
            Auto-merging sonar/system/application/views/reporting.php
            Auto-merging core/build/classes/core/reporting/classes/orders_report.php.php
            Auto-merging core/build/classes/core/reporting/classes/KPI_Report.php
            CONFLICT (content): Merge conflict in core/build/classes/core/reporting/classes/KPI_Report.php
            Automatic merge failed; fix conflicts and then commit the result.
        git push origin development
            Everything up-to-date

    Get single file from different branch from remote
    =================================================
        cd /data/kmuthuvel/code     #go to top code level
        git checkout origin/diff_branch full/path/to/file.ext
        git checkout origin/smt_usage_emails core/build/classes/core/ercot/SmtDataDailyPeer.php

        git checkout origin/master   #to live

    Clean
    ======
        git clean -f                # remove-local-untracked-files

    Remove/Delete remote/local branch
    =================================
        git branch -d       #local only
        git push origin --delete    #remove remote(if you know what you are doing!)
        git push origin :       #alias of above

        git push origin :refs/heads/rm-orch-tmp-files
        git push --delete --force origin rm-orch-tmp-files


    ### upstream and more
    =====================
    git remote add upstream git@git.xxx.com:lead/pmsmanager.git
    git fetch upstream; git pull upstream 

    git remote add peer1 git@git.xxx.com:peer1/pmsmanager.git
    git fetch peer1 ; git pull peer1 
    git checkout -b key_con_fix peer1/key_con_fix

    git fetch git@git.xxx.com:peer2/pmsmanager.git blahblah
    git checkout FETCH_HEAD

    git remote remove peer1  #undo

    git clone -b cet --single-branch git@git.xxx.com:lead/pmsmanager.git

    ### Cleanup remote branches
    ===========================
    git fetch --prune
    git push origin --delete 

    git fetch --prune origin


    Unable to commit ?
    ==================
        To git@198.123.45.678:kmuthuvel/code.git
         ! [rejected]        new_enchancements -> new_enchancements (non-fast-forward)
        error: failed to push some refs to 'git@198.123.45.678:kmuthuvel/code.git'
        hint: Updates were rejected because the tip of your current branch is behind
        hint: its remote counterpart. Integrate the remote changes (e.g.
        hint: 'git pull ...') before pushing again.
        hint: See the 'Note about fast-forwards' in 'git push --help' for details.

        [Option #1]
        git push origin --delete new_enchancements      #1 remove remote branch
        cd /data/kmuthuvel; rm -rf code                 #2 remove local setup
        git clone git@198.123.45.678:kmuthuvel/code.git #3 setup fresh code
        git branch new_enchancements (git branch -a)    #4 create unique branch
        git checkout new_enchancements                  #5 switch to new branch
        ...                                             #6 develop changes
        git diff                                        #7 verify changes
        git status;git add file1 file2 ;                #8 add files and status
        git commit -m 'Reports enchanced'               #9 commit changes
        git push -u origin new_enchancements            #10 done!

        [Option #2]
        $git push -u -f origin fix-pogo-bulk-orders
        Counting objects: 2, done.
        Delta compression using up to 8 threads.
        Compressing objects: 100% (2/2), done.
        Writing objects: 100% (2/2), 263 bytes | 0 bytes/s, done.
        Total 2 (delta 1), reused 0 (delta 0)
        remote:
        remote: View merge request for fix-pogo-bulk-orders:
        remote:   https://de-gitlab.engine.host/fireengine/code/merge_requests/3903
        remote:
        To git@de-gitlab.engine.host:fireengine/code.git
         + a752aaa...cf10736 fix-pogo-bulk-orders -> fix-pogo-bulk-orders (forced update)
        Branch fix-pogo-bulk-orders set up to track remote branch fix-pogo-bulk-orders from origin.

    git clone over slow network
    ============================
        git clone  --depth 10 user@example.org:awesome/project.git project.mini

    Diff & Logs
    ===========
        git diff   file.ext   # Compare latest to Old
        git diff a268ab7670c5430a2a98638cb04820516f8b1b9e 85cfd5ae0e4a1d888eb9611d99c6eac2ba92740f  orders_report.php.php
        git diff HEAD^ HEAD [users_controller.php]

        git diff --text                                 # Diff over bin files

        #.gitconfig
        [diff "hex"]
            textconv = hexdump -v -C
            binary   = true

        git log -Spattern -- orders_report.php  #accepts a string
        git log -Gpattern -- orders_report.php  #accepts a regex

        git grep [-e] case_sensitive_pattern ro
        git grep -i case_insenstive_pattern

        git log --grep=word         #find all commits where commit message contains given word

        git show 211dbe40cd784b06932122f7ba67d656ed438b01   # Particular commit

        git diff --unified=0 -- filename.ext  # git diff with line numbers (aka git diff -U0)

        [TIP]   #http://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History

        git log --pretty=format:"%h - %an, %ar : %s" -S'unique_identifier' -- orders_report.php
        git log --pretty=format:"%h - %an, %ar : %s" orders_report.php
        git log --pretty=format:"%H - %an, %ar : %s" orders_report.php
        git log --author=kmuthuvel
        git log --author="\(kmuthuvel\)\|\(rms\)|\(einstein\)"
        git log --pretty=format:"%h %s" --graph --author=kmuthuvel
        git log --no-merges master

        git log --all -- this-is-deleted-file.pl            #who deletes this file ; tracks all the history of file that got deleted.
        git log --all --full-history -- "**/filename.ext"   # from the root of repo 

        #List all the modified files for a commit (better version below)
        git diff-tree --no-commit-id --name-only -r 2bc51f53a15da1428f8320d9ee93f8e7069a05a2

        #Quick summary on a commit ( --stat & --name-status)
        git show --stat --summary 66064dbfb18f2562261588c64f8e74a9c941ab00
        git show --name-status a5e347198e93a6ecb69077ac2cd1491337531671

        git show --name-only 581c968d50ca3259b94081ac428969184ed51eab

        git diff --name-only | xargs  ls -lt        # latest modified files

        git log --name-only --pretty=format:"%H - %h - %an, %ar : %s"  --author=kmuthuvel  --walk-reflogs   my_hot_fix          # log on only that specific branch
        git log --stat --oneline --pretty=format:"%h - %an, %ar : %s" --author="\(kmuthuvel\)\|\(raju\)" --walk-reflogs welcome-offshore

        git log --date=local --pretty=format:\%h%x09%C\(cyan\)%an%x09%ad:%Creset%s parameters.yml.dist
        git log --date=short --pretty=format:\%h%x09%C\(cyan\)%ad%C\(green\)%x09%an%Creset%x09%s parameters.yml.dist
        
        #team work on date wise
        git log --date-order --date=iso  --pretty=format:'%C(cyan)%ad%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08 %C(red)%h  %C(bold blue)%aN%C(reset)%C(bold yellow)%d %C(reset)%s' --after="2019-01-01"  --author="\(Kesavan\)\|\(kmuth\)"



        # original 
        alias glx="git log --date=short --color=always --pretty=format:'%C(magenta)%h%C(cyan)%C(bold)%ad %C(green)%<(20,trunc)%an%x09%Creset%C(yellow)%s%Creset'| head -20| cat -n"

        # Undo git rm -r --cached
        git reset HEAD~1

        GIT TIME maching
        ================
        git reflog # ref log on current local repo

        # you will see a list of every thing you've done in git, across all branches!
        # each one has an index HEAD@{index}
        # find the one before you broke everything
        git reset HEAD@{index}
        # magic time machine

        #digging for an info
        git log --pretty=format:"%h - %an, %ar : %s"  * | grep -i -E 'social|ssn'
        #digging log with modified files
        git log --name-status --author=kmuthuvel --pretty=format:"%h - %an,%ar| %f : %s " * | grep -A2 -i -E 'social sec|ssn'


        git log --graph --pretty=format:"%x09%h | %<(10,trunc)%cd |%<(25,trunc)%d | %s" --date=short

        //R-n-d
        git log --graph --pretty=format:"%x09%h | %<(10,trunc)%cd |%<(25,trunc)%d | %s" --date=short
        git log --graph --pretty=format:'%Cred%h%Creset %ad %s %C(yellow)%d%Creset %C(bold blue)<%an>%Creset' --date=short
        git log --graph --pretty=format:'%Cred%h%Creset %ad %s %C(yellow)%d%Creset %C(bold blue)<%an>%Creset' --date=short
        git log --graph --pretty=format:"%C(yellow)%H%C(green)%d%C(reset)%n%x20%cd%n%x20%cn%x20(%ce)%n%x20%s%n" --color --all
        git log --graph --pretty=format:"%x1b[31m%h(green)%ad %x09%x1b[32m%d%x1b[0m%x20%s%x20%x1b[33m(%an)%x1b[0m" --date=short --full-history --all --color


        Changed files:
        ==============
        git diff --name-only development
        git log --oneline --pretty="format:" --name-only development.. | awk 'NF' | sort -u
 
        #list all commits carry change to file
        git log --all --first-parent --remotes --reflog --author-date-order -- filename
        git log  --all --first-parent --remotes --reflog --author-date-order --date=local --pretty=format:"%h%x09%C(cyan)%an%x09%ad:%Creset %s"
    ## colorize git
    git config --global color.ui true


    ## diff tools
    git icdiff      #column diff tool highlights changes with numbers
    FIX CONFLICTS
    =============
    git clean -f                                # clean your local
    git fetch origin                            # fetch all
    git checkout -b hot-fix origin/hot-fix      # make sure you don't any existing branch with same name
    git merge --no-ff origin/development        # try to fix automatic and you'll see errors
    vim core/conflict.php                       # remove conflicts manually
    git commit -am 'fixed conflicts on 1234'    # add and commit to git
    git merge --no-ff origin/development        # it should work now
    git push origin hot-fix                     # job done
    git checkout development                    # back to development
    git branch -d hot-fix                       # delete the hot-fix that no more need

    git branch -D --remote origin/orch-fine-tune origin/checksum-api origin/dm-orch 
    
    MISC
    =====
        git fetch origin
        git checkout -b new_enchancements origin/new_enchancements
        git checkout development
        git merge --no-ff new_enchancements
        git push origin development

        git checkout development            #Always checkout development
        git branch
        git add file.php                    #Adding new file to git
        git commit -m "Fixed,all files"     #Commit the file
        git push origin new_enchancements   #Send to origin

        On branch development
        Your branch is up-to-date with 'origin/development'.

        git pull
        git push -u origin new_enchancements    #Send to origin

        # quick view on all branches
        ORIG=`git branch|grep \* | sed -e 's/\* //g'` ; for i in `git branch|sed -e 's/\* //g' -e 's/ //g'` ; do git checkout $i 1> /tmp/$USER_git_warings.log; if [ /tmp/$USER_git_warings.log ] ; then if [ `grep up-to-date /tmp/$USER_git_warings.log  |wc -l` -eq 0 ] ; then ST='-w' ;  else ST='-g' ; fi ; cat /tmp/$USER_git_warings.log | msg2 $ST  ; rm -f /tmp/$USER_git_warings.log;   fi ;git diff --stat --cached origin/$i ; done  ; git checkout $ORIG ;

        #Git Repository Deleted File Recovery Method
        http://www.gitguys.com/how-to-recover-a-deleted-a-file-from-my-git-repository/

        Undo a commit and redo
        ======================
        git commit -m "Something terribly misguided"              (1)
        git reset --soft HEAD~                                    (2)
        << edit files as necessary >>                             (3)
        git add ...                                               (4)
        git commit -c ORIG_HEAD                                   (5)
            (Thanks:http://stackoverflow.com/questions/927358)

        git commit --amend -m "New commit message"      #Amending the most recent commit message
                                                        #Edit an incorrect commit message in Git




        $git rm --cached   #deal with error “Git: fatal: Pathspec is in submodule

        Delete the last commit
        ======================
        git reset HEAD^ --hard
        git push origin/branch_name -f

        #bring a clean env
        git update-index --assume-unchanged  .gitignore
        git update-index --no-assume-unchanged .gitignore

    Merge into MASTER
    =================
        git checkout master
        git pull               # to update the state to the latest remote master state
        git merge develop      # to bring changes to local master from your develop branch
        git push origin master # push current HEAD to remote master branch

    Alternative to cherry-pick
    ==========================
        git checkout replica-map && git pull        # goto branch
        git reset origin/staging --hard             # hard reset to base branch
        git checkout abcd01 -- deploy.yaml          # check the change by commid_id
        git diff -w  deploy.yaml                    # ensure the changes 
        git add deploy.yaml                         # add 
        git commit -m 'on top of latest'            # and commit
        git push -uf origin replica-map             # go go gooo

	someone's branch into local
	===========================
	git fetch git@github.com:einstein/relativity.git fix-gravity
	git checkout FETCH_HEAD



    Skip mode changes in diff
    =========================
        git config --global core.filemode false

COMPOSER
        COMPOSER_PROCESS_TIMEOUT=600  COMPOSER_MEMORY_LIMIT=-1 composer update

APACHE
    Disable/Enable modules
    ======================
    sudo a2dismod php5.6
    sudo a2enmod php7.3


    #kmuthuvel - to fix "Invalid argument: AH00076: Failed to enable APR_TCP_DEFER_ACCEPT"
    AcceptFilter https none
    AcceptFilter http none
       
AWS/Cloudwatch/Console/InSight

    fields @timestamp, @message
    | filter @logStream like "web-prod"
    | filter @message like "80108216905"
    | sort @timestamp desc
    | limit 20

    fields @timestamp, @message
    | filter @logStream like "web-prod"
    | filter @message like "MyaccountPay.getWalletInformation.error" 
    | parse @message '"RequestID":"*",' as @RequestID
    | parse @message 'payment_event: order-*-' as @order
    | parse @message 'error @*:' as @ip        

    fields @timestamp, @message
    | filter @logStream like "web-prod"
    | filter @message like "MyaccountPay.getWalletInformation.error" 
    | parse @logStream /(?<@brand>([a-z]+))-web-prod/
    | stats count(*) by bin(1d)


    fields @timestamp, @message
    | parse @message /(?<@ip>^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})[.]*)/
    | stats count() as requestCount by @ip
    | sort requestCount desc

    PARSE & ESCAPE & SHOW/HIDE(DISPLAY)
    ===================================
    fields @timestamp, @message , @logStream
    | filter @message like 'MyaccountPay.getAutoPayment.error'
    | parse @logStream "*-" as  @brand 
    | parse @message "order-*-*OperationResult\":\"*\",*}" as @order_id,@misc, @OperationResult,@rest
    | sort @timestamp desc
    | display @timestamp, @brand ,@order_id, @OperationResult

    
    fields @timestamp, @message, @logStream
    | filter @message like '//powertochoose.'
    | filter @message like 'msid/3051/pid'
    | parse @message '/texas/electricity-plans/*/msid/*/pid/' as @plan_misc,@msid
    | parse @message /(?<@ip>^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})[.]*)/
    | parse @message 'utm_source=*&utm_medium=* ' as @utm_src, @utm_medium
    | parse @message 'http://*Plan/Results' as @ref
    | parse @logStream /(?<@brand>([a-z]+))-web-prod/
    | parse @log  'var/log/httpd/*' as @file 

    Logical OR condition
    ====================
    fields @timestamp, @message ,@logStream , @log
    | filter @logStream like 'cruncher-prod-i-0d90d48ac1355ec63'
    | filter @log  like '457289674159:/var/log/core.log'
    | filter @message like /(Importer: Beginning Import files|Importer: Completed Import)/

    HTTP Status Code from /var/log/httpd/access_log
    ================================================
    fields @timestamp, @message,@logStream, @log
    | parse  @message "* - - [*] \"* " as @ip,@datetime,@method,@misc
    | parse  @misc "* *\" * * * *" as @uri,@protocol,@code,@size,@referer,@user_agent
    | fields @timestamp, @message,@logStream
    | limit  10
    
    Last 5 500 Error HTTP Status Code from /var/log/httpd/access_log
    ================================================================    
    parse @logStream /(?<@brand>([a-z]+))-web-prod/
    | parse  @message "* - - [*] \"* " as @ip,@datetime,@method,@misc
    | parse  @misc "* *\" * * * *" as @uri,@protocol,@code,@size,@referer,@user_agent
    | filter @code = '500'
    | fields @logStream, @log 
    | display @brand, @ip, @datetime, @method, @uri, @protocol,@code,@size,@referer,@user_agent,@logStream,@log


    REGEX with logical OR condition and  CASE insensitive condition
    ===============================================================
    fields  @timestamp, @message ,@logStream , @log
    | filter @logStream like 'fcp-cruncher-prod-i-0d90d48ac1355ec63'
    | filter @log  like '457289674159:/var/log/fireengine/core.log'
    | filter @message like 'ERCOT Importer'
    | filter @message like /(?i)(Beginning IMpOrT files|CompleTEd Import)/
    | sort   @timestamp asc
    | limit  10

    fields @timestamp,@logStream, @message 
    | filter @logStream like 'fcp-web-prod'
    | filter @message like 'CreateNewAccountNumber'
    | filter @message like 'exception="1"'
    | parse @message 'action="*"' as @action
    | parse @message 'exception="*"' as @exception 
    | parse @message 'exception_message="*"' as @exception_message
    | stats count(*) by bin(1d), @exception_message

    fields @timestamp, @message, @logStream
    | filter @logStream like /(?i)((cpl|fcp)-cruncher-dev)/
    | filter @message like /(?i)(delet)/

    RegEX NOT LIKE & word 
    =====================
    fields @timestamp, @message , @logStream
    | filter @logStream like 'de-web-prod'
    | filter @message not like 'handleVerificationMethodPosting'
    | filter @message like /(?i)(smtp[\. ])/
    | parse @message "Exception: subject='* ' * :" as  @subject, @Exception
    | display @timestamp, @subject , @Exception 


### OCI 
    sudo mount  -t ext4 /dev/sdb /mnt/kesavan/


Splunk

    index="access_log" "/account/login" POST mobile host="de-*" | timechart span="1d" count
    index="access_log" "/account/login" POST mobile host="de-*" Android Firefox

    host="de-*" index="myaccount_frontend_dce" | table _time customer_id order_id mobile browser platform service_state
    host="de-*" 382450 | table _time

    host="de-*" "direct-your-energy"  sourcetype=fe_metrics | table _time customer_id order_id total_execution_time customer_service_state

    host="de-*" uri="*direct-your-energy*" sourcetype=access_log phpsessid!=''|eval session=phpsessid | eval  os = case(match(user_agent,"Windows .. 5\.1"),"Windows XP",match(user_agent,"droid"),"Android",  match(user_agent,"Windows NT 610"),"Win10", match(user_agent,"Mac"),"Mac",          match(user_agent,"Windows NT 6.1"),"Windows 7"    )   | eval browser = case(match(user_agent,"MSIE 10.0"),"Internet Explorer 10.0",match(user_agent,"Trident"),"IE11", match(user_agent,"Chrome"),"Chrome",match(user_agent,"Safari/"),"Safari") | eval arch = case(match(user_agent,"droid"),"android",match(user_agent,"iPad"),"ipad",match(user_agent,"iPod"),"ipod")  |table os browser uri session|join session [search host="de-*" sourcetype=fe_metrics | table _time session order_id customer_id customer_service_state]

    host="de-w*"  confirmation_page_trace order_id=2417516 OR order_id=2417512 OR order_id=2417509|rex field=_raw "confirmation_page_trace: (?[^XYZ]+):" | table _time order_id customer_id session_id host method view |sort -_time
    host="de-w*"  confirmation_page_trace order_id=2417516 OR order_id=2417512 OR order_id=2417509|rex field=_raw "confirmation_page_trace: (?[^XYZ]+):" | table _time customer_id order_id session_id host method view |sort  order_id _time

    //Multi XML element extraction
    host="de-w*" credit_check_id|rex field=_raw "\(?[^\<]+)" | rex field=_raw "\(?[^\<]+)"|table _time credit_check_id order
    host="de-w*" credit_check_id|rex field=_raw "\(?[^\<]+)" | rex field=_raw "\(?[^\<]+)"| rex field=_raw "\(?[^\<]+)"|table _time credit_check_id order_id customer_id | sort -_time

    index="de_apps_containers"  carom  rule |table _time _raw
    index="de_apps_containers" "apps_apps-nginx" "de-admin" (upstream OR 504)

    cakeerror index="tigger_log" | stats count by host | sort - count
    cakeerror index="flubbar_log"

    index="php_error_log" host="de-w01"

    host="de-w*" address-unserviceable | table _time ip host phpsessid|  iplocation ip  table clientip, status, City,State, Country
    host="de-w*" address-unserviceable |table _time ip phpsessid host sourcetype | iplocation ip  clientip, status, City,State, Country | stats count by  Region | sort - count

    "/address-unserviceable" source="*access.log" |  convert timeformat="%m/%d/%Y" ctime(_time) AS datex | table datex| stats count by  datex

    index="de_apps_containers" admin "timed out"   proxy_read_timeout 180;

    code=5** OR code=4** |  stats count by host, code | eventstats sum(count) as hostx by host| eval percent=count/hostx |
    table host,code,count,percent|timechart span="1d" count

    code=5** OR code=4** |  stats count by host, code |timechart span="1d" count

    code=5** OR code=4** | iplocation ip  clientip, status, City,State, Country|eval  os = case(match(user_agent,"Windows .. 5\.1"),"Windows XP",match(user_agent,"droid"),"Android",  match(user_agent,"Windows NT 610"),"Win10", match(user_agent,"Mac"),"Mac",match(user_agent,"Windows NT 6.1"),"Windows 7",match(user_agent,"iPhone"),"iPhone")| eval browser = case(match(user_agent,"MSIE 10.0"),"Internet Explorer 10.0",match(user_agent,"Trident"),"IE11", match(user_agent,"Chrome"),"Chrome",match(user_agent,"Safari/"),"Safari") | eval arch = case(match(user_agent,"droid"),"android",match(user_agent,"iPad"),"ipad",match(user_agent,"iPod"),"ipod") |  table host code uri method sourcetype request_time referer user_agent os browser ip,City,State, Country

    "QuickPay error: msg='Server was unable to process request. ---> CISTranslator.CISTranslatorException: System.NullReferenceException: Object reference not set to an instance of an object." order_id |eval hostx= case(match(host,"de-w*"), "de",match(host,"wtu-w*"), "wtu",match(host,"fcp-w*"), "fcp",match(host,"cpl-w*"), "cpl") |table hostx,_time|timechart span="1month" count by hostx


    /api/v1/dye/bill/cycle code=500|table _time phpsessid ip code _raw | eval session = case(match(phpsessid,"-"),"empty", !match(phpsessid,"-"),"not-empty") |
    stats count by session | eventstats sum(count) as perc | eval perc=round(count*100/perc,2)

    (host="de-w*" OR host="fcp-w*" ) index="access_log" sourcetype="access_log" (date_hour>=4 date_hour<=5) (date_wday=tuesday ) |
    eval  brand = case(match(host,"de-w"),"de",match(host,"fcp"),"fcp"    ) | table _time ip brand
    | timechart span="1d" dc(ip) count by brand


    (host="de-w*" ) index="access_log" sourcetype="access_log" (date_hour>=5 date_hour<=5) (date_wday=tuesday )|
    eval brand = case(match(host,"de-w"),"de",match(host,"fcp"),"fcp")|timechart span="1d" dc(ip)

    #7 day weekly view - Peak day reporting
    host="de-w*" code=500 index=access_log  | convert timeformat="%A" ctime(_time) AS c_time |chart count by c_time

    #24 Hour View - Peak Hour reporting
    host="de-w*" code=500 index=access_log  | convert timeformat="%H" ctime(_time) AS c_time | table uri c_time | chart count by  c_time

    host="de-w*" code=500 index=access_log | table uri | top limit=20 uri |  convert timeformat="%m/%d/%Y" ctime(_time) AS datex | table datex|timechart count by datex

NRQL
    SELECT COUNT(*) FROM TransactionError WHERE  httpResponseCode = 500 AND  `request.headers.referer` LIKE '%/pogo/search' AND SERVER_NAME ='www.example.com' AND timestamp > 1548201600  AND timestamp < 1549584000 AND  timestamp > 1549670399 AND timestamp <   1550880000

MS SQL
    SELECT TOP 10 * FROM SMT.ESIIDMaster WHERE ESIIDID = 566455 ;

DOS
    Netsh

    gitlab.yaazhdev.com 198.123.45.678:8080


    # route add 198.123.45.678 gitlab.yaazhdev.com
    #
    # Netsh
    # add v4tov4 listenport=8080 connectaddress=gitlab.yaazhdev.com  listenaddress=198.123.45.678:8080 protocol=tcp
    # netsh interface portproxy add v4tov4 listenport=8080 listenaddress 198.123.45.678 connectaddress=gitlab.yaazhdev.com

    C:\WINDOWS\system32>netsh interface portproxy add v4tov4 listenport=8080 listenaddress=198.123.45.678 connectport=80 connectaddress=gitlab.yaazhdev.com


    C:\WINDOWS\system32>netsh interface portproxy show v4tov4

    Listen on ipv4:             Connect to ipv4:

    Address         Port        Address         Port
    --------------- ----------  --------------- ----------
    198.123.45.678   8080        gitlab.yaazhdev.com 80


    C:\WINDOWS\system32>

    FORFILES
    ========
    forfiles /s  /c "cmd /c if @isdir==FALSE echo @path @fsize  /S /D +11/04/2016 "
    forfiles /P . /S /D +11/04/2016 /c "cmd /c if @isdir==FALSE echo @path @fsize"

    Link RESET
    ==========
    C:\WINDOWS\system32>assoc.lnk=lnkfile
    .lnk=lnkfile

    C:\WINDOWS\system32>

    CHANGE Permissions:
    ==================
    takeown /f "C:\Users\kmuthuvel.old" /r
    icacls "C:\Users\kmuthuvel.old" /reset /T


    Wi-Fi creds:
    ===========
    netsh wlan show profile SpectrumSetup-7F key=clear|findstr Key

    Data Recovery
    =============
    find AppData  -iname '*xlsb*' -o -name '*foo*'  #excel
    find .   -iname '*wr*tmp*'                      #word / temp / auto recovery(wrd,wrf,wra)
    find .   -iname '*wbk*'                         #auto recovery file that is complete


    Domain Group Memeber lookup
    ============================
    gpresult /USER KMUTHUVEL /V
    net user KMUTHUVEL /DOMAIN
    for user in kmuthuvel cog_Mthapa TKhan2 SBasutkar ; do  NET USER $user /DOMAIN; done


    MOUNT
    wmic logicaldisk get caption,description,drivetype,providername,volumename

    SHORTCUT FOR INET OPTIONS

    C:\Windows\System32\control.exe Inetcpl.cpl,Connections,4

    #stored Wifi
    for ssid in `netsh wlan show profiles|grep "All User" | awk  -F: '{print $2}'` ; do; netsh wlan show profile name=$ssid key=clear |grep -E 'SSID name|Key Content' ; done;

    #find for files
    DIR /B /S /R /O:N /W *sample*

MarkDown
    Name    |Sex|City,State
    -|
    Jorge   |M|Corpus, TX
    Valerie |M|Corpus, TX
    Sabrina |F|Corpus, TX

Excel
    To convert the numbers into text?
    =================================
    1)  Use a datevalue(text(XX,”mm/dd/yyyy”) formula
    2)  Use the text to values function to separate anything so “DATE” and “TIMESTAMP” are in two different columns.

    Multi Instance
    ===============
    #ExcelLauncher  !!! WARNING !!! Breaks lot of built-in functionality
        http://dottech.org/26491/how-to-force-microsoft-excel-to-open-files-in-new-window-how-to-guide/
        http://blog.thomascsherman.com/2010/06/opening-excel-files-in-new-processes-excel-launcher-helper-app/

    Indian currency format(millions to lakhs)
        Update Custom:
        [>=10000000]"RS "##\,##\,##\,##0;[>=100000]"RS " ##\,##\,##0;"RS "##,##0

    Freezing
    =========
        Step 1 - Select
            First 2 rows:       Click on A3 Cell.
            First 2 cols:       Click on C1 Cell.
            First x rows & y cols:  Click on (y+1)(x+1) Cell
        Step end - View  > Window > Freeze Panes > Freeze Panes

    Compare
    =======
    =VLOOKUP(NEEDLE,L$5:L$9,1,FALSE)                    # String search
    =VLOOKUP($NEEDLE&"*",'sheetx'!$A$1:$Z$26,2,FALSE)   # Partial string search

    =TEXT(J13 -F13, "d"" days ""h"" hrs ""m"" mins """)

    Pivot Data Range : Analyze >> Data >> Change Data Source

    To seconds
    ==========
    =TEXT(F155-E155,"[s]")

SHAREPOINT/WINWORD CACHE


    %userprofile%\Local Settings\Temporary Internet Files\Content.MSO\

ShortCuts
    HeidiSQL REDO SHIFT+ALT+BACKSPACE

GNU/Linux

    `ldconfig` is a program that is used to maintain the shared library cache. This cache is typically stored in the file /etc/ld.so.cache and is used by the system to map a shared library name to the location of the corresponding shared library file.
    Usage :  ldconfig -v  will make new  programs ,ex gpg2 was able to find libksba.so.0
    #export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/instantclient_19_6
    #validate library file for linked libs using ldd 
    ldd  /usr/lib/instantclient_19_6/libsqora.so.19.1

    Performance/Tuning/Cleanup
    ==========================
    . .profile.open # ( https://github.com/kesavanm/handy-tools/blob/master/.profile.open)
    cleanit
    cleandebs

    find .  -maxdepth 1 -type d  -exec du -hs {} \;                     #list files usage
    find . -size +5M -type f -mtime -3 -exec ls -larht {} \;            #greater than 5MB

    du -S . | sort -nr | head -25

    du -ch -d 1 | sort -hr              # depth level - 1
    du -cksh *  | sort -hr | head -10   # top 10
    du -ch -t 100m  # list only files which are bigger than 100 MB r

    $du -Pshxc .* 2>/dev/null
    716M    .
    658M    ..
    1.4G    total

    $sudo du -h /home/ | grep -P '^[0-9\.]+G'
    1.1G    /home/kesavan
    2.3G    /home/

    space cleaning tools
    -------------------
    tdu , gt5 , & ncdu


    Better Booting
    ==============
    systemd-analyze plot > Desktop/boot.svg
    systemd-analyze blame
    systemd-analyze critical-chain
    service --status-all


    thulasi@thulasi-Inspiron-15-3567(49.204.208.161)|~|2019-01-01 20:36:46
    $sudo systemctl disable mysql.service
        Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install.
        Executing: /lib/systemd/systemd-sysv-install disable mysql

    $history | tail
    1007  2019-01-01 20:19:45 systemd-analyze --user blame
    1008  2019-01-01 20:20:20 systemd-analyze --system blame
    1009  2019-01-01 20:28:21 sudo systemctl disable mysql.service
    1010  2019-01-01 20:28:47 sudo systemctl mask mysql.service
    1011  2019-01-01 20:30:35 systemctl status mysql.service rvice
    1012  2019-01-01 20:31:43 sudo systemctl unmask mysql.service
    1013  2019-01-01 20:31:48 systemctl status mysql.service rvice
    1014  2019-01-01 20:32:24 systemctl status mysql.service
    1015  2019-01-01 20:36:33 systemd-analyze --user critical-chain
    1016  2019-01-01 20:36:46 history | tail
    0 ✓ success ^_^  ________________________________________________________________________________
    thulasi@thulasi-Inspiron-15-3567(49.204.208.161)|~|2019-01-01 20:36:46


    ### unistall script for compiled source
    ./configure --prefix=/tmp/abc
    make install
    cd $PREFIX
    find . -type f | cut -b 1 --complement | sed 's/^/rm -f \/usr\/local/g' > uninstall.sh
    find . -type d | cut -b 1 --complement | sed 's/^/rmdir --ignore-fail-on-non-empty \/usr\/local/g' >> uninstall.sh

    whereis abc
    sudo rm -rf <>


    # APT source key Fix
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C
    sudo apt-get install mate-core mate-desktop-environment


### Increase disk size
```bash
    du –shT /home    (sudo du -h -x -d 1 /home/)
    du -shT .[^.]*  | sort -hr| head


    df -h /var
    lvextend -L +3G /dev/mapper/vg01XXX-var
    resize2fs  /dev/mapper/vg01XXXX-var
    xfs_growfs /dev/mapper/vg00-home

```


#service-failures
sudo service apache2 restart
See "sudo systemctl status apache2.service" and "sudo journalctl -xeu apache2.service" for details.



PrivateTmp in #WSL https://stackoverflow.com/a/63358357
    Ubuntu uses "private temp" directories, so your xdebug.log log file is likely available in one of the directories like /tmp/systemd-private*/tmp/.

Display: - custom resolution
    cvt 1920 1080
    sudo xrandr --newmode  "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
    sudo xrandr --addmode eDP-1 "1920x1080_60.00"



    C:\Users\kmuthuvel\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\18C17SJ6

Mozilla/Firefox
    general.useragent.locale    ta-IN   about:config
    595c99c907d7bc86620ebe8bc7f23532b8428468    password-1
    security.enterprise_roots.enabled   # false to handle Peer’s Certificate issuer is not recognized.

GNU/Screen:

    export SCREENDIR=$HOME/S-$USER
    
    screen -S