Skip to content

Instantly share code, notes, and snippets.

View CloudBlobExtensions.cs
public static class CloudBlobExtensions
{
/// <summary>
/// Uploads a string of text to a block blob.
/// </summary>
/// <param name="content">The text to upload, encoded as a UTF-8 string.</param>
public static void UploadText(this ICloudBlob blob, string content)
{
UploadText(blob, content, Encoding.UTF8, null);
}
@SamVanhoutte
SamVanhoutte / enableping.cmd
Created Apr 9, 2014
Enable ping on windows machines (good for azure VPN, etc)
View enableping.cmd
netsh firewall set icmpsetting 8 enable
View azureobd
#! /bin/bash
### BEGIN INIT INFO
# Provides: azureobd
# Required-Start: $remote_fs $syslog $network $all
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start AzureOBD at boot time
# Description: Start AzureOBD at boot time.
### END INIT INFO
@SamVanhoutte
SamVanhoutte / EventHub.cs
Created Jan 20, 2015
EventHub json serialization
View EventHub.cs
async void Main()
{
var mf = MessagingFactory.CreateFromConnectionString("***");
var eventHubClient = mf.CreateEventHubClient("test");
Random rnd = new Random();
Parallel.For(1, 11, deviceId =>
{
for(int cnt = 0; cnt < 100; cnt++)
{
Console.WriteLine ("Sending event nr {1} for device {0}", cnt, deviceId);
@SamVanhoutte
SamVanhoutte / EventHubCode.cs
Last active Aug 29, 2015
Azure Stream Analytics - blog post sample
View EventHubCode.cs
async void Main()
{
var mf = MessagingFactory.CreateFromConnectionString("your cnx string here");
var eventHubClient = mf.CreateEventHubClient("ehname");
Random rnd = new Random();
Parallel.For(1, 11, async (deviceId) =>
{
for(int cnt = 0; cnt < 50; cnt++)
{
Console.WriteLine ("Sending event nr {0} for device {1}", cnt, deviceId);
@SamVanhoutte
SamVanhoutte / RandomExtensions.cs
Created Jan 22, 2015
Random string generator, based on format
View RandomExtensions.cs
void Main()
{
Random rnd = new Random();
rnd.GetString("1-###-000").Dump();
}
public static class RandomExtensions
{
public static string GetString(this Random random, string format)
{
@SamVanhoutte
SamVanhoutte / PiGlowController.cs
Last active Dec 15, 2015
This class can be used to control the PiGlow LED on a Windows 10 IoT Core device. This has been tested on the Raspberry PI II against the build 10586. The controller is very easy to use and to instrument from a Universal Windows App.
View PiGlowController.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Devices.Enumeration;
using Windows.Devices.I2c;
namespace Codit.IoT.PIGlow
View GetImageInformation.sql
REFERENCE ASSEMBLY ImageCommon;
REFERENCE ASSEMBLY FaceSdk;
REFERENCE ASSEMBLY ImageEmotion;
REFERENCE ASSEMBLY ImageTagging;
REFERENCE ASSEMBLY ImageOcr;
@imgs =
EXTRACT FileName string, ImgData byte[]
FROM @"/data/employees/{FileName:*}.jpg"
USING new Cognition.Vision.ImageExtractor();
@SamVanhoutte
SamVanhoutte / TableTransmitter.cs
Last active Jan 2, 2020
Generic table transmitter class
View TableTransmitter.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Table;
using TableStorage.Abstractions.TableEntityConverters;
using Traiders.Storage.Configuration;
@SamVanhoutte
SamVanhoutte / DataLakeTransmitter.cs
Created Dec 18, 2020
Data lake file transmitter
View DataLakeTransmitter.cs
using System;
using System.Text;
using System.Threading.Tasks;
using Azure.Storage.Files.DataLake;
using System.IO;
using System.Net;
using Azure;
using Azure.Storage;
using Azure.Storage.Files.DataLake.Models;
using Azure.Storage.Sas;