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 / 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;
@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 / 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 / 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 / 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 / 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 / JsonDeserializerOptional{TError}.cs
Last active December 7, 2015 07:50
Deserialize error object for RestSharp.Portable
public class JsonDeserializerOptional<TError> : IDeserializer
{
/// <summary>
/// Deserialize the response
/// </summary>
/// <typeparam name="T">Object type to deserialize the result to</typeparam>
/// <param name="response">The response to deserialize the result from</param>
/// <returns>The deserialized object</returns>
public T Deserialize<T>(IRestResponse response)
{
@fubar-coder
fubar-coder / App.config
Created April 19, 2016 19:28
Modifications to allow PASV to use predefined ports (by Guillaume Pelletier)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="System.Net" maxdatasize="1024">
<listeners>
@fubar-coder
fubar-coder / NonNullableReferenceTypes.md
Last active May 5, 2017 15:08
Random ideas around non-nullable reference types for the C# and the .NET CLR/JIT

NNRT = Non-Nullable Reference Type

  1. Using attributes

    • Feature set similar to what ReSharper delivers today
    • Can attributes be added to generic type arguments?
    • Compatible with the .NET Framework
    • Compatible with languages not supporting NNRTs
    • High overhead because every public function must check if the passed function argument might be null

Keybase proof

I hereby claim:

  • I am fubar-coder on github.
  • I am fubarcoder (https://keybase.io/fubarcoder) on keybase.
  • I have a public key ASDPDyv1Q2SB_navNG9GLnwdlVAclY1JPQiseOo0Pv-vxwo

To claim this, I am signing this object: