Stuart Breckenridge

Facebook Records Over 1Bn Users In A Day

“Here’s a crazy statistic for you: For the first time in history, one billion people used Facebook in a single day this past Monday. That means one out of every seven people on the planet was logged into the network at some point during that day.”

Napier Lopez

Mind boggling. Remember when Friends Reunited was all the rage?

Windows 10 Adoption

“14 million machines had been upgraded to Windows 10 within 24 hours of the operating system release last month, and that figure has now risen to more than 75 million in just four weeks. Microsoft has been rolling out Windows 10 in waves, as a free upgrade for Windows 8 and Windows 7 users. While it’s difficult to compare exact figures between Windows 10 and Windows 8, Microsoft “sold” 40 million licenses of Windows 8 a month after its debut. It took Microsoft six months to get to 100 million licenses of Windows 8, and it’s clear the free aspect of Windows 10 is obviously driving higher adoption rates.”

Tom Warren

The free upgrade element of Windows 10 upgrade is almost certainly the main driver in the increased adoption rates as compared to Windows 8. It also helps that Windows 10 is receiving generally favourable reviews.

Swift 2 Adds Another Try Keyword

In Xcode 7 beta 6, Apple has introduced a new try? keyword to the Swift language. try? will attempt to perform an operation and if it succeeds the result is wrapped in an optional, otherwise the result is nil. One of the critical differences—and which I consider to be a downside—is that errors are no longer surfaced. In practice, try? looks something like this:

enum DayError: ErrorType, CustomStringConvertible
    case NeedADateError
    var description: String {
        switch self {
        case .NeedADateError:
            return "Error: A date must be provided."

func isItTuesday(date:NSDate?) throws -> String
    if date != nil
        let dateFormatter = NSDateFormatter()
        dateFormatter.dateFormat = "EEEE"
        let day = dateFormatter.stringFromDate(date!)
        if day == "Tuesday"
            return "It is."
        } else
            return "It isn't."
    } else
        throw DayError.NeedADateError

Pretty simple: a function which throws an error if a parameter isn’t provided.1

The new try?:

// Example 1: result is nil with no error surfaced.
if let today = try? isItTuesday(nil)
    print("Date has been set.") // Never called.
} else
    print("Uh oh. No error handling. Result is nil.")
// Example 2: result is an optional. 
if let actual = try? isItTuesday(NSDate())
    print(actual) // Returns "It is." (Optional)
// Example 3: do-try-catch with error handling. 
do {
    let x = try isItTuesday(nil)
} catch
    print(error) // Error: A date must be provided.

I don’t think I’ll use try? all that often. I like to know why something failed and deal with it correctly.

  1. Obviously you can work around this scenario by using a non-optional parameter. ↩︎

Signing Emails with Outlook 2013 on Windows 10

For outgoing email I always sign with a digital signature. After installing Windows 10 and Office 2013 I added my certificate, but every time I attempted to send an email I got an error which stated:

“A required action was not successful because of an unspecified error.”

The Windows Error Department

Not even slightly helpful. I tried everything: from running as administrator to installing Outlook 2015 on the Mac and testing the certificate there. It was only an issue with Outlook 2013 on Windows 10.

It turns out the fix is pretty strange:

  1. With Outlook not running, fire up Command Prompt as an administrator.
  2. Type sfc /scannow1, and hit Enter.
  3. Wait till this completes…
  4. Open Outlook and send signed emails.
  1. System File Checker is a utility in Windows that allows users to scan for corruptions in Windows system files and restore corrupted files. ↩︎

FATCA Metadata for Windows

Metadata Screenshot

I’ve been playing around with C# and Visual Studio recently and my test project was to build an app—in this case a Windows form—that took user data, validated it, and then created a correctly formatted XML file that could be used as part of annual FATCA submissions. As part of this learning process two technologies stood out as really impressive: XDocument and ClickOnce Deployment.

The XML file I wanted to create was pretty simple:

