Skip to content

Instantly share code, notes, and snippets.

View nickharris's full-sized avatar

Nick Harris nickharris

View GitHub Profile
@nickharris
nickharris / gist:4950450
Created February 14, 2013 03:39
insert sensor reading from .NET MF to Mobile Services
void temperatureHumidity_MeasurementComplete(TemperatureHumidity sender, double temperature, double relativeHumidity)
{
//may as well take a light reading as well
double lightPercentage = lightSensor.ReadLightSensorPercentage();
//create a new sensor reading and set the values
var reading = new SensorReading()
{
SensorID = "nicks-office", //can you believe i have to share my office with http://ntotten.com ?
Temp = temperature,
@nickharris
nickharris / gist:4950428
Last active December 13, 2015 17:48
SensorData Insert Script
var Pusher = require('pusher');
function insert(item, user, request) {
request.execute({
success: function() {
// After the record has been inserted, trigger immediately to the client
request.respond();
// Publish event for all other active clients
publishItemCreatedEvent(item);
}
@nickharris
nickharris / gist:4950398
Last active December 13, 2015 17:48
pusher and jqplot implementation for live graphs
@{
ViewBag.Title = ".NET MicroFramework, Mobile Services + Pusher demo";
}
<h2>Mobile Services - Sensor Demo</h2>
<div id="chartdiv" style="height:600px;width:800px;display:none"></div>
<br />
<div id="lightdiv" style="height:600px;width:800px;display:none"></div>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@*Add Pusher script reference*@
<script type="text/javascript" src="http://js.pusher.com/1.12/pusher.min.js" />
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
public partial class Program
{
private GT.Timer timer = new GT.Timer(5000);
void ProgramStarted()
{
// Event that fires when a measurement is ready
temperatureHumidity.MeasurementComplete += new TemperatureHumidity.MeasurementCompleteEventHandler(temperatureHumidity_MeasurementComplete);
ethernet_J11D.Interface.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Interface_NetworkAddressChanged);
ethernet_J11D.DebugPrintEnabled = true;
@nickharris
nickharris / gist:4949948
Last active December 13, 2015 17:39
create MobileServiceClient instance
using Microsoft.WindowsAzure.MobileServices;
namespace SensorDemoMobileServices
{
public partial class Program
{
//TODO: add your mobile service URI and app key below from the Windows Azure Portal https://manage.windowsazure.com
public static MobileServiceClient MobileService = new MobileServiceClient(
new Uri("http://<your Windows Azure Mobile Service subdomain >.azure-mobile.net/"),
"<your Windows Azure Mobile Service App Key> "
@nickharris
nickharris / gist:4949513
Last active December 13, 2015 17:38
Gadgeteer collect sensor data and insert to mobile service
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
@nickharris
nickharris / gist:4949367
Last active December 13, 2015 17:38
SensorReading
using System;
using Microsoft.SPOT;
using Microsoft.Azure.Zumo.MicroFramework.Core;
namespace SensorDemoMobileServices
{
public class SensorReading : IMobileServiceEntity
{
public int Id { get; set; }
public string SensorID { get; set; }
@nickharris
nickharris / gist:4357369
Created December 22, 2012 03:34
Windows Azure Mobile Services Scheduler
function CheckFeed() {
getUpdatesAndNotify();
}
var request = require('request');
function getUpdatesAndNotify() {
request('http://search.twitter.com/search.json?q=@cloudnick&rpp=2',
function tweetsLoaded (error, response, body) {
var results = JSON.parse(body).results;
if(results){
var azure = require('azure');
var qs = require('querystring');
function insert(item, user, request) {
var accountName = '<replace with your storage account name>';
var accountKey = '<replace with your storage account key>';
var host = accountName + '.blob.core.windows.net';
var canonicalizedResource = '/' + item.containerName + '/' + item.resourceName;
//Must be lowercase
item.containerName = item.containerName.toLowerCase();