Sunday, September 06, 2015

Facebook + Chrome: Please try closing and reopening your browser window.

Symptom:

You get "Please try closing and reopening your browser window." when posting a message on Facebook. But closing the window does not get this message to go away.

Possible Cause

In my situation, this was due to having the Cross Origin Resource Sharing mode enabled on my Chrome using the CORS extension. By turning it off, the problem went away.

This is often considered as a non-secure mode and Facebook especially will not allow some features to be used like Posting and Messaging when the web request has been modified.

The CORS extension is used by developers like myself to access resources from different web servers and it is not normally needed for consumer use, so if you do get into this situation, you may actually have some other mechanisms/extensions which is causing the same effect, and that could mean that your Chrome may be infected with malware so be sure to check your extensions and remove anything that you do not understand what they do.

Also try with a different browser and if it only happens on Chrome (or vise versa), then I will clean up the browser.


Friday, June 19, 2015

Hibernate Envars, ValidityAuditStrategy Fails with Cannot update previous revision for entity

Symptom:

You have configured for the org.hibernate.envers.strategy.ValidityAuditStrategy with your Hibernate Envers to audit trail SQL table records with the following exception;

java.lang.RuntimeException: Cannot update previous revision for entity

Root Cause:

This happens when the table that already has records and you add the Envers auditing with ValidateAuditStrategy "after the fact". In other words, there are legacy records which were not originally audited.

Basically, the ValidityAuditStrategy was designed only with the assumption that you started using it from completely no data in the table and its related tables. It requires the initial INSERT record of the very first record of all rows with a unique record ID.

This issue has been logged in the Hibernate JIRA HHH-8456

Workarounds:

If you can afford to disable the ValidyAuditStrategy, that will log the entries.

The initial revision entry must be inserted into the newly created _AUD table for every existing legacy record.

This problem may be worked around by using the following tool that's available from the GitHub.

https://github.com/hydra1983/hibernate-envers-tools

Sunday, May 24, 2015

IntelliJ IDEA 14.x How To Resolve "routes" Activator/Play Object

Problem:

You just imported the SBT project of Activator or Play framework app in IntelliJ IDEA (14), and you found that you "routes" among other symbols do not resolve.

Root Cause:

You are lacking the dependency for the auto-generated routing class.

Solution:

You can add Module Dependency to classes_managed. This is located in the target/scala_2.xx/classes_managed

I originally posted a similar solution, but this one is much better and works with Play 2.3 or later. This video shows you exactly what you will need to do.



Thursday, April 30, 2015

Windows File History (7, 8 and 10) - One Of the Most Useful and Overlooked Feature

You are probably using some type of backup software from a commercial vendor. I have been too, but recently I stopped using it and switched to a Built in File History.

If you are used to Mac OS Time Machine, it comes as close to that, but in some ways better because you can still control what gets backed up and what does not. Like the Time Machine, you can ask it to back up hourly or even every 30 min of recent file changes and then automatically prune off old backups.

Another advantage is that it is very well integrated with the power control of your system, especially a laptop. I was using another vendor's backup software and any time I wanted to sleep or shutdown, it refused to do so because it was in a middle of a backup. Not with this, you can go to sleep, close the cover and you won't get in a situation where you have a hot battery drained laptop when you pull it out of your case.

In my situation, what I needed was automated hourly backup of some of my important documents, especially the code I am currently working on (but not quite ready to commit to Git). But if you are a teacher or an accountant just keeping the Office docs that works pretty painlessly.

Where to Backup?


Cloud backup is very popular, but the problem is that you are not always on the most reliable network especially on laptops. You could also be in flight and working on documents or code. Fortunately, most laptops have a memory card slot. So I advise that you buy as big of a memory (SD card) as you can afford, I would say get at least 64 GB. So just plug it in, format it in NTFS.

Since this is a solid-state memory, it does not consume much power and you know you have a backup available to you pretty much anywhere.

How To Enable and Configure It?





  • Go to your control panel and find File History which is under System and Security.
  • You can now enable the feature and select the destination "drive" here.
  • After the drive has been configured, click Advanced Settings

  • You can configure how often you want to back up.

