Moved gist to a repo: UNT-CAS/Update-VSCode
View interfaces
This file contains 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
# This file describes the network interfaces available on your system | |
# and how to activate them. For more information, see interfaces(5). | |
source /etc/network/interfaces.d/* | |
# The loopback network interface | |
auto lo | |
iface lo inet loopback | |
# The primary network interface |
View Django: User Email Validation without a DB
This file contains 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
C:\Temp>env\Scripts\python.exe manage.py shell | |
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32 | |
Type "help", "copyright", "credits" or "license" for more information. | |
(InteractiveConsole) | |
>>> from myapp.settings import EMAIL_KEY_EXPIRY_TIME | |
>>> from user.helpers import signing_dumps_w_entropy, signing_loads_w_entropy, get_uri | |
>>> import urllib.parse | |
>>> | |
>>> email = 'VertigoRay@example.com' | |
>>> key = signing_dumps_w_entropy(email) |
View CloudStation_Rename_Errors.ps1
This file contains 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
[System.Collections.ArrayList] $already_done = @() | |
Get-Content .\AppData\Local\CloudStation\log\daemon.log -Wait | ?{ $_ -match '\[ERROR\]' } | %{ | |
$_ -match '(\\Users\\[^\\]+\\CloudStation\\[^\]]+)' | Out-Null | |
if ($Matches[1] -and ($already_done -inotcontains $Matches[1])) { | |
Write-Host ($Matches[1] | Out-String) | |
Rename-Item (Resolve-Path $Matches[1]) "_$(Split-Path $Matches[1] -Leaf)" | |
while (-not (Test-Path $Matches[1])) { | |
Start-Sleep -Seconds 1 | |
} | |
Remove-Item "$(Split-Path $Matches[1] -Parent)\_$(Split-Path $Matches[1] -Leaf)" -Force |
View ForEachSpeeds.Tests.ps1
This file contains 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
<# | |
Invoked the test with the following command, so that I could save the times take the average of each Context: | |
```posh | |
Invoke-Pester -OutputFile test.xml -OutputFormat NUnitXml | |
``` | |
Then I did some math on the results as shown (yes, I use pipelines when not scripting): | |
```posh |
View Pause.ps1
This file contains 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 | |
Mimics the command prompt Pause command. | |
.DESCRIPTION | |
Powershell doesn't have a Pause command that Prompts the user with "Press any key to continue..." and waits for a response. | |
This brings that command to PowerShell and allows you to customize the message. | |
.PARAMETER Message | |
The paused Message can be customzied by passing a string. | |
.INPUTS |
View Get-FileEncoding.ps1
This file contains 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 | |
Gets file encoding. | |
.DESCRIPTION | |
The Get-FileEncoding function determines encoding by looking at Byte Order Mark (BOM). | |
Based on port of C# code from http://www.west-wind.com/Weblog/posts/197245.aspx | |
.OUTPUTS | |
System.Text.Encoding | |
.PARAMETER Path | |
The Path of the file that we want to check. |
View CatchLineNumbers.ps1
This file contains 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 a { | |
param( | |
[string]$UninstallString = 'thing' | |
) | |
$MyInvocation | |
Write-Host -Fore Cyan "$($here.File) $($MyInvocation.MyCommand):$($MyInvocation.ScriptLineNumber)" | |
b | |
try { | |
Throw('Thing!!!!') |
View Write-Json
This file contains 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 Write-Json { | |
param( | |
[Parameter( | |
Mandatory=$true, | |
HelpMessage = "Json object to be printed out in human readable format." | |
)][PSCustomObject]$Json, | |
[int]$tab=1, | |
[bool]$array=$false | |
) |
View pre-commit
This file contains 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/sh | |
# Line to test if POSH is even executing | |
/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command "Get-Location | Out-File C:\Temp\test.txt" | |
if /c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command "If ((Get-AuthenticodeSignature .\install.ps1).Status -ne 'Valid') { Exit 1 }" | |
then | |
cat <<\EOF | |
The install.ps1 file has a valid signature. | |
EOF |
NewerOlder