Skip to content

Instantly share code, notes, and snippets.

View ChaseFlorell's full-sized avatar
🇨🇦

Chase Florell ChaseFlorell

🇨🇦
View GitHub Profile
@ChaseFlorell
ChaseFlorell / Add-ToPath.ps1
Created April 13, 2015 18:33
Add a path to your $env:PATH
function Add-ToPath{
param(
[parameter(Mandatory=$true,position=0)][string] $pathToAdd
)
if(-NOT ($env:path.Contains($pathToAdd)))
{
Write-Host "Adding '$pathToAdd' to your Environment Path."
$env:path += ";$pathToAdd"
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $env:path
$apiKey = "Your API Key"
$OctopusURL = "Your Octopus URL"
$Header = @{ "X-Octopus-ApiKey" = $apiKey }
#Getting all machines given an Environment name
$EnvironmentName = Read-Host 'What environment do you want to wipe out?'
Write-Warning "You are about to remove ALL machines from the $EnvironmentName environment."
$confirm = Read-Host 'Are you sure you want to continue? Y/N'
@ChaseFlorell
ChaseFlorell / Get-FullName.ps1
Last active August 29, 2015 14:19
A slick way to do overloads in powershell.
function Get-FullName {
param(
[parameter(position=0, parametersetname="a")] [string] $firstName,
[parameter(position=1, parametersetname="a")] [string] $lastName,
[parameter(position=0, parametersetname="b")] [hashtable] $name
)
if($PSCmdlet.ParameterSetName -eq 'b') {
# Doing recursion will allow for parameter validation if need be!
Get-FullName $name.first $name.last
function Add-Post {
param (
[parameter(Mandatory=$true, Position=0)][string]$post,
[parameter(Mandatory=$false, Position=1)][switch]$draft
)
if(!(Assert-IsGitRepo)) {
throw 'you are currently not in a git repository.'
}
@ChaseFlorell
ChaseFlorell / GridView.cs
Last active August 6, 2017 23:53
Xamarin.Forms GridView
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
namespace TimeTracker.Controls
{
public class GridView : Grid
@ChaseFlorell
ChaseFlorell / invoke-outHtml.ps1
Last active October 9, 2015 01:31
A PowerShell document generator Influenced by Vegard Hamar's [Out-Html](http://poshcode.org/587)
Import-Module MyAwesomeModule
.\out-html.ps1 -moduleName 'MyAwesomeModule' -outputDir "path\to\output"
source ~/.git-completion.bash
source ~/.git-prompt.sh
alias edit='open -a visual\ studio\ code'
alias cd..='cd ..'
alias co='git checkout'
alias pull='git fetch;git pull'
alias chr='open -a Google\ Chrome'
alias projects='cd ~/Projects'
@ChaseFlorell
ChaseFlorell / keybindings.json
Created May 7, 2015 15:29
Visual Studio Code Customizations
[
{ "key": "ctrl+f4", "command": "workbench.action.closeActiveEditor" }
]
@ChaseFlorell
ChaseFlorell / markdown.css
Last active December 26, 2023 19:29 — forked from imjasonh/markdown.css
.md *{
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
.md h1::before { content: "# "; }
@ChaseFlorell
ChaseFlorell / Execute.ps1
Last active July 28, 2021 11:03
Passing switches to child functions within PowerShell
# this is the final (child) function being called
function Invoke-Foo {
[cmdletbinding()]
param([switch] $Custom)
Write-Host 'Hello world'
Write-Verbose 'I''m a verbose message'
Write-Debug 'I''m a debug message' #this will pause execution
if($Custom.IsPresent){
Write-Host 'I''m a custom message'