Skip to content

Instantly share code, notes, and snippets.

View msanjaypandit's full-sized avatar

Sanjay Chaturvedi msanjaypandit

View GitHub Profile
<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
</head>
<body>AngularJS directives are used to extend HTML. These are special attributes starting with ng- prefix. We're going to discuss following directives
<div id="App1" ng-app = "myapp1" ng-controller = "HelloController1">
<h3> Instant type your name </h3>
@msanjaypandit
msanjaypandit / Mysql_Backup_Restore_Script.md
Last active March 8, 2018 06:06
[MySql Backup/Restore] Generate and restore mysql backup #Mysql #backup #restore

Download full database (.gz extention)
mysqldump -h[host] -u[user] -p[password] [database] | gzip -c | cat > /var/www/html/mysqldump_[database]_$(date +%Y%m%d_%H%M%S).sql.gz

Download full database with ssl enabled (.gz extention)
mysqldump -h[host] -u[user] -p[password] [database] --ssl-ca=[.PEM file] [database] | gzip -c | cat > /var/www/html/mysqldump_[database]_$(date +%Y%m%d_%H%M%S).sql.gz

Download Specific database table (.gz extention)
mysqldump -h[host] -u[user] -p[password] [database] [tablename] | gzip -c | cat > /var/www/html/mysqldump_[database]_[tablename]_$(date +%Y%m%d_%H%M%S).sql.gz

Download Database after ignore some table (.gz extention)

@msanjaypandit
msanjaypandit / cronjob-linux.md
Last active January 29, 2018 06:08
[Cron jobs on linux] #cronjob #linux
# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed
@msanjaypandit
msanjaypandit / virual-host-ubuntu.md
Last active March 7, 2018 08:54
[Virtual Host on Ubuntu] How to write virtual host/subdomain configuration file #xampp #virtual-host #lamp #ubuntu #subdomain #configuration

Ubuntu

You may be using a ubuntu machine or you are creating virtual host on ubuntu server. Open terminal using ctrl+alt+T in ubuntu, putty on windows. Connect with ssh if you are going to creating virtual host on ubuntu server.

  1. sudo apt-get update (it will update all system libraries)
  2. cd /var/www (Move to www path)
  3. sudo mkdir -p example1.com/public_html (it will create both directory example1.com and example1.com/public_html)
  4. sudo mkdir -p example2.com/public_html (it will create both directory example2.com and example2.com/public_html)
  5. cd /etc/apache2/sites-available/
@msanjaypandit
msanjaypandit / php-codes1.md
Last active March 7, 2018 09:23
[PHP Codes] #php #php-log-file #errors #php-file-write

Generate PHP Error on a Specific IP Generate PHP Errors on a Specific IP

if($_SERVER["REMOTE_ADDR"] =='xxx.xxxx.xxx.xxx'){
  error_reporting(E_ALL);
	ini_set('display_errors','Off');
	ini_set("log_errors", 1);
	ini_set("error_log", "Your Error log path");
  # Your Error log path e.g "D:/xampp/htdocs/live/errors/lservererror.html"
}
@msanjaypandit
msanjaypandit / redirect.md
Last active March 7, 2018 09:28
[www and https Redirection] Redirect all files to https url and www domain name #www #htaccess

Redirection to https file

RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirection to https and www page

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@msanjaypandit
msanjaypandit / mysql-queries1.md
Last active December 20, 2018 16:10
[MySQL Queries] Mysql queries #mysql #query
  • Convert DateTime in UnixTimeStamp
    SELECT *,from_unixtime(date_added) FROM TABLE_NAME order by date_added desc

  • Space consume by a table
    SELECT table_schema "Data Base Name",sum( data_length + index_length ) / 1024 / 1024 /1024 "Used GB" FROM information_schema.TABLES GROUP BY table_schema ;

  • Character Set utf8mb4_unicode_ci

  • Set a login path using terminal/putty

@msanjaypandit
msanjaypandit / compress.md
Last active January 29, 2018 06:13
[compress/decompress files] Compress and decompress .tar.gz files #tar.gz #compress
##To compress all files of foldername##
tar -cvzf docs.tar.gz /var/www/html/foldername

##extract docs.tar.gz in docs folder##
tar -xvzf docs.tar.gz
@msanjaypandit
msanjaypandit / git.md
Last active May 25, 2022 14:21
[Git Commands] A basic git commands #git #commands

1. git checkout master

  • git checkout allows you to move between branches and potentially restore tree files.
  • The command git checkout master switches you to the master branch, which is always the best place to start before making changes to your repo.

2. git pull origin master

  • Get the latest updates on the master branch,
  • This is typically done to merge upstream changes. A git pull is actually a combination of git fetch, which grabs all the latest information, and git merge, which merges the two histories together.
  • Essentially, git pull origin master allows you to do two commands at once. It’s a great time-saver!
  • Always run git pull origin master before starting work on a repository. After all, you want to be sure your repository is up to date with the remote repo where you collaborate.
@msanjaypandit
msanjaypandit / linux-commands.md
Last active February 7, 2022 13:19
[Linux Commands] linux command #linux #commands
  • grep keyword /var/spool/cron/root | egrep -v ^# | grep -v ^$ | awk '{print $1,$2,$3,$4,$5,$8}'
  • cat netstat.log.5 | awk '$4 ~ /:80$/ {c++;print $5 | "sed 's/::ffff://' | sed 's/:.*$//'| sort | uniq -c | sort -n | tail -n 10"} END {print c}'
  • netstat -plantu | grep -c :1433
  • ifconfig eth0
  • Print last 20 lines from the error_log file tail -20 /var/log/httpd/error_log
  • Get max number of client on apache configuration grep -i maxclients /etc/httpd/conf/httpd.conf
  • cat /etc/my.cnf | grep cache -i | grep -v ^#
  • grep "^|" queries-pre-restart.txt | awk '{ print $14 }' | sort | uniq -c | sort -nr
  • mkdir -p www/public_html Will make directory at nested level (it will create both directory)