Skip to content

Instantly share code, notes, and snippets.

@kangmasjuqi
kangmasjuqi / mongo_copying_row.txt
Created April 4, 2019 07:17
Mongodb - copying/duplicating a document row
#assuming we have already on mongo terminal
// this will resulting no row
> db.users.find({'email':'[email protected]'}).pretty()
// copying Greg's data and store it into temp variable 'marjuqi'
> marjuqi = db.users.findOne({'email':'[email protected]'})
// generate new unique ID for 'marjuqi' data
> marjuqi._id = new ObjectId()
@kangmasjuqi
kangmasjuqi / mongodb_export_import_database.txt
Created March 22, 2019 15:26
mongodb_export_import database
# GRAB/EXPORT DATABASE
mongodump -d <database_name> -o <directory_backup>
# RESTORE/IMPORT
mongorestore -d <database_name> <directory_backup>
STEPS :
assuming we have already log into the server.
@kangmasjuqi
kangmasjuqi / php_version_switch.txt
Last active February 8, 2019 09:04
switch php version on machine that installed multiple version of php
# lets assume that we have something like below structure of /usr/bin folder
# on our Centos 7
#
# this indicate that we've installed 2 version of php : 5.6 and 7.2
#
# here is the example source that shows us how to install multiple php version on Centos 7:
# https://cloudwafer.com/blog/installing-multiple-versions-of-php-on-centos/
#
#
@kangmasjuqi
kangmasjuqi / setup_multiple_vhost.txt
Created January 4, 2019 03:55
setup multiple virtual host for multiple app/web
https://httpd.apache.org/docs/2.4/vhosts/examples.html
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7
https://www.rootusers.com/how-to-configure-an-apache-virtual-host/
@kangmasjuqi
kangmasjuqi / daily_vm_healthy_check.sh
Created December 12, 2018 03:28
bash script for daily vm healthy check
#!/bin/bash
# created by marjuqi, sept 2018
red=$'\e[1;31m'
green=$'\e[1;32m'
yellow=$'\e[1;33m'
blue=$'\e[1;34m'
endcolor=$'\e[0m'
@kangmasjuqi
kangmasjuqi / devops_troubleshooting_checklist.txt
Created November 29, 2018 10:00
DevOps-Troubleshooting CHECK-list
DevOps-Troubleshooting CHECK-list
check log files (if any)
check file accessability
file existence (name and path)
file ownership
file permission
check credentials
@kangmasjuqi
kangmasjuqi / git_list_commit_of_file.sh
Created November 26, 2018 06:40
how to find list of git commits that affecting/changed specific file
how to find list of git commits that affecting/changed specific file
# show list commit with diff/changes detail
git log -p -- __PATH_TO_FILE__
# show list commit without diff/changes detail
@kangmasjuqi
kangmasjuqi / regex_for_checking_valid_url.sh
Last active December 5, 2018 04:41
regex for capturing valid URL
^(ht{2}ps?:\/\/|w{3}\.)(w{3})?([a-z0-9\-]+\.?)+(\/[a-zA-Z0-9\-\.=?&^%#@_]+)*\/?$
=====================================
example of matched/valid URL :
=====================================
http://yourdomain.com
@kangmasjuqi
kangmasjuqi / find_10_largest_files.sh
Created November 5, 2018 04:40
find largest files under a directory
# this commands will Find 10 Larget Files under 'your_target_directory'
find 'your_target_directory' -printf '%s %p\n'| sort -nr | head -10
# example :
find /var/logs/ -printf '%s %p\n'| sort -nr | head -10
@kangmasjuqi
kangmasjuqi / show_history_with_datetime.sh
Created October 30, 2018 04:42
History - show datetime on history
# sometime we need to know when exactly a command executed
# on a linux-based computer
# so we need to adjust bashrc file :
#
echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc
source ~/.bashrc
# output example of `history` command BEFORE bashrc adjusment
888 sudo monit -t