This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bad! | |
// The FooProvider is instantiated in the constructor. Very hard to test. | |
public class OldSchool | |
{ | |
private FooProvider _fooProvider; | |
public OldSchool() | |
{ | |
_fooProvider = new FooProvider(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class MachineKeyGenerator | |
{ | |
[Test] | |
public void GenerateMachineKey() | |
{ | |
Console.Out.WriteLine(@"<machineKey validationKey=""{0}"" decryptionKey=""{1}""/>", Key(512), Key(192)); | |
} | |
private static string Key(int bits) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<meta-runner name="Set Assembly Version from Git Release/Tag"> | |
<description>Set the version of all assemblies to the value of the Git tag.</description> | |
<settings> | |
<parameters> | |
<param name="autoinc.path" value="%autoinc.path%" spec="text description='The file containing per-configuration, per-branch build counters. Will be created if it does not exist.' display='normal' label='Build Counter Data File Path' validationMode='not_empty'" /> | |
</parameters> | |
<build-runners> | |
<runner name="Set Assembly Version from Git Release/Tag" type="jetbrains_powershell"> | |
<parameters> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Net.Http; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Newtonsoft.Json; | |
using Nito.AsyncEx; | |
using Org.BouncyCastle.Crypto; | |
using Org.BouncyCastle.Crypto.Parameters; | |
using Org.BouncyCastle.OpenSsl; | |
using Org.BouncyCastle.Security; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using System.Security.Claims; | |
using System.Security.Principal; | |
namespace Common | |
{ | |
public static class PrincipalExtensions | |
{ | |
public static IEnumerable<string> Roles(this IPrincipal user) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ConcurrentCollectionExtensions | |
{ | |
private const int MaxDegreeOfConcurrency = 10; | |
/// <summary> | |
/// Concurrently perform a task on each member of a collection | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="collection">The collection upon which each task should be performed</param> | |
/// <param name="concurrentTask">The task to perform</param> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LINQPad | |
void Main() | |
{ | |
new Demo().Nested(1).Result.Dump(); | |
new Demo().Continuation(1).Result.Dump(); | |
new Demo().Variables(1).Result.Dump(); | |
new Demo().NestedAlt(1).Result.Dump(); | |
} | |
// Define other methods and classes here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lightbulb | |
public static async Task<TOut> MapAsync<TIn,TOut>(this Task<TIn> @this, Func<TIn, Task<TOut>> fn) => await fn(await @this); | |
// all permutations | |
public static TOut Map<TIn,TOut>(this TIn @this, Func<TIn, TOut> fn) => fn(@this); | |
public static async Task<TOut> MapAsync<TIn,TOut>(this TIn @this, Func<TIn, Task<TOut>> fn) => await fn(@this); | |
public static async Task<TOut> MapAsync<TIn,TOut>(this Task<TIn> @this, Func<TIn, TOut> fn) => fn(await @this); | |
public static async Task<TOut> MapAsync<TIn,TOut>(this Task<TIn> @this, Func<TIn, Task<TOut>> fn) => await fn(await @this); | |
// example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Caveats: does not support async enumerations, i.e. ToListAsync, ToArrayAsync | |
public class MockDbContext<T> | |
where T : Entity | |
{ | |
public static ApplicationDbContext Create() => Create(new List<T>()); | |
public static ApplicationDbContext Create(List<T> entities) | |
{ | |
var queryable = entities.AsQueryable(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from boxsdk import JWTAuth | |
from boxsdk import Client | |
# automation id => 32828.... What to do with this? | |
auth = JWTAuth( | |
client_id='8grfp2...', | |
client_secret='1FwTmL...', | |
enterprise_id='322105', | |
jwt_key_id='qasd...', | |
rsa_private_key_file_sys_path='c:\\temp\\private_key_nopass.pem' |
OlderNewer