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.Linq.Expressions;
using System.Reflection;
namespace MiscUtil.Reflection
{
/// <summary>
/// Non-generic class allowing properties to be copied from one instance
/// to another existing instance of a potentially different type.
@ChaseFlorell
ChaseFlorell / Progress.cs
Created April 26, 2017 18:18
How to run two processes simultaneously.
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Utils
{
public static class Progress
{
public static Task ProgressDots(CancellationToken token)
{
@ChaseFlorell
ChaseFlorell / listview.cs.xaml
Created April 21, 2017 18:01
my idea of a xamarin forms listview
<ListView SeparatorWidth="2"
PullToRefreshCommand="{Binding Fetch}"
ItemTappedCommand="{Binding Navigate}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ItemStyles>
<ViewCellItemStyle State="Normal" BackgroundColor="White" SeparatorColor="Red" />
<ViewCellItemStyle State="Pressed" BackgroundColor="Grey" SeparatorColor="Blue" />
<ViewCellItemStyle State="LongPressed" BackgroundColor="Green" SeparatorColor="Pink" />
@ChaseFlorell
ChaseFlorell / FontData.cs
Created April 18, 2017 20:01
Build a formatted string for Xamarin Forms
using System;
using System.Linq;
using Xamarin.Forms;
namespace Helpers
{
public class FontData
{
public double FontSize { get; set; }
public FontAttributes FontAttributes { get; set; }
@ChaseFlorell
ChaseFlorell / TouchableBoxViewRenderer_Droid.cs
Created November 16, 2016 16:57
Xamarin Forms Android Ripple Effect
public class TouchableBoxViewRenderer_Droid : BoxRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e)
{
base.OnElementChanged(e);
if (e.NewElement == null) return;
var attrs = new[] {Android.Resource.Attribute.SelectableItemBackground};
var ta = Context.ObtainStyledAttributes(attrs);
@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)
{
@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 / Implementation.cs
Last active June 2, 2016 17:24
Fugly back doors for Xamarin Forms + UITest
app.Invoke("Backdoor", "MyActualMethod")
@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 / 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