Wednesday, November 18, 2015

Handy Diff Utility (aka Differ)

How many times has someone asked you to tell them the difference between two files and that person would be upset if you handed them the output of a unix diff command? For developers who have access to IDE's or fancy difference tools you can see the changes easily but do any of them output those nice views into something useful you can hand over?

Due to this issue and not finding anything useful on the web I decided to create such a utility. I call this program Differ.

The command to run the application is: "java -jar Differ.jar changes.txt original.txt"

Pass into the application the newly changed file first and the existing or original version as the second parameter. The system will run through and generate an html report which can be passed around and viewed by everyone in an easily readable format.

Sample Report:

The source code will be available on my github page at the following:

Easy Bash Git Scripts

While enjoying all the benefits of git source control on my local development machine I thought I would share a few of my favorite shortcut scripts I've created for you to enjoy.

This script is used to display the stat diff version between master and the current branch I'm working on. Save the script below in an executable path named gitstat.

echo ""
echo "Command: git diff --stat master..$1"
echo "----------------------------------------------------"
git diff --stat master..$1
echo ""

Run it with the command: gitstat branch_name

This is a simple echo of commonly used command line options for git to give me a quick reminder when I may forget something. Save the script in a executable path and name it githelp.

echo "Useful git commands"
echo "---------------------------------------------------------------------------"
echo "Create Branch              :   git branch nameofbranch"
echo "Switch to Branch           :   git checkout nameofbranch" 
echo "Update master              :   git checkout master | git merge nameofbranch"
echo "Remove branch              :   git branch -D nameofbranch"
echo "Add all files to staging   :   git add -all"
echo "Add staged files to branch :   git commit -m \"message\""
echo "Show diff between branches :   git diff branchone..branchtwo"
echo "Show all branches          :   git branch"

echo ""

Run it with the command: githelp

Thursday, November 12, 2015

ScanMyCode : A Code Count Generator

Recently I was sitting around wondering just how much code I had in a project I've been working on single handedly for the last couple years. Since there are programs out there that do this today I thought the best approach would be to write one myself.

The main aspects I wanted to gather were total files of each type and their line count minus blank lines. I also thought I would write a few lines of code to capture the method count as well.. why not... :)

So in order to complete the task I had to create a Java application which takes the base directory and a report name. I would then generate both a HTML and a CSV file after the code was finished. I used maps for files, lines, and methods. Then I used a collection of type Extension (custom class) and used a comparable to sort it by lines of code.

The output of the HTML report looks like the following screenshot.

The code can be found at my github account: