Category Archives: Tools

Windows file symlinker gui

Windows has the ability to create file links. Not the regular “shortcuts”, Linux like links.

MKLINK
This is hidden in a shell command called MKLINK. Many people are not comfortable with a command shell (even many developers!). I sometimes just want to stay in the graphical view too.

Example Use
Just downloaded the new Groovy 2.1.0-rc-1 to check it out. I put my tools in a versions folder and then I create a directory link to the version I currently use. I wrote about this in “Switching between versions of tools“. So, when I install this new version a directory list (dir groovy) would look like this.

C:\java>dir g* | find "groovy"
01/10/2013  09:08 PM    <JUNCTION>     groovy [C:\java\GroovyVersions\groovy-2.1.0-rc-1]

This would usually be created with the mklink command as follows:

mklink /D groovy GroovyVersions\groovy-2.1.0-rc-1

With symlinker:
“The goal is just make it easier to create symbolic links, hard links, or directory junctions, using a pretty simple interface, so no more bogus command line to do it… ”

Is there any gui linker that allows you to create the link in the current explorer location? Yes, we can create a shell extension and all that, but shouldn’t computers make this easier to do? On symlinker’s project site, a user asks for this capability.

Ok, so it is graphical and looks good. However, now you have to fill in two input fields that require you to navigate using Windows explorer, where to create the link and then where to point the link. Using the command line is faster especially if you use tab-completion. You can use the Windows explorer window and type, of course, however, the “completion” there is more awkward.

Anyway, recommended tool for occasional link creation in Windows.

Tool Switching
The approach above is easy and works. If you need to switch a group of tools and libraries to different versions, that is more complex, perhaps even in the realm of package managers. In Windows there are no lightweight frameworks for this. On Linux there are tools like GVM.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

Synergy now easier to configure

Just updated Synergy to version 1.4.10 which uses a GUI to help layout the different screen relationships. Nice. Took about two minutes to install and share the keyboard and mouse between a PC and laptop.

Synergy lets you easily share your mouse and keyboard between multiple computers on your desk, and it’s Free and Open Source. Just move your mouse off the edge of one computer’s screen on to another. You can even share all of your clipboards. All you need is a network connection. Synergy is cross-platform (works on Windows, Mac OS X and Linux).

Basically, it is a software Keyboard Video Mouse (KVM) switch.

Links

  1. Synergy
  2. How To Control Multiple Computers With A Single Keyboard And Mouse
  3. Synergy for Mac: SynergyKM
  4. KVM Switch
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

‘TheBrain’ still unique!

I have been a PersonalBrain (TheBrain) user for many years. Lately I have not used it much since my current contract job is behind a firewall, allows no downloadable software, etc. Not complaining, security is important.

Today, at home, I had to look up a subject on the web. Did the search, not much found. Looked at my saved links in a folder, not much. Then opened up my TheBrain, version 5. Lo and behold, the opened “plex” user interface allowed me to browse the subject, find long ago formed context mappings, explore new relationships, see things in a different light, give new ideas, stimulate new things to look up and explore.

How can one interface do that? Well, it is a cognitive interface. That is how real brains work, forming tangles of relationships, directed graphs. TheBrain is unique software. Surprisingly, even in 2012, there is no similar product. It doesn’t fall into familiar categories; it is not Mind Mapping or context mapping, for example.

I think I’ll think of it as a category of Cognitive Mapping product.  Its like Context Mapping but with “focus”.

Update, Feb 26, 2013: I read that they are working on an iOS and Android version. That would be interesting. Would be a big challenge I would imagine if they target smartphones.

Further reading
Beyond hierarchies: A better paradigm for mind mapping – Part 2
Beyond hierarchies: A better paradigm for mind mapping?
What’s new in TheBrain 7
Any alternatives? Nope!
FreePlane
FreeMind

Software
Free your mind (map) with Groovy

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

MultiMouse

What a great idea for collaborative work groups: MultiMouse.

Users can drag the mouse cursor out of their computer’s desktop and multiple mouse cursors will appear on the common desktop of the central PC:

Multiple mouse pointers are useful for workgroups who want to brainstorm on a project and discuss ideas.

While all users are using their own computer, they can work together on one screen. All mouse cursors are visible on the main computers desktop. Users can also enter text on the central PC from their own keyboard.

