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
#!/bin/bash | |
# Check if the input directory, output directory, and filename prefix are provided | |
if [ "$#" -ne 4 ]; then | |
echo "Makes backup of <input_directory> keeping last <retention> number of backups in <output directory>" | |
echo "Usage: $0 <input_directory> <output_directory> <filename_prefix> <retention>" | |
exit 1 | |
fi | |
input_dir="$1" |
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 static void Main(string[] args) | |
{ | |
//string input = "34409157850"; | |
//Console.WriteLine(ValidateControlDigit(input)); | |
string filePath = "C:\\test\\natids.txt"; | |
ReadFileValidateNationalID(filePath); | |
} | |
public static void ReadFileValidateNationalID(string filePath) | |
{ |
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
void Main() | |
{ | |
var rules = new List<BreakRule>(); | |
rules.Add(new BreakRule {DrivingLimit = 8, Break = 0.5m, Remaining = 4}); | |
rules.Add(new BreakRule {DrivingLimit = 11, Break = 10m, Remaining = 8}); | |
rules.Add(new BreakRule {DrivingLimit = 60, Break = 34m, Remaining = 30}); | |
CalculateTruckDrivingTime(39, rules).Dump(); |
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
/// <summary> | |
/// Queue with limit (last items are removed when limit is reached) | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
public class LimitedQueue<T> : ConcurrentQueue<T> | |
{ | |
private object _syncRoot = new object(); | |
private int? _maxCapacity; |
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
/// <summary> | |
/// This class is required to force accepting JWT signed only with HS512 algorithm | |
/// Startup.cs: | |
/// var key = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("123")) {CryptoProviderFactory = new CryptoProviderFactory() { CustomCryptoProvider = new ForcedHmacSha512CryptoProvider() }}; | |
/// </summary> | |
public class ForcedHmacSha512CryptoProvider : ICryptoProvider | |
{ | |
public bool IsSupportedAlgorithm(string algorithm, params object[] args) | |
{ | |
//2 args - Request to create SignatureProvider |
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
//Fastest c# nationalid validator with birthdate extraction | |
public static class NationalIdValidator | |
{ | |
public static bool ValidateNationalId(string nationalId, out DateTime? birthdate) | |
{ | |
birthdate = null; | |
if (nationalId.Length != 11 || !long.TryParse(nationalId, out long nid)) | |
return false; | |
return ValidateNationalId(nid, out birthdate); | |
} |
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; | |
namespace csharp | |
{ | |
public class GildedRose | |
{ | |
IList<Item> Items; | |
public GildedRose(IList<Item> Items) | |
{ | |
this.Items = Items; |
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.Threading; | |
using System.Threading.Tasks; | |
class Program | |
{ | |
static void Main() | |
{ |
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
/* | |
This is stripped version of https://gist.github.com/Dissimilis/b1e848524c841c1617b0 | |
It is not thread safe to only some extent, but we don't care in this use case | |
*/ | |
public class CircularBufferCounter | |
{ | |
[StructLayout(LayoutKind.Sequential, Pack = 1)] | |
private struct SecondCount | |
{ | |
public SecondCount(long ticks, int count) |
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.Net; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.Logging; | |
using Microsoft.Extensions.Primitives; | |
namespace X | |
{ |
NewerOlder