Skip to content

Instantly share code, notes, and snippets.

@ThePVD
ThePVD / postmanEmptyCellsDeleter.js
Created July 9, 2021 02:15 — forked from Mondonno/postmanEmptyCellsDeleter.js
Empty JSON cells deleter (can be used in Postman prerequests)
const deleteEmptyValues = (body) => {
let obj = {};
let keys = (bb) => (!Object.keys(bb).length && Object.keys(bb).length !== undefined)
typeof body === 'string' ? body = JSON.parse(body) : null;
for (const key in body) {
let skip = [false];
if (body.hasOwnProperty(key))
if ((body[key] !== false && !body[key]) || (body[key].length !== undefined && !body[key].length)) { skip[0] = true; }
else
if (typeof body[key] === 'object') {
# stolen from http://woshub.com/powershell-get-folder-sizes/
gci -force . -ErrorAction SilentlyContinue | ? { $_ -is [io.directoryinfo] } | % {
$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length }
$_.fullname, '{0:N2} GB' -f ($len / 1Gb)
}
@ThePVD
ThePVD / formatephemeral.ps1
Last active May 5, 2020 22:26
Powershell: Windows EC2 - find and format an ephemeral NVMe drive if not already active
#This script will identify a single ephemeral disk presented to windows and format it w/64k blocksize and TEMPORARY label.
#Created by DTH 5/4/20
#Identify disk with Friendly Name indicating Ephemeral
$disknum = get-disk |where-object {$_.FriendlyName -eq 'NVMe Amazon EC2 NVMe'}| select-object -ExpandProperty Number
#Check to make sure disk is RAW, if so format / label
$operationalstatus = get-disk $disknum | Select-Object -ExpandProperty OperationalStatus
$partitionstyle = get-disk $disknum | Select-Object -ExpandProperty PartitionStyle
if ( $partitionstyle -eq 'RAW' ) {
{
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Sql/servers/firewallRules"
},
{
"anyOf": [
{
@ThePVD
ThePVD / devlogin.ps1
Created December 12, 2018 21:18
Azure Powershell device login (utilize SSO when credentials are not known)
$clientId = "1950a258-227b-4e31-a9cf-717495945fc2" # This is the standard Client Identifier for Windows Azure PowerShell
$redirectUrl = [System.Uri]"urn:ietf:wg:oauth:2.0:oob" # This is the standard Redirect URI for Windows Azure PowerShell
$tenant = "tenantid.onmicrosoft.com" # Substitute tenant ID here
$resource = "https://management.azure.com";
$serviceRootURL = "https://graph.windows.net/$tenant"
$authUrl = "https://login.microsoftonline.com/$tenant";
$postParams = @{resource="$resource";client_id="$clientId"}
$response = Invoke-RestMethod -Method POST -Uri "$authurl/oauth2/devicecode" -Body $postParams
Write-Host $response.message

Keybase proof

I hereby claim:

  • I am thepvd on github.
  • I am thepvd (https://keybase.io/thepvd) on keybase.
  • I have a public key ASC33xVVsmgsvoyN0CXxDdF6HsQcYuwkWSZEJLOVUJZU2go

To claim this, I am signing this object:

/**
* ps_Nest Thermostat
*
* Copyright 2014 Patrick Stuart
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*