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 class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc(options => | |
{ | |
options.ModelValidatorProviders.Insert(0, new ListOfFooValidatorProvider()); | |
}); | |
} |
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
import UIKit | |
import PlaygroundSupport | |
class MySlider: UISlider { | |
// indent the tracking so the thumb does not hang outside the view | |
private let padding = CGFloat(18) | |
// the default rect for tracking is indented by a few pixels; keep note of that value here | |
private var trackIndent = CGFloat(0) |
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 class Startup | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc(config => | |
{ | |
var requireAgent = new AuthorizationPolicyBuilder() | |
.RequireAuthenticatedUser() | |
.RequireRole(RoleNames.Agent) |
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 Bits | |
{ | |
public static int[] ToInt32s(byte[] bytes) | |
{ | |
var paddedBytes = new byte[bytes.Length + 3]; | |
Array.Copy(bytes, paddedBytes, bytes.Length); | |
var numberOfInts = (bytes.Length + 3) / 4; | |
var ints = new int[numberOfInts]; |
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 class Startup { | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
... | |
services.AddApplicationServices(); | |
} | |
} | |
// Defines which stategies to use, and assemblies to scan, as an extension to be called from startup |
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; | |
using System.Collections.Generic; | |
using System.Drawing; | |
using System.Linq; | |
namespace Trendy | |
{ | |
internal class Program | |
{ | |
private static void Main(string[] args) |
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; | |
using System.IO; | |
using System.Linq; | |
using System.Xml.Linq; | |
namespace ConsoleApplication1 | |
{ | |
internal class Program | |
{ | |
private static void Main(string[] args) |
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
([$,\t,” “]*//.*\n){2,} |
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
import Foundation | |
extension Array { | |
func group<Discrimininator>(by discriminator: (Element)->(Discrimininator)) -> [Discrimininator: [Element]] where Discrimininator: Hashable { | |
var result = [Discrimininator: [Element]]() | |
for element in self { | |
let key = discriminator(element) |
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
struct AsyncTaskChain<Success, Error> { | |
typealias TaskClosure = (Success?, Error?) -> () | |
typealias Task = (TaskClosure) -> () | |
typealias ChainClosure = ([Success], Error?)->() | |
private let tasks: [Task] | |
private let completion: ChainClosure | |
private let previousSuccesses: [Success] |