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 abstract class CrontabService : BackgroundService | |
{ | |
private DateTime nextRun; | |
private readonly CrontabSchedule _schedule; | |
private readonly ILogger _logger; | |
public CrontabService(CrontabSchedule schedule, ILogger logger) | |
{ | |
_schedule = schedule; |
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 Ref<T> | |
{ | |
public Ref() { } | |
public Ref(T value) { Value = value; } | |
public T Value { get; set; } | |
public override string ToString() | |
{ | |
T value = Value; | |
return value == null ? "" : value.ToString(); | |
} |
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 MongoDbExtensions | |
{ | |
public static IMongoQueryable<TDestination> ProjectTo<TSource, TDestination>(this IQueryable<TSource> query, AutoMapper.IMapper autoMapper) => | |
query.ProjectTo<BookListDTO>(autoMapper.ConfigurationProvider) as IMongoQueryable<TDestination>; | |
} | |
// usage ... | |
private readonly IMongoCollection<Book> _books; | |
private readonly IMapper _mapper; | |
// ... |
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 Microsoft.Azure.Cosmos.Table; | |
using System.Collections.Generic; | |
using System.Runtime.CompilerServices; | |
using System.Threading; | |
public static class TableQueryExtensions | |
{ | |
public static async IAsyncEnumerable<T> ExecuteAsync<T>(this TableQuery<T> query, [EnumeratorCancellation] CancellationToken ct = default) | |
{ |
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 AzureTableStorageCache : IDistributedCache | |
{ | |
private readonly AzureTableStorageCacheOptions _options; | |
private readonly CloudTable _table; | |
public AzureTableStorageCache(IOptions<AzureTableStorageCacheOptions> options) | |
{ | |
_options = options.Value; | |
var tableClient = CloudStorageAccount.Parse(_options.ConnectionString).CreateCloudTableClient(); |
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 | |
while read line | |
do | |
echo "$line" | |
done < "${1:-/dev/stdin}" |
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 | |
recurse () | |
( | |
recurse2 () | |
{ | |
[ $_recurse_stop -eq 1 ] && return | |
cd "$1" || return | |
pwd ## do whatever you want in the pwd | |
for entry in $(ls); |
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 Microsoft.Extensions.Logging; | |
using System; | |
using System.Linq; | |
public static class LoggingExtensions | |
{ | |
public static IDisposable BeginPropertyScope(this ILogger logger, params (string key, object value)[] properties) => | |
logger.BeginScope(properties.ToDictionary(p => p.key, p => p.value)); | |
} |
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; | |
namespace PasswordAttack | |
{ | |
static class Program | |
{ | |
const string EXPRESSION = "replace(concat(take(items('For_each')?['DATAB'],4),'-',take(skip(items('For_each')?['DATAB'],4),2),'-',take(skip(items('For_each')?['DATAB'],6),2)),'0000-00-00','1753-01-01')"; |
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 string GreaterOrEqual(string first, string second, string part) => | |
$"{part}({first}) ge {part}({second})"; | |
private static string GreaterThan(string first, string second, string part) => | |
$"{part}({first}) gt {part}({second})"; | |
private static string Equal(string first, string second, string part) => | |
$"{part}({first}) eq {part}({second})"; | |
/// <summary> |