Skip to content

Instantly share code, notes, and snippets.

Bruno Hildenbrand hd9

Block or report user

Report or block hd9

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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!");
}
@hd9
hd9 / EF-AccessBgContext-Step1.cs
Created Oct 18, 2019
Accessing Entity Framework context on the background on .NET Core
View EF-AccessBgContext-Step1.cs
// Step 1 - Inject IServiceScopeFactory in your controller
// Source: https://blog.hildenco.com/2018/12/accessing-entity-framework-context-on.html
private readonly IServiceScopeFactory serviceScopeFactory;
public ApiController(ApplicationDbContext context, IServiceScopeFactory serviceScopeFactory)
{
this.context = context;
this.serviceScopeFactory = serviceScopeFactory;
}
@hd9
hd9 / Azure-migrate-data-between-servers.sql
Created Feb 1, 2019
AZURE: Migrate data between Sql Server databases using Sql and PolyBase
View Azure-migrate-data-between-servers.sql
-- Script to migrate data between Azure Databases
-- Author: Bruno Hildenbrand (https://github.com/hd9)
-- Full post detailed here: https://blog.hildenco.com
-- Note: replace everything between <> with your own configuration
print '--- STARTING MIGRATION ---'
-- create master key
print 'Creating master key...'
CREATE MASTER KEY ENCRYPTION BY PASSWORD = '<super-strong-password>';
@hd9
hd9 / Vue-ChatRoom.js
Created Jan 24, 2019
A simple chatroom to demo how simple and elegant Vue.Js is
View Vue-ChatRoom.js
// Vue-ChatRoom.js: A simple chatroom to demo how simple and elegant Vue.Js is
// By: Bruno Hildenbrand
// Source: https://github.com/hd9/vue-chatroom
// blog post available at: blog.hildenco.com
const app = new Vue({
el: '#chat',
data: {
name: 'Bruno',
msg: '',
@hd9
hd9 / gh-integrated-sec-vuln.md
Created Nov 1, 2018
GitHub - Integrated Security
View gh-integrated-sec-vuln.md
@hd9
hd9 / LocalFunctions-Razor-AspNetCore.cshtml
Last active Aug 29, 2018
Simplifying Razor logic with C# Local Functions in Asp.Net Core | blog.hildenco.com
View LocalFunctions-Razor-AspNetCore.cshtml
@using Microsoft.AspNetCore.Mvc.Controllers
@{
var controllerName = ((ControllerActionDescriptor)ViewContext.ActionDescriptor).ControllerName;
string GetClass(string controller)
{
return $"nav-link { (controllerName == controller ? "active admin" : "" ) }";
}
}
<nav class="navbar navbar-expand-lg navbar-light bg-light">
@hd9
hd9 / export-csv-aspnet.cs
Last active Oct 18, 2019
Export CSV generated in-memory from an Asp.Net controller
View export-csv-aspnet.cs
// Export CSV generated in-memory from an Asp.Net controller
// Source: https://blog.hildenco.com/2018/03/exporting-csv-generated-in-memory-in.html
public class MyController : Controller
{
public void DownloadReport(string id)
{
var rptLines = new List<CsvLine>();
var count = 0;
@hd9
hd9 / js-pdf-exporter.html
Last active Nov 1, 2018
A simple js-pdf exporter
View js-pdf-exporter.html
<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js"></script>
<script>
$(document).ready(function(){
$('#cmd').click(function () {
doc.fromHTML($('#content').html(), 15, 15, {
'width': 170,
You can’t perform that action at this time.