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 | |
let input: [Any] = [1, [2, 3], [4, [5, 6]]] | |
let output: [Int] = input.description.characters.filter { !"[] ".characters.contains($0) }.reduce(""){ "\($0)\($1)" | |
}.components(separatedBy: ",").map{ Int($0)!} | |
print(output) |
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
func visit<Element>(_ arrayOrSingleItem: Any, with visitor: (Element)->()) { | |
if let singleItem = arrayOrSingleItem as? Element { | |
visitor(singleItem) | |
} else if let array = arrayOrSingleItem as? [Any] { | |
array.forEach { visit($0, with: visitor)} | |
} | |
} | |
func flatten<Element>(_ untypedItems: [Any], whereElementsAreOfType type: Element.Type) -> [Element] { | |
var elements = [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
public class IdentityOptions | |
{ | |
public string AuthorityUrl { get; set; } | |
public string ClientId { get; set; } | |
} | |
public class AgencyOptions | |
{ | |
public string ApiUrl { get; set; } | |
} |
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; | |
using System.Collections.Generic; | |
namespace Foo | |
{ | |
public class SequentialGuidEnumerator : IEnumerator<Guid> | |
{ | |
private byte[] bytes; | |
private readonly byte[] firstBytes; |
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 | |
struct Point { | |
let x: Double | |
let y: Double | |
} | |
struct Hypotrochoid { | |
let R: Double |
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
private IEnumerable<Measurement> MakeTestMeasurementRequests() | |
{ | |
var baseDay = new DateTimeOffset(2000, 1, 1, 0, 0, 0, new TimeSpan(0)); | |
var issuerUrl = GetType().FullName; | |
const int numberOfUsers = 5; | |
const int numberOfDaysPerUser = 10; | |
var kinds = EnumValueTool.GetValues<MeasurementValueKind>(); |
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; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var context = default((IBus, IDatabase)); |
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 | |
protocol Cipher { | |
func encrypt(message: String, secret: Int) -> String | |
func decrypt(message: String, secret: Int) -> String | |
} | |
struct XOR: Cipher { | |
private func impl(message: String, secret: Int) -> String? { |
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.Linq; | |
using NUnit.Framework; | |
namespace AvailSpike | |
{ | |
[TestFixture] | |
public class UseCase | |
{ | |
[Test] |
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
enum Action { | |
case tookOne | |
case wentToStore | |
} | |
struct Verse { | |
let countBeforeAction: Int | |
let action: Action | |
let countAfterAction: Int | |
} |