Skip to content

Instantly share code, notes, and snippets.

View marcduiker's full-sized avatar
/-/

Marc Duiker marcduiker

/-/
View GitHub Profile
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"topicName": {
"type": "string",
"metadata": {
"description": "The value to use for creating the Event Grid Application Topic."
}
},
@marcduiker
marcduiker / xunit_fact.snippet
Last active February 6, 2022 13:15
Visual Studio C# snippet for xUnit test methods (Facts) using the naming convention proposed by http://osherove.com/blog/2005/4/3/naming-standards-for-unit-tests.html. Import the snippet using the SnippetManager in VS and type `fact[tab][tab]` inside a class to insert the snippet.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>xUnit Fact</Title>
<Shortcut>fact</Shortcut>
<Description>Code snippet for an xUnit test method (Fact) following the naming convention UnitOfWork_StateUnderTest_ExpectedBehaviour.</Description>
@marcduiker
marcduiker / HttpStart.cs
Created November 5, 2017 21:40
Durable Functions: HttpTrigger function which is used to start an orchestration function.
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
namespace DurableFunctionsDemo
{
public static class HttpStart
{
@marcduiker
marcduiker / HelloWorld.cs
Created November 5, 2017 22:03
Durable Functions: Extremely basic implementation of an orchestration function (which actually doesn't do any orchestration).
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace DurableFunctionsDemo.Functions
{
public static class HelloWorld
{
[FunctionName("HelloWorld")]
public static string Run(
[OrchestrationTrigger]DurableOrchestrationContext context,
@marcduiker
marcduiker / local.settings.json
Created November 7, 2017 17:04
Durable Functions: local.settings.json with connection strings for local development.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10002/"
}
}
@marcduiker
marcduiker / CollectNames.cs
Last active November 8, 2017 22:19
Durable Functions: 'eternal' orchestration function which waits for either an 'addname' or 'iscompleted' event.
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace DurableFunctionsDemo.OrchestrationFunctions
{
public static class CollectNames
{
[FunctionName("CollectNames")]
@marcduiker
marcduiker / HelloNameActivity.cs
Last active September 4, 2019 11:42
Example of using nameof() in order to use the class name in the [FunctionName] attribute (activity function) and in the CallActivityAsync() method (orchestration function).
namespace DurableFunctions.Demo.DotNetCore.Basics.Activities
{
public static class HelloNameActivity
{
[FunctionName(nameof(HelloNameActivity))]
public static string Run(
[ActivityTrigger] string name,
ILogger logger)
{
logger.LogInformation($"Name: {name}");
@marcduiker
marcduiker / FunctionName.cs
Last active September 4, 2019 11:45
Example of using string constants in a static class in order to use these in the [FunctionName] attribute (activity function) and in the CallActivityAsync() method (orchestration function).
namespace DurableFunctions.Demo.DotNetCore.Basics
{
public static class FunctionName
{
public const string HelloNameActivity = "HelloNameActivity";
public const string HelloNameOrchestration = "HelloNameOrchestration";
}
}
@marcduiker
marcduiker / GetLatestGitHubRelease_Snippet.cs
Created March 3, 2019 20:47
Using the Octokit.Net client library to get the latest release for a public GitHub repository.
var client = new GitHubClient(new ProductHeaderValue("SomeApplicationIdentifier"));
var latestRelease = await client.Repository.Release.GetLatest(
repoConfiguration.RepositoryOwner,
repoConfiguration.RepositoryName);
@marcduiker
marcduiker / PostTweetUsingTweetInvi_Snippet.cs
Created March 3, 2019 20:49
Post a new Tweet using the Tweetinvi client library.
var creds = new TwitterCredentials(
consumerApiKey,
consumerApiSecret,
accessToken,
accessTokenSecret);
var tweetMessage = CreateMessage(newRelease);
var tweet = Auth.ExecuteOperationWithCredentials(creds, () =>
{