Monday, November 23, 2015

Changes to .gitignore - Updating the Repository

I frequently start a git project without a .gitignore or often add entries to a .gitignore later. And then I have to update the repository to remove entries that match those entries. Here's the sequence I use:

git rm -r --cached .
 and then 
git add .git commit -m "..."git push...

Wednesday, November 11, 2015

HTML Flash Messages

Occasionally, and especially during the debugging phase of a development effort, I like to be able to create a message that appears in the web page on which I'm working, one that disappears after a few seconds. A flash message.

In the past, I've accomplished this in a variety of ways, including timeouts and so on. And some frameworks (Tapestry, e.g.) provide this kind of thing from the server as a built-in mechanism. But I'm just interested in doing this from within javascript.

Anyway, I was recently fooling around with prototypes and extending the javascript String object, and it occurred to me that a String extension to flash a message would be trivial to do, epsecially with JQuery to handle the timing parts. So I wrote this:

String.prototype.flash = function(){
    }, 3500);
Coupled with a
element in the HTML in which to display the message

I am able to write flash messages off typical JS Strings:

("This is COOOOOL...").flash();
Which will show that message inside the DIV, then get rid of it after 3.5 seconds. I could extend it to parameterize the time and even the fade effects. But sometimes simpler is bester.

Saturday, November 7, 2015

Creating an MD5 Hash From a String in Java

Using the MessageDigest Class, here's code to create an MD5 Hash of a String:

public static String makeAuthKey(String k) {
    MessageDigest hasher = MessageDigest.getInstance("MD5");
    byte[] kbh = hasher.digest(kb);
    String bs = new BigInteger(1,kbh).toString(16);
    return bs;

Java/Spring Caching

File it under "another thing I need to do a lot"... Some kind of caching of java objects.

Turns out there is a neat cache library from google called Guava that's very easy to inject into Spring and easy to configure and access.

The Spring beans look like this:

<bean id="cacheBuilderSpec"
  c:cacheBuilderSpecification="${cacheSpecification}" />

<bean id="cacheBuilderFromSpec"
  c:spec-ref="cacheBuilderSpec" />

<bean id="cache"
  factory-method="build" />

And where the injected $cacheSpecification looks like this:


Using it in my code then becomes a simple matter of injecting the 'cache' bean into whatever class I'm using and then accessing it with these kinds of code:


Saturday, March 7, 2015

Windows Explorer Opening to a Particular Folder

Dumb Windows Things annoy me, which means I'm annoyed a lot :-)

One thing is that opening Windows Explorer always opens to the user's "home" directory. As a developer, that's almost always the last place I want to be. What I really want is to have a shortcut that opens Windows Explorer on a specific folder, or on the root of my C: drive.

Turns out, this is trivially easy. Open properties on the link and add the folder to the end of the "Target":

      %windir%\explorer.exe C:


Saturday, February 14, 2015

Laptop Sleep Versus Shutdown after a Windows Upgrade Failure

I have a Dell XPS laptop running Windows 7. Recently, MS pushed out an update which, for some reason, never really completed - I was left with a message about Windows shutting down after the upgrade was complete.  I had left the machine on to perform the upgrade overnight, so it was a surprise to see this the next morning.

Well, not figuring out anything else to do, I pushed the power off button and then again to restart the laptop. Every time I did this, I would end up at the same place - with the message that Windows would restart after is was complete. I tried to get into safe startup mode (F8), but that never worked. I was getting a little concerned and called an IT guy to help.

He suggested that when I power off the laptop, I hold the power button down and not just press it. Well, that worked fine. I should have realized it, but simply pressing the power button puts the laptop in sleep or hibernate mode and then pressing it again starts back where it was left off. I knew how this worked in normal operations, but was surprised (though shouldn't have been?) to find the same during an update. So - lesson learned...

Friday, February 6, 2015

Internet Connection Failure...

Weirdest thing happened. After starting my laptop (Dell XPS 17, Windows 7), I had no internet connectivity. The network connections were fine - I could see other machines on my domain, but no connect out to the internet. My laptop is set up with an external monitor (LG Electronics 34UM94-P 34-Inch LCD - waaay cool!), mouse and keyboard. And the keyboard and mouse are USB connected to the monitor, which in turn is connected to the XPS laptop.

Did a bunch of poking around for possibilities. In the end, what worked was shutting down the laptop, unplugging the USB and the monitor, and then restarting the laptop. It came up fine, with full network and internet access. Then plugged in the monitor - still had internet; and then the USB. Internet and network access was fine and the keyboard and mouse worked.

Don't know why, but recording this for posterity!

Monday, January 26, 2015

Installing Oracle Java in Ubuntu, Something I seem to do a lot!

I create Virtual Box Virtual Machines for just about every project, so I end up installing Java on them a lot. I like the Oracle JDK, but for licensing reasons, that install is not available as part of the "normal" apt repository.

I installed Java via a PPA ( by webupd8team ( I ran these commands to add the PPA to the apt-get repo and update that repo, install Java7, and set up the various java 7 environment variables.

add-apt-repository ppa:webupd8team/java

apt-get update
apt-get install oracle-java7-installer
apt-get install oracle-java7-set-default

This installs the java 7 version. Same commands work with 8 by changing the version number.

Saturday, January 24, 2015

Switching to an SSD

I switched over to an SSD to replace the HDDs on my Dell XPS laptop. What a speed improvement. And, this is way too easy.

I was a little nervous about going to an SSD for everything - I had read that there are limits to the number of write operations an SSD can support before failure. But a little online reading put my mind at ease - mostly the thinking that on a 3 year old laptop, the computer itself will be out of date before the SSD fails.  The laptop is an XPS 17. It has an I7 quad code CPU, 16GB of RAM, and dual 750GB HDD drives. So I went ahead.

I ordered a Samsung 850 1TB SSD from Amazon ( When it arrived, I also realized it did not come with a USB cable, so I ordered that next (

Once I had both, I installed the Samsung migration tool that came with the SSD and ran the clone from my C: drive to the new SSD. It took about 3 hours to clone about 650GB. Word to the wise: make sure nothing else besides the migration tool is running or the clone might be incomplete.

After that was complete, I shut down the laptop, unscrewed that back panel and removed the #1 HDD. Then plugged in the SSD and screwed it in. It all fit perfectly. I booted the laptop, also no problems. And boot time was remarkably quick.

And that's it. I am thrilled with the speed.