Skip to content

Instantly share code, notes, and snippets.

View hd9's full-sized avatar

Bruno Hildenbrand hd9

View GitHub Profile
@hd9
hd9 / MyApp.nuspec
Created February 7, 2020 20:18
Sample NuGet for deploying NServiceBus on Azure WebJobs
<!--
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2020/02/migrating-nservicebus-backends-to-azure.html
// **********************************************
-->
<?xml version="1.0"?>
<package>
<metadata>
@hd9
hd9 / NServiceBus-WebJob-async.cs
Last active February 10, 2020 22:11
Sample debug/async initialization code for NServiceBus running as Azure WebJobs
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2020/02/migrating-nservicebus-backends-to-azure.html
// **********************************************
// Related docs:
// - NSB WebJobs: https://docs.particular.net/samples/azure/webjob-host/
// - Azure WebJobs: https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-get-started
public class Program
{
@hd9
hd9 / NServiceBus-WebJob-Debug.cs
Last active February 7, 2020 19:26
Sample initialization code for NServiceBus running on Azure WebJobs supporting local debug
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2020/02/migrating-nservicebus-backends-to-azure.html
// **********************************************
// Related docs:
// * NSB WebJobs: https://docs.particular.net/samples/azure/webjob-host/
// * Azure WebJobs: https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-get-started
public class Program
{
@hd9
hd9 / NServiceBus-WebJob.cs
Last active February 7, 2020 19:25
Sample initialization code for NServiceBus running on Azure WebJobs
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2020/02/migrating-nservicebus-backends-to-azure.html
// **********************************************
// Related docs:
// * NSB WebJobs: https://docs.particular.net/samples/azure/webjob-host/
// * Azure WebJobs: https://docs.microsoft.com/en-us/azure/app-service/webjobs-sdk-get-started
public class Program
{
@hd9
hd9 / Blog-VerifyAllowAnonymousAttribute-Usage.cs
Last active February 7, 2020 19:24
How to validate incoming requests on ASP.NET endpoints using custom ActionFilters
// **********************************************
// Fore more information, visit:
// https://blog.hildenco.com/2017/12/aspnet-allowing-anonymous-requests-on.html
// **********************************************
[HttpPost]
[ValidateAntiForgeryToken]
[RequirePermission("Update")]
public async Task<JsonResult> SomeOperation(string id)
{
// your code here
@hd9
hd9 / list-dotnet-frameworks.ps1
Last active January 16, 2020 22:27
List installed .NET Framework versions
######################################################################
# list-dotnet-frameworks.ps1 | List installed .NET Framework versions
######################################################################
# Source: https://blog.hildenco.com/2020/01/determining-installed-net-framework.html
# It may be required to run Powershell with the following command line:
# Powershell.exe -executionpolicy remotesigned -File
function Get-Installed-Framework-Versions() {
#################################
# Source: https://blog.hildenco.com/2019/08/how-i-fell-in-love-with-i3.html
#################################
# start a terminal
bindsym $mod+Return exec gnome-terminal
# kill focused window
bindsym $mod+x kill
@hd9
hd9 / RavenDBCloud-DbOperations.cs
Created December 20, 2019 17:54
RavenDB Cloud Operations
using Raven.Client.Documents;
using Raven.Client.Documents.Operations.Backups;
using Raven.Client.Documents.Operations.ETL.SQL;
using Raven.Client.Documents.Smuggler;
using Raven.Client.ServerWide;
using Raven.Client.ServerWide.Operations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
@hd9
hd9 / EF-AccessBgContext-Step3.cs
Created October 18, 2019 17:42
Accessing Entity Framework context on the background on .NET Core
// Step 3 - Resolve the service from the background task
// Source: https://blog.hildenco.com/2018/12/accessing-entity-framework-context-on.html
private async Task BgTask(string id, IServiceScopeFactory serviceScopeFactory)
{
await Task.Delay(30000);
using (var scope = serviceScopeFactory.CreateScope())
{
var dbContext = scope.ServiceProvider.GetService<ApplicationDbContext>();
@hd9
hd9 / EF-AccessBgContext-Step2.cs
Created October 18, 2019 17:41
Accessing Entity Framework context on the background on .NET Core
// Step 2 - Pass it to your background thread
// Source: https://blog.hildenco.com/2018/12/accessing-entity-framework-context-on.html
public async Task<IActionResult> TestAsyncCall(string id)
{
Task.Run(() => BgTask(id, serviceScopeFactory));
return Ok("Thanks, your code will be executed!");
}