Vers localis

Cinkosa légy a tetűnek, gonosznak, s az alja népnek
Ilyen világba születtél, mutasd mivé lettél,
Talán félsz bemutatni önmagad, miközben felfeded magad?

Mutasd hát, hogy mi a helyes, és hogy játsszák a nagyok ezt!
Erkölcstelen, rohadt kurva? Neked jár az első strófa!
Strici, mocskos férges genny? Tied lesz majd fent a menny!

Gusztustalan mocskos állat? Hát a népek csak rád vártak!
Mutasd magad, forogj körbe, álljon a közönség körbe,
Eltorzult szexrabszolga? Azonnal az első sorba!

Tátják mind a szájukat, elképesztő ámulat,
Ilyet még sose láttak! Értékálló baromállat!
Kipeckelt száját nézik, miközben csak beleverik

Új századba érkeztünk, és most ilyenné lettünk,
A maradi lesz liberál, szabadelvű meg emigrál,
Kínkeservel néz a lóra, berakná neki cipóba

Fantasztikus a doboz is, mennyi rengeteg kanális,
Análisan is kanális a Hírös Tévé majális,
Hol Bayert Bencsik kényezteti és A’lohára ki-ki veri

Nem homokság művészet, ki nem érti elvérzett,
Kékké veri, zöldre festi, elbarnítja, és megszegi
Felhasítja, és kimetszi, felkaparja, leteremti,

Nem érted miről beszélek? Avantgardra nyisd ki füled
Ha e verset te megveted, problémádat fejben keresd
Ez az ország élhetetlen, ha e vers kiejthetetlen

Relatív értékítélet, szül relatív emberséget,
Észnél legyél, mi mellé állsz, még a végén te emigrálsz,
Embert lásd meg a másikban, soha gondunk nem lesz másban

My “new” philosophy

Today is 7/13/2019 and the thoughts still haunt me about my past.

I am determined to live my life according to the following eastern principle -for the next weeks-. I hope it will bring some peace on my tumbling soul, otherwise I live my days as in the past couple of months. Unable to work, think clearly, or achieve anything, except self-pity. I do not want to relive my faults, and fiascos, day-by-day. Enough is enough. The people who had hurt me, I take for deceased. They do not exist. Here comes the famous idea:

The past does not exist, the future is an illusion. Only the present is the reality.

Static Constructor

Guess what the following program does, and then see the answer.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StatikusKonstruktor
{
    class Car
    {
        protected static string szoveg="";
        protected static StringBuilder sb;
        public Car()
        {
           sb.Append('A');
        }
        static Car()
        {
            sb = new StringBuilder();
            sb.Append('B');
        }

        public string GetString
        {
            get
            {
                return sb.ToString();
            }
        }
    }
    class Suzuki : Car
    {
        public Suzuki()
        {
            sb.Append('C');
        }
        static Suzuki()
        {
            sb.Append('D');
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Car car = new Car();
            Suzuki suzuki = new Suzuki();

            Console.WriteLine(suzuki.GetString);
            Console.ReadKey();
        }
    }
}

And the result is…

Select this with cursor:

BADAC

What? Why?

Well, because static constructors run first. Always. And runs only once -thank you Attila!-. Than comes the dynamic constructors. When the Suzuki’s static constructor runs, it automatically calls the base class dynamic constructor, because it is its parent class.

A simple Breadth First Search on a hard-coded map

Breath First Search is to be simply put a searching algorithm for traversing a Graph. Well, what I did my search on wasn’t exactly a Graph but regardless… 🙂 The simple idea, that this hard coded part is used for the traversing:

static class Map
    {
        public static char[,] map = new char[,]
        {
            {'r', '*', '*', '#', '*', '*'},
            {'*', '#', '#', '#', '#', '*'},
            {'*', '#', '*', '*', '*', '*'},
            {'*', '#', '*', '#', '#', '*'},
            {'*', '#', '*', '#', '*', '*'},
            {'*', '#', '*', '#', '*', '*'},
            {'*', '*', '*', '#', 'g', '*'}
        };
    }

Little explanation for the above code

