Skip to content

Instantly share code, notes, and snippets.

@krokofant
krokofant / Use-Kubectl.ps1
Created Jun 13, 2022
Easily change between kubectl versions on PowerShell
View Use-Kubectl.ps1
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
View git powershell eol stats.ps1
$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 Oct 25, 2018
Perform name changes with git (git mv) recursively with PowerShell
View GitChangeFileExtension.ps1
Get-ChildItem -Recurse -Include *.js | % { git mv --dry-run $_.FullName $_.FullName.replace
(".js",".ts") }
@krokofant
krokofant / android-magisk-root-certificate.md
Created Nov 21, 2017
Certificate installation as system with the use of Magisk
View android-magisk-root-certificate.md
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"
View OxygenOS CallFix.xml
<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 Sep 22, 2016
AHKScript to add Volume Controls for Apple Keyboard for Windows
View VolumeAppleKeyboard.ahk
#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