This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
import atexit | |
from pyVim.connect import SmartConnectNoSSL, Disconnect | |
import pyVmomi | |
from pyVmomi import vim | |
from typing import List, Dict, Union | |
from tabulate import tabulate | |
from getpass import getpass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class NativeMethods | |
{ | |
[DllImport("user32.dll")] | |
private static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, MonitorEnumDelegate lpfnEnum, IntPtr dwData); | |
private delegate bool MonitorEnumDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref Rect2 lprcMonitor, IntPtr dwData); | |
[DllImport("user32.dll")] | |
private static extern bool GetMonitorInfo(IntPtr hwnd, ref MonitorInfo mInfo); | |
[DllImport("Shcore")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Get CDP information from one or more ESX hosts. | |
.PARAMETER VMHost | |
VMHost can be a list of the below entries: | |
- FQDN name of the host | |
- VMware.Vim.HostSystem (return type of 'Get-View -ViewType HostSystem') | |
- VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl (return type of 'Get-VMHost') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ipChangeHandler { | |
Write-Host "Detected an IP change..." | |
Write-Host "Collecting connections information..." | |
$connObjs = New-Object System.Collections.ArrayList | |
$ints = Get-NetIPAddress -AddressFamily IPv4 -PrefixOrigin Dhcp -AddressState Preferred | |
foreach ($int in $ints) { | |
$_alias = $int.InterfaceAlias | |
$_index = $int.InterfaceIndex | |
$_ipaddr = $int.IPAddress | |
$intCfg = $int | Get-NetIPConfiguration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check physical and logical sector size | |
lsblk -o Name,PHY-SEC,LOG-SEC | |
# wipe disk | |
sudo shred -v -n1 -z /dev/sdx | |
# check bad sectors (readonly) | |
sudo badblocks -vs -b 4096 -c 65536 /dev/sdx | |
# check bad sectors and wipe disk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# testing | |
docker run -it --rm busybox sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git checkout --orphan latest_branch # orphan omits all the history | |
git add * # if you want to include all files (respecting gitignore). Otherwise make other changes here. | |
git commit -am "commit message" | |
git branch -D master # delete master branch | |
git branch -m master # rename current branch to master | |
git push -f origin master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//KeyedCollection keeps an internal lookup dictionary for better performance. | |
//With normal implementations of an observable KeyedCollection, when used for | |
//data bindings in WPF, once the key of the item is changed with bindings, the | |
//corresponding key internal dictionary is not changed, which leads to hidden | |
//problems when the dictionary is used. | |
//Below is a custom implementation of KeyedCollection to solve that problem. | |
using System; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; |
NewerOlder