Skip to content

Instantly share code, notes, and snippets.

View yorek's full-sized avatar
:octocat:
Working from home

Davide Mauri yorek

:octocat:
Working from home
View GitHub Profile
@yorek
yorek / azure-functions-save-form-data-to-sql-azure.sql
Last active April 5, 2017 07:06
T-SQL to support yorek/azure-functions-save-form-data-to-sql-azure.csx
/*
Expected JSON:
{
"Subject": "Form's Subject",
"FirstName": "Davide",
"LastName": "Mauri",
"EmailAddress": "info@davidemauri.it",
"OtherField1": "OtherValue1",
@yorek
yorek / access-json-file.sql
Last active October 1, 2019 06:55
Access to JSON file content using T-SQL
/*
Create the Database Master Key, if needed
*/
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'My-L0ng&Str0ng_P4ss0wrd!';
GO
/*
Create database scoped credentials to store the Shared Access Signature (SAS)
needed to access the Azure Blob Container. More info on Azure Blob SAS here:
@yorek
yorek / OAuth2Middleware.cs
Last active December 14, 2021 05:50
ASP.NET Core 2 Custom OAuth2 Authentication
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OAuth;
using Newtonsoft.Json.Linq;
@yorek
yorek / get-latest-object-version.sql
Last active December 20, 2017 21:09
get-latest-object-version
USE tempdb
GO
/*
Generate Sample Data
*/
DROP TABLE IF EXISTS dbo.[Sample]
GO
WITH cte AS
@yorek
yorek / update-az-cli.ps1
Created March 13, 2018 04:02
Powershell Script to download and update AZ CLI 2.0
Invoke-WebRequest https://aka.ms/installazurecliwindows -OutFile AzCliLatest.msi
.\AzCliLatest.msi /passive
@yorek
yorek / Microsoft.PowerShell_profile.ps1
Last active April 6, 2018 00:18
Powershell Profile
# Taken from https://joonro.github.io/blog/posts/powershell-customizations.html
# and https://hodgkins.io/ultimate-powershell-prompt-and-git-setup
Import-Module posh-git
Import-Module Get-ChildItemColor
Import-Module PSReadLine
$global:GitPromptSettings.BeforeText = '['
$global:GitPromptSettings.AfterText = '] '
@yorek
yorek / stackoverflow-dapper-50091943.cs
Created May 2, 2018 06:25
Return a single JSON from SQL Server and map it into a custom object
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Dapper;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace stackoverflow_dapper_50091943
{
@yorek
yorek / stackoverflow-dapper-50091943.sql
Created May 2, 2018 06:26
Create sample data using Continents, Countries and Cities
use tempdb
go
drop table if exists dbo.City;
drop table if exists dbo.Country;
drop table if exists dbo.Continent;
create table dbo.Continent
(
continent_id int not null primary key,
@yorek
yorek / Security-Audit.ps1
Last active May 2, 2018 19:08
Get information needed to comply with a security audit
Login-AzureRmAccount
Select-AzureRmSubscription -Subscription <your-subscription-id>
$servers = Get-AzureRmSqlServer
foreach($s in $servers) {
$databases = Get-AzureRmSqlDatabase -ServerName $s.ServerName -ResourceGroupName $s.ResourceGroupName
foreach ($d in $databases)
{
@yorek
yorek / import-csv-from-blob.sql
Created May 10, 2018 16:47
Bulk insert CSV data stored in a Blob Store
/*
Create the Database Master Key, if needed
*/
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'My-L0ng&Str0ng_P4ss0wrd!';
GO
/*
Create database scoped credentials to store the Shared Access Signature (SAS)
needed to access the Azure Blob Container. More info on Azure Blob SAS here: