Skip to content

Instantly share code, notes, and snippets.

View tomconte's full-sized avatar
💻
Working from home

Thomas Conté tomconte

💻
Working from home
View GitHub Profile
@tomconte
tomconte / EsploraSensors.ino
Created July 12, 2014 12:50
Read various sensor values from an Esplora board and print them to serial port.
/*
** Read various sensor values and print them to serial port.
**
** Thomas Conté @tomconte
*/
#include <Esplora.h>
int lightMin = 1023; // minimum sensor value
int lightMax = 0; // maximum sensor value
@tomconte
tomconte / send_amqp_telemetry.py
Created July 12, 2014 12:58
Send telemetry data read form the serial port to the Azure Service Bus, using the Apache Qpid Proton AMQP library.
#!/usr/bin/python
import sys
import commands
import re
import uuid
import serial
from proton import *
# Device ID
@tomconte
tomconte / snapshot_utility.py
Created July 23, 2014 16:25
Sample Python script to manage Azure Blob Storage snapshots: list snapshots, take a snapshot, delete a snapshot, copy a snapshot to a new Blob.
#!/usr/bin/python
from azure.storage import BlobService
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("container", help="the blob container")
parser.add_argument("blob", help="the blob name")
parser.add_argument("-s", "--snapshot", help="take a new snapshot", action="store_true")
parser.add_argument("-d", "--delete", help="delete a snapshot")
/*
** This sample Arduino sketch uploads telemetry data to Azure Mobile Services on an Arduino Yun
** The Bridge library is used to run cURL to send the data securely using SSL.
** See the full article here: http://hypernephelist.com/2014/08/19/https_on_arduino_yun.html
**
** Thomas Conté @tomconte
*/
#include <Process.h>
@tomconte
tomconte / send_to_eventhub.js
Last active June 24, 2016 03:07
This small Node.JS example can be used to send some data to an Azure Event Hub publisher. The function create_sas_token() shows how to generate the SAS token used to sign the requests.
var https = require('https');
var crypto = require('crypto');
// Event Hubs parameters
var namespace = 'tomhub-ns';
var hubname ='tomtest001';
var devicename = 'device-01';
// Payload to send
var payload = '{\"Temperature\":\"37.0\",\"Humidity\":\"0.4\"}';
@tomconte
tomconte / upload_azure_blob_sas.js
Created September 24, 2014 08:13
Upload a Blob to Azure Storage using Shared Access Signatures (SAS) in Node.JS
var fs = require('fs');
var https = require('https');
var blob_host = 'tconeu.blob.core.windows.net';
var blob_container = 'tessel-uploads';
// Use any tool to generate a Shared Access Key e.g. Azure Management Studio
var blob_sas = '?sr=c&sv=2014-02-14&si=tessel&sig=xxxxRv%2xxxxUTd8xxxxMKc0xxxxi%2Fxxxxw6VsxxxxGjdJxxxx';
var blob_name = 'test.jpg';
@tomconte
tomconte / tessel_upload_camera_picture.js
Created September 24, 2014 15:19
This Tessel script will take a picture and upload it to Azure Blob Storage. You will first need to generate a Shared Access Signature: http://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-1/
var tessel = require('tessel');
var https = require('https');
// Upload parameters
var blob_host = 'tconeu.blob.core.windows.net';
var blob_container = 'tessel-uploads';
// Use any tool to generate a Shared Access Key e.g. Azure Management Studio
var blob_sas = '?sr=c&sv=2014-02-14&si=tessel&sig=xxxxRv%2xxxxUTd8xxxxMKc0xxxxi%2Fxxxxw6VsxxxxGjdJxxxx';
#!/usr/bin/python
import sys
import commands
import re
import uuid
import serial
from proton import *
# Device ID
@tomconte
tomconte / event_hubs_send.py
Last active February 15, 2018 08:54
Send messages to an Azure Event Hub using the Apache Qpid Proton AMQP library.
#!/usr/bin/python
# Send messages to an Azure Event Hub using the Apache Qpid Proton AMQP library.
import sys
import commands
from proton import *
# Event Hub address & credentials
# amqps://<keyname>:<key>@<namespace>.servicebus.windows.net/<eventhubname>
@tomconte
tomconte / event_hubs_receive.py
Created December 6, 2014 10:44
Receive messages from an Azure Event Hub using the Apache Qpid Proton AMQP library. Nota bene: in order to receive all messages, you should really subscribe to all your Event Hub partitions. This example shows how to read from a single partition.
#!/usr/bin/python
# Receive messages from an Azure Event Hub using the Apache Qpid Proton AMQP library.
import sys
import commands
import re
import uuid
import serial
from proton import *