Skip to content

Instantly share code, notes, and snippets.

@mattia72
mattia72 / Get-ReplacedContent.ps1
Last active March 21, 2025 09:44
Replace file content in a range with ripgrep
$r = @{
Pattern = '(some)?text';
Replacement = 'some other text';
StartLine = 3553;
EndLine = 6236;
File = '\file.txt'
RgArgs = @(
'--case-sensitive',
'--encoding=windows-1252',
'--crlf',
@mattia72
mattia72 / download-latest-release.ps1
Created March 21, 2025 09:14 — forked from maxkoshevoi/download-latest-release.ps1
Download latest GitHub release via Powershell
$repoName = "PowerShell/PowerShell"
$assetPattern = "*-win-x64.msi"
$extractDirectory = "C:\Users\Public\Downloads"
$releasesUri = "https://api.github.com/repos/$repoName/releases/latest"
$asset = (Invoke-WebRequest $releasesUri | ConvertFrom-Json).assets | Where-Object name -like $assetPattern
$downloadUri = $asset.browser_download_url
$extractPath = [System.IO.Path]::Combine($extractDirectory, $asset.name)
@mattia72
mattia72 / List-DripGrepperVersions.ps1
Last active March 5, 2025 13:10
list DripGrepper version releases
$releasesUri = 'https://api.github.com/repos/mattia72/DRipGrepper/releases'
(Invoke-WebRequest $releasesUri | ConvertFrom-Json).assets | Where-Object name -like DRipExtension* | Select-Object Name
@mattia72
mattia72 / Convert-SvgToBmpWithTransparentBackground.ps1
Created December 27, 2024 17:13
Converts *.svg to *.bmp in current directory with transparent background using imagemagic
Get-ChildItem *.svg |%{&magick.exe -background none $_.FullName "$($_.BaseName).bmp"; Write-Host $_.BaseName}
@mattia72
mattia72 / Export-ScoopListCSV.ps1
Created April 30, 2024 05:28
Create a list of apps installed by scoop
scoop list | %{scoop info $_.Name} | Select-Object -Property Name, Website, Description | Export-Csv -Path .\Desktop\scoopp.csv
(1..10) | %{
Start-Sleep -Milliseconds 200;
Write-Host "`r" "$("{1} {0,-300}" -f ('\','|','/','-')[$i++%4], "$_")".Trim() -NoNewline
};
Write-Host "`rReady"
@mattia72
mattia72 / Compare-Json.ps
Created January 30, 2023 11:04
Powershell compare one-liner json file
$a = $(Get-Content .\schema2.json) -split ','
$b = $(Get-Content .\schema.json) -split ','
Compare-Object -ReferenceObject $a -DifferenceObject $b
@mattia72
mattia72 / AsyncRun -post: Error
Last active November 4, 2022 09:57
AsyncRun -post: Error detected while processing function AsyncRun_Job_OnTimer ... 99_AsyncRun_Job_OnFinish: E107: Missing parentheses
Error E107 raises, if -post function is defined like this
```
command! -bang -bar -nargs=? -complete=file_in_path DelphiMake
\ call delphi#SetDefaultShell()
\| execute 'AsyncRun'.<bang>.' -post='.fnameescape('call delphi#PostBuildSteps()').' -auto=make -program=make @ /p:config='.g:delphi_build_config.' '.delphi#FindProject(<f-args>))
\| call delphi#RestoreOrigShell()
```
Error disapears if function call has g: prefix and between () has a space
```
execute 'AsyncRun'.<bang>.' -post='.fnameescape('call g:delphi#PostBuildSteps( )').' -auto=make -program=make @ /p:config='.g:delphi_build_config.' '.delphi#FindProject(<f-args>))
@mattia72
mattia72 / gist:846a4622537187ee06090d8ca8625a39
Created July 10, 2021 06:05
block ascii art neovim logo
vim.g.dashboard_custom_header = {
' ▒ ',
' ░▓▓▓ ▓▓▓ ',
' ▒▓▓▓▓▓▓▒ ░▓▓▓▓ ',
' ▒▓▓▓▓▓▓░░░░ ▓▓▓▓▓▓▒ ▓▓▓▓ ',
'▓▓▓▒▓▓▓▓▒▒▒▒▒ ▓▓▓▓▓▓▓▓ ',
'▓▓▓▓▓▒▓▓▓▓▓▓▓▓▒ ░▓▓▓▓▓▓▓ ▒ ▓▓▒▒ ▒▒▓▒ ▒▓▓▒▒ ▓▓▓▓ ▒▓▓▓ ▓▓▓▓ ▓▓▓ ░▓▓▓▓▒ ░▓▓▓▓▓▓ ',
'▓░░░░░▒▓▓▓▓▓▓▓▓▓ ░▓▓▓▓▓▓▓ ▓▓▓░ ▓▒ ▓▓ ░▓ ░▓▓ ░▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓ ▓▓▓▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▒',
'▓▒▒▒▒▒▒▒░░░░░░░░▓ ░▓▓▓▓▓▓▓ ▓▓ ▓░ ▓░ ▓░ ▓▓ ▓▓ ▓▓▓▓ ▓▓▓░ ▓▓▓▓ ▓▓▓▓ ░▓▓▓▒ ▒▓
SX. ;8.
. . . :S8@.: . . . . . . . %8 S. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. :S8@@@@ % . . %888%@ . . . . . . . . . . . . . . . .
.t 8@@8@@8%; . . . . %88:888:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. :@88@8X8@@88%@. . .%8:@X;8 %. . . . . . . . . . . . ::::::. . . .
.8X8@8@88@8@8@@%8