Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Harris nickharris

View GitHub Profile
@nickharris
nickharris / gist:4950450
Created Feb 14, 2013
insert sensor reading from .NET MF to Mobile Services
View gist:4950450
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 Dec 13, 2015
SensorData Insert Script
View gist:4950428
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 Dec 13, 2015
pusher and jqplot implementation for live graphs
View gist:4950398
@{
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>
View gist:4950358
<!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")
View gist:4950009
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 Dec 13, 2015
create MobileServiceClient instance
View gist:4949948
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 Dec 13, 2015
Gadgeteer collect sensor data and insert to mobile service
View gist:4949513
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 Dec 13, 2015
SensorReading
View gist:4949367
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 Dec 22, 2012
Windows Azure Mobile Services Scheduler
View gist:4357369
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){
View gist:4063605
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();