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
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
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
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
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}--------");
return;
@LanceMcCarthy
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="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Hacked.Forms;assembly=Hacked.Forms"
x:Class="Hacked.Forms.Views.MainPage"
xmlns:telerik="clr-namespace:Telerik.XamarinForms.DataControls;assembly=Telerik.XamarinForms.DataControls"
xmlns:listView="clr-namespace:Telerik.XamarinForms.DataControls.ListView;assembly=Telerik.XamarinForms.DataControls"
xmlns:primitives="clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives"
xmlns:common="clr-namespace:Hacked.Forms.Common;assembly=Hacked.Forms"
xmlns:converters="clr-namespace:Hacked.Forms.Converters;assembly=Hacked.Forms"
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)
{
try
{
//if task already exists, unregister it before adding it
foreach (var task in BackgroundTaskRegistration.AllTasks.Where(cur => cur.Value.Name == taskFriendlyName))
{
task.Value.Unregister(true);
#region Background Task management
private async Task<bool> ConfigureBackgroundTaskAsync()
{
try
{
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
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;
}