Lightning: How to detect Salesforce1 context?

Some events are handled specifically within Salesforce1, so you can use that to check context. See this link for a list of Salesforce1 events.

This example displays a toast message in Salesforce1 but not in a standalone/separate app.

var toast = $A.get("e.force:showToast");
if (toast){
    toast.setParams({
        "title": "Success!",
        "message": " Your contacts have been loaded successfully."
    });
    toast.fire();
} else {
        console.log("not in Salesforce1");
    }

Update - April 9, 2015 I was advised by an S1 developer that you can also use $A.getContext().getApp() to get context.

if (context=="one:one") {
            //you're running Salesforce1
        }
        else {
            //you're running a standalone app
        }

See the JavaScript API docs (https://[your-salesforce-instance]/auradocs/reference.app#reference?topic=api:Aura) for more details.