Skip to content

Instantly share code, notes, and snippets.

View theTonyHo's full-sized avatar

Tony Ho theTonyHo

View GitHub Profile
# Reference: https://ss64.com/ps/syntax-elevate.html
# Place this in beginning of script
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
# Relaunch as an elevated process:
Write-Host "Executing Script as Administrator" -ForegroundColor Green
Start-Process powershell.exe "-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs
exit
}
Write-Host "Executing script"
@theTonyHo
theTonyHo / autoVersion.csproj
Last active March 28, 2023 15:39
MSBuild AutoVersion using Regex
<!-- reference: https://stackoverflow.com/questions/2982559/extract-number-from-string-in-msbuild -->
<!-- source: https://gist.github.com/theTonyHo/e346d59a886433cccd990800f1cefceb -->
<Target Name="NugetPackAutoVersioning" AfterTargets="Build">
<PropertyGroup Condition=" '$(AssemblyVersion)'=='' ">
<AssemblyInfo>$(MSBuildProjectDirectory)\Properties\AssemblyInfo.cs</AssemblyInfo>
<AssemblyInfoContent>$([System.IO.File]::ReadAllText('$(AssemblyInfo)'))</AssemblyInfoContent>
<Pattern>\[assembly: AssemblyVersion\("(\d+.\d+.\d+.\d+)</Pattern>
<AssemblyVersion>$([System.Text.RegularExpressions.Regex]::Match($(AssemblyInfoContent), $(Pattern), System.Text.RegularExpressions.RegexOptions.Multiline).Groups[1].Value) (From $(AssemblyInfo))</AssemblyVersion>
</PropertyGroup>
<PropertyGroup>
@theTonyHo
theTonyHo / Readme.md
Last active February 11, 2020 00:58
Coordinate Reference Systems

To create a projection with custom origin, modify "natural origin" parameters i.e.

        PARAMETER["Latitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8801]],
        PARAMETER["Longitude of natural origin",0,
            ANGLEUNIT["degree",0.0174532925199433],
            ID["EPSG",8802]],
@theTonyHo
theTonyHo / index.html
Last active November 20, 2019 06:00 — forked from d3noob/.block
Interactive d3.js tree diagram
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tree Example</title>
<style>
.node {
@theTonyHo
theTonyHo / Readme.md
Last active November 19, 2019 22:07
D3 Tree interactive visualisation

READ ME

@theTonyHo
theTonyHo / DeleteAllKernels.ipynb
Created October 8, 2019 04:25
Jupyter Delete All Kernels
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@theTonyHo
theTonyHo / custom.css
Last active October 8, 2019 04:20
Install custom.css to Jupyter Notebook
/* Hide relevant elements */
#header, #menubar-container, div.input, div.run_this_cell, div.prompt {
display: none;
}
/* Output to expand to 100% if div.run_this_cell is hidden */
div.output_subarea {
max-width: 100%;
}
@echo off
REM SOURCE:
REM http://stackoverflow.com/questions/19467792/batch-command-line-to-eject-cd-tray/28422571#28422571
echo Set oWMP = CreateObject("WMPlayer.OCX.7") >> %temp%\temp.vbs
echo Set colCDROMs = oWMP.cdromCollection >> %temp%\temp.vbs
echo For i = 0 to colCDROMs.Count-1 >> %temp%\temp.vbs
echo colCDROMs.Item(i).Eject >> %temp%\temp.vbs
echo next >> %temp%\temp.vbs
echo oWMP.close >> %temp%\temp.vbs
Function GetProperty(fileFolder As String, fileName As String, strName As String)
'All properties are saved in an array so that the actual name of the _
'property can be found in lieu of using the numbered index of the property.
'REFERENCE: https://social.msdn.microsoft.com/forums/en-US/873cfe9f-13fe-4d2f-ad52-af020eaa0f7f/find-the-title-of-a-pdf-document
'
'AVAILABLE PROPERTIES:
'SIZE
'ITEM TYPE
'DATE MODIFIED
'DATE CREATED

VMWare CLI SSH Commands

Create Virtual Disk

This will create a thin 0.01GB vmdk file. vmkfstools --createvirtualdisk 0.01G --diskformat thin FS-18XX.vmdk

Convert VMDK to Thin