Installing Plug-in XML Format in Sublime 3

Installing Plug-in
Open the editor and hit Ctrl+Shift+P to open Command Palette.
Type"Install Package" and hit Enter. Type Indent XML.

Select the highlighted plug-in and click Enter. You should see the message that saying the plug-in has been installed successfully.

Restart the editor. At least I had to.

Formatting XML

Copy the non formatted XML
Hit Ctrl + K + F.

You can also do it from the Menu option.

Formatting JSON
Hit Ctrl + K + F.
You can also do it from the Menu option.
That's it for today. Happy Formatting !

Struts 2 Vulnerability

Looking for vulnerability
Original Article: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-5638
Refer: https://github.com/mazen160/struts-pwn
Script: struts-pwn-master.zip

$ python struts-pwn.py --check --url 'https://my.domain.com/checkme.action'

[*] URL: https://my.domain.com/checkme.action
[*] Status: Vulnerable!
[%] Done.

Using rsync for copy with status

Refer: http://askubuntu.com/questions/17275/progress-and-speed-with-cp
$ rsync -ah --progress source destination
$ alias copy="rsync -ah --progress"
$ alias copydir="rsync -ahr --progress"

AngularJS Sample Build Project

Refer: https://github.com/jhades/angularjs-gulp-example/blob/master/gulpfile.js
Note: list folder has wrong relative file paths

Refer: http://blog.angular-university.io/what-every-angular-project-likely-needs-and-a-gulp-build-to-provide-it/

WebStorm Debugger

In order to Debug in WebStorm, you will need a couple of things.  The Chrome plug-in for WebStorm is the first.

Once that is done, you should setup a debugger configuration to launch from within WebStorm, using JavaScript Debug.  You'll need launch this target in Debug.  You can also setup Chrome as your default browser.

2016-06-21_07-51-32

Using eTags

Refer: http://thespringthing.blogspot.com/2015/06/etags-and-browser-cache.html

ETags and browser cache
Caching resources on the browser is one of the patterns followed to minimize redundant trips to the server and thus reduce load on the server. This works well for data that is static. But, there are cases where the data changes every once in a while (although less frequently) and you would want the browser to get the latest data without waiting for the cached data to expire. e.g. changes to a css or javascript in the new version of the application should be reflected immediately on the browser. To handle these refreshes, you might be tempted to make it a non-cacheable resource. Entity tags( or ETags for short) help you cache such resources.

ETag is a unique identifier that represents the response content of a request. By comparing Etags, you should be able to tell if the response for a request has changed or not, and decide if you need to send the new data back to the client or just use the cached data.

HTTP supports ETag response headers which can be used along with If-None-Match request headers for managing cache data. These headers are meant to be used for GET and HEAD requests, which are the recommended methods for fetching cacheable resources.

The following sequence diagrams illustrates the ETag workflow for an example of 3-step resource fetch. Each step requests for the same resource.

Step 1
Browser sends a request for a resource
Server creates an ETag value for the resource using hash or other techniques.
Server sets this value in "ETag" header in response.
Server sends the resource along with ETag.
Client caches the resource and the ETag

Step 2
Client requests for the same resource
Client sends the ETag value for the resource through the If-None-Match header.
Server calculates the ETag for the resource.
Server compares the new ETag with If-None-Match.
If it matches, then server sends a 304 response code.
Client uses the data from cache.

Step 3
Client requests for the same resource.
Client sends the ETag value for the resource through the If-None-Match header.
Server calculates the ETag for the resource.
Server compares the new ETag with If-None-Match.
If it does not match, then server sets the ETag response header with the new value.
Server sends the resource along with ETag.
Client caches the new resource and the ETag

ETag generation

ETag generation in itself could add some amount of latency, depending upon the techniques used. The simplest technique to calculate is to generate a hash of the content through MD5 algorithm or something similar. This could be pretty sluggish depending upon the size of the content.
The ETag need not necessarily be unique, as long as it can indicate the change in the content. For example, in one of my projects I used the content version as the ETag. The version indicated change in the content and that was good enough for me to refresh the cache.

Look for deleted files in Git

# Example to quickly look for a deleted file
$ git log --diff-filter=D --summary | grep -i delete | grep -i barclay

Use this to find actual commit for file and you can search it like a less command
$ git log --diff-filter=D --summary

Refer: http://stackoverflow.com/questions/7203515/how-to-locate-a-deleted-file-in-the-commit-history