Each remote mouse cursor has a customizable name tag to identify each user.

The user’s mouse cursor positions and remote text input is transmitted by MultiMouse using any existing Wireless or Ethernet connection. No extra hardware required!

MultiMouse

Related
MaxiVista
UltraMon
Synergy

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

Diagnostic Differential Logging with JavaScript Example

Synopsis
Reducing the quantity of information to what is essential is very important in maintaining complex software. Modern development environments have debuggers and other tools to assist in this effort: conditional breakpoints, watch expressions, logging, stop on change techniques, and so forth.
As a supplementary technique an approach to debugging is shown which uses the dynamic differences in a running system to output a reduced level of information. A simple programmatic implementation is shown in a JavaScript scenario, but the technique is applicable using other languages and automated techniques.

KEYWORDS: logging, diff, debugging, diagnostics, BIST, JavaScript, AOP, BIST

Context
Recently I was debugging a legacy JavaScript program. I used the outstanding FireBug plug-in in the FireFox browser. By the way, FireBug is truly indispensible, such a wealth of features and it is FOSS. Now combine that with Selenium which gives you the ability automate the browser and you have a powerful Integrated Development Environment (IDE). All that could be lacking is time and skill.
Unfortunately, I was not finding the problem. Later at home I got an idea. What if I could simply log what changed? That way I could more clearly see how the program behaves. All programs are just obfuscated state machines. Through a use-case or scenario, state variables are being manipulated and non-state data is being changed. Correlating these two with the events that drive the system, is a prime aspect of debugging.

Forces
• You want to log what is happening in a system, but you don’t want to be inundated with non-useful data.
• You or someone else want to be able to quickly resume this investigation in another situation or project.
• By saving ‘interests’, a Built-in-self-test aid can be implemented.
• During development hooks can be put in place to provide differential logging.
• You want to capture the live system not a system which is controlled by a debugger.
• You cannot install new systems, tools, or frameworks to help.
• Breakpoints will break as the system is maintained.

Solution
My solution was to dynamically log the differences. I’m sure this is not new. However, it probably is not explicitly discussed. The usual approach is to log as much as possible, but since this is prohibitive, instead the logging is limited, level filters, and contexts are used to control the output. Breakpoints and watches while usually enough to do the job are in the long term brittle since the target program may change during the dev and debug process. Thus, dynamic difference reporting would be a better approach in this situation.

Consequences
Todo.

Implementation
There are a few implementation choices.

API
One is to declare the data of interest. Then the logging system will track these and only output anything when there is a change in any of the data. With this approach the logger must be triggered either manually or automated. Manually is very easy; at an event change or at enter and exit points of a module or function, the differential logger is invoked.

Automated
To avoid changing the source code (it may not even be available), AOP could be used to implement the above. For example, an Around advise can be used to differentially trace the changes in methods.

Framework Plugin
If the system under test is running as part of a debug or is instrumented, it may already have a facility to capture change events. For example, FireBug, the FireFox plugin has this and the FireBug plug-in, FireDiff, implements a change monitor and visualization output. There may be or should be a comparable plug-in for other systems like the Eclipse IDE.

Code Example
To illustrate this concept it is used to debug a web page’s DOM changes via JavaScript. The page has a button that when clicked will randomly change two input field’s content. Notice that when the change involves just an ordering of two adjacent characters in a field, it is not readily apparent. The Differential logging makes it explicit. The log output is just the result object converted to JSON. An example: {“event”:”run”,”record”:{“foo2”:[“”,”accd”],”foo4″:[“”,”ollrr”]}}. A real implementation would do otherwise.

To specify which DOM nodes to monitor, a JavaScript object is used:

{"foo2":{"get":"v"},"foo4":{"get":"v"}};

The “get” field is used to specify how to get the value from the browser DOM. Another method would be “innerHTML” access. A better approach is to detect the appropriate ‘getter’ via using the node type.

demo screen capture

Listing 1, implementation


/**
 * 
 * Differ constructor.
 * 
 * @param data which nodes to record
 * @param formatter how to show results
 * @returns
 */
function Differ(data, formatter){
	this.data = data;
	this.formatter = formatter;
	
	if(!formatter){
		this.formatter =this.format;
	}
};

/**
 * Data and methods of class.
 * 
 */
