Karl's Code

and other code related stuff

Using JavaScript in Octopress

I intend to write a series of blogs on JavaScript. It occurred to me that the blog should be able to demonstrate the JS code to make it more accessible. OK So, first things first, I need to get Octopress (my blogging framework) to use my JavaScript.

This blog intends to catalogue how I got my JS examples into the blog.

Testing angular.js at the Console

You’ve deployed your angular app

and now you want to test a Service or Controller quickly.

sure you can (and should) write a unit test but you just need to sanity check the service is doing the right thing.

Well the browser has a javascript console (f12) which has all your code loaded in it, so we should be able just run the service.

Batch Size for Software

We software developers all want to be efficient. There is a sweet self applied kudos from knowing that your code takes less CPU and runs faster than someone else’s, or quickly knocking up a feature because you spent time extracting a library that made it a breeze. But what about in our processes?

As usual, I was thinking about algorithms

Scala Implicit Class Pimp Gotcha

Since Scala 2.10 we’ve had the convenience to “Pimp” a library using implicit classes. For the details see Implicit Classes

This makes it trivial to add methods to previously closed classes. However there are some gotcha’s to beware of. In particular make sure you read the rules

The reason I’m writing this blog is that I fell foul of restriction 3. It took me ages to work it out.

Google Contacts - Installed App Workflow HOWTO

Installed apps typically mean apps that are not web apps. Using the installed app authentication flow is sometimes better than using a Service Account.

Pro

  • don’t need your admin to assign special “impersonate” permissions to the service account (once assigned it can impersonate anyone in the domain)
  • don’t need a Google Domain (see link ???)
  • app can use the refresh token to continue to fetch from Google API’s until the user is revoked.

Con

  • A user needs to accept the Scope of the app, not too bad as once accepted it can continue to use the refresh token to keep accessing the API
  • con you can’t choose the OAuth2 redurect_URI just get magig top of page or http://localhost (any port you want) so no good for webapps… but then they have a Web-AppClient if you want that.

Google Contacts API - Service Account Howto

Overview

I want to set up a server side App that can read list and filter the Google contacts in our company domain “mycompany.com”. This server side app can then be queried by some of our internal webapps to display helpful info.