Skip to content

Instantly share code, notes, and snippets.

Chris Hunt cdhunt

Block or report user

Report or block cdhunt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pestergenerator.ps1
#requires -Module NameIt
while ($true) {
$tc = Get-Random -Minimum 1 -Maximum 15
$t = 0
$c=ig "[noun]"
Write-Host "`t Context $c" -ForegroundColor Green
@cdhunt
cdhunt / downloadsgenerator.ps1
Last active Jan 23, 2018
Download Simulator
View downloadsgenerator.ps1
#requires -Module NameIt
while ($true) {
$limit = Get-Random -Minimum 500 -Maximum 4000
$t = 0
$p = 0
$r=ig "[adjective]-[noun]_v#.#.##."
$r += @('zip', 'exe', '7zip') | Get-Random
while($p -lt 100) {
@cdhunt
cdhunt / snapdrive.psm1
Created Sep 27, 2017
NetApp Windows Unified Host Utilities DSC Resource
View snapdrive.psm1
function Get-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[parameter(Mandatory = $true)]
[System.String]
$Path,
View Should-Volume.ps1
function ArchitestVolumeHaveSizeRemaining([Microsoft.Management.Infrastructure.CimInstance]$ActualValue, $ExpectedValue, [switch] $Negate)
{
$ActualValuePropertyValue = $ActualValue | Select-Object -ExpandProperty SizeRemaining
[bool] $succeeded = $ActualValuePropertyValue -gt $ExpectedValue
if ($Negate) { $succeeded = -not $succeeded }
$failureMessage = ''
if (-not $succeeded)
@cdhunt
cdhunt / .hyper.js
Last active Mar 16, 2017
Hyper config
View .hyper.js
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 14,
// font family with optional fallbacks
fontFamily: '"Fira Code", monospace',
uiFontFamily: '"Fira Code", monospace',
@cdhunt
cdhunt / Maybe.ps1
Last active Jan 10, 2017
Messing around with a filter function that is a mashup of Where-Object and If/Then. It might be a solution looking for a problem, but it's also fairly versatile. Do you see any value in it?
View Maybe.ps1
function Where-ObjectMaybe
{
[CmdletBinding(DefaultParameterSetName='Just')]
[Alias('Maybe')]
Param
(
[Parameter(ValueFromPipeline=$true,
Position=4)]
$InputObject,
@cdhunt
cdhunt / attr.ps1
Created Jan 3, 2017
Example usage of Custom Attributes
View attr.ps1
. "$PSScriptRoot\attr_common.ps1"
class PowerShellExecutable : Executable
{
[ExecutableArgument('File')]
[string]$File
[ExecutableArgument('Password', $true)]
[string]$Password
@cdhunt
cdhunt / madlib.ps1
Last active Nov 14, 2016
An example of using NameIt for madlibs.
View madlib.ps1
$customData = @{mword = echo money memory music mammoth; dword = echo data drive distance dance dude dog; adverb = echo badly carefully little much worse less more worst least most}
$madlib = @"
If you want to become [noun] literate, here are some key
[noun]s that you should [verb] as quickly as possible:
CD ROM: Stands for compact [dword]... read only
[mword]. This compact disc can hold as many as 600
[noun]s, which is the equivalent of 700 floppy [noun]s.
@cdhunt
cdhunt / map_fold.ps1
Created Oct 27, 2016
Map and Fold implementations in Powershell
View map_fold.ps1
function map([scriptblock]$map, [Collections.IEnumerable]$x, $y) { $x.ForEach({& $map $_ $y}) }
# Two parameters
map { param($x, $y) $x + $y } @(1,2,3) 10
# Anonymous function as a value
$squareIt = { param($x) $x + $x }
map $squareIt @(1,2,3)
# One parameter
@cdhunt
cdhunt / Microsoft.PowerShell_profile.ps1
Created Oct 3, 2016
Create and set a random "Session Name" in the PowerShell Console Title
View Microsoft.PowerShell_profile.ps1
Import-Module posh-git
Import-Module NameIt
function Test-Administrator {
return ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
}
##### Console Title ######
$SessionTitleName = Invoke-Generate '[Adjective][Noun]'
You can’t perform that action at this time.