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 / 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 / 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 / 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 / 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 / azure-functions-save-form-data-to-sql-azure.csx
Last active July 6, 2018 12:11
Save JSON data into SQL Azure using Azure Functions
#r "Newtonsoft.Json"
using System;
using System.Net;
using System.Net.Mail;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Dapper;
using Newtonsoft.Json;
@yorek
yorek / get-r-home.sql
Last active April 13, 2016 11:55
Get installation directory for MRO in SQL Server 2016
execute sp_execute_external_script
@language = N'R',
@script = N'OutputDataSet <- data.frame(R.home());'
with result sets (([R.home()] nvarchar(max) not null));
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@yorek
yorek / centos-set-keyboard
Last active August 29, 2015 14:23
Set keyboard map to Italian in CentOS 6.6
loadkeys it
@yorek
yorek / gist:77eca81a1ab4e0f51dea
Created April 8, 2015 15:58
Powershell script to add and process a new SSAS Multidimensional partition (mimicking subpartitions usage)
# Load Assembly
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") >$NULL
# Connect to Tabular SSAS
$srv = New-Object Microsoft.AnalysisServices.Server
$srv.connect("localhost")
# Point to a specific Database
$db = $srv.Databases.FindByName("MyDatabase");
@yorek
yorek / add-new-tabular-partition
Last active April 26, 2022 01:42
Powershell script to add and process a new SSAS Tabular partition
# Load Assembly
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") >$NULL
# Connect to Tabular SSAS
$srv = New-Object Microsoft.AnalysisServices.Server
$srv.connect("localhost\TABULAR")
# Point to a specific Database
$db = $srv.Databases.FindByName("DatabaseName");