Fix for Chromium Network Location Provider Returning Error Code 403

I had been using Chromium and wondered why it kept returning error code 403 and the message that’s in the title of this post when using the html5 geolocation features. It turns out that Chromium does not ship with Google’s API credentials as the normal build of Google Chrome does so those services are unavailable (Chrome/Chromium does not use the operating system’s built in location services and instead relies on Google’s API). After reviewing the Chromium documentation here, I’ve come up with the following steps to properly enable Chromium’s google services. It’s a lot of work, but I hope this is useful for the many people using Google’s open source Chromium on Linux, OS X, or Windows.

  1. Join the chromium dev group here by subscribing. You don’t have to receive email updates, you just have to be a member of the group in order for the right APIs to show up in the developer console.
  2. Visit the Google API Console and create a new project.
  3. Visit your project’s page in the console, click the APIs link in the left menu, and begin subscribing to developer APIs of your choice. In order to resolve network location provider issues when using Chromium, you’ll need the “Google Maps Geolocation API”. The Chromium documentation notes the following as useful APIs for Chromium:
    • Chrome Remote Desktop API
    • Chrome Spelling API
    • Chrome Suggest API
    • Chrome Sync API
    • Chrome Translate Element
    • Google Maps Geolocation API – (requires enabling billing but is free to use; you can skip this one, in which case geolocation features of Chrome will not work)
    • Safe Browsing API
    • Speech API
    • Time Zone API
    • Google Cloud Messaging for Chrome
    • Drive API (Optional, enable this for Files.app on Chrome OS and SyncFileSystem API)
    • Google Now For Chrome API (Optional, enabled to show Google Now cards)
  4. Click the settings gear after enabling the APIs of your choice and choose “Project Billing Settings”.
  5. Click “Enable Billing”, choose a personal billing account, and enter your billing information. Yes, in order for Google Maps Geolocation API calls to work, you have to have a payment method on your account. Having a payment method tied to your account won’t affect the fact that the quota for API calls to the Geolocation API is 100 calls per day and 100 calls are billed at $0.0 for personal accounts. If you’re still worried, check out Google’s documentation on Geolocation pricing here.
  6. Click the “Credentials” link in the left menu under “APIs & auth” on the Google API Console.
  7. Click “create new key”, then click “server key”, then click “create”. This is your “GOOGLE_API_KEY” which you’ll need later.
  8. Under “OAuth”, click “Create new Client ID”, choose “Installed application” and click “Configure consent screen”. Fill in the required information in the form and click “save”.
  9. Choose “Installed application” again, and click “Create ClientID”. Now you have your “GOOGLE_DEFAULT_CLIENT_ID” and “GOOGLE_DEFAULT_CLIENT_SECRET” which you’ll need later.
  10. Now you’ll need to setup some environment variables for Chromium to pick up when it’s launched, the following instructions are for OS X using launchd:
    1. Create a new script in your home directory, mine is named ‘.setGoogleEnvVars.sh’
    2. Add the following to the script, replacing the XXXs with appropriate values from your Google API developer console:
      launchctl setenv GOOGLE_API_KEY XXX
      launchctl setenv GOOGLE_DEFAULT_CLIENT_ID XXX
      launchctl setenv GOOGLE_DEFAULT_CLIENT_SECRET XXX
      
    3. Create a new launchd service in your home’s LaunchAgents directory, ~/Library/LaunchAgents/, mine is called ‘local.setGoogleEnvVars.plist’ with the following contents, replacing the label and program argument of “~/.setGoogleEnvVars.sh” if necessary:
      <?xml version="1.0" encoding="UTF-8"?>                                                                                  
      <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
      <plist version="1.0">
      <dict>
        <key>Label</key>
        <string>local.setGoogleEnvVars</string>
        <key>ProgramArguments</key>
        <array>
          <string>sh</string>
          <string>-c</string>
          <string>~/.setGoogleEnvVars.sh</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
      </dict>
      </plist>
      
    4. Make sure your startup script is executable by using the terminal and chmod +x to set the executable bit like this, replacing the script name if necessary:
      chmod +x ~/.setGoogleEnvVars.sh
    5. At this point, you can either restart your computer or load the service with launchctl load ~/Library/LaunchAgents/local.setGoogleEnvVars.plist, replacing the plist name if necessary.

