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
| package distancer | |
| import ( | |
| "fmt" | |
| ) | |
| type CalculatorType string | |
| const maxMatchesCanOccur = 4 |
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
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
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 interface IConsumerService<T> | |
| { | |
| Task Parse(Message<string, T> message); | |
| string GetTopic(); | |
| string GetConsumerGroup(); | |
| } |
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
| const toDictionary = ({ list = [], prop }) => Object.fromEntries(list.map(x => [x[prop], x])) |
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
| // 2.1 < | |
| foreach (var item in modelBuilder.Model.GetEntityTypes()) | |
| { | |
| item.Relational().TableName = item.Relational().TableName.ToSnakeCase(); | |
| foreach (var property in item.GetProperties()) | |
| { | |
| property.Relational().ColumnName = property.Relational().ColumnName.ToSnakeCase(); | |
| } | |
| } |
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
| { | |
| "acrylicOpacity": 0.75, | |
| "closeOnExit": true, | |
| "colorScheme": "Campbell", | |
| "commandline": "bash.exe", | |
| "cursorColor": "#FFFFFF", | |
| "cursorShape": "bar", | |
| "fontFace": "Fira Code", | |
| "fontSize": 10, | |
| "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6102}", |
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> | |
| /// Apply this attribute to your test method to automatically create a <see cref="TransactionScope"/> | |
| /// that is rolled back when the test is finished. | |
| /// </summary> | |
| [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] | |
| public sealed class AutoRollbackAttribute : BeforeAfterTestAttribute | |
| { | |
| TransactionScope scope; | |
| /// <summary> |
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 EFCoreExtensions | |
| { | |
| public static string ToUnderscoreCase(this string str) | |
| { | |
| return string.Concat(str.Select((x, i) => i > 0 && char.IsUpper(x) ? "_" + x.ToString() : x.ToString())).ToLower(); | |
| } | |
| public static IEnumerable<IMutableEntityType> EntityTypes(this ModelBuilder builder) | |
| { | |
| return builder.Model.GetEntityTypes(); |
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 override int SaveChanges() | |
| { | |
| try | |
| { | |
| return base.SaveChanges(); | |
| } | |
| catch (DbEntityValidationException ex) | |
| { | |
| // Retrieve the error messages as a list of strings. |
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 Mock<DbSet<T>> GetMockDbSet<T>( IQueryable<T> entities ) where T : class | |
| { | |
| var mockSet = new Mock<DbSet<T>>(); | |
| mockSet.As<IQueryable<T>>().Setup( m => m.Provider ).Returns( entities.Provider ); | |
| mockSet.As<IQueryable<T>>().Setup( m => m.Expression ).Returns( entities.Expression ); | |
| mockSet.As<IQueryable<T>>().Setup( m => m.ElementType ).Returns( entities.ElementType ); | |
| mockSet.As<IQueryable<T>>().Setup( m => m.GetEnumerator() ).Returns( entities.GetEnumerator ); | |
| return mockSet; | |
| } |
NewerOlder