Skip to content

Instantly share code, notes, and snippets.

@DBremen
DBremen / ConvertTo-LocalTime.ps1
Created Jun 29, 2020
Function to convert a remote time zone into a local time
View ConvertTo-LocalTime.ps1
class DateTransformAttribute : System.Management.Automation.ArgumentTransformationAttribute {
# property to take additional format strings for transformations
[string[]]$AdditionalFormatStrings
# default constructor:
DateTransformAttribute() : base() { }
# 2nd constructor with parameter AdditionalFormatStrings
DateTransformAttribute([string[]]$AdditionalFormatStrings) : base() {
@DBremen
DBremen / customArgumenTransformationAttribute_DateTime_example.ps1
Created Jun 29, 2020
PowerShell custom ArgumentTransformation attribute for DateTime example
View customArgumenTransformationAttribute_DateTime_example.ps1
# define a format that is supported by our attribute
$stringDate = '4/14 4:12PM'
# try it first with the normal datetime type
[datetime]'4/14 4:12PM'
# this threw an error
# define a variable that utilizes the attribute
[datetime][DateTransform()]$dt = $stringDate
# no error
$dt
@DBremen
DBremen / customArgumenTransformationAttribute_DateTime.ps1
Last active Jun 29, 2020
PowerShell custom argument transformation attribute for DateTime
View customArgumenTransformationAttribute_DateTime.ps1
class DateTransformAttribute : System.Management.Automation.ArgumentTransformationAttribute {
# property to take additional format strings for transformations
[string[]]$AdditionalFormatStrings
# default constructor:
DateTransformAttribute() : base() { }
# 2nd constructor with parameter AdditionalFormatStrings
DateTransformAttribute([string[]]$AdditionalFormatStrings) : base() {
@DBremen
DBremen / parseExact.ps1
Created Jun 29, 2020
DateTime.parseExact example
View parseExact.ps1
[datetime]::ParseExact('08|12|2009 4:33 PM','dd|MM|yyyy h:m tt',$Null)
#returns Tuesday, December 8, 2009 4:33:00 PM on an English system
@DBremen
DBremen / test.ps1
Last active Jun 28, 2020
Custom ArgumentCompleter attribute
View test.ps1
Param(
[Parameter(Mandatory)]
[ArgumentCompleter(
{
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
$allTimezones = Get-TimeZone -ListAvailable | Group-Object DisplayName -AsHashTable -AsString
$allTimezones.GetEnumerator() | Where-Object { $_.Name -like "*${wordToComplete}*" } |
Sort-Object { $_.Value.Displayname }-Unique | ForEach-Object {
New-Object System.Management.Automation.CompletionResult (
"'$($_.Value.Id)'",
View complex numbers.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View algebra2.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Matrix visualization.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View graphs and plots.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Refactoring polynomials.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.