Differ.prototype = {
  MAXSIZE : 15,
	
  /**
   * Detect changes and save latest.
   * 
   * @param event Where was diff created
   * @returns result object
   */
  diff : function(event){
    var results = {};
		
    if(!data){
    	return results;
    }
		
    if(event){
    	results = {"event":event};
    }
		
    results["record"] = {};
		
    var record = results["record"];
		
    for(var key in data){			
      var ref = document.getElementById(key);			
      var domValue = "";			
			
      switch (data[key].get) {
        case "v":
          domValue = ref ? this.shorten(ref.value) : "";
          break;
        }
			
        var prior = data[key].value ? data[key].value : "";
			
        if((domValue != prior)){
          record[key] = [prior, domValue];
          data[key].value = domValue;
        }
    } // end for	
		
    return results;
		
  }, 

  /**
   * Convert results to message.
   * 
   * @param results object
   * @returns JSON
   */
  toMessage : function(results){
    var obj = results;
    if(!results){
      obj ={"error":"results is undefined or null"};
    }		
		
    return this.format(JSON.stringify(obj));
  },
	
  /**
   * Get size of an object
   * @param obj
   * @returns {Number}
   */
  size : function(obj){
    var len = 0;
    for(var key in obj){
      if(obj.hasOwnProperty(key)){
        len++;
      }
    }
		
    return len;
  },
	
  /**
   * Limit size of value.
   * 
   * @param value
   * @returns
   */
  shorten : function(value){
    return (value.length > this.MAXSIZE) ? 
	value.substring(0,this.MAXSIZE-1):value;		
  },
	
  /**
   * Make message human readable.
   * 
   * @param message
   */
  format : function(str){
  	return str + '<br/>';
  }	
	
};	

Listing 2, Demo script

var data = {
  "foo2" : {
    "get" : "v"
   },
  "foo4" : {
    "get" : "v"
   }
};

var differ = new Differ(data);
differ.diff(); // prime values

function runIt() {
  var ref2 = document.getElementById('foo2');
  var ref4 = document.getElementById('foo4');
	
  if(Math.floor(Math.random()*101) > 60){
    swapInputs(ref2,ref4);
  }else{
    scramble(ref2,ref4);
  }

  var msg = differ.toMessage(differ.diff("run"));
  document.getElementById('output').innerHTML += msg;
  document.getElementById('output').innerHTML += 
    Array(60).join("-") + "<br/>";
}

function scramble(ref2, ref4){
  var ch = ref2.value.charAt(1);
  var r2v = ref2.value;
  ref2.value = replaceChar(r2v, 2, ch);
  ref4.value = replaceChar(ref4.value, 2, ref4.value.
    charAt(1));
}

function swapInputs(ref2,ref4){
  var temp = ref2.value;
  ref2.value = ref4.value;
  ref4.value = temp;	
}

function replaceChar(str, ndx, v) {
  return str.substr(0, ndx) + v + 
    str.substr(ndx + v.length);
}

Listing 3, the demo web page

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; 
    charset=iso-8859-1">
  <link rel="stylesheet" type="text/css" href="style.css" />	
  <script type="text/javascript" src="DebugUtils.js"></script>	
  <script type="text/javascript" src="DemoDiff.js"></script>	
</head>
<body>
  <span class="mytitle">Differential Logging Example</span>
  <div style="width:600px;">
	<div class="box inputBox">		
		1: <input type="text" id="foo1" value="xyyz"/>
		2: <input type="text" id="foo2" value="acbd"/><br/>
		3: <input type="text" id="foo3" value="wzlm"/>
		4: <input type="text" id="foo4" value="olxrr"/>

          <span class="buttonClass">
	    <input type="button" id="run" value="Test" 
               onclick="runIt()"/>
	  </span>		
	</div>
	Output
	<div id="output" class="box inputBox"></div>
	<span style="float:right;margin-right:10em;font-size:xx-small;">
           &copy; Josef Betancourt</span>		
	</div>
</body>
</html>

Listing 3, css

body {
  background-color:#E6E6E6;margin:3em 8em 12em 3em;
}	
.box{
  border: 3px solid #D4D4D4;padding:8px;
  padding:2em 1em 2em;margin:10px 5px 20px;
}
.inputBox{
   background-color:Beige;margin-right:36px;
   width:475px;font-family:monospace;
}
.buttonClass{
    float:right;margin-left:1em;margin-right:3em;
}
.mytitle{
   text-decoration:underline;font-weight:bold;
}

