Skip to content

Instantly share code, notes, and snippets.

View Clancey's full-sized avatar

James Clancey Clancey

View GitHub Profile
public static string SignES256(string privateKey, string header, string payload)
{
CngKey key = CngKey.Import(
Convert.FromBase64String(privateKey),
CngKeyBlobFormat.Pkcs8PrivateBlob);
using (ECDsaCng dsa = new ECDsaCng(key))
{
dsa.HashAlgorithm = CngAlgorithm.Sha256;
var unsignedJwtData =
@Clancey
Clancey / GoogleSimpleAuth.cs
Last active May 19, 2017 06:57
Native Google Auth setup for Simple Auth. https://github.com/clancey/simpleauth
//#iOS Setup
// In Appdelegate override OpenUrl (UIApplication app, NSUrl url, NSDictionary options) and add
return SimpleAuth.Native.OpenUrl(app, url, options);
//#Android
//In Activity override OnCreate and add
SimpleAuth.Providers.Google.Init(this.Application);
//In Activity override OnActivityResult(int requestCode, Result resultCode, Intent data) and add
SimpleAuth.Native.OnActivityResult (requestCode,resultCode,data);
static string GetString(string defaultValue = "",[CallerMemberName] string memberName = "")
{
return AppSettings.GetValueOrDefault(memberName,defaultValue);
}
static void SetString (string value,[CallerMemberName] string memberName = "")
{
AppSettings.AddOrUpdateValue<string>(memberName, value);
}
static int GetInt(int defaultValue = 0, [CallerMemberName] string memberName = "")
public class VectorImageViewRenderer : ImageRenderer
{
static readonly NGraphics.IPlatform Platform = new AndroidPlatform();
protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
this.DrawImage();
@Clancey
Clancey / ImageCacheService
Created April 6, 2016 19:45
Android SVG Image Cache
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Android.Graphics.Drawables;
using System.Threading.Tasks;
using Xamarin.Forms.Platform.Android;
@Clancey
Clancey / NGraphicsExtensions.cs
Created April 6, 2016 19:01
NGraphicsExtensions
using System;
using System.IO;
using UIKit;
namespace NGraphics
{
public static class NGraphicsExtensions
{
static readonly IPlatform Platform = new ApplePlatform();
static readonly double Scale = (double) UIScreen.MainScreen.Scale;
@Clancey
Clancey / Resourceloader.cs
Created April 6, 2016 18:57
Resource Loader
using System;
using System.IO;
using System.Linq;
using System.Reflection;
public static class ResourceLoader
{
public static Stream GetEmbeddedResourceStream(string resourceFileName)
{
var assembly = typeof(ResourceLoader).GetTypeInfo().Assembly;
return GetEmbeddedResourceStream(assembly, resourceFileName);
using System;
using System.IO;
using NGraphics;
namespace UIKit
{
public static class NGraphicsExtensions
{
static readonly IPlatform Platform = new ApplePlatform();
static readonly double Scale = (double)UIScreen.MainScreen.Scale;
Unexpected character encountered while parsing value: . Path '', line 0, position 0. (Newtonsoft.Json.JsonReaderException)
at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002c2] in <filename unknown>:0
at Newtonsoft.Json.JsonTextReader.ReadInternal () [0x00043] in <filename unknown>:0
at Newtonsoft.Json.JsonTextReader.Read () [0x00007] in <filename unknown>:0
at Amazon.CloudDrive.CloudDriveApi+<GetChanges>c__asyncD.MoveNext () [0x001bc] in /Users/Clancey/Projects/AmazonCloudDriveApi/src/AmazonCloudDriveApi/AmazonCloudDriveApi.Shared/CloudDrive/CloudDriveApi.cs:210
public static void EnsureInvokedOnMainThread(Action action)
{
if (NSThread.Current.IsMainThread)
{
action();
return;
}
BeginInvokeOnMainThread (action );
}