Selecting Items to Back Up

Here is another cool thing about this. You can easily manage which stuff on your system is backed up. The key answer to " how to select which folder to backup" is that anything included in the Libraries part of your Explorer is backed up. By default your Documents, Music, Photos and Videos are backed up. In the picture below I have dragged in WinguMD folder which contains my work stuff. Note that dragging the items in the Libraries folder does not move the folder there, but it just like the shortcuts but backups are enabled.  I would not back-up videos if you have a small memory card.

On a side note, I have been wondering what the Libraries were for the longest time. Now we both know what this is.





Windows 10 Lost Ability to RDP Into the System

Symptom:


You upgraded to Windows 10 and now you cannot RDP to the system at your home network. (I do this a lot because I use Mac at home and RDP to my laptop which is Surface 3).

One of the Root Causes

In my situation, all of my WiFi connection went to Public which automatically turned off just about any incoming traffic to it from the Windows Firewall. This is a good feature. Do not turn that off.

To Make Your WiFi Network to Private

This, I guarantee you will take some time as there has been a big change.

  1. On your desktop, click the New Notifications icon on the task bar. That' far right and looks like a Messaging icon.
  2. Right click over WiFi and "Go to Settings."
  3. This is where you will be lost, especially if you have many spots.
  4. On the list of WiFi access points scroll all the way down.
  5. Click HomeGroup
  6. If your system is like mine, you will get a chance to enable the HomeGroup on the network you are on.




Friday, April 03, 2015

VertX Development with IntelliJ IDEA

Problem:


How can I develop Vert.X Verticles with IntelliJ IDEA?

Some Tips (May not be a Solution):


I have been trying to evaluate the Vert.X system (after getting my head spin around Activator + Scala), and believe or not, I have been in C/C++/C# woorld all this time and manged to avoid Java altogether (yes, you can have a whole career based on C# and JavaScript only!). So I am sure there are some figments of ignorance in this article. If you find anything wrong, please let me know as that will help me a lot.

As I stared on this path, I did find many other articles all over the net but I have found that most were written by seasoned Java developers directed to other still-a-bit-seasoned Java developers. This article is written by someone who hardly know much about Java. So if that's your situation this will help a lot, at least get to the point your Verticle to run and debug under IDEA.

Much of the hurdle in dealing with the Java environment (not so much with the language itself) is that  there is initial confusion as where all the classes come from (yes CLASSPATH) and there are more than one ways of doing things right. As a result it has gotten very time consuimg tasks to learn each of the paradigm. For example, there are Maven, Gradle and Ant to handle the builds just to name a few then there are things like Scala and Groovy and such to even confuse us, and on top of various Java frameworks for example Vert.X is one of them and Activator is another, then there are even more stuff like Spring, Netty etc.

Each serves slightly different purpose but they also get combined to do a lot of similar things like serving up Web APIs and web pages and such.

So with that in mind, here is probably very overly simplistic description of how to work IntelliJ with VertX development.

How To Start


I started with both Gradle based project initialization to Marven based. I have found that the Maven based one is a bit less intimidating to approach and lot simpler overall, so I also advise you try the Maven way first then do other stuff.

The most of how to set up the Maven based project skeleton is described on Vert.X document on THIS PAGE. But that page does not give you much more info on how to debug etc.

So first off, follow the directions on that page until you are all done and typed in "mvt idea:idea" to create the IDEA project. Then you can open the top level of your project (where you will find the IDEA files like .iml, .ipr and .iws). This will first convert the project format. Let IDEA handle that.

Integrating the Maven Project is the Key


After you open the project, and after a few minutes IDEA will say, it has found a Maven project and if you want to import it. Say yes. This will cause a small Marven Tab on the right hand side of the IDE.



What I have found out is that clean, compile and package commands (goals) are very handy.

For example, let's say you have added a new Verticle class. I have found that first doing the clean then do compile will make it appear in the target directory.

