Skip to content

Instantly share code, notes, and snippets.

View erjjones's full-sized avatar

Eric Jones erjjones

  • Indianapolis, Indiana
View GitHub Profile
@erjjones
erjjones / guide-workspaces-sample.json
Created April 22, 2014 02:30
Guide to Workspaces Sample
{
"WorkspaceUri": "Sample",
"Title": "Sample Title",
"Description": "This is a sample workspace.",
"Anonymous": false,
"EnableTriggers": false,
"Records": 0,
"Collections": [
{
"CollectionUri": "Products",
@erjjones
erjjones / Triggers
Created August 27, 2014 02:31
Default Trigger Class
using System;
using ODataHQ.Code.Common;
public class Triggers : ITriggers
{
public void Create(ExecutionContext context)
{
context.Execute();
}
@erjjones
erjjones / GarageDoor-Agent
Last active August 29, 2015 14:05
Home Monitor Garage Door Electric Imp Device
const ODATAHQ_URL = "https://query.odatahq.com/v3/{accountkeyhere}/homemonitor/garagedoor?api-key={apikeyhere}";
// Print light reading trigger URL
server.log("Sensor Agent URL: " + http.agenturl());
// Define funtions
function requestHandler(request, response)
{
// Handle an incoming web request for a reading
try
@erjjones
erjjones / garagedoor
Created August 28, 2014 03:30
Garage Door Collection Metadata
{
"collectionUri": "garagedoor",
"title": "garagedoor",
"description": "Collection of garagedoor objects.",
"typeName": "garagedoor",
"enableTriggers": false,
"properties": [
{
"name": "Status",
"description": "",
@erjjones
erjjones / odatahq-workspace-configuration-sample
Created June 29, 2015 00:15
Define Workspace Configuration
var configuration = new WorkspaceConfiguration
{
QueryServiceUri = new Uri("https://query.odatahq.com/v3/{accountKey}/{workspaceUri}", UriKind.Absolute),
ClientID = "{clientId}",
ClientSecret = "{clientSecret}"
};
@erjjones
erjjones / odatahq-workspace-configuration-user-scope-sample
Created June 29, 2015 00:26
Define Workspace Configuration With a User in Scope
var configuration = new WorkspaceConfiguration
{
QueryServiceUri = new Uri("https://query.odatahq.com/v3/{accountKey}/{workspaceUri}", UriKind.Absolute),
ClientID = "{clientId}",
ClientSecret = "{clientSecret}",
Username = "{username}",
Password = "{password}"
};
// Create a session for the workspace specified in the configuration.
using (var session = new WorkspaceSession(configuration))
{
// Define a new user to be registered, notice that we don't need to assign any audit column values.
var user = new User
{
DocumentID = Guid.NewGuid().ToString(),
Username = "someusername",
Password = "s@m5p@ssw@rd" // Password will automatically be MD5'd using a trigger on the server.
};
@erjjones
erjjones / odatahq-store-data-then-delete-sample
Created June 29, 2015 00:41
Store Data In a Workspace Then Delete
// Create a session for the workspace specified in the configuration.
using (var session = new WorkspaceSession(configuration))
{
// We'll authenticate using standard workspace token authentication with an example user.
await session.AuthenticateAsync("{username}", "{password}");
var anonymousDocument = new AnonymousCollection
{
DocumentID = Guid.NewGuid().ToString(),
Name = "Example Inserted Document"
// Create a session for the workspace specified in the configuration.
using (var session = new WorkspaceSession(_configuration))
{
// We'll authenticate using standard workspace token authentication with an example user.
await session.AuthenticateAsync("{username}", "{password}");
// Insert example documents to ensure we have something to query.
await session.InsertDocumentAsync(new AnonymousCollection
{
DocumentID = Guid.NewGuid().ToString(),
@erjjones
erjjones / Custom.js
Created December 21, 2011 20:02
Custom.js
jQuery(function () {
var paper = Raphael("graph", 940, 81),
timeline;
timeline = new Timeline(paper, [
{date:"06/25/2004", version:"0.5"},
{date:"12/13/2005", version:"1.0.0"},
{date:"12/07/2007", version:"2.0.0"},
{date:"6/10/2010", version:"3.0 ?"}