Skip to content

Instantly share code, notes, and snippets.

View Kieranties's full-sized avatar
🤘

Kieranties Kieranties

🤘
View GitHub Profile
@Kieranties
Kieranties / gifterm.ps1
Last active June 26, 2019 18:52
Hacky script to set gifs as the background to the new Windows Terminal => iwr http://bit.ly/gifterm | iex
<#
iwr http://bit.ly/gifterm | iex
$env:gifq='cats and dogs'; iwr http://bit.ly/gifterm | iex
#>
using namespace System.IO
param(
[string]$Query = ($env:gifq),
[string]$QueryRoot = 'https://giphy.com/search'
)
@Kieranties
Kieranties / config
Last active August 22, 2019 09:42
Git Next - Simple alias for presenting when using a git repo - https://blog.kieranties.com/2019/04/06/git-next
[alias]
start = "!f() { \
baseTag='1'; \
startTag=$1; \
selectedTag=${startTag:-${baseTag:-startTag}}; \
git reset --hard $selectedTag; \
git clean -df; \
git tag -l $selectedTag -n999; \
}; f"
next = "!f() { \
@Kieranties
Kieranties / Write-HostExample.ps1
Last active October 8, 2021 01:15
Write information messages in PowerShell that support colors (like Write-Host) but always honors the context `$InformationPreference variable - https://blog.kieranties.com/2018/03/26/write-information-with-colours
<#
.SYNOPSIS
A simple example of Write-Host
#>
# Displays the message
Write-Host -Object 'Hello'
# Try to silence directly
Write-Host "Still shown :-(" -InformationAction SilentlyContinue
@Kieranties
Kieranties / Newguid.ps1
Last active November 4, 2016 11:19
Get a new guid on your clipboard quickly
<#
.SYNOPSIS
Creates a guid of a specified format and writes to the clipboard
.EXAMPLE
PS> NewGuid
Write a new guid to your clipboard
e.g. 8a3c4316-5865-405d-94b7-5992446b12ce
@Kieranties
Kieranties / vnextTest.ps1
Created April 8, 2015 14:46
Test availability of vNext package
$feedStub = "http://www.myget.org/F/{0}/api/v2/FindPackagesById()?Id='{1}'"
$package = "Microsoft.Framework.Runtime.Roslyn"
$feeds = @("aspnetmaster", "aspnetvnext")
$feeds | % { Invoke-RestMethod -uri ($feedStub -f $_, $package) } | select -ExpandProperty properties | select version
<#
Output
Version
-------
@Kieranties
Kieranties / Install-IEVM.psm1
Last active August 29, 2015 14:05
Quick and dirty function to download VMs from http://Modern.ie and trigger extraction
<#
.EXAMPLE
Get the "Batch File Download" address for the (Hyper-V) VM of your choice from https://modern.ie/en-gb/virtualization-tools#downloads
PS> $source = "https://az412801.vo.msecnd.net/vhd/VMBuild_20141027/HyperV_2012/IE11/Windows/IE11.Win7.For.Windows.HyperV_2012.txt"
PS> $destination = (mkdir "$env:USERPROFILE\downloads\vms" -Force) # or use default
PS> Install-IEVM $source $destination -import # Will import to default locations
#>
Function Install-IEVM {
param(
[Parameter(Mandatory=$true)]
@Kieranties
Kieranties / Invoke-FillDB-Examples.ps1
Last active December 22, 2016 14:26
Simple script to execute commands against the FillDB page in Sitecore 7.2
# Example of running Invoke-FillDB.ps1
# Additional files to download
$downloads= @(
"http://www.gutenberg.org/files/42698/42698-0.txt",
"http://www.gutenberg.org/cache/epub/42705/pg42705.txt",
"http://www.gutenberg.org/cache/epub/42710/pg42710.txt",
"http://www.gutenberg.org/files/42700/42700-0.txt",
"http://www.gutenberg.org/files/42706/42706-0.txt"
)
@Kieranties
Kieranties / Copy-ItemWithPath
Last active August 29, 2015 13:56
Copy-ItemWithPath - Copy files while retaining a folder structure
Function Copy-ItemWithPath {
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
[Alias("FullName")]
[string[]]$item,
[Parameter(Mandatory=$true, Position=1)]
[string]$destination,
[Parameter(Mandatory=$true, Position=2)]
[string]$root
)
@Kieranties
Kieranties / Pushover-Fib.ps1
Last active April 12, 2018 23:53
PS-Pushover Examples
<#
.SYNOPSIS
Calculate a high Fibonnachi number and send a Pushover message
#>
Import-Module PS-Pushover
Start-Job -ScriptBlock {
$current = $previous = 1;
while ($current -lt 1000000000) {
@Kieranties
Kieranties / Import-CsvToMongo.ps1
Last active August 16, 2017 19:19
A quick and dirty way of getting data from a csv into MongoDB. Knocked together for #NHTG13
<#
.NOTES
You'll need the excellent C# driver: http://docs.mongodb.org/ecosystem/drivers/csharp/
#>
Add-Type -Path "c:\mongodb\bin\MongoDB.Bson.dll"
Add-Type -Path "c:\mongodb\bin\MongoDB.Driver.dll"
Function Import-CsvToMongo{
param($path, $dbUrl, $collection, $matchCol) #matchCol is used as a lookup to check if entry is to be added or updated