About Me

My photo
India
Hey there, lovely people! I'm Hemant Menaria, and I'm passionate about programming. Having completed my MCA in 2011, I've delved into the world of coding with fervor. I believe in sharing knowledge, making complex concepts easy to grasp for everyone. JAVA, PHP, and ANDROID hold a special place in my heart, and I spend most of my time immersed in them. Currently, I'm deeply engaged in API/Webservice frameworks and crafting Hybrid mobile applications to enhance flexibility in the digital realm. If you ever find yourself stuck with a programming challenge, feel free to reach out to me at +91-8955499900 or drop me a line at hemantmenaria008@gmail.com. I'm always eager to help fellow enthusiasts navigate the intricacies of coding!

Thursday, December 7, 2017

Excel split data into multiple worksheets based on column

 Here VBA Code to split data into multiple worksheets based on selected column

If you have an excel sheet and want to split the data into individual multiple sheet based on column valued then the below code is best for you.


Open Visual basic editor by pressing Alt+F11
On project window at left side => right click on project => insert=>Module.
now paste below code. read comments and set your parameter.

Sub parse_data()
Dim lr As Long
Dim ws As Worksheet
Dim vcol, i As Integer
Dim icol As Long
Dim myarr As Variant
Dim title As String
Dim titlerow As Integer
vcol = 7  ''name of column on which basis you want to create saprate sheet
Set ws = Sheets("finalsheet")  ''name of your master sheet which need to compile
lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
title = "A1:V1"  ''range of column which need to transfer into each individual sheet
titlerow = ws.Range(title).Cells(1).Row
icol = ws.Columns.Count
ws.Cells(1, icol) = "Unique"
For i = 2 To lr
On Error Resume Next
If ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(ws.Cells(i, vcol), ws.Columns(icol), 0) = 0 Then
ws.Cells(ws.Rows.Count, icol).End(xlUp).Offset(1) = ws.Cells(i, vcol)
End If
Next
myarr = Application.WorksheetFunction.Transpose(ws.Columns(icol).SpecialCells(xlCellTypeConstants))
ws.Columns(icol).Clear
For i = 2 To UBound(myarr)
ws.Range(title).AutoFilter field:=vcol, Criteria1:=myarr(i) & ""
If Not Evaluate("=ISREF('" & myarr(i) & "'!A1)") Then
Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = myarr(i) & ""
Else
Sheets(myarr(i) & "").Move after:=Worksheets(Worksheets.Count)
End If
ws.Range("A" & titlerow & ":A" & lr).EntireRow.Copy Sheets(myarr(i) & "").Range("A1")
Sheets(myarr(i) & "").Columns.AutoFit
Next
ws.AutoFilterMode = False
ws.Activate
End Sub



=========================
now its time to run your code by pressing F5.
Done!



Wednesday, July 26, 2017

X-Frame-Options Header Not Set 'ClickJacking' attacks

X-Frame-Options header is included in the HTTP response to protect against 'ClickJacking' attacks.

The X-Frame-Options header is used to indicate whether or not a website/browser should be allowed to open a page in frame or iframe.This will prevent website content embedded into other websites.
It protect against 'ClickJacking' attacks.
 
There are three options for X-Frame-Options: 

  • SAMEORIGIN: This option will allow page to be displayed in frame on the same origin, means you can render the same website page into iframe/frame. 
  •  DENY: This option will prevent a page displaying in a frame or iframe, means no one website can render website page in frame/iframe.  
  • ALLOW-FROM uri: This Option will allow page to be displayed only on the specified origin.if you want to allow render the page of website for a particular website then you can use this option.

Syntax: 

IN HTML Page:- Type below code in head section:



       http-equiv="X-FRAME-OPTIONS" content="DENY">
 
IN PHP Page:- 



 ========================================================
You can use any web developer tool to view Response headers and ensure you see


======================================================

Configuring Apache HOw to Check X-Frame-Option of a web page:
To configure Apache to send the X-Frame-Options for all pages, add below setting to your site as required:

  • Header always append X-Frame-Options SAMEORIGIN 
  • Header set X-Frame-Options DENY 
  • Header set X-Frame-Options "ALLOW-FROM https://example.com/"  
======================================================

Wednesday, July 19, 2017

Cpanel Cron job for mysql datbase backup


Cron Job: Cron Job is a time base task which will execute on a fixed time or interval (repeat after a time).

How to create a cron job in cpanel to take database backup. 

Now Follow the Steps:

Step 1- First of all Create a file on your computer system and paste below code into file 

[client]
user = yourCpanelUserName
password = "yourCpanelPassword"
host = localhost

save above file with .my.cnf and upload it to your server directory (like /home/Your_Domain_Directory/)

 Step 2- Create a folder for backup with name of  db_backup on server at same place ( /home/Your_Domain_Directory/)

Step 3- 
1 -Go to Cpanel main page
2- Click on Cron Job
3- Enter email for notification regarding cron job.
4- Select Job Setting  means frequency of your task /job execution.
5- Paste below line in command text box:

mysqldump --all-databases  > /home/Your_Domain_Directory/db_backup/All_DB_Backup_$(date +'\%d-\%m-\%Y').sql

The above code will generate backup for your all databases in /home/Your_Domain_Directory/db_backup directory with the name of "All_DB_Backup_TodayDate".  so if you set daily backup policy then it will create a backup file with current date without overriding the same file.

if you want to take backup of a particular database then at the place of --all-database you can write the name of the particular database.

Step 4 - Finally click on Add Crone Job button to save it.

Step 5 - Go to the folder /home/Your_Domain_Directory/db_backup  to check your datbase backup.


Tuesday, June 27, 2017

httpd-xampp.conf: How to allow access to an external IP or another computer IP to mysql


Access Xampp mysql from another computer:-

Open your xampp folder go to =>apache=>conf=>extra=>httpd-xampp.conf
 copy below cod and past it into httpd-xampp.conf file 

// How to allow a particular IP to access


    Require local
    Require ip 10.0.0.1
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
 
=====================
Note: Write the remote IP at the place of 10.0.0.1
======================================= 

// How to allow anyone to access which is not safe.

    # Require local
    Require all granted
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var