Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘

Kieranties Kieranties

🤘
View GitHub Profile
@Kieranties
Kieranties / gifterm.ps1
Last active Jun 26, 2019
Hacky script to set gifs as the background to the new Windows Terminal => iwr http://bit.ly/gifterm | iex
View gifterm.ps1
<#
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 Aug 22, 2019
Git Next - Simple alias for presenting when using a git repo - https://blog.kieranties.com/2019/04/06/git-next
View config
[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 Oct 18, 2019
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
View Write-HostExample.ps1
<#
.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 Nov 4, 2016
Get a new guid on your clipboard quickly
View Newguid.ps1
<#
.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 Apr 8, 2015
Test availability of vNext package
View vnextTest.ps1
$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 Aug 29, 2015
Quick and dirty function to download VMs from http://Modern.ie and trigger extraction
View Install-IEVM.psm1
<#
.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 Dec 22, 2016
Simple script to execute commands against the FillDB page in Sitecore 7.2
View Invoke-FillDB-Examples.ps1
# 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 Aug 29, 2015
Copy-ItemWithPath - Copy files while retaining a folder structure
View Copy-ItemWithPath
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 Apr 12, 2018
PS-Pushover Examples
View Pushover-Fib.ps1
<#
.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 Aug 16, 2017
A quick and dirty way of getting data from a csv into MongoDB. Knocked together for #NHTG13
View Import-CsvToMongo.ps1
<#
.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
You can’t perform that action at this time.