Skip to content

Instantly share code, notes, and snippets.

View NikiforovAll's full-sized avatar
🇺🇦

Oleksii Nikiforov NikiforovAll

🇺🇦
View GitHub Profile
@NikiforovAll
NikiforovAll / embed-images-in-markdown
Last active April 15, 2020 08:09
This is POC of hosting images as a gist
Create the Gist
Drag an image into the comment field below. This will upload your image file and insert the markdown code with the url for your uploaded image.
Copy this markdown and paste it into the file you want to display it.
@NikiforovAll
NikiforovAll / get-bella-error-code.sh
Created March 12, 2020 12:33
allows to search for errors in bella hierarchically
#!/bin/sh
# grep -R --include "*.bs" 'error\[.*\]' $PROJECT_PATH | cut -d' ' -f9- | sort | uniq
geterr4m() {
METHOD_NAME="$1"
PROJECT_PATH='/c/Nikiforov/dev/nuts-bella/src/Domain/components/';
# echo $METHOD_NAME $PROJECT_PATH
METHOD_PATH=$(grep -rl --include "*.bs" "re.*${METHOD_NAME}" $PROJECT_PATH)
using System;
using SingletonExample;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
var s1 = Singleton.Instance;
var s2 = Singleton.Instance;
@NikiforovAll
NikiforovAll / MementoImpl.cs
Last active June 9, 2019 14:14
MementoImpl
using System;
using System.Collections.Generic;
namespace Memento {
public class Caretaker : Stack<Memento> { }
}
namespace Memento {
public class Memento {
public (string Id, int balance) State { get; private set; }
//probably better to use read-only state
@NikiforovAll
NikiforovAll / InterpreterImpl.cs
Last active June 9, 2019 13:54
InterpreterImpl
using System;
namespace Interpreter {
public abstract class AbstractInterpreter {
public abstract int Interpret (Context context);
}
}
namespace Interpreter {
public class Context {
@NikiforovAll
NikiforovAll / ChainOfResponsibilityImpl.cs
Last active June 9, 2019 13:13
ChainOfResponsibilityImpl
using System;
using System.Collections.Generic;
using System.Linq;
namespace ChainOfResponsibility {
/// <summary>
/// The 'Handler' abstract class
/// </summary>
public abstract class Approver {
public string Id { get; }
@NikiforovAll
NikiforovAll / ChainOfResponsibilityImpl.cs
Created June 9, 2019 13:11
ChainOfResponsibilityImpl
using System;
using System.Collections.Generic;
using System.Linq;
namespace ChainOfResponsibility {
/// <summary>
/// The 'Handler' abstract class
/// </summary>
public abstract class Approver {
public string Id { get; }
@NikiforovAll
NikiforovAll / Program.cs
Last active June 9, 2019 12:01
StateImpl
using System;
using System.Collections.Generic;
using System.Linq;
using State;
public class Program {
public static void Main () {
var ctx = new StateClient ();
ctx.State = new StateOne (ctx);
Assert.Equal ("StateOne", ctx.State.GetType ().Name);
@NikiforovAll
NikiforovAll / CommandImpl.cs
Last active June 9, 2019 11:07
CommandImpl
using System;
using System.Collections.Generic;
namespace Command {
public class Calculator {
private int _curr = 0;
public int CurrentResult { get => _curr; set => _curr = value; }
public int Operate (char @operator, int operand) {
@NikiforovAll
NikiforovAll / Program.cs
Last active June 9, 2019 10:38
VisitorImpl
using System;
using Visitor;
public class Program {
public static void Main () {
var baseEntry = new SimpleLogEntry () {
Created = DateTime.Now,
Message = "test"
};