Skip to content

Instantly share code, notes, and snippets.

View ChaseFlorell's full-sized avatar
🇨🇦

Chase Florell ChaseFlorell

🇨🇦
View GitHub Profile
@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
@ChaseFlorell
ChaseFlorell / 1-FunctionTranslator.ps1
Last active August 29, 2015 14:27
First stab at translating functions.
param(
[Parameter(Mandatory=$true, Position=0)]$key
)
Write-Verbose "Attempting to establish new function '$key'"
$keyParts = ($key -split '-')
if($keyParts.length -gt 0){
$validVerb = Get-Verb $keyParts[0]
if(!$validVerb){
Write-Warning "'$($keyParts[0])' is an unapproved verb which might make it less discoverable. Use the Verbose parameter for more detail or type Get-Verb to see the list of approved verbs."
}
@ChaseFlorell
ChaseFlorell / ObservableObject.cs
Created September 25, 2015 15:14
Observable Object for Xamarin Forms
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using Xamarin.Forms; // PropertyChanging event handler, and Command object
namespace Some.Namespace
{
public abstract class ObservableObject : INotifyPropertyChanged
@ChaseFlorell
ChaseFlorell / boxstarter.ps1
Last active November 29, 2015 19:55
2015-boxstarter
Set-ExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOsFiles -showFileExtensions
Enable-RemoteDesktop
choco install agentransack -y
choco install xamarin -y
choco install resharper -y
choco install visualstudio2013professional -y
choco install git -y
choco install poshgit -y
choco install greenshot -y
@ChaseFlorell
ChaseFlorell / LatLong.cs
Created January 27, 2016 18:56
Implicit type example
using System;
namespace Foo.Bar.Baz
{
/// <summary>
/// Allows us to define actual LatLong in our models and have all platforms handle them whether
/// they use float, decimal, or double as their underlying types.
/// </summary>
/// <remarks>Our "opinion" is that at the end of the day, a <see cref="LatLong"/> is simply a <see cref="Double"/></remarks>
public struct LatLong
@ChaseFlorell
ChaseFlorell / HockeyApp.psm1
Created May 22, 2016 21:08
Powershell upload to HockeyApp
#region Private Functions
function Get-AsciiBytes($str){
return [System.Text.Encoding]::ASCII.GetBytes($str)
}
function Write-MultiPartProperty {
param(
[parameter(Mandatory=$true)][System.IO.MemoryStream] $body,
[parameter(Mandatory=$true)][string] $boundary,
[parameter(Mandatory=$true)][string] $key,
@ChaseFlorell
ChaseFlorell / Implementation.cs
Last active June 2, 2016 17:24
Fugly back doors for Xamarin Forms + UITest
app.Invoke("Backdoor", "MyActualMethod")
@ChaseFlorell
ChaseFlorell / android-ndk.ps1
Created June 9, 2016 19:41
Install the Android NDK as part of your PowerShell build. Xamarin Android
$path ='C:\Android\android-ndk'
$ndk = 'android-ndk-r11c'
$fullPath = Join-Path $path $ndk
if(!(Test-Path $fullPath)){
New-Item $path -Force -ItemType directory
(New-Object Net.WebClient).DownloadFile("http://dl.google.com/android/repository/$ndk-windows-x86.zip", "C:\Temp\$ndk-windows-x86.zip")
(new-object -com shell.application).namespace("$path").CopyHere((new-object -com shell.application).namespace("C:\Temp\$ndk-windows-x86.zip").Items(),16)
$regPath = 'HKCU:\Software\Novell\Mono for Android'
$regKey = 'AndroidNdkDirectory'
$regValue = $fullPath
@ChaseFlorell
ChaseFlorell / Localize.cs
Created August 31, 2016 17:34
Xamarin Forms Localization
// iOS
public class Localize : ILocalize
{
private static CultureInfo _currentCulture;
public CultureInfo GetCurrentCultureInfo()
{
if (_currentCulture != null)
{