Skip to content

Instantly share code, notes, and snippets.

function Get-IniContent ($filePath) {
$ini = @{}
switch -regex -file $FilePath {
"^\[(.+)\]" { # Section
$section = $matches[1]
$ini[$section] = @{}
$CommentCount = 0
continue
}
"^(;.*)$" { # Comment
@krokofant
krokofant / Show-CameraSettings.ps1
Last active October 25, 2022 16:29
Show camera settings
<# Show camera settings #>
New-Module -ScriptBlock {
function Show-CameraSettings {
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline)]
[ArgumentCompleter({
param (
[string]$CommandName,
[string]$ParameterName,
@krokofant
krokofant / Use-Kubectl.ps1
Created June 13, 2022 11:11
Easily change between kubectl versions on PowerShell
function Use-Kubectl {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline, Mandatory)]
[ArgumentCompleter({
param (
$CommandName, $ParameterName, $WordToComplete, $CommandAst, $FakeBoundParameters
)
$versions = Invoke-RestMethod "https://api.github.com/repos/kubernetes/kubernetes/releases"
$stableVersions = $versions | Where-Object -Property prerelease -EQ $false | Select-Object -ExpandProperty tag_name | ForEach-Object { $_.Substring(1) } | Sort-Object -Descending
$files = git ls-files --eol *.less *.cshtml *.html *.txt *.config *.csproj *.sln *.cs *.js *.ts *.json *.bat *.ps1 --full-name;$files | Group-Object { $_.Split('.')[-1] } | Sort Count -Descending | Format-List @{Label="crlf"; Expression={$_.Group | ? { $_ -match "i/crlf" } | % {$i=0} {$i++} {$i} }},@{Label="lf"; Expression={$_.Group | ? { $_ -match "i/lf" } | % {$i=0} {$i++} {$i} }} -GroupBy @{Name="ext";Expression={"." + $_.Name}}
@krokofant
krokofant / GitChangeFileExtension.ps1
Created October 25, 2018 12:16
Perform name changes with git (git mv) recursively with PowerShell
Get-ChildItem -Recurse -Include *.js | % { git mv --dry-run $_.FullName $_.FullName.replace
(".js",".ts") }
@krokofant
krokofant / android-magisk-root-certificate.md
Created November 21, 2017 21:53
Certificate installation as system with the use of Magisk
hash=$(openssl x509 -inform PEM -subject_hash_old -in charles-ssl-proxying-certificate.pem | head -1)
mv charles-ssl-proxying-certificate.pem "$hash.0"
echo "Download magisk"
wget https://github.com/topjohnwu/magisk-module-template/archive/1400.zip

echo "Put $hash.0 into /system/etc/security/cacerts/"
echo "chmod 644 the file"
echo "zip into module and install"
<TaskerData sr="" dvi="1" tv="4.9u4m">
<Task sr="task2">
<cdate>1497738763230</cdate>
<edate>1499562571055</edate>
<id>2</id>
<nme>CallFix</nme>
<pri>100</pri>
<Action sr="act0" ve="7">
<code>123</code>
<Str sr="arg0" ve="3">settings put global op_voice_recording_supported_by_mcc 1</Str>
@krokofant
krokofant / VolumeAppleKeyboard.ahk
Created September 22, 2016 16:08
AHKScript to add Volume Controls for Apple Keyboard for Windows
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; F16-F9, SC067-SC06A
SC067:: ; Volume Mute
Send {Volume_Mute} ; Mute/unmute the master volume.
return