Skip to content

Instantly share code, notes, and snippets.

View ChaseFlorell's full-sized avatar
🇨🇦

Chase Florell ChaseFlorell

🇨🇦
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace FutureState.AppCore.Pages
{
public class SegmentTab : ContentPage
{
private Grid _grid;
@ChaseFlorell
ChaseFlorell / Namespace.js
Created October 28, 2014 14:48
Namespacing Javascript
// self executing function keeps code off of the global namespace.
(function() {
// initialize the namespace at the top of your very first code file.
var ns = {};
// begin declaring some classes
// This class is using the OBJECT LITERAL pattern
ns.Class1 = {
@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.'
}
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 / benchmark.ps1
Last active August 29, 2015 14:21
Powershell inner collection iteration performance benchmark
$complexObject = @{
test = "test"
guid = [guid]::NewGuid()
int = [int]::MaxValue
str = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
arr = @(1..100)
}
$complexCollection = @()
$sw = [System.Diagnostics.Stopwatch]::StartNew()
@ChaseFlorell
ChaseFlorell / pipline.test.ps1
Created June 12, 2015 17:45
Powershell Write-Output vs return
clear
function Invoke-First {
Write-Output 'if not piped, will display before Write-Host, if piped, will display after Write-Host'
Write-Host 'Writes every single time invoke-first is called, but is not piped out.'
return 'will not display unless piped or used as a return variable'
}
function Invoke-Second {
param(
[Parameter(ValueFromPipeline=$True)] [string] $val