Saturday, August 13, 2016

A simple gradle plugin to print the task execution graph of a gradle build.

Here is a gist for a simple gradle plugin implementation that can generate an HTML report of your gradle build's Task Execution Graph.

Here is a sample output for a simple project:

↦ :clean - Deletes the build directory.
↦ :build - Assembles and tests this project.
   ┖ :assemble - Assembles the outputs of this project.
      ┖ :jar - Assembles a jar archive containing the main classes.
         ┖ :classes - Assembles main classes.
            ┖ :compileJava - Compiles main Java source. ⊣
            ┖ :processResources - Processes main resources. ⊣
   ┖ :check - Runs all checks.
      ┖ :test - Runs the unit tests.
         ┖ :classes - Assembles main classes. ↑
         ┖ :testClasses - Assembles test classes.
            ┖ :compileTestJava - Compiles test Java source.
               ┖ :classes - Assembles main classes. ↑
            ┖ :processTestResources - Processes test resources. ⊣

To use it simply apply it in your build.gradle like so:

:
:
apply from: 'build-task-graph.gradle'
:
:

And then run any build like this;

> .\gradlew -m clean build

and find the output report in:

build/reports/printteg.html


It should be a simple exercise to generate hyperlinked output or alternatively emit a .dot file graph or even generate SVG.

I use this to determine which tasks I should exclude using the -x flag and only (carefully) run the ones I need. Of course you have to know what you are doing. The idea is similar to my Maven Phases and Goals plugin.

Feedback welcome!

Tuesday, August 09, 2016

Angular 2 - template reference variable shadows the component property

Given the Angular 2 component:

import { Component } from '@angular/core';

@Component({
  moduleId: module.id,
  selector: 'app-root',
  template: '<div ref-title>{{title}}</div>',
  styleUrls: ['app.component.css']
})
export class AppComponent {
  title =  'app works!';
}

you get this on the webpage:

[object HTMLDivElement]

The reason is that Template Reference Variable ref-title shadows the title of  AppComponent when evaluating {{title}}.

I guess this is sort of like the loop variables inside an

<li *ngFor="let title in titles">{{title}}</li>

But something does not feel right about TRV.

Sunday, August 07, 2016

A simple Weather App using Angular 2, Angular Material 2 and Electron

Working on a simple Weather App using

Also runs as a standard web app.

Built using



Will document the details soon!



Sunday, June 05, 2016

Weekend Hack

I recently acquired a tripod with Bluetooth remote for my smart phone. The tripod  is only up to 10 inches tall and works very well indoors when you have something to perch it on.


However I wanted to a taller, up to 5 feet tall monopod, which I can use to video record my son's outdoor or theater concerts. I hacked it with some material that I could find in the garage:

  • L bracket as the base
  • conduit clip and knob to hold the PVC pipe


  • PVC pipe
  • velcro to firmly hold the tripod



Here is the result



Do you have any hacking ideas you would like to share?

Thursday, June 02, 2016

Try this repeatedly in your browser console...

var party = Math.random(), country = Math.random(), what = (party >= country ? 64783292855 : 2569542479746150); 'party=' + party + ' country = ' + country + ' party/county = ' + what.toString(36);

Friday, May 06, 2016

Try this in your browser console...

var party = 64783292855, country = 1; alert((party/country).toString(36));

Thinking.oO { Party/Country != Patriotism , Party/Country == Treason }

var party = 0;
var country = 1;
var result = [ 'Treason', 'Patriotism' ];

party/county =

Monday, April 25, 2016

Electronic eyes


Electronic eyes

Fun!

Sunday, April 24, 2016

Electron based POM360


A simple POM360 tool to get a 360 view of Maven POM. It is developed using Electron framework. It uses mvn command.

Saturday, April 23, 2016

Electron based Portmon tool


A simple Portmon tool to monitor listening TCP ports and associated PIDs. It is developed using Electron framework. It uses netstat.

NOTE: Works on windows only at the moment.



Monday, December 28, 2015

Print angular module dependencies

