Skip to content

Instantly share code, notes, and snippets.

View fubar-coder's full-sized avatar

Mark Junker fubar-coder

View GitHub Profile
@fubar-coder
fubar-coder / SliceExtensions.cs
Created December 1, 2015 10:52
Simple slice implementation for C#
public static class SliceExtensions
{
public static Slice<T> ToSlice<T>(this T[] array)
{
return new Slice<T>(array);
}
public static Slice<T> ToSlice<T>(this T[] array, int offset, int length)
{
return new Slice<T>(array, offset, length);
@fubar-coder
fubar-coder / LexwarePasswordEncryption.cs
Last active October 11, 2015 18:05
This source code encrypts/decrypts lexware passwords for Lexware database access
public static class LexwarePasswordEncryption
{
public static string Encrypt(string password, string key)
{
return PerformCrypt(password, true, key);
}
public static string Decrypt(string encryptedPassword, string key)
{
return PerformCrypt(encryptedPassword, false, key);
@fubar-coder
fubar-coder / RestClientExecuteWithCallback.cs
Last active August 29, 2015 14:16
Execute request with callbacks
public static class RestClientExecuteWithCallback
{
public static Task ExecuteWithCallbacks<T>(this IRestClient client, IRestRequest request, Action<T> success, Action<Exception, string> failure)
{
return ExecuteWithCallbacks(client, request, success, failure, null);
}
public static Task ExecuteWithCallbacks<T>(this IRestClient client, IRestRequest request, Action<T> success, Action<Exception, string> failure, Action<IRestResponse, string> requestFailure)
{
if (success == null)
@fubar-coder
fubar-coder / StyleCop-Layout.xaml
Last active September 2, 2015 22:02
StyleCop layout for ReSharper
<?xml version="1.0" encoding="utf-8"?>
<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
<TypePattern DisplayName="StyleCop Pattern">
<Entry DisplayName="Constant Fields">
<Entry.Match>
<And>
<Kind Is="Constant" />
<Kind Is="Field" />
</And>
</Entry.Match>
@fubar-coder
fubar-coder / FollowRedirectHttpClientFactory.cs
Last active August 29, 2015 14:16
HTTP message handler with an active "AllowAutoRedirect"
using System;
using System.Net.Http;
namespace RestSharp.Portable.HttpClientImpl
{
/// <summary>
/// Creates a HTTP message handler with an active "AllowAutoRedirect".
/// </summary>
public class FollowRedirectHttpClientFactory : DefaultHttpClientFactory
{
@fubar-coder
fubar-coder / AzureAdSystemClient.cs
Created November 19, 2014 14:46
Prototype of Auzre AD OAuth2 client for RestSharp.Portable
using Newtonsoft.Json;
using RestSharp.Portable;
using RestSharp.Portable.Authenticators.OAuth2;
using RestSharp.Portable.Authenticators.OAuth2.Configuration;
using RestSharp.Portable.Authenticators.OAuth2.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;