Skip to content

Instantly share code, notes, and snippets.

View jongio's full-sized avatar

Jon Gallant jongio

View GitHub Profile
@jongio
jongio / photonflash.cmd
Last active October 24, 2015 16:59
A cmd file that can be used to flash the photon firmware
dfu-util -d 2b04:d006 -a 0 -s 0x8020000 -D system-part1-0.4.7-photon.bin
dfu-util -d 2b04:d006 -a 0 -s 0x8060000:leave -D system-part2-0.4.7-photon.bin
@jongio
jongio / aspnet-webhooks-nuget-install.ps1
Last active November 15, 2015 03:50
PowerShell script to install nuget packages needed for ASP.NET WebHooks preview
Install-Package Microsoft.AspNet.DataProtection -Pre
Install-Package Microsoft.AspNet.WebHooks.Custom -Pre
Install-Package Microsoft.AspNet.WebHooks.Custom.AzureStorage -Pre
Install-Package Microsoft.AspNet.WebHooks.Custom.Mvc -Pre
Install-Package Microsoft.AspNet.WebHooks.Custom.Api -Pre
Install-Package Microsoft.AspNet.WebHooks.Receivers.Custom -Pre
@jongio
jongio / twitter-date-parsing-csharp
Created December 1, 2015 23:22
Twitter Date Parsing with C#
DateTimeOffset.ParseExact("Tue Dec 01 22:35:28 +0000 2015", "ddd MMM dd HH:mm:ss zzz yyyy", CultureInfo.InvariantCulture);
DateTime.ParseExact("Tue Dec 01 22:35:28 +0000 2015", "ddd MMM dd HH:mm:ss K yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
var telemetryClient = new TelemetryClient();
telemetryClient.TrackException(sendException, replacements);
telemetryClient.Flush();
static void Main()
{
TelemetryConfiguration.Active.InstrumentationKey = CloudConfigurationManager.GetSetting("appInsightsInstrumentationKey");
new TelemetryClient().TrackEvent("WebJobStart", new Dictionary<string, string> { { "appInsightsInstrumentationKey", TelemetryConfiguration.Active.InstrumentationKey } });
var host = new JobHost();
host.Call(typeof(Functions).GetMethod("ProcessQueueMessage"));
}
Install-Package Microsoft.ApplicationInsights.
Install-Package Microsoft.ApplicationInsights.DependencyCollector
Install-Package Microsoft.ApplicationInsights.PerfCounterCollector
Install-Package Microsoft.ApplicationInsights.WindowsServer
public class GreetingsOrchestration : TaskOrchestration<string,string>
{
public override async Task<string> RunTask(OrchestrationContext context, string input)
{
string user = await context.ScheduleTask<string>(typeof(GetUserTask));
string greeting = await context.ScheduleTask<string>(typeof(SendGreetingTask), user);
return greeting;
}
}
public sealed class GetUserTask : TaskActivity<string, string>
{
public GetUserTask()
{
}
protected override string Execute(DurableTask.TaskContext context, string input)
{
GetUserName userNamedialog = new GetUserName();
Console.WriteLine("Waiting for user to enter name...");
public class GreetingsOrchestration2 : TaskOrchestration<string,int>
{
public override async Task<string> RunTask(OrchestrationContext context, int secondsToWait)
{
var user = context.ScheduleTask<string>("DurableTaskSamples.Greetings.GetUserTask", string.Empty);
var timer = context.CreateTimer<string>(context.CurrentUtcDateTime.AddSeconds(secondsToWait), "TimedOut");
var u = await Task.WhenAny(user, timer);
string greeting = await context.ScheduleTask<string>("DurableTaskSamples.Greetings.SendGreetingTask", string.Empty, u.Result);
SELECT
position,
sum(count) as count
INTO
jongblogpowerbi
FROM
jongblogiothub
GROUP BY TumblingWindow(second, 1), position