<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2014 rel. 2 (>
<FATCAIDESSenderFileMetadata xmlns="urn:fatca:idessenderfilemetadata" xmlns:xsi="">

Creating this on a Mac using a technology I’m familiar with—NSXMLDocument—is simple, if overly verbose:

func generateXMLFile() -> NSXMLDocument
    // Header
    let xmlFile = NSXMLDocument()
    xmlFile.version = "1.0"
    xmlFile.characterEncoding = "UTF-8"
    xmlFile.standalone = true
    xmlFile.addChild(NSXMLNode.commentWithStringValue("FATCA Report") as! NSXMLNode)
    // Root Element
    xmlFile.setRootElement(NSXMLElement(name: "FATCAIDESSenderFileMetadata"))
    xmlFile.rootElement()?.addNamespace(NSXMLNode.namespaceWithName("", stringValue: "urn:fatca:idessenderfilemetadata") as! NSXMLNode)
    xmlFile.rootElement()?.addNamespace(NSXMLNode.namespaceWithName("xsi", stringValue: "") as! NSXMLNode)
    // Child Elements
    xmlFile.rootElement()?.addChild(NSXMLElement.elementWithName("FATCAEntitySenderId", stringValue: "000000.00000.TA.840") as! NSXMLNode)
    xmlFile.rootElement()?.addChild(NSXMLElement.elementWithName("FATCAEntityReceiverId", stringValue: "000000.00000.TA.124") as! NSXMLNode)
    xmlFile.rootElement()?.addChild(NSXMLElement.elementWithName("FATCAEntCommunicationTypeCd", stringValue: "NTF") as! NSXMLNode)
    xmlFile.rootElement()?.addChild(NSXMLElement.elementWithName("SenderFileId", stringValue: "000000.00000.TA.840_Payload.xml") as! NSXMLNode)
    xmlFile.rootElement()?.addChild(NSXMLElement.elementWithName("FileFormatCd", stringValue: "XML") as! NSXMLNode)
    xmlFile.rootElement()?.addChild(NSXMLElement.elementWithName("BinaryEncodingSchemeCd", stringValue: "NONE") as! NSXMLNode)
    xmlFile.rootElement()?.addChild(NSXMLElement.elementWithName("FileCreateTs", stringValue: "2015-06-30T00:00:00Z") as! NSXMLNode)
    xmlFile.rootElement()?.addChild(NSXMLElement.elementWithName("TaxYear", stringValue: "2014") as! NSXMLNode)
    xmlFile.rootElement()?.addChild(NSXMLElement.elementWithName("FileRevisionInd", stringValue: "false") as! NSXMLNode)
    return xmlFile

Now, compare that to XDocument:

XDocument generateXMLFile()
			XNamespace metaNS = "uri:fatca:idessenderfilemetadata"
            XDocument xmlFile = new XDocument(
                new XComment("FATCA Report"),
            new XElement(metaNS + "FATCAIDESSenderFileMetadata",
				new XAttribute(XNamespace.Xmlns + "xsi", ""),
                new XElement(metaNS + "FATCAEntitySenderId", "000000.00000.TA.840"),
                new XElement(metaNS + "FATCAEntityReceiverId", "000000.00000.TA.124"),
                new XElement(metaNS + "FATCAEntCommunicationTypeCd", "NTF"),
                new XElement(metaNS + "SenderFileId", "000000.00000.TA.840_Payload.xml"),
                new XElement(metaNS + "FileFormatCd","XML"),
                new XElement(metaNS + "BinaryEncodingSchemeCd","NONE"),
                new XElement(metaNS + "FileCreateTs", "2015-06-30T00:00:00Z"),
                new XElement(metaNS + "TaxYear", "2014"),
                new XElement(metaNS + "FileRevisionInd", "false"),
            xmlFile.Declaration =  new XDeclaration("1.0", "utf-8", "true");
			return xmlFile;

XDocument, in comparison to NSXMLDocument, is both simpler and more concise. However, I think Swift itself also contributes to the complexity with constant forced as! conversions for each element. It’s generally very untidy.

With the app built, I started looking at how it could be deployed and immediately came across ClickOnce. ClickOnce is an easy to use deployment technology that lets you publish self-updating applications. For this app, I’ve chosen to deploy via my website. It can be installed via the link at the end of this article. Despite ClickOnce ease of use, the issue I’ve found is with Windows SmartScreen which prevents the app being installed until it’s built up enough reputation. This is somewhat annoying considering the app is code signed (see the note at the end of this post).

The app is open source and available on GitHub. Or you can simply install it by clicking the button below.

Install Now User Guide

Code Signing: You may see installation warnings; however, as long as you see my name in the Publisher section (below), you can be almost sure that the code hasn’t been tampered with.