Friday, October 7, 2016

Metric prefix conversions made easy

This units conversion wheel was created to help my son visualize the process of converting the prefix of metric units; e.g. converting from milligrams to grams.  To use it, just select the units in the dropdown and then enter a number in the edit box. Then rotate the wheel to the desired units by rotating the wheel with either the mouse or swiping it with your finger.

Friday, May 27, 2016

Sources for a small maven multi-module project


This is a multi-module maven project that was created according to the sonatype maven tutorial, which can be found here: https://books.sonatype.com/mvnex-book/reference/multimodule.html.

The sources for the project can cloned from here: https://wmmnpr@bitbucket.org/wmmnpr/weather-parent.git

I created it so that I could experiment with deploying a webapp (weather-webapp), which was part of a maven multi-module project, to weblogic.

It appears that the source code referred to in the apache documentation (https://maven.apache.org/guides/mini/guide-multiple-modules.html) is no longer available.

Type "mvn install" in the weather-parent directory and all the modules should be built and deployed to weblogic, which you will undoubtly  have to reconfigured or remove. To make it work without weblogic just delete the weblogic-maven-plugin plugin and run it using jetty as in: mvn jetty:run

I threw in the plugin for no special reason other than that I needed a sample plugin project as well. The plugin was created with the "maven-archetype-plugin" and the webapp with the "maven-archetype-webapp". Its "touch" goal should execute during the compile phase of the default lifecycle; see the pom of weather-service module. Eclipse's Lifecycle Mapping show this nicely.



Once deployed, the webapp can be accessed by calling:  http://host:port/weather-webapp/weather, which should show "Windy".

Sorry, it's pretty boring but I was trying to keep it simple.


Friday, February 19, 2016

Working with npm/bower/git behind a NTLM authenticating proxy server.

Working with development tools like maven, npm, and bower on Windows behind a proxy server, which only supports NTLM authentication has always been a cause of head aches for me. For the solution I am about to describe, I can only thank the creators of cntlm at source forge (http://cntlm.sourceforge.net/), who must surely really know what they are doing.

In essence, the solution is to install cntlm locally and divert the development tools' requests through it rather than sending directly to the proxy server. 

The quickest way to get started is to unzip cntlm and configure the cntlm.ini file in the application's home directry in the appropriate places with the following

/-----------------------------------------------------------------------------------------------------/
Username YOUR_USERNAME
Domain YOUR_DOMAIN
Password

PassNTLMv2 01213D7806A61B78FB3BA894CAA4BA9D

Proxy t-web-gw.farnet.net:8080
Listen 8082

Auth NTLMv2
/-----------------------------------------------------------------------------------------------------/
Be sure to leave  the "Password" setting blank.

To generate the hashed credentials and get the appropriate Auth value, highlighted in yellow above and below, run the program as follows and enter in your normal login password when prompted:
>cntlm -c cntlm.ini  -I -M http://www.google.de
Password:
Config profile  1/4... OK (HTTP code: 200)
----------------------------[ Profile  0 ]------
Auth            NTLMv2
PassNTLMv2      01213D7806A61B78FB3BA894CAA4BA9D
------------------------------------------------

Now your settings, with lots of logging to the console, can be tested by running the server in the forground as follows:
>cntlm -c cntlm.ini  -f -v

If it's npm that you would like to use, then look for a file in your home directory called: ".npmrc" .  Here you should add
proxy = http://localhost:8082/
https-proxy = http://localhost:8082/

You can also use nplm itself:
npm config set proxy http://localhost:8082:8080
npm config set https-proxy localhost:8082:8080

For bower, add them to the .bowerrc file in the project's folder or in whichever folder you ran bower init
{
"proxy":"http://localhost:8082",
"https-proxy":"http://localhost:8082"
}

If you still get errors like below, when trying to execute "bower -update":
bower ECMDERR Failed to execute "git ls-remote --tags --heads git://github
.com/angular/bower-angular.git", exit code of #128 fatal: unable to access 'http
s://github.com/angular/bower-angular.git/': Received HTTP code 407 from proxy after CONNECT

Then check your credentials again by using cmtlm as previously shown above:
>cntlm -c cntlm.ini  -I -M http://www.google.de

Adding the "url.https://.insteadof" to the git settings, as suggested in many places, with
git config --add url.https://.insteadof git:// 
will probably not help.

Wednesday, January 27, 2016

Traversability of Networks (Durchlaufbarkeit von Netzen)


I panicked the other day when my ten year old son, as part of his homework, asked me about traversing graphs.  Even worse, the following day, he was to have a test and was supposed to be able to determine if one could travel along every edge of a given graph only once without lifting the pencil from the paper after having started and whether or not it was possible to end up at the starting point.

When it is possible to do so, then the graph is said to contain an Euler cycle or circuit and is often referred to as an Eulerian graph after the famous Swiss mathematician Leonhard Euler, who dealt with such puzzles while solving the famous Seven Bridges of Königsberg problem in 1736.

If it’s possible to traverse over every edge only once but not end up at the starting point, then the graph is said to contain an Euler trail or path.

The rules for determining whether a graph has an Euler circuit, Euler path or neither, is unsolveable, can be summed up as follows:

For Euler circuits, or Eulerian graphs, every node or vertex of the graph must be of an even degree (the degree of a vertex is counted by the number of edge, which are connected to it).

For graphs that only have a path but no circuit, there can only be two odd vertices present. The presence of one, three or more odd vertices means that it is not possible to completely traverse the graph and only travel along each edge once and only once.

Euler Circuit (ending at beginning node)
One can start at any node. All the nodes are of even degree. Click on the nodes below to traverse the graph. Clicking twice on a node will undo the last move.


Euler Path (traverse graph but not end up at the starting node)
Exactly two of the vertices are odd. One must start at one of the odd vertices and end up at the second one.


Not traversable or impossible 

One, three or more than three of the nodes are of odd degree.