Skip to content

Instantly share code, notes, and snippets.

Avatar
💾
Bashing __(ง'̀-'́)ง__ bugs

Lance McCarthy LanceMcCarthy

💾
Bashing __(ง'̀-'́)ง__ bugs
View GitHub Profile
@LanceMcCarthy
LanceMcCarthy / HttpClientExtensions.cs
Last active Jan 12, 2016
HttpClient Extension Method to send image byte[] data to API
View HttpClientExtensions.cs
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 Feb 19, 2016
Custom RadImageEditor Win2D GaussianBlur Tool
View GaussianBlurTool.cs
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 Mar 4, 2016
Copy a table's schema without the data
View JoeR.txt
create table newtable as select TOP 0 * from oldtable
View ExceptionLogger.cs
public class ExceptionLogger
{
private static readonly int daysToKeepLog = 14;
private static ExceptionLogger current;
public static ExceptionLogger Current => current ?? (current = new ExceptionLogger());
private ExceptionLogger() { }
View VoiceCommandUtilites.cs
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 Jun 28, 2016
This is a straight copy/paste of a Xamarin Forms view where I am using the RadSideDrawer
View RadSideDrawerInXamForms
<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}}">
View TaskHelpers.cs
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);
View AddAndRemoveTask
#region Background Task management
private async Task<bool> ConfigureBackgroundTaskAsync()
{
try
{
vm.IsBusy = true;
vm.IsBusyMessage = "configuring Background Task";
var accessStatus = await BackgroundExecutionManager.RequestAccessAsync();
View ParallaxWithOpacityBehavior.cs
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); }
View OnTargetPlatform
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;
}