Here is a simple function to print angular module dependencies:

    angular.__moduleDependencies__ = function (moduleName, indent, nonlast, seen) {
        var module, suffix;
        indent = indent || '';
        seen = seen || [];
        suffix = (indent === '' ? '' : (nonlast ? '├─ ' : '└─ '));
        if (seen.indexOf(moduleName) !== -1) {
            console.log(indent + suffix + moduleName + ' ^');
            return;
        }
        seen.push(moduleName);
        module = angular.module(moduleName);
        if (angular.isDefined(module)) {
            console.log(indent + suffix + moduleName);
            angular.forEach(module.requires, function(requiredModuleName, key){
                var requiredMod = angular.module(requiredModuleName);
                if (angular.isDefined(requiredMod)) {
                    
                    angular.__moduleDependencies__(requiredModuleName,
                        indent + '| ', key < (module.requires.length - 1), seen);
                } else {
                    console.error(indent + requiredModuleName);
                }
            });
        } else {
            console.error(indent + suffix + moduleName);
        }
    };

Usage

angular.__moduleDependencies__('todomvc')


Output

todomvc
 | ├─ ngRoute
 | | └─ ng
 | | | └─ ngLocale
 | └─ ngResource
 | | └─ ng ^

Sunday, December 27, 2015

Filed Eclipse enhancement

Many time I copy a file and the only difference is that I need to map a noun to another.e.g.

firstName -> lastName

getFirstName() -> getLastName()

FIRSTNAME -> LASTNAME

and even better:

FIRST_NAME -> LAST_NAME

FIRST-NAME -> LAST-NAME

This is supported by emacs to some extent. See below.

The Eclipse find/replace dialog should support this using a Case mapping chekbox option like this:

__ Options ____________________

[ ] Case sensitive

    [X] Case mapping

Some languages use camel case, some use hyphen or underscore. The dialog could take that into account.

Support Emacs style case matching replace behavior.

"
15.10.3 Replace Commands and Case
:
:
In addition, when the newstring argument is all or partly lower case, replacement commands try to preserve the case pattern of each occurrence. Thus, the command

M-x replace-string RET foo RET bar RET

replaces a lower case ‘foo’ with a lower case ‘bar’, an all-caps ‘FOO’ with ‘BAR’, and a capitalized ‘Foo’ with ‘Bar’. (These three alternatives—lower case, all caps, and capitalized, are the only ones that replace-string can distinguish.)

If upper-case letters are used in the replacement string, they remain upper case every time that text is inserted. If upper-case letters are used in the first argument, the second argument is always substituted exactly as given, with no case conversion. Likewise, if either case-replace or case-fold-search is set to nil, replacement is done without case conversion.
"

REF: http://www.gnu.org/software/emacs/manual/html_node/emacs/Replacement-and-Case.html#Replacement-and-Case

Sunday, December 13, 2015

TIP: Track window innerWidth using AngularJS

Here is a simple Plumkr to track the window innerWidth using AngularJS:

Try it

Tuesday, July 07, 2015

Eclipse Console Support for Frontend builds

If you use Eclipse of frontend development and use any of the front end tools such as ESLint or JSHint to do static analysis of your Java Script code, then Frontend Maven Plugin Console Support is the plugin for you.

This plugin parses the messages in Eclipse consoles (Process Console or Maven Console) and converts them to hyperlinks. It also adds warnings and error markers as applicable.


Install it using Help > Install New Software in your Eclipse IDE and specifying this update site:

http://cdn.rawgit.com/sandipchitale/frontend.maven.plugin.console.support/1.0.9/frontend.maven.plugin.console.support.updatesite/site.xml

I will soon add this to Eclipse Marketplace.

Enjoy!

Sunday, July 05, 2015

A simple Maven Event Spy

In the context of this blog entry I developed a simple Maven Event Spy. However it works by itself too.

Simply drop mavenbuildspy.jar into your Maven installation's lib/ext folder and run your Maven build and you will see something like:



Alternatively download it somewhere and invoke it on-demand in your Maven build with:

mvn -Dmaven.ext.class.path=path-to/mavenbuildspy.jar ....

Feedback welcome!