Skip to content

Instantly share code, notes, and snippets.

Avatar

Bruno Hildenbrand hd9

View GitHub Profile
@hd9
hd9 / MyApp.nuspec
Created Feb 7, 2020
Sample NuGet for deploying NServiceBus on Azure WebJobs
View MyApp.nuspec
<!--
// **********************************************
// 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 Feb 10, 2020
Sample debug/async initialization code for NServiceBus running as Azure WebJobs
View NServiceBus-WebJob-async.cs
// **********************************************
// 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 Feb 7, 2020
Sample initialization code for NServiceBus running on Azure WebJobs supporting local debug
View NServiceBus-WebJob-Debug.cs
// **********************************************
// 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 Feb 7, 2020
Sample initialization code for NServiceBus running on Azure WebJobs
View NServiceBus-WebJob.cs
// **********************************************
// 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 Feb 7, 2020
How to validate incoming requests on ASP.NET endpoints using custom ActionFilters
View Blog-VerifyAllowAnonymousAttribute-Usage.cs
// **********************************************
// 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 Jan 16, 2020
List installed .NET Framework versions
View list-dotnet-frameworks.ps1
######################################################################
# 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() {
View i3-config
#################################
# 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 Dec 20, 2019
RavenDB Cloud Operations
View RavenDBCloud-DbOperations.cs
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 Oct 18, 2019
Accessing Entity Framework context on the background on .NET Core
View EF-AccessBgContext-Step3.cs
// 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 Oct 18, 2019
Accessing Entity Framework context on the background on .NET Core
View EF-AccessBgContext-Step2.cs
// 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!");
}