That’s it! It’s a lot of work, but you’ve now enabled any of your selected Google APIs in Chromium, and you should no longer receive error messages like network location provider at 'https://www.googleapis.com/' : returned error code 403. code 2 if you’ve chosen to enable the Geolocation API and billing.

ExpressJS, AngularJS, and pretty URLs

We added a new web interface to a set of internal developer APIs so our developers would no longer have to manage unruly postman collections and I kept running into problems where the catch-all express route was catching too much or other routes were no longer behaving correctly.
If you’re having problems with

$locationprovider.html5mode(true)

Here are all the steps I took to resolve our issues:

  1. Add a base tag of <base href=”/”> to your angular index file.
  2. Make sure all of your static routes are defined first in your express app.
  3. After all of your app’s routes, make sure your catch all route is absolutely last
    app.all('/*', function(req, res, next) {
      res.sendfile('index.html', { root: 'myWebRoot' });
    });
  4. That’s it.

I kept running into so many issues and they all boiled down to the static routes not being defined absolutely first. Hopefully with this post you don’t have to make the same mistake.

Possible Fix for Hosted Git (Github.com) Timeout Issues

When installing packages using your language or framework of choice, you’re often required to have git installed when the packages are hosted remotely and versioning is done using git tags or branches. This is great usually, but occasionally you’ll come across a dreaded timeout error like this:

ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/angular/bower-angular.git", exit code of #128




Additional error details:

fatal: unable to connect to github.com:

github.com[0: 192.30.252.129]: errno=Operation timed out

When this occurs, often it’s just an issue with Github handling git commands. To bypass git using git:// addresses, force them to use https:

git config --global url."https://".insteadOf git://

This isn’t a solution for everyone, especially if you have locally hosted git repositories that are only accessible via git:// , but it might resolve your Github or Bitbucket issues temporarily. To revert this change, simply run the following:

git config --global --unset url."https://".insteadOf

Windows 10 Technical Preview – Finally, virtual desktops.

I made a quick video highlighting my experience with Microsoft’s Virtual Desktop solution inside the new Windows 10 Technical Preview. So far, I’m extremely thrilled that Microsoft added virtual desktops, as it was something sorely lacking in Windows and yet was available on most other popular operating systems. Also included is a remapping of the old Windows Aero Flip 3d (Windows Key + Tab) to the new Windows 10 Task View – which is basically OS X’s Mission Control – a method for managing, switching to, and viewing virtual desktops. Here are some other useful shortcuts that are new or changed from previous versions of Windows (from here on out I’ll refer to Windows Key as WinKey):

Alt + Tab is basically unchanged and properly switches to the correct desktop when an app is selected that isn’t on the current desktop.

WinKey + Ctrl + D is the shortcut to create a new virtual desktop.

WinKey + Ctrl + F4 is the shortcut to close a virtual desktop. Closing a virtual desktop will move all open applications and windows on that desktop to the next available desktop – so don’t fret about losing all of your work by closing a desktop.

WinKey + Ctrl + Left (or Right) Arrow switches you to the left or right virtual desktop you have open. If you’re currently switched to a virtual desktop on one of the ends, it does not loop you back around if you try to continue in that direction.

The only downside to the new virtual desktop setup in Windows 10 is that you currently cannot move applications or windows from one virtual desktop to the next while in Task View. This is a major selling point of Mission Control for me, as it allows me to easily manage all of my open applications and regroup them under current or new virtual desktops as necessary to fit my current task. Other than my hopes that Microsoft implements better application and virtual desktop management into Task View before launch, I’m excited to upgrade all of my Windows 8.1 desktops and virtual machines to Windows 10 when it’s launched. The new Start menu (with integrated Start Screen) is really what Windows 8 should have shipped with; Microsoft’s new Windows 10 operating system is finally aware of its place when installed on a computer with a mouse.

