Skip to content

Instantly share code, notes, and snippets.

View MarkTiedemann's full-sized avatar

Mark Tiedemann MarkTiedemann

View GitHub Profile
@MarkTiedemann
MarkTiedemann / pid-cpu.vbs
Last active May 3, 2017 09:11
CPU percentage of a process
' cscript.exe //B //NoLogo pid-cpu.vbs
set fs = createObject("Scripting.FileSystemObject")
set stdout = fs.getStandardStream(1)
' https://msdn.microsoft.com/en-us/library/aa393838(v=vs.85).aspx
set refresher = createObject("WbemScripting.SWbemRefresher")
set namespace = getObject("winmgmts:root\cimv2")
' https://msdn.microsoft.com/en-us/library/aa394323(v=vs.85).aspx
set perfdata = refresher.addEnum(namespace, "Win32_PerfFormattedData_PerfProc_Process").objectSet
'bc'.replace('', 'a') // => 'abc'
@MarkTiedemann
MarkTiedemann / dim-files-regex.ps1
Last active June 27, 2017 21:08
Build `Dim Files on Github` Regex
# PowerShell command to build a regex for Dim Files on Github
# see: https://github.com/bfred-it/dim-files-on-github
# README
#
# Copy-and-paste the lines below into your PowerShell.
# Then hit enter: The built regex will be copied to your
# clipboard automatically.
'^\.', `
@MarkTiedemann
MarkTiedemann / functionapps.ps1
Created July 11, 2017 23:03
List Azure Function Apps
$sites = az resource list --resource-type=Microsoft.Web/sites | convertfrom-json
$functionapps = $sites | where -property kind -eq functionapp
@MarkTiedemann
MarkTiedemann / AZURE_FUNCTIONS_COSTS.md
Last active July 18, 2017 00:40
Simple Azure Functions Cost Calculator

Live Demo: https://repl.it/J6L1/0

// --------- PARAM ---------

const invocations = _`100_000_000`
const avgRuntimeInSec = 0.5
const avgMemoryInMb = 256

// --------- CALC ---------
@MarkTiedemann
MarkTiedemann / pull-all.ps1
Created August 17, 2017 12:25
Git pull all subdirectories
ls -dir | % {
cd "$_"
write-host "~ $_" -foregroundcolor magenta
git pull
cd ..
}
<#
PS dir> .\pull-all.ps1
~ subdir1
@MarkTiedemann
MarkTiedemann / docker-rm-all.ps1
Last active August 23, 2017 02:51
Remove all docker containers and images in Powershell
(docker ps -q -a).split('\n') | % { docker rm $_ }
(docker images -q -a).split('\n') | % { docker rmi $_ }
get-dnsclientserveraddress |
where { $_.InterfaceAlias -like "*(DockerNAT)" } | % {
set-dnsclientserveraddress `
-interfaceindex $_.InterfaceIndex `
-serveraddresses @("8.8.8.8", "8.8.4.4")
}
@MarkTiedemann
MarkTiedemann / hosts.cmd
Last active August 24, 2017 20:13
Manage Windows hosts file from command line
@echo off
powershell -f %~dp0hosts.ps1 %1 %2 %3
@MarkTiedemann
MarkTiedemann / USAGE.md
Created August 31, 2017 15:54
Get build minutes of a Bitbucket repository
λ set BITBUCKET_USERNAME=me
λ set BITBUCKET_PASSWORD=secret
λ buildmins org/repo
42