Skip to content

Instantly share code, notes, and snippets.

View albertospelta's full-sized avatar
🏠
Working from home

Alberto Spelta albertospelta

🏠
Working from home
View GitHub Profile

Reclaim disk space from Docker Desktop on Windows (WSL 2)

Docker keeps everything in one virtual disk, docker_data.vhdx, which grows but never shrinks by itself. These steps free space inside it, then compact the file. Images, containers and volumes are not touched.

With Docker Desktop running, paste one block at a time in a normal CMD (not as administrator): docker commands run from an elevated prompt can leave an elevated com.docker.build.exe behind that blocks the next Docker Desktop start. Only diskpart, in step 5, needs administrator rights.

1. Check the starting point

@albertospelta
albertospelta / Query-PowerBIDataset.ps1
Last active May 6, 2023 19:06
An example of how to query a PowerBI dataset using Powershell and AdomdClient
$ErrorActionPreference = "Stop"
function LoadAdomdClientPackage() {
$package = Get-Package -Name Microsoft.AnalysisServices.AdomdClient.retail.amd64 -ErrorAction SilentlyContinue
if (!$package) {
Install-Package -Name Microsoft.AnalysisServices.AdomdClient.retail.amd64 -RequiredVersion 19.61.1.4 -ProviderName NuGet -Source "https://www.nuget.org/api/v2" -Scope CurrentUser -SkipDependencies -Force
$package = Get-Package -Name Microsoft.AnalysisServices.AdomdClient.retail.amd64
}
$assemblyPath = Join-Path (Get-ChildItem $package.Source).DirectoryName "lib\net45\Microsoft.AnalysisServices.AdomdClient.dll"
try { Add-Type -Path $assemblyPath} catch { $_.Exception.LoaderExceptions }
@albertospelta
albertospelta / SampleException.cs
Created October 16, 2018 10:47
Template for creating custom exceptions
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
namespace App.Infrastructure.Exceptions
{
[Serializable]
public class SampleException: Exception, ISerializable
{
public string CustomErrorProperty { get; set; }
@albertospelta
albertospelta / install-spark-anaconda-ubuntu-1804LTS.sh
Last active May 9, 2019 18:43
Install Spark standalone and Anaconda distribution on Ubuntu 18.04 LTS
#!/bin/bash
# Install Spark and Anaconda distribution on Ubuntu 18.04 LTS
sudo apt-get update && sudo apt-get upgrade
# install oracle jdk
sudo add-apt-repository ppa:webupd8team/java
sudo apt update && sudo apt install oracle-java8-set-default
@albertospelta
albertospelta / zenburn-theme.xml
Created October 13, 2017 15:27
Zenburn-like style for Notepad++
<?xml version="1.0" encoding="Windows-1252" ?>
<!--
File name: Zenburn.xml
Style Name: Zenburn
Description: Zenburn-like style for Notepad++.
Inspired by the original Zenburn colorscheme for Vim by Jani Nurminen.
Official Vim Zenburn home page: http://slinky.imukuppi.org/zenburnpage/
Supported languages: All the languages supported by release 5.6.4
Created by: Jani Kesänen (jani dot kesanen gmail com)
Released: 12.01.2010
@albertospelta
albertospelta / chocolatey-setup-env.ps1
Last active November 15, 2017 12:42
My @chocolateynuget install
Set-ExecutionPolicy Bypass
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install googlechrome /y
choco install notepadplusplus /y --x86
choco install visualstudio2017community /y
choco install visualstudiocode /y --params '"/NoDesktopIcon"'
choco install sql-server-management-studio /y
choco install 7zip /y
choco install conemu /y
@albertospelta
albertospelta / SSASEventStreamSample.cs
Last active October 5, 2024 21:11
Collect streaming xEvents with C#
namespace SSASEventStreamSample
{
using Microsoft.AnalysisServices.AdomdClient;
using Microsoft.SqlServer.XEvent.Linq;
using System;
using System.Data;
using System.Xml;
class Program
{