This file contains 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.Threading.Tasks; | |
namespace RetryPolicies | |
{ | |
internal sealed class ExponentialRetryPolicy | |
{ | |
public TimeSpan InitialDelay { get; set; } = TimeSpan.FromSeconds(10); | |
public int NumberOfRetries{ get; set; } = 5; |
This file contains 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
(?x) | |
(?<![0-9]) | |
(?: | |
[0-9]{12,19} # sequence of digits in the text between [12, 19] length | |
| | |
(?:[0-9]{4}[ -]){4}[0-9]{3} # 4-4-4-4-3 pattern | |
| | |
(?:[0-9]{4}[ -]){3}[0-9]{4} # 4-4-4-4 pattern | |
| | |
(?:[0-9]{4}[ -]){2}[0-9]{5} # 4-4-5 pattern |
This file contains 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; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
int[] arr = {-2, -3, 4, -1, -2, 1, 5, -3}; | |
var result = LargestSumContiguousSubarray(arr); | |
Console.Write(result); | |
} |
This file contains 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; | |
public class Program | |
{ | |
public static void Main() | |
{ | |
int[] values = {110, 100, 200 }; | |
int[] weights = {10, 20, 30}; | |
int maxWeight = 30; |
This file contains 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 int BinarySearch(int[] arr, int k) | |
{ | |
var minIndex = 0; | |
var maxIndex = arr.Length - 1; | |
while (minIndex <= maxIndex) | |
{ | |
var mid = (minIndex + maxIndex) / 2; | |
if (k == arr[mid]) |
This file contains 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 interface IMemoryCacheExtended : IMemoryCache | |
{ | |
TItem GetOrCreate<TItem>(object key, Func<ICacheEntry, TItem> factory); | |
Task<TItem> GetOrCreateOnceAsync<TItem>(object key, Func<ICacheEntry, Task<TItem>> factory); | |
} | |
public class MemoryCacheExtended : IMemoryCache | |
{ | |
private readonly MemoryCache _memoryCache; |
This file contains 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.Linq; | |
class Program | |
{ | |
static void Main() | |
{ | |
var product = new Product(1) { Price = 10 }; |
This file contains 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 static bool IsValidCreditCardNumber(string creditCardNumber) | |
{ | |
// based on Luhn algorithm | |
// https://en.wikipedia.org/wiki/Luhn_algorithm | |
if (creditCardNumber == null) throw new ArgumentNullException(nameof(creditCardNumber)); | |
// credit card number length must be between [12, 19] | |
if (creditCardNumber.Length < 12 || creditCardNumber.Length > 19) | |
{ |
This file contains 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 Newtonsoft.Json.Linq; | |
namespace OpenApi.Extensions | |
{ | |
/// <summary> | |
/// Consolidates enums based on <code>x-type-fullname</code> vendor extension. | |
/// <example> | |
/// { |
This file contains 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.Linq; | |
using System.Web.Http.Description; | |
using Newtonsoft.Json.Serialization; | |
using Swashbuckle.Swagger; | |
namespace Swagger.Configurations | |
{ | |
public class SwashbuckleDocument |
NewerOlder