Wednesday, November 02, 2016

IntelliJ Ultimate Debugging JavaScript from the LightBend Activator/Play Framework


You tried to debug a {java | type|}script in Chrome browser and it does not fire a breakpoint.

You have already made sure that JetBrain extension is installed in Chrome and configured right.

You've also added the JavaScript debugging configuration, and the web page launches (e.g., http://localhost:9000)


There is one more missing piece to this puzzle. You need to map the URL for where the scripts come from. This is clearly documented in the IntelliJ documentation, but nevertheless, it is not intuitive enough that it took a while for me to find out.

The key is that you need to type in the Remote URL in the Remote URL list. This is NOT OPTIONAL for Play users. If you are running the "out of the box" configuration of Play framework, and putting in your *.js under the "public" directory somewhere, then all you need to do is to just type in /assets (will become http://assets after you save it without any ill effect) where the public folder is in the list. Save it and any JavaScript or Typescript (with a map) can be debugged.


Saturday, October 08, 2016

Azure VPN Client: A certificate chain processed, but terminated in a root certificate Issue after Windows 10 Upgrade


I have upgraded my Windows OS to Windows 10 Anniversary edition recently and right after doing that I started to get the following error when connecting to the VPN. I have downloaded the same VPN client.

A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.

Yes, we know your certs were going fine until a moment ago and I am not sure why I get myself in to this situation, but you should be able to fix this in a matter of 1/2 hr or less.

Fix or Workaround

I was able to get around this issue by simply re-generating the root certificate and then generating a client certificate. Then exporting the full public and private key pair files to Azure portal for your private network.

After you do so you can have the portal re-gen the VPN client software, then you can download and install.

You can follow the Self Signed Certificate Steps on the Azure web site to generate the Root and also Client certificates.

Some Point to Note: You will have to deal with two and half certificates:

1. The Root certificate.
1.5 The public part of the root certificate, which you will upload to Azure. Actually you can paste the hex number part of the cert directly in to the Azure console.
2. The Client certificate that you derive from the root certificate. This does not get uploaded to Azure but this has to be given to each user, if needed generate one per user if you are sensitive to revoking people individually (i.e., off-boarding an employee).

Do Not Go Down These Paths

  • There is no need to discard the original certificate pair you have uploaded. You can simply upload your new certificate. This may break other VPN users who are relying on current certificates. Both certificates are good.
  • More importantly, there is no need to re-do the private network.
  • You can use both Classic and Resource Manager model, so use the model that you are familiar with. It is all about uploading the proper certificates.
  • Do not do "extract the cert using RAR" stuff. The self-signed root certificates are just not right for your situation so extracting and manually installing them won't do a jack.

Saturday, October 01, 2016

XCODE-8 Missing Push Notification Entitlement Issue


You had a perfectly working iOS App build on XCODE 7. Now you have upgraded to XCODE 8, and when you push the build to the iTunes Connect, you get the following message back.

Dear developer,
We have discovered one or more issues with your recent delivery for "BodyMapSnap". Your delivery was successful, but you may wish to correct the following issues in your next delivery:
Missing Push Notification Entitlement - Your app includes an API for Apple's Push Notification service, but the aps-environment entitlement is missing from the app's signature. To resolve this, make sure your App ID is enabled for push notification in the Provisioning Portal. Then, sign your app with a distribution provisioning profile that includes the aps-environment entitlement. This will create the correct signature, and you can resubmit your app. See "Provisioning and Development" in the Local and Push Notification Programming Guide for more information. If your app does not use the Apple Push Notification service, no action is required. You may remove the API from future submissions to stop this warning. If you use a third-party framework, you may need to contact the developer for information on removing the API.
After you’ve corrected the issues, you can use Xcode or Application Loader to upload a new binary to iTunes Connect.
The App Store team

You checked many times that you had the correct provisioning profile and such.

Root Cause

If you had a good build before then XCODE has likely broken your build.

The Fix

Try these fixes first even before you go down the other line. Do not muck with your provisioning profile stuff either locally or on the developer provisioning portal or let alone generating a new set of key as they won't do anything without this fixed.

In your XCODE project find the Capabilities Tab then scroll down a bit to where it says Push notifications. It is very likely this is now in red and allows you to fix. Basically pressing the "Fix Issues" button will fix this, and that's all.

If Have Fiddled With It Too Much and You Do Not see the Fix Issue Button

We were down so many wrong routes, that we did quite a number of bad things to the project files.
I will new provide some recovery information to get the Fix button back.

Check to make sure that .entitlements file is not present in your project root directory. For us it is BodyMapSnap.entitlements, and lack of this file is the root cause of this. You should delete that file.

Next check in .xcodeproj/project.pbxproj  in our case this was BodyMapSnap.xcodeproj/project.pbxproj

Using the editing feature of XCODE locate CODE_SIGN_ENTITLEMENTS in above file which should point to the .entitlements file. If you delete the whole line, you can get back the "Fix Issue" button under the Capabilities tab. Press that fix button again then you can Archive then Push to the iTunes connect.

The following Source Tree GIT Diffs shows you the types of files and file modifications XCODE makes after you press the Fix Issues button.

Saturday, August 13, 2016

Microsoft MVC6 New JSON Based Configuration Tips

I have been away from the MVC world for 2 years, and just started a brand new project with it today. Things have changed quite a bit from MVC4 days. Now there is no Web.config in the base project template for Visual Studio.

After starting to learn about this change, which should be positive and there are good reasons for this change, I have found out, as usual, all the examples out there are outdated from RC times or not complete.

Here are some things I ran into that you would also run into.

You Will Need to Install Microsoft.Extensions.Options and also Microsoft.Extensions.Options.ConfigurationExtensions

If you do not do this, you will see

'Microsoft.Extensions.Configuration.IConfigurationRoot' to 'System.Action<CustomSettings>'  error.

They are available via NuGet, Just look for Microsoft.Extensions.Options and both should come up.

Where to Put My Option Plain C# Object (POCO)?

I would put that under your Models folder (create one under the root if needed), but it can be anywhere, perhaps Confgs subfolder, if you make one would just be OK too.

You Should Be Using PowerShell, Here are the Bare Minimums

I see most people avoiding PowerShell. I say if you just learn a few essential usage, it is a much easier environment to use, especially switching between MacOS and Windows.


Go to the start menu and type in powershell. If you frequent your Windows environment, I would "pin" this to Start or the Taskbar, and also start avoiding Cmd.

Some Basic Coolness

If you are going back and forth between IOS and Windows, it would be a bit more comfortable to use the PowerShell as it comes "out of the box" without the need for installing the "bash" shell and many of the Unix like commands are supported as "alias".

  • Like on the Unix shell you no longer have to type in /Users/myname/<wheatever> instead you'd be like in the familiar Unix environment like..
  • .
    • cd ~  works auend gret ysou tyoo /ura/<ccount>
    • cd ~/Downloads works!
    • cd~/Desktop works
    • ls works (this is an alias so cannot go too fancy like ls -lR)
    • From there if you do "open ." then you can open the Explorer at that directory.
  • You can now Ctrl-C and Ctrl-V if you just enable them. Right click the title bar of the PowerShell window for the Properties. Then open the Options menu and look for "Enable Ctrl key shortcuts." This was added in Windows 8

Some Peculiar Stuff

  • If you want to see environment variables, use "printenv"
  • One issue with environment variable. For example, let's say you want to use $JAVA_HOME as in MacOS, then you need to do $env:JAVA_HOME   I don't really like this, but so there

The Basic Idea

Like most anything, understanding the architecture and the basic philosophy of the design is the key to understanding whatever you are running into.

In terms of PowerShell, they tried to standardize basically on the REST type API Call style. So this is why they have commands like Get-This or Set-That.  So if you master those, then you can chain them together like you do with Unix pipes with a much more consistent "schema" they set up. 

The "help" is quite extensive and comprehensive as a result, so if you type in just about any phrase you think about, as "help something", it is a good way to move forward with more stuff.

Windows Git/GitHub Results in "Error Repository Not Found" or Denied Public Key Solution

I spent a good chunk of a day to resolve issues related to "Error Repository Not Found" or even got Permission denied (publickey) type error messages.

This issue happened suddenly on my Git environment integrated with IntelliJ Ultimate. While investigating this, I made things even worse and Git was totally denied including using SSH.

Along the way, I also tried Two Factor authentication on GitHub, and eventually got that to work both in IntelliJ and also with SourceTree.

The following sequence of events finally have fixed the issue.

If You've Tried These Already, then You Have the Same Problem as I Had.

  • Instead of trying you tried Note that this would not work if your Windows Credentials already has cached your user name and password.
  • You tried to change to the SSH URL
  • You've even tried to generate a new SSH key
  • You've even loaded the SSH key via pagent.exe
    • Note that SSH issue is a separate issue, so in this article I will stick with getting you back up and going with https (including using the Two-Factor authentication.)

1. Check the Windows Credentials to Remove Any Git Related

  • Open the Start menu and type in "Credential Manager"  This will open the Windows Credential Manager. This is basically the same thing as "Mac OS Keychain" in fact, if you are on the Mac, you would want to check there. Check and remove all Git related credentials, this is the most likely cause if you see https:// Repository not Found issue. 
  • Now try your Git access and see this will issue a new username and password prompt.

2. Last Resort: Completely Remove Your Git and Re-Install it Directly

  • Be sure you have done Step 1.
  • For this does not use chocolaty. If you did already, first try the uninstall via "choco uninstall git".
  • Go to the Program and Features and remove any installations of Git
  • Go to C:\Program Files\Git or likewise and manually delete all remnants of Git
  • Download and install from the Git Web Site. 
  • Check your~/.gitconfig file to make sure nothing strange is there. Also, I would check in your local Git repos./.git/config file for URLs pointing to the repo.  (Note, you can type in cd ~ if you are using PowerShell, if anything else, that's one big attraction of using PowerShell to be able to cd to ~/Downloads and ~/Desktop)  give it a shot I will post an article about PowerShell Essential Survival Guide next.
If You Have Activated Two-Factor Authentication...

The password field you provide should not be your interactive login password, but you should generate a Personal Access Token on your GitHub account  Note that you only see the token once after you generate it, so have a Notepad ready to temporarily copy it.

Next launch your Git UI app like SourceTree and do some operation like Fetch, this should prompt you again for the password. Use the token you have just copied in the password field and let the credential to save. This will wind up in the Windows Credentials Manager so next time you change this, you would want to do Step 1 as above.

Tuesday, July 19, 2016

Fix: IntelliJ Ultimate 2016.2 Play Framework Views.html Resolution Issue (Again!)


You've just upgraded to IntelliJ 2016.2 and your existing Play Framework no longer resolves your Views.html.* references.

Note that this is different from the Route issue which requires you to add the Source dependency from target/scala-2.11/routes/main (which refers to the set of auto-generated Java sources).

Solution for Resolving Views:

I have solved this issue by going to File => Project Structure and then specifying the folder dependency to the target/scala-2.11/classes/views

Be sure that you pick "JARs or directories..." when you click the + sign on the right.

Saturday, July 09, 2016

TypeScript: Avoid Using Lambda in CallBack, "this" is not Captured


You have created a TypeScript class, and assigned a callback to an object implemented in Lambda expression (or have been suggested by Reshaper or IntelliJ to convert it to a lambda expression).

See the example below and what the problem is about to become much more clear.

The Issue

The issue is that the Lambda captures "this" in a different way than the anonymous function (). This is actually clearly documented under the Arrow Functions section in the Mozilla MDN page.

But if you are like me it is much easier to understand by actually coding the situation.

The Explanation of The Example:

I have created a simple Main class in which a callback "whatIsThis()" can be externally installed after the class has been instantiated. Then by calling whatReallyIsThis(), it will in turn calls the installed whatIsThis(). This is a fairly typical scenario, I would say.

If you are not aware of all of the implications of this, you would (and I have) thought that the class member property "s" should be accessible from within the callback in all of the scenarios.

The ones that works are;

  • If the callback function is is a function() and not an arrow function like =>(). This will not work.
  • Also, you can try this yourself, any attempt to pass "this" as main like Apply, Call or Bind to the lambda function will have no effect. 
Lessons Learned

You should treat lambda as a whole new beast of function. It appears that they tried to fix the variable notion of "this" in lambda and it only captures "this" in the line of code where it was created. What throws you off is that you've learned about "this" with anonymous functions, and assumed it works the same. Be aware of this major difference!

class Main {
    constructor(public s: string) {}
    whatIsThis:  () => void;
    whatReallyIsThis() {

let main = new Main("works!");

console.log("Anonymouns func - this points to Main instance!");

main.whatIsThis = function() { 
    console.log("This " + this.s);

main.whatReallyIsThis(); // This works.

console.log("Using the Labmda - this does not work!");

main.whatIsThis = () => {
    console.log("This s is " + this.s);

main.whatReallyIsThis(); // This s is undefined

console.log("Finally, what is this is all about");
let that = main;
exports.s = "in Global scope"; // Yup, it's in the Global!
main.whatIsThis = =&gt;()  {
    console.log"Thi(s s is " + this.s); 
    console.log("That.s " + that.s); 
main.whatReallyIsThis(); // This s is in Global scope, That.s works.