Now if you want to create the mod directory containing your Verticles, then doing package.


  • For each of the action, which is called Goal in Marven, select an item then press the Green start button above to execute.
  • clean will clean out any derived objects
  • compile should be used each time you update the source
  • package will create the mod directory in the target
  • install will also create the mod directory on the top level of the project, but what will be install is not always updated when you change the source.

Starting Verticles from Within the IDEA

For the reasons that I do not completely know, if you run "vert runnomd com...." stuff from the top directory of your project, it can find your module. So do not be afraid to use that option. But if you want to debug your updated verticle code each time via the mod then you can first do the "package" Marven goal first, then you can "cd" into your "target" directory then you can run the latest version.

Also not shown in this but instead of specifying Make before you debug, you can specify the Maven "package" goal which will always recreates the mod directory with the latest code. You may want to do that. Make takes forever to build, so I would at least switch to "compile" verb of the Marven and remove the Make action.





Adding or Running Your Own Verticle From Within IDEA

This is still an area that is a bit of mystry to me, but here is what I know so far and it does work, but the Vert.X documentation does not tell you how, so I had to do some experimentation to find what worked for me.

  • Go a head and add a new Verticle class under src/main/java/com.blah/ directory.
  • Do not remove PingVerticle.java If you do remove it what will happen is that it will break the build because there are some "tests" that will call this. You could, in theory, remove the tests too but why bother when you actually do not have to remove it.
  • If you want to run your own Verticle, you will have to go inside the "resources" directory, find mod.json and edit it to contain your class under "main": 
  • Now do a clean and then package and you will have your new Verticle to launch when you do runmod com.blah... stuff.
I am sure there are some errors in my post, but I feel that I have given you enough information that allowed me to do what I wanted to do. As I find more information, I will plan to update this document.




Thursday, February 12, 2015

Method with C# Generic Cannot Have == (Equality) or Comparison Operator

Problem:

You have written a function like the following;

       static Boolean IsV1GtV2(T v1, T v2)
        {
            return v1 > v2;
        }

And you get a compiler error stating;

Operator '>' cannot be applied to operands of type 'T' and 'T'

The error is reasonable, since there is no gurantee that some generic type T would support comparison.

The Following will Also Break

So next you could have tried.

return (int) v1 > (int) v2;

And you still cannot get that to work. 

Solution

The only real way it works (for me at least) is to work the code this way. 

            if (typeof (T) == typeof (System.Int32))
            {
                return (int) (object) v1 > (int) (object) v2;
            }

You wold, of course, need to add this type of block for every possible type that you plan to use.







Sunday, January 11, 2015

Fixing Plantronics Voyager Legend Audio Drop Issue + Activating Google Now

I have been a big fan of Plantronics. They come up with innovative product and of course, my friend works there too!

I have also been using Motrola MotoX for some time and I have had some issues with my Voyager Legend for some time for which I finally got around to address.

Frequent Disconnect Issue

There are several forum complaints that the Legend disconnects. I have the same issue with it. One thing that can help resolve this issue is to download the Firmware Updater from the company's web site. This requires a direct USB connection to your Mac or PC.

To do that, go to This Support KB Article.

The Talk Button Does Not Turn on Google Now Voice Recognition


With an iPhone or other Android phones when I press and hold the Pickup button for a few seconds, you can activate Siri or Google Now for most phones, but that stopped working (or never worked until now) on my Moto X.

This is more likely specific to Moto X with the hands-free operation mode. In my case Google Now, by default, turns off the Bluetooth Headset Mode OFF. By turning that feature on, you can gain back the mode that you can press the pickup button for a few seconds.

Here is what you need to do;


  1. Open Google Now uses the Google Now gesture (swiping up on the screen.)
  2. Scroll through all the cards until you see the last one on the bottom.
  3. You should now see the familiar (vertical set of 3 dots ...) setup icon on the bottom right of the screen. Tap that.
  4. Tap Settings
  5. Tap the Voice icon
  6. Enable the "Bulethooth headset" mode. It says Records audio through Bluetooth Headset if available. The term "record" does not sound quite appropriate, but what it means is that it can pick up the audio from the headset after pressing the pickup button.