Skip to content

Instantly share code, notes, and snippets.

View VertigoRay's full-sized avatar
🔌
😏

Raymond Piller VertigoRay

🔌
😏
View GitHub Profile
@VertigoRay
VertigoRay / Get-FileEncoding.ps1
Last active November 24, 2023 20:51
Get-FileEncoding function determines encoding by looking at Byte Order Mark (BOM).
<#
.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.
@VertigoRay
VertigoRay / Test Horizon Connections.md
Last active November 15, 2023 01:35
Test Horizon Connections

Use these scripts to test VMware Horizon client connections. The idea with these simple scripts is that a user might be telling IT staff that "they can't connect" or "it's not working." These are simple scripts that can be run to collect useful information into a TestHorizonConnections.*.log file for sending to the IT staff.

The log file will get automatically created in the users Downloads folder. the * is a timestamp. The file will be named something like this:

  • TestHorizonConnections.2023-11-06T12_19_46.5917880-06_00.log

Windows

@VertigoRay
VertigoRay / ForEachSpeeds.Tests.ps1
Last active August 22, 2021 15:39
Used Pester to do some speed tests, because the comments on my stackoverflow post (http://stackoverflow.com/a/16175967/615422) peaked my interest.
<#
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
@VertigoRay
VertigoRay / init.pp
Created July 17, 2013 20:39
Puppet - sethostname /etc/puppet/modules/common/sethostname/manifests/init.pp
class sethostname {
file { "/etc/hostname":
ensure => present,
owner => root,
group => root,
mode => 644,
content => "$::fqdn\n",
notify => Exec["set-hostname"],
}
exec { "set-hostname":
@VertigoRay
VertigoRay / interfaces
Created July 11, 2017 05:38
Ubuntu Server: Bonding Adaptive Load Balancing
# 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
@VertigoRay
VertigoRay / Update-VSCode.md
Last active June 16, 2018 00:49
Changed my mind and made this a repo: https://untcas.page.link/L8tc
@VertigoRay
VertigoRay / Install.vbs
Last active February 23, 2017 06:00
This is a simple Install Wrapper. I use it with SCCM 2012 to allow STDOUT to be captured and sent to a log file, since STDOUT appears to be lost when deploying software as an SCCM 2012 Application.
Option Explicit
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' FIRST THINGS FIRST:
' Change this DeploymentTypeName to match the Deployment Type Name used in the Application.
' - It's just used to for the log file name.
' - For Uninstall action, append ".x" to name, such as: Application - Install.x
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim DeploymentTypeName
DeploymentTypeName = "CAS Remote - Install"
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@VertigoRay
VertigoRay / CatchLineNumbers.ps1
Last active January 15, 2017 06:01
The `$MyInvocation.ScriptLineNumber` variable is not the Current Line Number. It’s the Line number from where the function that you’re in was called. Actual line numbers can be caught for an error if you catch them. Used in this comment: http://goo.gl/7oeSEL
function a {
param(
[string]$UninstallString = 'thing'
)
$MyInvocation
Write-Host -Fore Cyan "$($here.File) $($MyInvocation.MyCommand):$($MyInvocation.ScriptLineNumber)"
b
try {
Throw('Thing!!!!')
@VertigoRay
VertigoRay / InstallFirefox.ps1
Last active June 8, 2016 15:31
You'll want to sign the code so you can run it without changing the execution policy to unrestricted. Sample Usage: InstallFirefox.ps1 22.0 http://go.vertigion.com/PowerShell-InstallFirefox
Param (
[parameter(
Position = 0,
Mandatory = $true,
HelpMessage = 'This is the version number, such as "22.0". Valid version numbers can be found here: http://mzl.la/1c9hPmo'
)]
[string] $version,
[parameter(
Position = 1,
Mandatory = $false,
@VertigoRay
VertigoRay / Django: User Email Validation without a DB
Last active May 17, 2016 03:27
Typically, when you want to validate an e-mail address, you store an activation key and expiration date in the user profile table. So you can validate it one time. Then what? Just keep storing it forever? Clear it out and have the empty columns? I wanted a disposable key that didn't have to be stored in a database. This is my solution ... http:/…
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)