Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/bin/bash | |
gunzip < $1 | mysql -uUSER -pPASSWORD --database=DATABASENAME |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

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 | |
Template of Function which takes any number of parameters | |
.DESCRIPTION | |
Template of Function which takes any number of parameters. | |
Function has default parameter block $defaults which can be overridden by command line parameters. | |
Function accumulates command line parameters and merges them with default parameters to the $__ENV.env hashtable. |
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 | |
Merges any number of hashtables into one | |
.DESCRIPTION | |
Merges any number of hashtables taken both from pipeline and arguments, with the hashtables in the right overwriting the keys with the same names from hastables in the left | |
.EXAMPLE | |
$a = @{a = 'a1'; b = 'a2'} | |
$b = @{b = 'b1'; c = 'b2'} | |
$c = @{c = 'c1'; d = 'c2'} |
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 | |
# Reads and evaluates Hastable object from file | |
# | |
# .DESCRIPTION | |
# Reads and evaluates Hastable object from file. As example you can read Module manifest | |
# file (*.psd1) as Hashtable object | |
# | |
# .EXAMPLE | |
# PS C:> Get-Module | Where { [IO.Path]::GetExtension($_) -match '.psd1' } | | |
# Select -Last 1 | |
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
<# Determine invocation method: . | & | <script path > | |
https://poshoholic.com/2008/03/18/powershell-deep-dive-using-myinvocation-and-invoke-expression-to-support-dot-sourcing-and-direct-invocation-in-shared-powershell-scripts/ | |
if ($MyInvocation.InvocationName -eq '&') { | |
"Called using operator" | |
} elseif ($MyInvocation.InvocationName -eq '.' -or $MyInvocation.Line -eq '') { | |
"Dot sourced" | |
} elseif ((Resolve-Path -Path $MyInvocation.InvocationName).ProviderPath -eq $MyInvocation.MyCommand.Path) { | |
"Called using path $($MyInvocation.InvocationName)" | |
} |
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
Get-Content SomeFile.ps1 | | |
ForEach { Select-String '(?ix) ^ \s* function \s+ ( [^{( ]+ ) \s* ( \( [^()]+ \) )? \{' -input $_ -Allmatch } | | |
ForEach { $_.Matches.Groups[1].Value } | |
Get-Content SomeFile.ps1 | Select-String '(?i)^function\s+((\w|-)+)' | ForEach { $_.Matches.Groups[1].Value } | |
Get-Content SomeFile.ps1 | | |
ForEach-Object { $_ -match '(?ix) ^ \s* function \s+ ( [^{( ]+ ) \s* ( \( [^()]+ \) )? \{' } | |
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 Test-FilenameValid { | |
PARAM( [PARAMETER( Mandatory )] | |
[String] | |
$filename | |
) | |
# IndexOfAny returns -1 if there is no any characters from argument in the string | |
$filename.IndexOfAny( [System.IO.Path]::GetInvalidFileNameChars() ) -eq -1 |