Monday, March 04, 2019

Open .java file for .class file


M2Eclispe supports resolution of dependencies from Workspace projects. With this you can click on a method from dependency owned class, M2Eclipse will automatically load the .java file for that .class file from. This is fine and dandy as long as your projects are Maven based. No fear...I wrote a simple Eclipse plugin to do just that - Open .java file for .class file.

How it works


Monitors the opening of a .class editor. Then uses the JDT Java search mechanism to locate the corresponding .java file in any of the Java projects in the Eclipse workspace. It also tries to move the caret to the same offset in .java file. By default closes the .class file, however by setting a preference you can opt-in to not close the .class file. The association of source folder with the .jar file containing the .class file is required for this to work.

Preferences


Github

https://github.com/sandipchitale/odjfdc

Update site

https://sandipchitale.github.io/odjfdc/OpenDotJavaForDotClassUpdateSite/site.xml


Eclipse Marketplace

https://marketplace.eclipse.org/content/open-java-file-class-file

Wednesday, February 27, 2019

Devtools App (Angular)


UPDATE: Release 1.0.8 Load devtools code ignoring cache by CTRL+SHIFT+Clicking when launching devtools.

UPDATE: Release 1.0.7 also allows using the Chrome devtools master branch as your devtools frontend.



UPDATE: Go to members all files will go to source mapped location when available. Also builds a cache (WeakMap) first time so subsequent invocations are very fast.

UPDATE: Version 1.0.6 is released. Download from Github releases page.

I have implemented a Angular based Devtools App using Electron framework. It allows you to use any hosted Chrome Devtools instance as your devtools frontend. For example, by default it will load my enhanced Chrome Devtools which implements the Go to members all files ( Ctrl+Shift+8 on windows, Command+Shift+8 on mac) action. With this you can find and navigate to classes, functions and properties in all the loaded scripts not only in active source script editor.

If you are debugging an app written in Typescript e.g. Angular app, make sure to Enable JavaScript source maps in Settings to take full advantage of Go to members all files functionality.

Screenshot




Github repository for Devtools App (Angular) The README in the repository explains how to use it.

Download the distribution zip.

Monday, January 01, 2018

Moving to Medium

I have decided to publish on Medium.com. You can follow my posts there.

Tuesday, September 27, 2016

Light Cone Animation

I generated this animation of Past and Future Light Cones of a stationary point object with vertical line as it's world line using Mathematica. As such the each light cone should sweep a (pencil-like cylendrical) shape as time passes, but I am showing the light cones at any given moment only. Also the cones extend to + ve and -ve infinite time as such.



The vertical axis is time axis with unit t seconds.
The z=0 is the NOW plane showing two (not three) dimensional space. The normalized unit for space axes is ct, where c is the speed of light. Thus distance of 1 in x or y direction is the distance travelled by light in 1 second.
That gives us 45 degree sloped light cones.
The downward moving planes are future moments, becoming NOW and then the past moments.
The top cone is the Future cone.
The bottom cone is past cone.
The vertical line is the world line of a stationary point object.

Sunday, September 25, 2016

Mathematica


I started playing with Mathematica this weekend. Here is a simple widget to plot Cos and Sin functions on Unit circle. You may have to force evaluate the cell by clicking on Gear > Evaluate Cell.

Saturday, August 20, 2016

Console magic

You can detect duplicate ids by evaluating this Javascript expresssion in Chrome devtools console:

([].slice.call(document.querySelectorAll("[id]")))
    .map(function(ele){ return ele.id;})
    .sort()
    .reduce(function(countMap, word) {countMap[word] = ++countMap[word] || 1;return countMap}, {})

Boom! You will get:

> Object { 
   id1: 1, 
   id2: 1,
   some-other-id: 1,
   duplicate-id: 2
   …
}

What is going on here:

  • document.querySelectorAll() returns the NodeList of elements that have id attribute
  • slice() - converts a NodeList to a JavaScript Array
  • map() - converts elements array to array of id strings
  • sort() - sorts the array. If you evaluate only up to here you will get the sorted list of ids (with duplicates)
  • reduce() - creates an object with id value as key and number of occurrences as value

Additionally, if you add Object.keys(resultFromAbove).sort() you will get a sorted list of unique ids.

Also an example of Map-Reduce 

BTW you can use similar, slightly modified selector expression to list the CSS classes that are used on the page and also mow many times.