This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async Task InitNotificationsAsync() | |
{ | |
await notificationHub.RefreshRegistrationsAsync(); | |
if (!await notificationHub.RegistrationExistsForApplicationAsync("myUrgentToast")) | |
{ | |
await notificationHub.CreateTemplateRegistrationForApplicationAsync( | |
CreateToastTemplate(), "myUrgentToast", new string[]{"urgent", "alert"}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.ServiceBus.Messaging; | |
using System; | |
using System.Collections.Generic; | |
namespace MockMessageSender | |
{ | |
public class MutableMessageSender | |
{ | |
public delegate void _Send(BrokeredMessage message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace SqlFiltersAndRules | |
{ | |
using System; | |
using Microsoft.ServiceBus; | |
using Microsoft.ServiceBus.Messaging; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Tiny web service switching an LED made based on https://github.com/sirleech/Webduino */ | |
#include "SPI.h" | |
#include "Ethernet.h" | |
#include "WebServer.h" | |
#define DEBUG | |
static uint8_t mac[6] = { 0x90, 0xA2, 0xDA, 0x0D, 0xBC, 0xAE }; | |
static uint8_t ip[4] = { 192, 168, 2, 107 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Example use (from an email I sent) | |
I’m using WhenAny to either register for a callback on any of the pending operations and to use | |
the IO thread that comes up with their respective completion or to execute handling of completed | |
work on the current thread (‘borrowing’ the IO thread). | |
So if I read from a socket and from a queue, first both ops hang. Queue read completes and I get | |
called back on an IO thread which continues the await. I process that completion in the loop. | |
Meanwhile the socket read completes. That IO thread pops up and just registers the fact that it’s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
“What was the deal with the Halloween Documents?” | |
* I can also sell you a very fine 1998 Ford F-150. My team is committing to Apache | |
Qpid Proton. Maybe go talk to the NodeJS folks. | |
“So, when is the last time you hacked on a project in Visual Studio?” | |
* Yesterday. I'm writing this at breakfast. | |
“Do you have code on GitHub?” (GitHub, not CodePlex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Task flushingTask = null; | |
public override Task FlushAsync(CancellationToken cancellationToken) | |
{ | |
Interlocked.CompareExchange( | |
ref flushingTask, | |
Task.Delay(200, cancellationToken).ContinueWith( | |
async (t) => | |
{ | |
await write.FlushAsync(cancellationToken); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//FromAsync variant that can be used with APM across M<arshaling boundaries (you make your own TArgX overloads, please) | |
static class MarshalTask | |
{ | |
public static Task<TResult> FromAsync<TArg1, TArg2, TResult>(Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult> beginFunc, Func<IAsyncResult, TResult> endFunc, TArg1 arg1, TArg2 arg2) | |
{ | |
var cp = new Completer<TResult>(endFunc); | |
var tcs = new TaskCompletionSource<TResult>(cp); | |
cp.TaskCompletionSource = tcs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NamespaceManager nsm = NamespaceManager.CreateFromConnectionString(serviceBusConnectionString); | |
string name = nsm.Address.Host.Substring(0, nsm.Address.Host.IndexOf(".", System.StringComparison.Ordinal)); | |
var sendKey = SharedAccessAuthorizationRule.GenerateRandomKey(); | |
var listenKey = SharedAccessAuthorizationRule.GenerateRandomKey(); | |
var manageKey = SharedAccessAuthorizationRule.GenerateRandomKey(); | |
CreateSharedAccessRuleOnNamespaceRoot(name, "send", sendKey, AccessRights.Send, subscriptionId, publisherCertificate); | |
CreateSharedAccessRuleOnNamespaceRoot(name, "manage", manageKey, AccessRights.Manage|AccessRights.Send|AccessRights.Listen, subscriptionId, publisherCertificate); | |
CreateSharedAccessRuleOnNamespaceRoot(name, "listen", listenKey, AccessRights.Listen, subscriptionId, publisherCertificate); |