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 / read-vecs.cs
Last active January 23, 2024 16:48
Read FVECS and IVECS file and bulk load into MSSQL
private static void LoadFiles(string test)
{
LoadFile(LoadFVECS, $"c:\\Temp\\vector\\{test}\\{test}_base.fvecs", $"{test}_base", num:1000000, dim:128);
LoadFile(LoadFVECS, $"c:\\Temp\\vector\\{test}\\{test}_query.fvecs", $"{test}_query", num:10000, dim:128);
LoadFile(LoadIVECS, $"c:\\Temp\\vector\\{test}\\{test}_groundtruth.ivecs", $"{test}_groundtruth", num:10000, dim:100);
}
private static void LoadFile(Func<BinaryReader, int, string> FileLoader, string file, string tablename, int num, int dim)
{
Console.WriteLine($"Reading file {file}...");
@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");
@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 / apache-drill-azure-strorage.json
Last active February 26, 2021 08:20
Configuration sample to use Azure Blob Store with Apache Drill. More info on Medium Post:
{
"type": "file",
"connection": "wasbs://CONTAINER@ACCOUNT_NAME.blob.core.windows.net",
"config": null,
"workspaces": {
"root": {
"location": "/",
"writable": false,
"defaultInputFormat": null,
"allowAccessOutsideWorkspace": false
@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 / gist:d1664f8e5508c6c10c90f4f9a5b247b7
Created April 28, 2020 23:25
Azure SQL UDF and Persisted Columns
create or alter function dbo.CalculateSum(@a as int, @b as int)
returns int
with schemabinding
as
begin
return @a + @b
end
go
create table dbo.WithPersistedUDF
@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 / compare-version-az-cli-bash
Created December 5, 2018 20:26
Check that AZ CLI is using a command with a minium version
export curVer=`printf "%03d%03d%03d" $(az --version | grep 'eventgrid' | awk '{gsub(/[()]/, "", $2); print $2}' | tail -1 | tr '.' ' ')`
export reqVer=`printf "%03d%03d%03d" $(echo '0.5.0' | tr '.' ' ')`
if [[ curVer -lt reqVer ]] ; then
echo "error" >&2
exit 1
fi
@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 / 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: