Saturday, September 19, 2015

External Javascript Resources in Ionic Applications

Fun Fact: If you're using an externally referenced Javascript file in your Ionic browser, it will 404 out due to the default content policy on Android phones. This happened to me recently while I was working on an app that uses the Google Maps API to geocode locations.

Running the app in your browser via `ionic serve` does not reflect the issue - it appears only on actual devices. When I built the app and installed it on my phone, it showed me a very helpful blank screen.

I connected the Chrome debugger to the Ionic webview on my phone, and pretty soon tracked the problem down to the Google Maps API js file erroring out. A quick Google search revealed that the best way to get around this issue is to run `cordova plugin add cordova-plugin-whitelist`. The Whitelist plugin allows you to load third party Javascript files as part of your Ionic app. I'm surprised this isn't officially documented anywhere in the Ionic documentation - it seems like a pretty crucial issue to me!

Monday, August 3, 2015

Error opening file '{{path}}/difftar.gpg': Input/output error


While using Ubuntu's built-in backup tool, which uses Duplicity, I recently got the following error:

Backup failed
Error opening file '/media/yoshee/FreeAgent Drive/Backup/duplicity-full.20140514T064948Z.vol2132.difftar.gpg': Input/output error


After some research, I discovered that the best way to fix this on an NTFS drive is to boot into Windows - using either a Windows Live DVD or an actual machine you have with Windows installed - and run the following command in the command prompt:

chkdsk D: /R

Where D is the letter of the drive you want to check. /R asks check disk to fix and resolve any issues it finds.

Make sure you are running Command Prompt as an administrator. 

The process took six hours for me on my external hard drive, but once it had run through, I was able to complete my backup from within Ubuntu with no issues.

Wednesday, January 21, 2015

ASP.NET UserControl.Visible = true failing

Today I came across a situation where I was trying to set an ASP.NET UserControl to be Control.Visible = true, and try as I might, the call was failing. Here's what I did in the immediate window in Visual Studio.

MyControl.Visible = true;
MyControl.Visible; // output: false;


I almost bashed my head against my keyboard. It turns out that 'Visible' behaves like a property, not a field. You can set it to true, but it only returns true if the control is actually visible on the page. In my case, the control was not visible because I had set

ParentControl.Visible = false;

on Page_Load. I was trying to set MyControl.Visible to true on postback, but since ParentControl had not been explicitly set to true, MyControl.Visible was still returning false. I set

ParentControl.Visible = true;

et voila! MyControl.Visible immediately returned true.


Lesson: if you're trying to set your control's Visible property to true, and it's still returning false, check the parent controls and see whether those might not have their visibility set to false.