Skip to content

Instantly share code, notes, and snippets.

param (
[string]$Prompt
)
if (-not $Prompt) {
$Prompt = ""
while ($true) {
$line = Read-Host ">"
if (-not $line) { break }
$Prompt += $line + "`n"
@eugrus
eugrus / freepbx17-install-2024.09.26-18.58.38.log
Created September 26, 2024 20:37
Test install of FreePBX 17 on a Debian 12 LXC container on Proxmox VE 7
2024-09-26 18:58:38 - ###############################
2024-09-26 18:58:38 - wget already present ....
2024-09-26 18:58:38 - ###############################
2024-09-26 18:58:38 - Performing version check...
--2024-09-26 18:58:38-- https://github.com/FreePBX/sng_freepbx_debian_install/raw/master/sng_freepbx_debian_install.sh
@eugrus
eugrus / gui.ps1
Created September 24, 2024 15:17
Boilerplate to load a WPF GUI from XAML
Add-Type -AssemblyName PresentationFramework
$inputXAML=Get-Content -Path "$PSScriptRoot\gui.xaml" -Raw
$inputXAML=$inputXAML -replace 'mc:Ignorable="d"','' -replace "x:N","N" -replace '^<Win.*','<Window'
[XML]$XAML=$inputXAML
$xamlReader = (New-Object System.Xml.XmlNodeReader $XAML)
$window = [Windows.Markup.XamlReader]::Load($xamlReader)
$window.ShowDialog()
@eugrus
eugrus / libinspect.ps1
Last active September 21, 2024 16:24
Gives a look into objects inside a .NET assembly
param ([string]$dllname)
Add-Type -Path "$dllname"
$classes = [System.Reflection.Assembly]::LoadFile("$dllname").GetTypes() | Where-Object {$_.IsClass}
foreach ($class in $classes) {
Write-Host "- Class: $($class.FullName)"
$fields = $class.GetFields()
if ($fields.Count -gt 0) {
# Get the file path
param(
[string]$filePath
)
$filePath = Resolve-Path -Path $filePath
# Ensure the file exists
if (-not (Test-Path $filePath)) {
param ([string]$pathToInsertableTemplate)
# Преобразуем путь к источнику в полный путь
$pathToInsertableTemplate = Resolve-Path -Path $pathToInsertableTemplate
# Получаем активный экземпляр Word
$msword = [System.Runtime.Interopservices.Marshal]::GetActiveObject("Word.Application")
# Сохраняем ссылку на активный документ
$activeDocument = $msword.ActiveDocument
param (
[string]$findText,
[string]$replacewithText
)
$msword = [System.Runtime.Interopservices.Marshal]::GetActiveObject("Word.Application")
# https://learn.microsoft.com/ru-ru/office/vba/api/word.find.execute
$MatchCase = $false
$MatchWholeWord = $true
@eugrus
eugrus / WikiDataMovieByActors.sparql
Created March 30, 2024 18:13
Search for movies on WikiData by the actors who played in them.
SELECT ?film ?filmLabel
WHERE {
?actor1 rdfs:label "Jennifer Aniston"@en.
?actor2 rdfs:label "Adam Sandler"@en.
?film wdt:P161 ?actor1, ?actor2.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
@eugrus
eugrus / newdoc.sh
Created March 6, 2024 14:36
Create a new document in LibreOffice Writer, using an existing one as a template.
libreoffice --writer --infilter="writer8_template" $1