Related Patterns
None.

Related Intellectual Property
None.

Further Reading

Debuggers are for Losers

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

How to use multiple views in Notepad++

Good editors always have some support for showing multiple editor windows. This is supported in many ways. See this for a comparison of the available document interfaces.

Multiple Views
NotePad++
I was happily surprised to find that Notepad++ also supports this. The trick is to right click on an edit window’s tab and choose “Move to other view” or “Clone to other view”.

Eclipse IDE
By the way, Eclipse IDE also supports multiple docking of edit views. You can even open two views into the same file. However, Notepad++ allows you to synchronize this. Which, afaik, Eclipse does not.

Multiple instances
While the above is great, sometimes you want two Notepad++ instances to, for example, open them each in their own display monitor. For that you just have to add to the notepad exe startup: -multiInst. For example on my Windows 7 instance my Notepad++ shortcut has:
“C:Program Files (x86)Notepad++notepad++.exe” -multiInst

References
Comparison of document interfaces
Managing two views in a single Notepad++ instance

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

Show hidden windows utility on PC

Sometimes a program may crash or show deranged behavior and one of the dialogues cannot be accessed. This just happened to me. A program looks like it is stuck in a thread issue. When I look on its thread list it seems to be waiting for user input. There is no dialog visible. Clicking on the program’s window just gives the waiting mouse pointer. Sure you can just kill the program but this may not help you find out what the problem really is.

I remember years ago I used a utility that could show these hidden windows. Good luck searching on web for something like “show hidden windows” or better phrases. You won’t find it. Well, yea, you could. I did. But, I’m good, smirk.

Note that this utility is pretty basic, just shows a list of window objects. Some of them should not be unhidden, they will lock the utility itself or cause other problems. Perhaps there is something out there that is better? Seems this should be part of the Sysinternals utilities.

Links

  1. Unhider
  2. Windows Sysinternals
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

Use SED or Groovy to print paths, split with line feeds

Yea, this is easy, IF you use SED much. Now I updated this post with a Groovy approach, since this is easier to install where cygwin may be prohibited.

Using SED
With cygwin installed, SED, the stream editor is available. In a command shell, execute:

set path | sed s_;_;\n_g

Update: fixed the sed above, was missing the backslash before the n.

Explanation

  1. set path will print the Windows path. File path entries are separated by “;”.
  2. sed will invoke the cygwin installed linux SED command. Cygwin\bin is part of the executable path.
  3. “s” indicates the substitute command
  4. “_”, the underscore is used as the delimiter to each part of the substitution. One can use other characters for the delimiter.
  5. “;” is the regular expression to use for a match.
  6. “;\n” is the string to substitute with. \n is the crlf.
  7. “g” is the substitute flag, global replacement

No doubt there are more direct ways of doing this. Using PowerShell would be the most appropriate on Windows if it is available.

Using Groovy
Another approach is using the Groovy language, which has a command line mode using the “-e” switch:

set path | groovy -e "System.in.text.split(';').each{ println it}"

Explanation
The output of set path is piped to an inline Groovy script. The script uses the “text” value of the System.in standard input stream. ‘text’ is some magic Groovy dust. The Groovy development kit (GDK) extends Java io streams with a method, textO(), that gets the string value of the stream, like read a file. This is available as a java bean getter method, which again via magic is available as a field, “.text”. The string is then split, then a closure “each” is used to print each line, passed to the closure with the default variable “it”.

Example
If your path is: C:\fee;d:\fi;c:\foo;fum

The result would be:
C:\fee;
d:\fi;
c:\foo;
fum

You can, of course, pipe these together to allow finer control. However, the high level language makes for very long winded code, for example, find all properties in Java system properties that have the word ‘Java’ or ‘java’:

groovy -e "System.properties.each{println it}" | groovy -e "System.in.eachLine{ if(it.find('[jJ]ava')) println it}"

Better would be, just putting the filtering inside the closure:

groovy -e "System.properties.each{ if(it.key.find('[jJ]ava')) println it}"

Or as a script:

System.properties.each{ 
     if(it.key.find('[jJ]ava')){ 
        println it
     }
}

Consult the Groovy documentation for further Groovy syntax and idioms to make the above even better.

