Skip to content

Instantly share code, notes, and snippets.

View Splaxi's full-sized avatar

Mötz Jensen Splaxi

  • Essence Solutions P/S
  • Denmark
  • X @splaxi
View GitHub Profile
@Splaxi
Splaxi / vdi-file-compacting.md
Created October 6, 2017 07:01 — forked from kuznero/vdi-file-compacting.md
How to compact VirtualBox's VDI file size?

Source: StackOverflow

1. Run defrag in the guest (Windows only)

2. Nullify free space:

With a Linux Guest run this:

sudo dd if=/dev/zero | pv | sudo dd of=/bigemptyfile bs=4096k
sudo rm -rf /bigemptyfile
@Splaxi
Splaxi / format-cbh.ps1
Last active October 7, 2018 21:56 — forked from potatoqualitee/format-cbh.ps1
reformat and standardize comment based help in powershell
function Get-Header ($text) {
$start = $text.IndexOf('<#')
$temp = $start - 2
if($temp -gt 0) {
$text.SubString(0, $start - 2)
}
else {
""
}
}
@Splaxi
Splaxi / testing examples code
Created October 8, 2018 06:38 — forked from SQLDBAWithABeard/testing examples code
testiong examples code
$Function = 'Get-DbcCheck'
Describe "$Function" {
Context "Checking $Function Examples" {
$Examples = Get-Help $Function -Examples
foreach ($examplecode in $Examples.examples.example.Code) {
It "Example Code $examplecode should not throw" {
{$examplecode} | Should -Not -Throw
}
@Splaxi
Splaxi / gist:6d746acc56f48c3c044ecdee03ab1f08
Created October 8, 2018 07:12 — forked from NakedPowerShell/gist:9711e57e18fa4c4cd0fed148497f900e
Script to generate all the exploration I normally do when I want to install a new PowerShell module
Function Show-ModExplore {
<#
.SYNOPSIS
Generate all the exploration I normally do when I want to install a new PowerShell module
.DESCRIPTION
Script to generate all the exploration I normally do when I want to install a new PowerShell module
@Splaxi
Splaxi / helptest.ps1
Last active October 19, 2018 05:24 — forked from nohwnd/helptest.ps1
Automatic example testing
$excludeCommands = @(
"Invoke-D365SCDPBundleInstall"
)
$commandsRaw = Get-Command -Module d365fo.tools
if ($excludeCommands.Count -gt 0) {
$commands = $commandsRaw | Select-String -Pattern $excludeCommands -SimpleMatch -NotMatch
}
#Fill in the command that you want to generate an pester test for its examples
$commandName = "New-D365SelfSignedCertificate"
#The path where it traverse it's ways to get the file. Filename has to match the commandname
$file = Get-ChildItem -Path "C:\GIT\GITHUB\d365fo.tools.Workspace\d365fo.tools\d365fo.tools" -Recurse -Filter "$commandName.ps1" | Select-Object -First 1
# dot source load the file into current session
. $($file.Fullname)
$sb = [System.Text.StringBuilder]::new()
@Splaxi
Splaxi / Format-CommentBasedHelp.ps1
Last active November 2, 2018 21:28
Format comment based help
$moduleName = "d365fo.tools"
#$path = "C:\GIT\GITHUB\$moduleName.Workspace\$moduleName\$moduleName"
$path = "C:\GITHUB\LocalRepository\$moduleName"
function Get-Header ($text) {
$start = $text.IndexOf('<#')
$temp = $start - 2
if($temp -gt 0) {
$text.SubString(0, $start - 2)
}
@Splaxi
Splaxi / Generate-ParameterUnitTests.ps1
Last active November 2, 2018 21:31
Generate pester tests for parametersets
$moduleName = "d365fo.tools"
#$path = "C:\GIT\GITHUB\$moduleName.Workspace\$moduleName\$moduleName"
$path = "C:\GITHUB\LocalRepository\$moduleName"
Import-Module $path -Force
$excludeCommands = @()
$commandsRaw = Get-Command -Module $moduleName
@Splaxi
Splaxi / Update-Docs.ps1
Last active November 2, 2018 21:32
Update docs
$moduleName = "d365fo.tools"
#$path = "C:\GIT\GITHUB\$moduleName.Workspace\$moduleName\$moduleName"
$path = "C:\GITHUB\LocalRepository\$moduleName"
Import-Module $path -Force
$null = New-MarkdownHelp -Module $moduleName -OutputFolder "$path\docs" -Force
Get-ChildItem -Path "$path\docs" -Recurse -File | Set-PSMDEncoding
Remove-Item "$env:APPDATA\GitHub Desktop\window-state.json" -Force