Skip to content

Instantly share code, notes, and snippets.

View ArisAgnew's full-sized avatar
:electron:
You gotta do what you gotta do

Εὐγενής Αναγνωστόπουλος ArisAgnew

:electron:
You gotta do what you gotta do
  • Europe
View GitHub Profile
@ArisAgnew
ArisAgnew / invokeMetho_testContext.java
Last active June 1, 2020 17:02
preparePage(final Method invokedMethod, final ITestContext testContext)
@BeforeMethod
public void preparePage(final Method invokedMethod, final ITestContext testContext) {
inBrowser().navigate(refresh());
testContext.getSuite().getAllMethods()
.stream()
.filter(m -> m.getMethodName().equals(invokedMethod.getName()))
.flatMap(tngm -> Stream.of(tngm.getGroups()))
.filter(s -> s.equals("Управление доступами"))
.findFirst()
@ArisAgnew
ArisAgnew / Big_O_Performance.md
Last active April 16, 2021 09:40
Big O performance

Big O performance of common functions of different Java Collections.

List Add Remove Get/Read Contains Next Data Structure
[] O(n) O(n) O(1) O(n) O(1) Array
List O(1)* O(n) O(n) O(n) O(1) Array
ArrayList O(1) O(n) O(1) O(n) O(1) Array
LinkedList O(1) O(1) O(n) O(n) O(1) Linked List
CopyOnWriteArrayList O(n) O(n) O(1) O(n) O(1) Array
@ArisAgnew
ArisAgnew / MemoryCache.cs
Created September 9, 2020 08:36
MemoryCache
//Get instance of cache
using System.Runtime.Caching;
var cache = MemoryCache.Default;
//Check if cache contains an item with
cache.Contains("CacheKey");
//get item from cache
var item = cache.Get("CacheKey");
@ArisAgnew
ArisAgnew / AmplifiedFunctionsLab.cs
Last active September 11, 2020 10:27
Basic four amplified types (classes) are defined to enhance sporadic delegates before being executed.
<PropertyGroup>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
public class AmplifiedAction
{
private Action _action;
@ArisAgnew
ArisAgnew / TierHandler.cs
Last active October 8, 2020 11:29
Invariance, Contravariance, Covariance C#
internal class HightTier { }
internal class MediumTier : HightTier { }
internal class LowTier : MediumTier { }
internal delegate Covariance TierHandler<Invariance, in Contravariance, out Covariance>(Contravariance arg);
/// <summary>
/// if 1st_op = 2nd_op
/// then
/// <in> is tantamount to Going UP (emerged from MediumTier to HightTier)
@ArisAgnew
ArisAgnew / Fibonacci.cs
Last active March 10, 2021 10:42
Fibonacci IEnumerable C#
static void Main()
{
foreach (var num in Fibonacci(7))
{
Console.WriteLine(num);
}
}
protected static IEnumerable<uint> Fibonacci(uint number)
{
@ArisAgnew
ArisAgnew / EqualsExampleToRight.cs
Created April 4, 2021 11:27
EqualsExampleToRight
public Rect(decimal x, decimal y, decimal width, decimal height)
{
X = x;
Y = y;
Width = width;
Height = height;
}
/// <summary>
/// The x coordinate of the element in pixels.
@ArisAgnew
ArisAgnew / FibonacciExtended.cs
Created May 11, 2021 10:21
FibonacciInterfaceIterator.cs
public interface IReader<T> where T : notnull
{
IReadOnlyCollection<T> GetElements();
T GetElementAt(int index) => GetElements().ElementAtOrDefault(index);
}
public record FibonacciReader : IReader<int>
{
public IReadOnlyCollection<int> GetElements() => new FibonacciSequence().ToList();
}
@ArisAgnew
ArisAgnew / ValueObjectApproach.cs
Last active June 20, 2021 19:55
Refactoring If-Else to Value Object
//If-Else Approach
public class User
{
public string Name { get; set; }
public string Email { get; set; }
public void ChangeEmail(string email)
{
if (!IsEmailValid(email))
throw new ArgumentException("{email} is not valid.", email);
@ArisAgnew
ArisAgnew / StateDesignPattern.cs
Created June 20, 2021 19:58
Refactoring If-Else to State Design Pattern
//If-Else Approach
public enum Reaction
{
Initial = 1,
Liked = 2,
Disliked = 3
}
public class LikeDislikeComponent
{