Skip to content

Instantly share code, notes, and snippets.

View LanceMcCarthy's full-sized avatar
Bashing __(ง'̀-'́)ง__ bugs

Lance McCarthy LanceMcCarthy

Bashing __(ง'̀-'́)ง__ bugs
View GitHub Profile
LanceMcCarthy / HttpClientExtensions.cs
Last active January 12, 2016 18:28
HttpClient Extension Method to send image byte[] data to API
public static class HttpClientExtensions
/// <summary>
/// Helper method to POST binary image data to an API endpoint that expects the data to be accompanied by a parameter
/// </summary>
/// <param name="client">HttpClient instance</param>
/// <param name="imageFile">Valie StorageFile of the image</param>
/// <param name="apiUrl">The API's http or https endpoint</param>
/// <param name="parameterName">The name of the parameter the API expects the image data in</param>
/// <returns></returns>
LanceMcCarthy / GaussianBlurTool.cs
Created February 19, 2016 16:59
Custom RadImageEditor Win2D GaussianBlur Tool
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Windows.Storage.Streams;
using Windows.UI.Xaml.Media.Imaging;
using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using Telerik.UI.Xaml.Controls.Input.ImageEditor;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel.Core;
LanceMcCarthy / JoeR.txt
Created March 4, 2016 15:36
Copy a table's schema without the data
create table newtable as select TOP 0 * from oldtable
LanceMcCarthy / ExceptionLogger.cs
Created April 29, 2016 15:12
Exception Logger
public class ExceptionLogger
private static readonly int daysToKeepLog = 14;
private static ExceptionLogger current;
public static ExceptionLogger Current => current ?? (current = new ExceptionLogger());
private ExceptionLogger() { }
public static class VoiceCommandUtilites
private static int loadAttempts;
public static async Task InstallVoiceCommandFile()
if (loadAttempts > 0)
Debug.WriteLine($"-------Voice Commands load attempt max reached. loadAttempt: {loadAttempts}--------");
LanceMcCarthy / RadSideDrawerInXamForms
Created June 28, 2016 14:51
This is a straight copy/paste of a Xamarin Forms view where I am using the RadSideDrawer
<ContentPage xmlns=""
BindingContext="{Binding Source={x:Static local:App.ViewModel}}">
public static class TaskHelpers
public static async Task RegisterTaskAsync(string taskFriendlyName, string taskEntryPoint, uint taskRunFrequency, SystemConditionType condition = SystemConditionType.InternetAvailable)
//if task already exists, unregister it before adding it
foreach (var task in BackgroundTaskRegistration.AllTasks.Where(cur => cur.Value.Name == taskFriendlyName))
#region Background Task management
private async Task<bool> ConfigureBackgroundTaskAsync()
vm.IsBusy = true;
vm.IsBusyMessage = "configuring Background Task";
var accessStatus = await BackgroundExecutionManager.RequestAccessAsync();
public class ParallaxWithOpacityBehavior : Behavior<FrameworkElement>
#region DependencyProperties
/// <summary>
/// Gets or sets the element that will parallax while scrolling.
/// </summary>
public UIElement ParallaxContent
get { return (UIElement)GetValue(ParallaxContentProperty); }
LanceMcCarthy / OnTargetPlatform
Created August 12, 2016 16:16
Custom OnPlatform
public class OnTargetPlatform<T> : OnPlatform<T>
public T Windows { get; set; }
public static implicit operator T(OnTargetPlatform<T> onPlatform) => Device.OS == TargetPlatform.Windows ? onPlatform.Windows : (OnPlatform<T>) onPlatform;