Jet – A Costco for the Web

Jet is launching in the next month or so and it’s going to be something I’ll keep an eye on. The founder, Marc Lore, announced on his blog that they’ve closed a round of Series A funding so it’ll be interesting to see if they make it to IPO. Jet, founded by the same guy who started diapers.com and soap.com, is setting out to take the proven idea of a “members only” warehouse club in a more modern and tech savvy direction.

Costco, as a concept, has worked very well but their website and online inventory system are lacking. Amazon’s website and logistics are great, but their Prime membership is pricy and is far more than the cheap membership for fast, free shipping that it started as. Now that Prime is roughly $80 and includes streaming video (which most already have netflix for) and streaming music (with a pretty abysmal selection compared to any other paid streaming service), I feel like it’s approaching a “jack of all, master of none” situation. $80 for discounted shipping and two streaming services (one very mediocre, the other largely duplicated by Netflix) is likely pricing itself out of the normal $50 per year membership price most consumers have in their minds already thanks to Sam’s club and Costco. While most of my peers have Amazon Prime, my parents have Netflix and Costco memberships and I don’t think it’d be easy to convince them to get an $80 Prime membership as long as they hold on to the others. Even then, with a shiny new Prime membership, prices are almost always better at Costco for items carried by both Amazon and Costco.

Jet will likely be looking for the Costco/Sam’s member as well as bargain hunters who crawl through Slickdeals, Fatwallet, and Saviry as their potential customer base. If Jet comes out of the gate with a $50 or lower membership price, free “standard” shipping, and prices akin to most members-only clubs my parents would surely buy in to that, and so would I. It’s much easier to swallow a membership price if you can easily see the value. Costco’s value is the physical store itself whether it be for buying tires or trips to the brick and mortar store on a Saturday. Jet could easily put itself in a position to be an online Costco for the weekdays or nights when going to Costco is out of the question.

Connecting to an Azure SQL Database with FreeTDS (on a Mac even)

Connecting to an Azure database on your Mac can be more convenient than opening a virtual machine at times, especially when you’re working with a 128gb SSD and your Windows VM isn’t on said SSD. FreeTDS to the rescue!

While it would be nice if Microsoft would opensource the Microsoft SQL Server driver for Linux, FreeTDS seems to work for my situations just fine. In order to get FreeTDS installed and connecting to Azure, you’ll need Homebrew. After you get that sorted out, open up your favorite terminal emulator and run the following:

brew install --enable-msdblib --with-unixodbc freetds

Once this is completed and freetds is compiled, you’ll want to make some changes to your odbcinst.ini file possibly located at /usr/local/Cellar/unixodbc/2.3.2/etc/, but the best way to be certain about where your unixodbc installation assumes its files are is to run odbcinst -j from the terminal to check.

Once you have your odbcinst.ini opened in your favorite text editor, add the following:

[ODBC]
Trace = No
TraceFile = /tmp/odbc.log


[FreeTDS]
Driver = /usr/local/lib/libtdsodbc.so
UsageCount = 1

If something goes awry, you can try debugging the situation with Trace = Yes later.

At this point, you have a driver installed named FreeTDS but no data sources configured. Go back to your text editor and open up the file ~/.odbc.ini or use the SYSTEM DATA SOURCES file that was given when you ran odbcinst -j. Add the following to the file you just opened:

[AZURE]
Description = My MS SQL server on Azure
Driver = FreeTDS
Server = XXXXXXXXX.database.windows.net
Database = XXXXXXX
Port = 1433
TDS_Version = 7.2

Change the Server and Database options to match your own. Notice the TDS_VERSION, this option is key to connecting to Azure SQL Server instances since Azure doesn’t seem to accept connections for any protocol versions 7.0 or less.