References

  1. GNU sed
  2. Sed – An Introduction and Tutorial by Bruce Barnett
  3. SED, stream editor
  4. PLEAC-Groovy
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

alarm clock windows media player via PowerShell

The modern personal computer is so powerful, yet using it as a alarm clock is not so easy. There are a few commercial and free “PC Alarm Clocks” available, so all is not lost.

But, there is already a media player in Windows and a task scheduler, so it should be a piece of cake to schedule Windows Media Player to play a song or playlist every morning.

One way not to do it is to just schedule Media Player to start up and play a song as shown in this article ““Windows Media Player Alarm Clock using Task Scheduler“. As the author of the article states:

The only problem with this alarm clock is that if you are LOGGED OUT or the system is in standby prior to activating, it will run WMP as admin and you wont even see it open when you log in. To turn it off you will have run Task Manager and actually kill the process. A small price to pay for the reliability of a loud clock ….

What we need is a programmatic solution, and fortunately Windows now has a decent scripting language, PowerShell, with access to the Windows features. Thus, we use a script (from “Weekend Scripter: A Cool Music Explorer Script“):

Add-Type -AssemblyName presentationCore

$mediaPlayer = New-Object system.windows.media.mediaplayer
$path = "C:\Users\Public\Music\jazz\Oregon\1000 Kilometers"
$files = Get-ChildItem -path $path -include *.mp3,*.wma -recurse

foreach($file in $files)
{
 "Playing $($file.BaseName)"
  $mediaPlayer.open([uri]"$($file.fullname)")
  $mediaPlayer.Play()
  Start-Sleep -Seconds 10
  $mediaPlayer.Stop()
} 

And save it as a ps1 type file, for example: c:\batch\PlayMedia.ps1
In the above script, change the file so that ‘$path’ points to your own music folder. Note that the script plays each mp3 it finds for only ten seconds. How would you change it to just play the whole work?

Next you’ll open up the Task Scheduler and create a new basic task. The Actions tab is where you’ll edit how to run the task. So, enter into the dialog box:

Action:  Start a program
Program/script:  powershell
Add arguments (optional): -command "& 'C:\batch\PlayMedia.ps1' " 

Of course, set the days and times, and you can even select that the system will wake the computer to run the task.

I learned how to run PowerShell in scheduler at “How to schedule a Windows Powershell script“.

Advantages?
Well, now that you can program the system to act like a musical alarm clock, you can tweak it to use playlists, radio, etc. Soon you’ll be getting it to wake you up with “A Night On Bald Mountain” shaking the house, and while you are running around the bedroom screaming from fright, the PC will calmly start a batch of whole wheat pancakes and pouring on the real maple syrup; slowly the aroma from the coffee it started brewing will start to permeate your consciousness , and no, that giant Chernabog is not coming for you.

What is PowerShell?
Surprisingly, many technical people have never heard of PowerShell. This is Microsoft’s innovation in their management infrastructure. Before, the “command shell” and associated batch language were really decades old DOS-like behavior. That shell could not compare to Unix/Linux shells like bash. PowerShell is an object-based scripting language and shell. Afaik, it is unique in that instead of using only text manipulation, as in most unix pipe examples, it pipes objects.

Updates
Oct 11, 2013: I found the perfect system, Sonos. This is a premium wireless music system. It also can do sleep timer and alarm clock function.

System

  • Windows 7 64bit Professional
  • Windows Powershell 2.0

Further Reading

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

Can’t save a new TiddlyWiki in IE

I wrote before about saving issues in Chrome Browser, I now have a similar problem. I downloaded a new TiddlyWiki version and when I try to save a change in it, I get problems in IE browser. I don’t have administrator access to this system, so maybe this is an issue?

Here is the fix which someone mentioned in the TiddlyWiki forum. Just copy the file and save to a new file name. This won’t work with just a file level copy. You have to copy the internals themselves: open the new file in a text editor, I used GVim, then copy the contents into a new editor file and save to a new file. When you open this new file you will get the usual first time IE security and activeX warnings. After that, the TiddlyWiki file is now a “normal” instance.

BTW, I recommend the SinglePageModePlugin. It allows the setting the way TiddlyWiki opens Tiddlers, less confusing, especially for casual TiddlyWiki use.

What the heck is TiddlyWiki? See “TiddlyWiki for the rest of us” for an end-user guide.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.