Skip to content

Instantly share code, notes, and snippets.

🤔
Trying to make a living.

Jerry Nixon JerryNixon

🤔
Trying to make a living.
Block or report user

Report or block JerryNixon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JerryNixon
JerryNixon / BackgroundTask.cs
Created Nov 16, 2019
Simple, basic UWP Background Task
View BackgroundTask.cs
public class ApplicationTask : IBackgroundTask
{
public void Run(IBackgroundTaskInstance instance)
{
Debugger.Break();
}
public static async Task<IBackgroundTrigger> RegisterWithApplicationTriggerAsync(params IBackgroundCondition[] conditions)
{
var trigger = new ApplicationTrigger();
@JerryNixon
JerryNixon / CropUwpImageControl.cs
Created Sep 30, 2019
Image.Source = await CropImageAsync(Image.Source, new Rectangle(10, 10, 100, 100));
View CropUwpImageControl.cs
private async Task<SoftwareBitmapSource> CropImageAsync(ImageSource source, Rectangle rectangle)
{
try
{
SoftwareBitmap bitmap;
var image = source as BitmapImage;
var file = await StorageFile.GetFileFromApplicationUriAsync(image.UriSource);
using (var stream = await file.OpenAsync(FileAccessMode.Read))
{
@JerryNixon
JerryNixon / BoundingBoxLogic.cs
Created Sep 23, 2019
Making sense of Azure's Recognize Text computer vision cognitive service Line and Word BoundingBox array of longs property.
View BoundingBoxLogic.cs
public static void GetBoxCoordinates(long[] longs, out (Point TopLeft, Point TopRight, Point BottomRight, Point BottomLeft) corners, out Size size, out double angle)
{
if (longs.Length != 8)
{
throw new ArgumentOutOfRangeException(nameof(longs));
}
corners = (
new Point((int)longs[0], (int)longs[1]),
new Point((int)longs[2], (int)longs[3]),
new Point((int)longs[4], (int)longs[5]),
@JerryNixon
JerryNixon / Aspose.FindTables.cs
Created Sep 10, 2019
A test that we tried against artwork. Sort of works. Abandoned though.
View Aspose.FindTables.cs
static void Main(string[] args)
{
SetLicense();
var path = Path.Combine(Environment.CurrentDirectory, "artwork1.pdf");
using (var doc = new Document(path))
{
var tableOptions = new TextSearchOptions(false)
{
IgnoreShadowText = true,
@JerryNixon
JerryNixon / AzureFunction.cs
Last active Sep 4, 2019
How to use custom dependency injection.
View AzureFunction.cs
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Linq;
View UsingRingSegment.xaml
<Page
x:Class="UsingRing.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UsingRing"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
View PasswordChecker.cs
internal class Program
{
private static void Main(string[] args)
{
Test("pass");
Test("password");
Test("Password");
Test("P@ssword");
Test("P@ssw0rd");
Test("P@ssW0rD");
@JerryNixon
JerryNixon / app.xaml.cs
Created Oct 22, 2018
Preventing UWP Suspension
View app.xaml.cs
sealed partial class App : Application
{
public App()
{
InitializeComponent();
Suspending += (s, e) => Helpers.ShowToast("Suspending");
Resuming += (s, e) => Helpers.ShowToast("Resuming");
Helpers.SetupExSession(
allowed: () => Helpers.ShowToast("Allowed"),
denied: () => Helpers.ShowToast("Denied"),
View GenerateThumbnail.cs
static async Task<string> ScaleImageAsync(string path, uint height = 32, uint width = 32, StorageFile output_file = null)
{
// open file from path
var input_file = default(StorageFile);
try
{
input_file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(path));
}
catch (FileNotFoundException)
View AppBarLiteral.cs
[ContentProperty(Name = nameof(LiteralContent))]
public sealed class AppBarLiteral : AppBarSeparator
{
public AppBarLiteral()
{
DefaultStyleKey = typeof(AppBarLiteral);
}
public object LiteralContent
{
You can’t perform that action at this time.