Skip to content

Instantly share code, notes, and snippets.

View ghotz's full-sized avatar

Gianluca Hotz ghotz

View GitHub Profile
@ghotz
ghotz / memory-details.sql
Last active August 4, 2020 10:17
Get a quick overview of CPU and memory pressure
SELECT
physical_memory_in_use_kb/1024./1024. AS sql_physical_memory_in_use_gb,
large_page_allocations_kb/1024./1024. AS sql_large_page_allocations_gb,
locked_page_allocations_kb/1024./1024. AS sql_locked_page_allocations_gb,
virtual_address_space_reserved_kb/1024./1024. AS sql_VAS_reserved_gb,
virtual_address_space_committed_kb/1024./1024. AS sql_VAS_committed_gb,
virtual_address_space_available_kb/1024./1024. AS sql_VAS_available_gb,
page_fault_count AS sql_page_fault_count,
memory_utilization_percentage AS sql_memory_utilization_percentage,
process_physical_memory_low AS sql_process_physical_memory_low,
@ghotz
ghotz / sp_whoisactive-examples.sql
Last active June 13, 2019 09:02
sp_whoisactive favorites
-- Case 1: get waiting tasks (defaults to running, specific wait or open transactions)
EXEC sp_whoisactive;
GO
-- Case 2: add tasks wait details for parallel queries
EXEC sp_whoisactive @get_task_info = 2;
GO
-- Case 3: add execution Plans
EXEC sp_whoisactive @get_task_info = 2, @get_plans = 1;
@ghotz
ghotz / sys-health-deadlocks-files.sql
Last active January 3, 2023 06:58
Get deadlock graphs from System Health session
--
-- Get deadlock graphs from System Health session with files target
--
IF OBJECT_ID('tempdb..#deadlocks') IS NOT NULL
DROP TABLE #deadlocks;
WITH XmlDataSet AS
(
SELECT CAST(xe.event_data AS xml) AS XMLDATA,*
FROM sys.fn_xe_file_target_read_file('system_health_*.xel',NULL,NULL,NULL) as xe
@ghotz
ghotz / cscv-analyze-image-binary.ps1
Created August 10, 2018 22:03
Analyze local image with Azure Cognitive Services Computer Vision API in PowerShell
# Analyze local image with Azure Cognitive Services Computer Vision API in PowerShell
$ComputerVisionAPILocation = "westeurope";
$ComputerVisionAPIURL = "https://$ComputerVisionAPILocation.api.cognitive.microsoft.com/vision/v2.0";
$ComputerVisionAPIKey = "YOUR_KEY_GOES_HERE";
$ComputerVisionAPIAnalyzeTemplateURL = ($ComputerVisionAPIURL + "/analyze?visualFeatures={0}&details={1}&language={2}")
$visualFeatures = "Categories,Tags,Description,Faces,ImageType,Color,Adult";
$details = "Celebrities,Landmarks";
$language = "en";
@ghotz
ghotz / cscv-analyze-image-by-url.ps1
Last active August 11, 2018 22:09
Analyze image by URL with Azure Cognitive Services Computer Vision API in PowerShell
# Analyze image by URL with Azure Cognitive Services Computer Vision API in PowerShell
$ComputerVisionAPILocation = "westeurope";
$ComputerVisionAPIURL = "https://$ComputerVisionAPILocation.api.cognitive.microsoft.com/vision/v2.0";
$ComputerVisionAPIKey = "YOUR_KEY_GOES_HERE";
$ComputerVisionAPIAnalyzeTemplateURL = ($ComputerVisionAPIURL + "/analyze?visualFeatures={0}&details={1}&language={2}")
$visualFeatures = "Categories,Tags,Description,Faces,ImageType,Color,Adult";
$details = "Celebrities,Landmarks";
$language = "en";
@ghotz
ghotz / cscv-describe-image-binary.ps1
Created August 11, 2018 09:19
Describe local image with Azure Cognitive Services Computer Vision API in PowerShell
# Describe local image with Azure Cognitive Services Computer Vision API in PowerShell
$ComputerVisionAPILocation = "westeurope";
$ComputerVisionAPIURL = "https://$ComputerVisionAPILocation.api.cognitive.microsoft.com/vision/v2.0";
$ComputerVisionAPIKey = "YOUR_KEY_GOES_HERE";
$ComputerVisionAPIAnalyzeTemplateURL = ($ComputerVisionAPIURL + "//describe?maxCandidates={0}")
$maxCandidates = 10;
# Analyze image by URL with Google Cloud Vision API in PowerShell
$CloudVisionAPIURL = "https://vision.googleapis.com/v1/images:annotate";
$CloudVisionAPIKey = "YOUR_KEY_GOES_HERE";
$CloudVisionAPIAnalyzeTemplateURL = ($CloudVisionAPIURL + "?key={0}")
# Note: the aspect ratios for crop hints are 1:1, 4:3, 3:2 and 16:9
$AnnotateImageRequest =
@{
requests = @{
# Analyze image by URL with Google Cloud Vision API in PowerShell
$CloudVisionAPIURL = "https://vision.googleapis.com/v1/images:annotate";
$CloudVisionAPIKey = "YOUR_KEY_GOES_HERE";
$CloudVisionAPIAnalyzeTemplateURL = ($CloudVisionAPIURL + "?key={0}")
$ImageFilename = "C:\Temp\cognitive\20180805-120348-GH01C04-S00.jpg";
# Note: the aspect ratios for crop hints are 1:1, 4:3, 3:2 and 16:9
$AnnotateImageRequest =
@ghotz
ghotz / clarifai-predict-image-by-url.ps1
Last active August 13, 2018 11:32
Analyze image by URL with Clarifai API in PowerShell
# Analyze image by URL with Clarifai API in PowerShell
$ClarifaiAPIURL = "https://api.clarifai.com/v2";
$ClarifaiAPIKey = "YOUR_KEY_GOES_HERE";
$ClarifaiAPIPredictTemplateURL = ($ClarifaiAPIURL + "/models/{0}/outputs")
$PredictInputs =
@{
inputs = @(@{
data = @{
image = @{
@ghotz
ghotz / clarifai-predict-image-by-binary.ps1
Created August 13, 2018 11:32
Analyze local image by URL with Clarifai API in PowerShell
# Analyze local image by URL with Clarifai API in PowerShell
$ClarifaiAPIURL = "https://api.clarifai.com/v2";
$ClarifaiAPIKey = "YOUR_KEY_GOES_HERE";
$ClarifaiAPIPredictTemplateURL = ($ClarifaiAPIURL + "/models/{0}/outputs")
$ImageFilename = "C:\Temp\cognitive\20180805-143608-GH01C12-S00.jpg";
$PredictInputs =
@{
inputs = @(@{