The r means ready and the g is the goal, moreover the hashtags # represent the walls, on top of that the asterisks * show us the free places.

Explaining the classes below

The Position class is responsible for storing the x and y coordinates, and two Position objects can be compared by the help of the Equals method.

The Element class is the basic building block of this program. It is responsible for:

  • holding the Position, the character (#, *, s, g),
  • the Visited state (necessary for Breadth First Algorithm),
  • the adjacent/neighboring Elements and the Parent (necessary for BFS as well)
  • the element type which is the character
  • The SelectNeighbours method does what the name implies. The tricky part for this, was that the array behaves in a way that the first parameter for accessing the array is y, than x. Contradicting the common sense. For the Left side I needed to use the y coordinate.

The Game class is creating the Elements from the simple Map.

The TryToSolve method will initialize a Queue -we use a queue in order to avoid the usage of backtracking- then calls the BFS.

//Left
if (this.Position.y - 1 > -1 &&
    map[this.Position.x, this.Position.y - 1].elementType != '#')
{
    Left = map[this.Position.x, this.Position.y - 1];
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace BreadthFirstSearch
{
    struct Position : IEquatable<Position>
    {
        public int x;
        public int y;

        public bool Equals(Position other)
        {
            return this.x == other.x && this.y == other.y;
        }

        public override string ToString()
        {
            return string.Format("{0}, {1}", x, y);
        }
    }
    class Element
    {
        Position position;
        char elementType;
        bool visited;

        public char ElementType { get => elementType; set => elementType = value; }
        public bool Visited { get => visited; set => visited = value; }
        public Position Position { get => position; }

        public Element Left, Right, Top, Bottom;

        public Element parent;

        public Element(Position position, char elementType)
        {
            this.position = position;
            this.ElementType = elementType;
        }

        public void SelectNeighbours(ref Element[,] map)
        {
            if (this.ElementType != '#')
            {
                //Left
                //Ha nem lóg ki bal oldalt és nem fal azaz #
                if (this.Position.y - 1 > -1 &&
                    map[this.Position.x, this.Position.y - 1].elementType != '#')
                {
                    Left = map[this.Position.x, this.Position.y - 1];
                }
                //Right
                //Ha nem lóg ki jobb oldalt és nem fal azaz #
                if (this.Position.y + 1 < map.GetLength(1) &&
                    map[this.Position.x, this.Position.y + 1].elementType != '#')
                {
                    Right = map[this.Position.x, this.Position.y + 1];
                }
                //Top
                //Ha nem lóg ki felül és nem fal azaz #
                if (this.Position.x - 1 > -1 &&
                    map[this.Position.x - 1, this.Position.y].elementType != '#')
                {
                    Top = map[this.Position.x - 1, this.Position.y];
                }
                //Bottom
                //Ha nem lóg ki alul és nem fal azaz #
                if (this.Position.x + 1 < map.GetLength(0) &&
                    map[this.Position.x + 1, this.Position.y].elementType != '#')
                {
                    Bottom = map[this.Position.x + 1, this.Position.y];
                }
            }
        }
    }
    static class Map
    {
        public static char[,] map = new char[,]
        {
            {'r', '*', '*', '#', '*', '*'},
            {'*', '#', '#', '#', '#', '*'},
            {'*', '#', '*', '*', '*', '*'},
            {'*', '#', '*', '#', '#', '*'},
            {'*', '#', '*', '#', '*', '*'},
            {'*', '#', '*', '#', '*', '*'},
            {'*', '*', '*', '#', 'g', '*'}
        };
    }
    class Game
    {
        Element[,] mapElements;

        char[,] map = Map.map;

        public Game()
        {
            mapElements = new Element[map.GetLength(0), map.GetLength(1)];

            for (int x = 0; x < map.GetLength(0); x++)
            {
                for (int y = 0; y < map.GetLength(1); y++)
                {
                    mapElements[x,y] = new Element(new Position() { x = x, y = y }, map[x,y]);
                }
            }

            for (int x = 0; x < map.GetLength(0); x++)
            {
                for (int y = 0; y < map.GetLength(1); y++)
                {
                    mapElements[x,y].SelectNeighbours(ref mapElements);
                }
            }

            var kiirando = mapElements[2,2];
            /*
            Console.WriteLine("Top: " + kiirando.Top?.Position +
                            " Bottom: " + kiirando.Bottom?.Position +
                            " Left: " + kiirando.Left?.Position +
                            " Right: " + kiirando.Right?.Position);

            Console.WriteLine("Position x: {0}, y: {1} and value: {2}", kiirando.Position.x, kiirando.Position.y, kiirando.ElementType);
            */
        }
        private Element starting;
        private Element ending;
        public void PrintElements()
        {
            for (int x = 0; x < mapElements.GetLength(0); x++)
            {
                for (int y = 0; y < mapElements.GetLength(1); y++)
                {
                    //Finding the starting point
                    if (mapElements[x,y].ElementType.Equals('r'))
                    {
                        starting = mapElements[x,y];
                    }
                    //Finding the ending point
                    else if (mapElements[x,y].ElementType.Equals('g'))
                    {
                        ending = mapElements[x,y];
                    }

                    Console.Write(mapElements[x,y].ElementType);
                    //Thread.Sleep(1000);
                }
                Console.WriteLine();
            }
        }

        Queue<Element> elements;
        public void TryToSolve()
        {
            elements = new Queue<Element>();
            elements.Enqueue(starting);

            BFS(ref elements);

            PrintOutTheResult(ref elements);
        }

        public void PrintOutTheResult(ref Queue<Element> elements)
        {
            char[,] map = Map.map;
            bool found;
            for (int x = 0; x < map.GetLength(0); x++)
            {
                for (int y = 0; y < map.GetLength(1); y++)
                {
                    found = false;
                    foreach (var element in elements)
                    {
                        if (element.Position.Equals(new Position {x = x, y = y}))
                        {
                            found = true;
                            Console.Write("O");
                        }
                    }
                    if (found == false)
                    {
                        Console.Write(map[x,y]);
                    }
                }
                Console.WriteLine();
            }

            
        }
        
        public Queue<Element> BFS(ref Queue<Element> elements)
        {
            while (elements.Count != 0)
            {
                Element actual = elements.Dequeue();
                actual.Visited = true;
                
                //Console.WriteLine($"{++hanyszor} " + actual.Position);

                if (actual.Left != null && actual.Left.Visited == false)
                {
                    actual.Left.Visited = true;
                    actual.Left.parent = actual;
                    elements.Enqueue(actual.Left);
                }
                if (actual.Top != null && actual.Top.Visited == false)
                {
                    actual.Top.Visited = true;
                    actual.Top.parent = actual;
                    elements.Enqueue(actual.Top);
                }
                if (actual.Right != null && actual.Right.Visited == false)
                {
                    actual.Right.Visited = true;
                    actual.Right.parent = actual;
                    elements.Enqueue(actual.Right);
                }
                if (actual.Bottom != null && actual.Bottom.Visited == false)
                {
                    actual.Bottom.Visited = true;
                    actual.Bottom.parent = actual;
                    elements.Enqueue(actual.Bottom);
                }

                if (actual.ElementType == 'g')
                {
                    Console.WriteLine("The endpoint reached!");
                    elements = new Queue<Element>();
                    var drawingBack = actual;
                    while (drawingBack != null)
                    {
                        Console.WriteLine(drawingBack.Position);
                        elements.Enqueue(drawingBack);
                        drawingBack = drawingBack.parent;
                    } 

                    return elements;
                }
            }

            return elements;
        }

    }

    class TestTheArray
    {
        char[,] map = new char[,]
        {
            {'r', '*', '#', '*', 'g'},
            {'*', '*', '#', '#', '*'},
            {'*', '*', '*', '*', '*'},
            {'*', '*', '#', '*', '*'},
            {'*', '*', '#', '*', '*'}
        };
        public TestTheArray()
        {
            Console.WriteLine(map[0,0]);
        }
    }
        class Program
    {
        static void Main(string[] args)
        {
            Game game = new Game();
            game.PrintElements();
            //TestTheArray testTheArray = new TestTheArray();
            game.TryToSolve();
            Console.ReadKey();
        }
    }
}

Composite Design Pattern

Yes, I am finally back with another wonderful design pattern. This is a structural design pattern, meaning it can be used for building larger structures from the existing classes, by using the actual structure.

When do we use it?

If our instances of a class or classes can be ordered in a tree structure, this might be the way to go. This “design pattern” let us use the single instance of a class and multiple instances in the same way. For a more visual explanation, imagine it as a -binary- tree, with nodes and leaves. The leaf will be the single instance, and the node will be the “compound” class. We need to handle each node the same way, regardless of it is a leaf or a “Composite”/inner node. There are two different ways to do so.

The first way to go

The first way -the consensual – is to use an Interface as the link between the class and the other class which includes children of the first class (for example as a collection). So both the single class, and the composite class needs to use this interface.

import java.util.ArrayList;

/** "Component" */
interface Graphic {
    //Prints the graphic.
    public void print();
}

/** "Composite" */
class CompositeGraphic implements Graphic {
    //Collection of child graphics.
    private final ArrayList<Graphic> childGraphics = new ArrayList<>();

    //Adds the graphic to the composition.
    public void add(Graphic graphic) {
        childGraphics.add(graphic);
    }
    
    //Prints the graphic.
    @Override
    public void print() {
        for (Graphic graphic : childGraphics) {
            graphic.print();  //Delegation
        }
    }
}

/** "Leaf" */
class Ellipse implements Graphic {
    //Prints the graphic.
    @Override
    public void print() {
        System.out.println("Ellipse");
    }
}

/** "The other Leaf" */
class Rectangle implements Graphic {
   //Prints the graphic.
   @Override
   public void print() {
        System.out.println("Rectangle");
   }
}

/** Client */
public class CompositeDemo {
    public static void main(String[] args) {
        //Initialize four ellipses
        Ellipse ellipse1 = new Ellipse();
        Ellipse ellipse2 = new Ellipse();
        Rectangle rectangle1 = new Rectangle();
        Rectangle rectangle2 = new Rectangle();

        //Creates two composites containing the ellipses
        CompositeGraphic graphic2 = new CompositeGraphic();
        graphic2.add(ellipse1);
        graphic2.add(ellipse2);
        graphic2.add(rectangle1);
        
        CompositeGraphic graphic3 = new CompositeGraphic();
        graphic3.add(rectangle2);
        
        //Create another graphics that contains two graphics
        CompositeGraphic graphic1 = new CompositeGraphic();
        graphic1.add(graphic2);
        graphic1.add(graphic3);

        //Prints the complete graphic (Two times the string "Ellipse" and, two times "Rectangle").
        graphic1.print();
    }
}

The second way to go

The second way (C#) to go, is to make the Single instance implement the IEnumerable interface and by using an extension method for combing together the two -from now- collections.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static CompositeDesignPatternNeuron.Program;

namespace CompositeDesignPatternNeuron
{
    public static class NeuronExtension
    {
        public static void ConnectTo(this IEnumerable<Neuron> thisOne, IEnumerable<Neuron> other)
        {
            if (ReferenceEquals(thisOne, other)) return;

            foreach (var from in thisOne)
            {
                foreach (var to in other)
                {
                    from.Out.Add(to);
                    to.In.Add(from);
                }
            }
        }
    }

    public class Neuron : IEnumerable<Neuron>
    {
        public float Value;
        public List<Neuron> In;
        public List<Neuron> Out;
        public Neuron()
        {
            In = new List<Neuron>();
            Out = new List<Neuron>();
            Value = 2.5f;
        }
        public IEnumerator<Neuron> GetEnumerator()
        {
            yield return this;
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }
    }

    public class LayerOfNeuron : Collection<Neuron>
    {

    }

    public class Program
    {
        static void Main(string[] args)
        {
            Neuron neuron1 = new Neuron();
            Neuron neuron2 = new Neuron();
            neuron1.ConnectTo(neuron2);

            LayerOfNeuron layer1 = new LayerOfNeuron();
            LayerOfNeuron layer2 = new LayerOfNeuron();

            layer1.ConnectTo(neuron2);

            Console.ReadKey();
        }
    }
}

WTF

Please, do not read this post if you are down. It is nothing good, or uplifting. Some crazy talk is necessary to tell you my feelings. You have been warned!

Let’s summarize my life. I have no idea who am I, or what do I do with my life. Have no purpose or ideal, hence the “Kein positivität, oder Ziel zu erreichen zu können.” – No positive thoughts, or goal to accomplish attitude. I am the absolute abyss, and I don’t know what to do with my life. I thought it is okay back in the day, when I was 18, but now that I am 26 and still feel the same, I am speechless. The real horror is my own life. I hope that by writing these rows, I am able to get the grips with the constant depression, anxiety and BPD.

The ideas

The ideas that truly helped me for the previous months are:

  1. There are good people who care, GOD -if he exists- bless them
  2. Nobody really cares if you can’t stand up by yourself. -Thank you Leslie!-

Literally. I feel myself obliterated, and thankful when anyone from my environment took the time to talk with me during this ongoing period. Every time someone talked with me, it was better for sometime. I needed to realize, that some people don’t value me much, and would easily ignore my cry for help, even though I thought of them as friends. It was a fruitful experience in many senses. The second point is far more important. Nobody can pull you out of this “dreck”. Only you can pull out yourself from this, and if not, you’re gonna stay in the mud forever. Nobody can really help. And the ones that could won’t because they know how much work would it mean for them. Your friends aren’t your parents, even though my parents behaved like they weren’t my parents. You have no other steady point, but yourself. Only yourself. That’s the cold, muddy, ugly, damn truth. Others can help, but can’t, and won’t solve your problem. It is a cruel and nasty world, with far more problems than solutions.

The goals

The only way to keep your sanity, and self-respect -in BPD case to create it from the void- is to walk on your own, towards whatever goal you make. And those goals aren’t meant to be perfect or even make sense at the moment. YOU need to create THOSE. Because of the BPD I have no self-image. My goals would slide, and shift within a nanosecond if I would let it slide. So I try to persist, and don’t let go of my Informatics interest. No way! Even if you copy another idea, or other’s ideas and dreams, because you have no other at the moment. Stick to them for sometime, otherwise you won’t last!

He holds with the hare and runs with the hounds

The truth is, that even though I know these things, I can’t make myself to do these things day by day. But I try, I genuinely endeavor to become someone with dreams, and who is radiating stability. For my own sake, and not the others. Because trust me, others don’t care! You must, for your own good.

Let’s vote

This is a democracy after all! 😀

Thank you for your time! 🙂

Coming Soon
What would you like to see more?
What would you like to see more?
What would you like to see more?

Someone is around

At that same night, when I was in the boat, watching the other boat full of angled fish. I tried to seek for the guy who was tossed in the water. I had no idea whether it was deception or should I make frantic efforts to save one’s life who got just under the water. I saw something under the water surface that had been moved. I vehemently took off my gear and jumped into the lake. It was a guy who cannot swim I guess. I drew my service knife and cut the ties around his wrists, and legs. He was unconscious by the time I untied him from his hindrance. I was able to elevate him on my boat. He looked a mess. Not just the choking, he had many wounds on his body. Slanted around his breast mostly. Wow. Poor bastard. I’ve felt his pulse, and was given another task. I needed to reanimate him. After 3 minutes of unsuccessful trying, he woke, and coughed. I was revealed. Thank god! He looked at me with angst in his eyes. And out of thin air he asked: Where are they?

Who? – I asked surprised.

The ones that took me, the bastards! … They took me. I was enjoying the sun on my sunbed, when the penetrating light came from above. Like a beam, from those cheese vintage UFO movies. *He?* *I thought guy had some problems, that’s for sure… How big of a lie I was living in back then…*

Okay buddy, whatever you say, just let me get us to the pier. I started the motor on the rear end of the flat boat. The hook got caught in the motor. Oh, I didn’t mention both of my hands got hooks. Well therefore I use the paddles. Most of the time it is easier than starting the motor with these. Not to mention when I need to open a bottle of water or something.