At this point, you should be able to connect to your database via the isql tool:

isql -v AZURE MYUSERNAME MYPASSWORD

If something isn’t working, make sure to enable the ODBC Tracing and check that log. Also, verify you’ve added your ip to the Allowed IP Addresses section under the Configure tab once you’ve selected your SQL Database Server in the Azure management portal.

PHP 5.6 x86 (nts) Windows SQLSRV and PDO_SQLSRV Extensions

UPDATE: check out Rob’s additions and compiled extensions here. They have added patches and he’s done an excellent job keeping up to date with them. I initially compiled because there weren’t any sqlsrv extensions compiled for PHP 5.6

I compiled some pdo_sqlsrv and sqlsrv extensions for php 5.6 because who the heck knows when Microsoft will do another official release.
The sqlsrv source code does need a small patch to successfully compile which usually puts a lot of people off when compiling things on their own so I figured I should make them available to the public.

Here’s sqlsrv.dll and pdo_sqlsrv.dll for Windows PHP 5.6 x86 NTS: sqlsrv_pdo_sqlsrv_dll-php5.6_nts.zip.

Enjoy!

SQL Management Studio Jr.

It’s almost inarguable that Microsoft’s IntelliSense is either the top dog, or in the top three at syntax suggestion/completion. What bothers me is that with standard Visual Studio installs (as recent as VS 2013), you don’t get the full SQL Management Studio package. Instead you have to go download SQL Management Studio Jr., with a severely reduced feature set, from Microsoft. Why should you care?

How many developers of relational database-backed applications are there in 2014 that don’t have to think about database performance or troubleshooting ever?
I hope that answer is close to zero.
Even if you’re fortunate enough to have an experienced database administrator, as a developer it would be in everyone’s best interest if you tried to make their job easier and not harder.

As a developer that’s using Microsoft’s database platform, even if you’re not necessarily using Microsoft’s languages (Python, PHP, Ruby, and Node are all supported on Windows Servers), you should be able to do some simple query plan analysis, reporting, and troubleshooting. Yet, the tools required to do these simple tasks are mysteriously left out of the “free” version of Management Studio.

Have a query that’s running long for no apparent reason? Have fun; you’re on your own – unless of course you have access to a Microsoft SQL Server license key and supporting disk image.
In order to have access to the latest SQL Server Profiler, Integration Tools, and Database Engine Tuning Advisor, you’ll either need a better MSDN account (the MSDN account included with Visual Studio didn’t include SQL Server for me) or a full-on SQL Server license.

Hell.

Luckily, my workplace has an MSDN account for us and I was able to use that. Had I been on my own, I would’ve been shelling out some serious dollars (SQL Server licensing is hilariously expensive) to have very basic tools that should be bundled with Visual Studio by default.

While some might view Visual Studio as the best IDE currently available, I still believe it has a ways to go in terms of developer friendly enhancements and decoupling from Microsoft as an avenue for revenue and instead using it as an incentive (reduced cost, free, etc.) to bring more developers to their platform. The full version of SQL Server Management Studio is a developer tool and should be included with every Visual Studio install.

Best new iOS game – Monument Valley

I normally don’t link to apps and games unless they’re relevant to an article, but Monument Valley is truly quite great and deserves it.

Monument Valley really is the perfect mobile game for me. I cannot recommend it highly enough for those that like fun puzzle games that are perfectly designed and suited for the mobile platform. It’s simple enough to play through a level or two in the time I have available, yet that sense of adventure is there so I never quite get bored and end up wishing I had more time to spend with it by the time I have to put my phone down.

To elaborate on “perfect mobile game,” I’m simply stating that many games are not designed to be played in short bursts of available free time that one might have while waiting for a cashier in the grocery store or for someone to arrive at a restaurant. Monument Valley is my new favorite game to fill these small voids in my life, so twitter will have to take the back seat once more.