<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ivan</title>
    <description>The latest articles on DEV Community by Ivan (@cwetanow).</description>
    <link>https://dev.to/cwetanow</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F34417%2Fb9fe42e1-e949-424c-92a7-e84a57a39974.jpeg</url>
      <title>DEV Community: Ivan</title>
      <link>https://dev.to/cwetanow</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cwetanow"/>
    <language>en</language>
    <item>
      <title>Daily Coding Problem #4</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Thu, 02 Jan 2020 08:44:33 +0000</pubDate>
      <link>https://dev.to/cwetanow/daily-coding-problem-4-4c3g</link>
      <guid>https://dev.to/cwetanow/daily-coding-problem-4-4c3g</guid>
      <description>&lt;h2&gt;
  
  
  How it works?
&lt;/h2&gt;

&lt;p&gt;The folks at &lt;a href="https://www.dailycodingproblem.com/" rel="noopener noreferrer"&gt;Daily Coding Problem&lt;/a&gt; send you a problem that was asked at a top company every day for you to solve. The premium membership also offers the opportunity to verify your solution.&lt;/p&gt;

&lt;h1&gt;
  
  
  Problem #4
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This problem was asked by Stripe.

Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.

For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.

You can modify the input array in-place.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  My solution
&lt;/h1&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
using System.Collections.Generic;
using System.Linq;

namespace DailyCodingProblem.Solutions.Problem04
{
    public class Solution
    {
        public static void Test()
        {
            var input = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                .ToHashSet();

            var minPositiveNumber = GetMinimalPositiveNumber(input);

            Console.WriteLine(minPositiveNumber);
        }

        public static int GetMinimalPositiveNumber(HashSet&amp;lt;int&amp;gt; input)
        {
            var minPositiveNumber = 1;
            while (true)
            {
                if (!input.Contains(minPositiveNumber))
                {
                    break;
                }

                minPositiveNumber++;
            }

            return minPositiveNumber;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Solutions are posted in my Github account&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/cwetanow" rel="noopener noreferrer"&gt;
        cwetanow
      &lt;/a&gt; / &lt;a href="https://github.com/cwetanow/DailyCodingProblem" rel="noopener noreferrer"&gt;
        DailyCodingProblem
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;DailyCodingProblem &lt;a href="https://travis-ci.org/cwetanow/DailyCodingProblem" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/e9bf83d951fa36ffbc4d76784881db68ea3daf95bd1d9d6ea84ac83c32b2caa2/68747470733a2f2f7472617669732d63692e6f72672f63776574616e6f772f4461696c79436f64696e6750726f626c656d2e7376673f6272616e63683d6d6173746572" alt="Build Status"&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;This repository contains solutions of the &lt;a href="https://www.dailycodingproblem.com/" rel="nofollow noopener noreferrer"&gt;Daily Coding Problem&lt;/a&gt; tasks&lt;/p&gt;

&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/cwetanow/DailyCodingProblem" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
. 

&lt;p&gt;Feel free to leave a like and post a comment.&lt;/p&gt;

&lt;p&gt;If you also have any better solution in mind, by all means, share it, so we can learn from each other.&lt;/p&gt;

</description>
      <category>dev</category>
      <category>practice</category>
      <category>algorithms</category>
      <category>challenge</category>
    </item>
    <item>
      <title>Daily Coding Problem #3</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Mon, 26 Nov 2018 06:24:22 +0000</pubDate>
      <link>https://dev.to/cwetanow/daily-coding-problem-3-73i</link>
      <guid>https://dev.to/cwetanow/daily-coding-problem-3-73i</guid>
      <description>&lt;p&gt;For quite some time I found my time procastinating after getting home from work. Untill a few days ago I stumbled upon the &lt;a href="https://www.dailycodingproblem.com/" rel="noopener noreferrer"&gt;Daily Coding Problem&lt;/a&gt; (DCP) and decided to give it a shot. &lt;br&gt;
The code is in C#.&lt;/p&gt;
&lt;h2&gt;
  
  
  How it works?
&lt;/h2&gt;

&lt;p&gt;The folks at DCP send you a problem that was asked at a top company everyday for you to solve. The premium membership also offers the opportunity to verify your solution.&lt;/p&gt;
&lt;h1&gt;
  
  
  Problem #2
&lt;/h1&gt;

&lt;p&gt;This problem was asked by Google.&lt;/p&gt;

&lt;p&gt;Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree.&lt;/p&gt;

&lt;p&gt;For example, given the following Node class&lt;/p&gt;

&lt;p&gt;class Node: def init(self, val, left=None, right=None): self.val = val self.left = left self.right = right The following test should pass:&lt;/p&gt;

&lt;p&gt;node = Node('root', Node('left', Node('left.left')), Node('right')) assert deserialize(serialize(node)).left.left.val == 'left.left'&lt;/p&gt;
&lt;h1&gt;
  
  
  My solution
&lt;/h1&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Task03
{
    public class Program
    {
        private const string Empty_Marker = "1";

        public static void Main(string[] args)
        {
            var node = new Node("root", new Node("left", new Node("left.left")), new Node("right"));

            var serialized = Serialize(node);

            Console.WriteLine(serialized);
            node = Deserialize(serialized);

            Console.WriteLine(node.Left.Left.Value);
        }

        public static string Serialize(Node node)
        {
            if (node == null)
            {
                return Empty_Marker + '-';
            }

            var builder = new StringBuilder();

            builder.Append($"{node.Value}-");

            builder.Append(Serialize(node.Left));
            builder.Append(Serialize(node.Right));

            return builder.ToString();
        }

        public static Node Deserialize(string serializedNode)
        {
            var nodes = serializedNode
                .Split('-', StringSplitOptions.RemoveEmptyEntries)
                .ToArray();

            var queue = new Queue&amp;lt;string&amp;gt;(nodes);

            var node = DeserializeNode(queue);

            return node;
        }

        private static Node DeserializeNode(Queue&amp;lt;string&amp;gt; nodes)
        {
            if (nodes.Peek() != null)
            {
                var nextNode = nodes.Dequeue();

                if (nextNode == Empty_Marker)
                {
                    return null;
                }

                var node = new Node(nextNode);

                node.Left = DeserializeNode(nodes);

                node.Right = DeserializeNode(nodes);

                return node;
            }

            return null;
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Explanation
&lt;/h1&gt;

&lt;p&gt;For the serialization, we traverse the tree depth first and add the current node's value to the serialized string. When we reach a node which is null (basically it's parent doesn't have a child), we put an &lt;code&gt;Empty_Marker&lt;/code&gt; to signal that there is no node here. This works assuming the symbols for &lt;code&gt;Empty_Marker&lt;/code&gt; and '-' are not going to be used in any node's value.&lt;/p&gt;

&lt;p&gt;For the deserialize, we split the given string and put the results in a queue. Then build the tree depth first, getting through the queue's first element and stopping when we reach an &lt;code&gt;Empty_Marker&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I will try to do the daily problem everyday, but sometimes life gets in the way :)&lt;br&gt;
Solutions are posted in my github account&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/cwetanow" rel="noopener noreferrer"&gt;
        cwetanow
      &lt;/a&gt; / &lt;a href="https://github.com/cwetanow/DailyCodingProblem" rel="noopener noreferrer"&gt;
        DailyCodingProblem
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;DailyCodingProblem &lt;a href="https://travis-ci.org/cwetanow/DailyCodingProblem" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/e9bf83d951fa36ffbc4d76784881db68ea3daf95bd1d9d6ea84ac83c32b2caa2/68747470733a2f2f7472617669732d63692e6f72672f63776574616e6f772f4461696c79436f64696e6750726f626c656d2e7376673f6272616e63683d6d6173746572" alt="Build Status"&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;This repository contains solutions of the &lt;a href="https://www.dailycodingproblem.com/" rel="nofollow noopener noreferrer"&gt;Daily Coding Problem&lt;/a&gt; tasks&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/cwetanow/DailyCodingProblem" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
. 

&lt;p&gt;Feel free to leave a like and let me know in the comments if I should continue to post my solutions.&lt;/p&gt;

&lt;p&gt;If you also have any better solution in mind, by all means share it, so we can learn from each other.&lt;/p&gt;

</description>
      <category>dev</category>
      <category>practice</category>
      <category>algorithms</category>
      <category>challenge</category>
    </item>
    <item>
      <title>Daily Coding Problem #2</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Sun, 25 Nov 2018 07:08:04 +0000</pubDate>
      <link>https://dev.to/cwetanow/daily-coding-problem-2-21pj</link>
      <guid>https://dev.to/cwetanow/daily-coding-problem-2-21pj</guid>
      <description>&lt;p&gt;Seeing the first post gained some popularity, here is the second problem&lt;/p&gt;

&lt;p&gt;For quite some time I found my time procastinating after getting home from work. Untill a few days ago I stumbled upon the &lt;a href="https://www.dailycodingproblem.com/" rel="noopener noreferrer"&gt;Daily Coding Problem&lt;/a&gt; (DCP) and decided to give it a shot. &lt;br&gt;
The code is in C#.&lt;/p&gt;
&lt;h2&gt;
  
  
  How it works?
&lt;/h2&gt;

&lt;p&gt;The folks at DCP send you a problem that was asked at a top company everyday for you to solve. The premium membership also offers the opportunity to verify your solution.&lt;/p&gt;
&lt;h1&gt;
  
  
  Problem #2
&lt;/h1&gt;

&lt;p&gt;This problem was asked by Uber.&lt;/p&gt;

&lt;p&gt;Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.&lt;/p&gt;

&lt;p&gt;For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].&lt;/p&gt;

&lt;p&gt;Follow-up: what if you can't use division?&lt;/p&gt;
&lt;h1&gt;
  
  
  My solution
&lt;/h1&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
using System.Linq;

namespace Task02
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                .ToArray();

            var result = new int[input.Length];

            for (int i = 0; i &amp;lt; result.Length; i++)
            {
                result[i] = 1;

                for (int j = 0; j &amp;lt; result.Length; j++)
                {
                    if (j != i)
                    {
                        result[i] *= input[j];
                    }
                }
            }


            Console.WriteLine(string.Join(' ', result));
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Explanation
&lt;/h1&gt;

&lt;p&gt;Here I could not think of any better than the naive solution, which works in O(n^2) time and you never like square complexity. &lt;br&gt;
Basically for every item in the result array, foreach the input array and check if the index is different from the item's. If they are, multiply the current value of the item times the current input item&lt;/p&gt;

&lt;p&gt;I will try to do the daily problem everyday, but sometimes life gets in the way :)&lt;br&gt;
Solutions are posted in my github account&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/cwetanow" rel="noopener noreferrer"&gt;
        cwetanow
      &lt;/a&gt; / &lt;a href="https://github.com/cwetanow/DailyCodingProblem" rel="noopener noreferrer"&gt;
        DailyCodingProblem
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;DailyCodingProblem &lt;a href="https://travis-ci.org/cwetanow/DailyCodingProblem" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/e9bf83d951fa36ffbc4d76784881db68ea3daf95bd1d9d6ea84ac83c32b2caa2/68747470733a2f2f7472617669732d63692e6f72672f63776574616e6f772f4461696c79436f64696e6750726f626c656d2e7376673f6272616e63683d6d6173746572" alt="Build Status"&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;This repository contains solutions of the &lt;a href="https://www.dailycodingproblem.com/" rel="nofollow noopener noreferrer"&gt;Daily Coding Problem&lt;/a&gt; tasks&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/cwetanow/DailyCodingProblem" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
. 

&lt;p&gt;Feel free to leave a like and let me know in the comments if I should continue to post my solutions.&lt;/p&gt;

&lt;p&gt;If you also have any better solution in mind, by all means share it, so we can learn from each other.&lt;/p&gt;

</description>
      <category>dev</category>
      <category>practice</category>
      <category>algorithms</category>
      <category>challenge</category>
    </item>
    <item>
      <title>Daily Coding Problem #1</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Sat, 24 Nov 2018 08:48:38 +0000</pubDate>
      <link>https://dev.to/cwetanow/daily-coding-problem-1-23e0</link>
      <guid>https://dev.to/cwetanow/daily-coding-problem-1-23e0</guid>
      <description>&lt;p&gt;For quite some time I found my time procastinating after getting home from work. Untill a few days ago I stumbled upon the &lt;a href="https://www.dailycodingproblem.com/" rel="noopener noreferrer"&gt;Daily Coding Problem&lt;/a&gt; (DCP) and decided to give it a shot. &lt;br&gt;
The code is in C#.&lt;/p&gt;
&lt;h2&gt;
  
  
  How it works?
&lt;/h2&gt;

&lt;p&gt;The folks at DCP send you a problem that was asked at a top company everyday for you to solve. The premium membership also offers the opportunity to verify your solution.&lt;/p&gt;
&lt;h1&gt;
  
  
  Problem #1
&lt;/h1&gt;

&lt;p&gt;This problem was recently asked by Google.&lt;/p&gt;

&lt;p&gt;Given a list of numbers and a number k, return whether any two numbers from the list add up to k.&lt;/p&gt;

&lt;p&gt;For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.&lt;/p&gt;

&lt;p&gt;Bonus: Can you do this in one pass?&lt;/p&gt;
&lt;h1&gt;
  
  
  My solution
&lt;/h1&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
using System.Collections.Generic;
using System.Linq;

namespace Problem01
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var numbers = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                .ToList();

            var k = int.Parse(Console.ReadLine());

            var result = TwoNumbersEqual(numbers, k);
            Console.WriteLine(result);
        }

        public static bool TwoNumbersEqual(List&amp;lt;int&amp;gt; numbers, int k)
        {
            var set = new HashSet&amp;lt;int&amp;gt;();

            foreach (var number in numbers)
            {
                var remaining = k - number;

                if (set.Contains(remaining))
                {
                    return true;
                }

                set.Add(number);
            }

            return false;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Explanation
&lt;/h1&gt;

&lt;p&gt;The naive solution would be to do two nested for loops and check if any of the combinations gives the &lt;code&gt;k&lt;/code&gt; we desire.&lt;br&gt;
But because I wanted the bonus tag and after some tought, I realized that you could foreach the input array and for each item check find the difference between it and &lt;code&gt;k&lt;/code&gt;. After you find the difference, you can check if you have already seen this number before and the &lt;code&gt;HashSet&lt;/code&gt; data structure allows for constant lookups (because it is a hash table).&lt;/p&gt;

&lt;p&gt;I will try to do the daily problem everyday, but sometimes life gets in the way :)&lt;br&gt;
Solutions are posted in my github account&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/cwetanow" rel="noopener noreferrer"&gt;
        cwetanow
      &lt;/a&gt; / &lt;a href="https://github.com/cwetanow/DailyCodingProblem" rel="noopener noreferrer"&gt;
        DailyCodingProblem
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;DailyCodingProblem &lt;a href="https://travis-ci.org/cwetanow/DailyCodingProblem" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/e9bf83d951fa36ffbc4d76784881db68ea3daf95bd1d9d6ea84ac83c32b2caa2/68747470733a2f2f7472617669732d63692e6f72672f63776574616e6f772f4461696c79436f64696e6750726f626c656d2e7376673f6272616e63683d6d6173746572" alt="Build Status"&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;/div&gt;
&lt;p&gt;This repository contains solutions of the &lt;a href="https://www.dailycodingproblem.com/" rel="nofollow noopener noreferrer"&gt;Daily Coding Problem&lt;/a&gt; tasks&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/cwetanow/DailyCodingProblem" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
. 

&lt;p&gt;Feel free to leave a like and let me know in the comments if I should continue to post my solutions.&lt;/p&gt;

&lt;p&gt;If you also have any better solution in mind, by all means share it, so we can learn from each other.&lt;/p&gt;

</description>
      <category>dev</category>
      <category>practice</category>
      <category>algorithms</category>
      <category>challenge</category>
    </item>
    <item>
      <title>Why you should be strength training</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Fri, 28 Sep 2018 14:45:36 +0000</pubDate>
      <link>https://dev.to/cwetanow/why-you-should-be-strength-training-4d6h</link>
      <guid>https://dev.to/cwetanow/why-you-should-be-strength-training-4d6h</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R3vesy5F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bodymorphology.files.wordpress.com/2012/08/cropped-barbells.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R3vesy5F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://bodymorphology.files.wordpress.com/2012/08/cropped-barbells.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The stereotypical programmer wakes up in the afternoon, has a couple of Red Bulls or Monsters for breakfast, and codes until the wee hours of the morning with the occasional break to open the door for the pizza delivery guy. &lt;br&gt;
Those days are long passed and I have noticed more and more devs are aware of the benefits of a healthy lifestyle and proper weightlifting routine.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Strength training is a physical activity designed to improve muscular fitness by exercising a specific muscle or muscle group against external resistance, including free-weights, weight machines, or your own body weight.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;First of all, life is EASIER when you’re strong. You don't have to make a second trip to get the other half of the groceries, can easily carry 2-3 kids when they are sleepy after a long day at the park or push your car with easy when it is stuck in the snow.&lt;/p&gt;

&lt;p&gt;In addition to making life easier, proper strength training has a lot of great benefits. A few are listed down below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Enhance your quality of life&lt;/strong&gt;.  When you get stronger, sitting, walking and standing with good posture will become a lot easier, will feel more natural and you will start to do it without constantly reminding yourself. Other common tasks like carrying objects will get a lot easier as well.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Manage your weight&lt;/strong&gt;. Strength training increases muscle mass increased muscle increases the number of calories your body naturally burns at rest. In addition to this your body will burn calories during the weight lifting session and will require additional calories to repair your muscles after it, allowing you to eat a little more food without the guilt.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You can level up&lt;/strong&gt; Cardio is boring. With strength training, when taken seriously, you will try to lift more weight, perfect your technique and try to break your own records every workout. Everybody likes to be like their favourite RPG game character and get stronger with training.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Boosts energy levels and imroves mood&lt;/strong&gt;. Strength training will elevate your level of  endorphins (natural opiates produced by the brain), which lift energy levels and improve mood. If that isn't enough to convince you, there’s evidence strength training may help you sleep better..&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Manage chronic conditions&lt;/strong&gt;. Strength training can reduce the signs and symptoms of many chronic conditions, such as arthritis, back pain, obesity, heart disease, depression and diabetes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If that is not enough to convince you, I do not know what will.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you get started with strength training?
&lt;/h2&gt;

&lt;p&gt;If you’re looking to add strength or resistance training to your routine you have a lot of options - you definitely don’t need a gym membership or expensive weight machines. For starters, squatting on a chair at home, push-ups, planks, or other movements that require you to use your own body weight as resistance be very effective.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you have any health issues, ask your doctor what type of strength training is best to meet your needs and abilities. You can also work with a fitness expert to design a strength-training program that will be safe and effective for you.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Who doesn't want to look better, feel better, and live a longer, healthier life?&lt;/p&gt;

&lt;p&gt;When you step foot in the gym, it is important to pick the proper exercises and frequency for our abilities. The workouts, designed for an advanced athlete, could be impossible for a beginner to do.&lt;/p&gt;

&lt;p&gt;All compound movements(movements that include more than one joint) are a good pick for a person with little to no weightlifting experience. Those exercises include squat, deadlift, bench press, overhead press, pull ups, push ups, dips and many more variations.&lt;/p&gt;

&lt;p&gt;A good program to start with is &lt;a href="https://startingstrength.com/get-started/programs"&gt;Starting Strength Linear Progression&lt;/a&gt;. &lt;strong&gt;First make sure to learn proper technique on the movements before starting any program&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: I am not a doctor or a medical professional.  Always consult a physician before starting any exercise program. Use of this information is strictly at your own risk. &lt;/p&gt;

&lt;h2&gt;
  
  
  Feel free to leave a comment about any questions you may have or share with us your recent gym PRs.
&lt;/h2&gt;

</description>
      <category>dev</category>
      <category>fitness</category>
      <category>lifting</category>
      <category>health</category>
    </item>
    <item>
      <title>My top dev podcasts</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Fri, 21 Sep 2018 15:02:21 +0000</pubDate>
      <link>https://dev.to/cwetanow/my-top-dev-podcasts-4ffo</link>
      <guid>https://dev.to/cwetanow/my-top-dev-podcasts-4ffo</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Uu00Wk_4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pi.tedcdn.com/r/talkstar-assets.s3.amazonaws.com/production/playlists/playlist_399/podcast_lover_1200x627.jpg%3Fquality%3D89%26w%3D800" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Uu00Wk_4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pi.tedcdn.com/r/talkstar-assets.s3.amazonaws.com/production/playlists/playlist_399/podcast_lover_1200x627.jpg%3Fquality%3D89%26w%3D800" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For quite a while I wondered what can one do to be productive while he/she was doing housework, public transportation or other mindless activities. &lt;br&gt;
So I decided to give podcasts a try. Needless to say, I was hooked right from the start.&lt;br&gt;
First I started with a few podcasts and as time passed, my list now has over 50 podcasts in it, ranging in different topics - software development, fitness, finances, productivity, enterpreneurship, investing and such.&lt;/p&gt;

&lt;p&gt;So here is my list of Top Software Development podcasts&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://www.codingblocks.net/"&gt;Coding blocks&lt;/a&gt;
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;A podcast for software developers and computer programmers to educate on the go.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Really informative and easy to follow. The subjects covered are really relevant to modern techniques, patterns and practices as well as discussing fundamentals to be a good developer.&lt;br&gt;
Only downside is that episodes are a bit longer (about 100 minutes)&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://completedeveloperpodcast.com/"&gt;Complete Developer Podcast&lt;/a&gt;
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;A podcast by coders for coders about all aspects of life as a developer.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Podcast topics also include soft skills, life advice and other non-technical stuff. Will and BJ make a great combo, episodes are also shorter (about an hour)&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="http://www.weeklydevtips.com/"&gt;Weekly Dev Tips&lt;/a&gt;
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Weekly Dev Tips offers a variety of technical and career tips for software developers. Each tip is quick and to the point, describing a problem and one or more ways to solve that problem. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The episodes are very short but straight to the point. The topics are interesting, the tips are valuable and thought provoking.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://www.mergeconflict.fm/"&gt;Merge Conflict&lt;/a&gt;
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Merge Conflict is a weekly discussion with Frank and James on all things development, technology, &amp;amp; more. Much more than just another mobile development podcast, Merge Conflict, reaches all areas of development including desktop, server, and of course mobile. They also cover fun things happening in the world of technology and gaming and whatever else happens to be on Frank's and James' minds.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Wide range of topics and also covering recent events in development world. Mainly focused on mobile development.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://cynicaldeveloper.com/"&gt;The Cynical Developer&lt;/a&gt;
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;The UK based, weekly podcast that helps you to improve your development knowledge and career,&lt;br&gt;
through explaining the latest and greatest in development technology and providing you with what you need to succeed as a developer.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This podcast covers a wide range of topics with a good ratio of both technical and soft skills.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://spec.fm/podcasts/developer-tea"&gt;Developer Tea&lt;/a&gt;
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Developer Tea exists to help driven developers connect to their ultimate purpose and excel at their work so that they can positively impact the people they influence&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Nice, short episodes with a wide variety of topics. Sometimes due to the episodes being shorter, a big portion of the time is spent on sponsors of the show. &lt;br&gt;
Like the podcast but starting to have doubts because of all the sponsor talks (yeah yeah, I know he has to eat)&lt;/p&gt;

&lt;p&gt;Those are my top podcasts. &lt;br&gt;
I have also subscribed to other, but have not listened to much of them to give an opinion&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.fullstackradio.com/"&gt;Full Stack Radio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.se-radio.net/"&gt;Software Engineering Radio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://softwareengineeringdaily.com/"&gt;Software Engineering Daily&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hanselminutes.com/"&gt;Hanselminutes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I use &lt;a href="https://play.google.com/store/apps/details?id=com.bambuna.podcastaddict&amp;amp;hl=en"&gt;Podcast Addict&lt;/a&gt; as a player. It has nice UI and also good functionalities.&lt;/p&gt;

&lt;p&gt;If you know other good development podcasts or want me to list other podcasts I listen to, feel free to leave a comment.&lt;/p&gt;

</description>
      <category>podcast</category>
      <category>productivity</category>
      <category>dev</category>
    </item>
    <item>
      <title>Wiring up Ninject with ASP.NET Core 2.0</title>
      <dc:creator>Ivan</dc:creator>
      <pubDate>Thu, 23 Nov 2017 09:28:56 +0000</pubDate>
      <link>https://dev.to/cwetanow/wiring-up-ninject-with-aspnet-core-20-3hp</link>
      <guid>https://dev.to/cwetanow/wiring-up-ninject-with-aspnet-core-20-3hp</guid>
      <description>&lt;p&gt;&lt;em&gt;This guide is for Ninject versions 3.3.x&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.ninject.org/"&gt;Ninject&lt;/a&gt; is a lightning-fast, ultra-lightweight dependency injector for .NET applications. It helps you split your application into a collection of loosely-coupled, highly-cohesive pieces, and then glue them back together in a flexible manner. By using Ninject to support your software's architecture, your code will become easier to write, reuse, test, and modify.&lt;/p&gt;

&lt;p&gt;To test if the injector is working correctly, create a service that implements an interface&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public interface ITestService
    {
        string GetData();
    }

    public class TestService : ITestService
    {
        public string GetData()
        {
            return "some magic string";
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Download the package from Nuget
&lt;/h4&gt;

&lt;p&gt;Using the package manager console &lt;code&gt;Install-Package Ninject -Version 3.3.4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Using dotnet cli &lt;code&gt;dotnet add package Ninject --version 3.3.4&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Add these members to &lt;code&gt;Startup.cs&lt;/code&gt; class as shown below
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    private readonly AsyncLocal&amp;lt;Scope&amp;gt; scopeProvider = new AsyncLocal&amp;lt;Scope&amp;gt;();
    private IKernel Kernel { get; set; }

    private object Resolve(Type type) =&amp;gt; Kernel.Get(type);
    private object RequestScope(IContext context) =&amp;gt; scopeProvider.Value;  

    private sealed class Scope : DisposableObject { }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Add the following binding in the end of &lt;code&gt;ConfigureServices&lt;/code&gt; (&lt;code&gt;Startup.cs&lt;/code&gt;)
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;services.AddSingleton&amp;lt;IHttpContextAccessor, HttpContextAccessor&amp;gt;();&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Create class &lt;code&gt;RequestScopingStartupFilter&lt;/code&gt; implementing the &lt;code&gt;IStartupFilter&lt;/code&gt; interface
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public sealed class RequestScopingStartupFilter : IStartupFilter
    {
        private readonly Func&amp;lt;IDisposable&amp;gt; requestScopeProvider;

        public RequestScopingStartupFilter(Func&amp;lt;IDisposable&amp;gt; requestScopeProvider)
        {
            if (requestScopeProvider == null)
            {
                throw new ArgumentNullException(nameof(requestScopeProvider));
            }

            this.requestScopeProvider = requestScopeProvider;
        }

        public Action&amp;lt;IApplicationBuilder&amp;gt; Configure(Action&amp;lt;IApplicationBuilder&amp;gt; nextFilter)
        {
            return builder =&amp;gt;
            {
                ConfigureRequestScoping(builder);

                nextFilter(builder);
            };
        }

        private void ConfigureRequestScoping(IApplicationBuilder builder)
        {
            builder.Use(async (context, next) =&amp;gt;
            {
                using (var scope = this.requestScopeProvider())
                {
                    await next();
                }
            });
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Create a static class &lt;code&gt;AspNetCoreExtensions&lt;/code&gt; with the following extension method
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    using System;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.DependencyInjection;

    public static class AspNetCoreExtensions
    {
        public static void AddRequestScopingMiddleware(this IServiceCollection services, 
            Func&amp;lt;IDisposable&amp;gt; requestScopeProvider)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (requestScopeProvider == null)
            {
                throw new ArgumentNullException(nameof(requestScopeProvider));
            }

            services
                .AddSingleton&amp;lt;IStartupFilter&amp;gt;(new
                    RequestScopingStartupFilter(requestScopeProvider));
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Configure to use the middleware in &lt;code&gt;ConfigureServices&lt;/code&gt;(in the end of the method)
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;services.AddRequestScopingMiddleware(() =&amp;gt; scopeProvider.Value = new Scope());&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Create a file &lt;code&gt;Activators.cs&lt;/code&gt; with the following
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   public sealed class DelegatingControllerActivator : IControllerActivator
        {
            private readonly Func&amp;lt;ControllerContext, object&amp;gt; controllerCreator;
            private readonly Action&amp;lt;ControllerContext, object&amp;gt; controllerReleaser;

            public DelegatingControllerActivator(Func&amp;lt;ControllerContext, object&amp;gt; controllerCreator,
                Action&amp;lt;ControllerContext, object&amp;gt; controllerReleaser = null)
            {
                this.controllerCreator = controllerCreator ?? 
                    throw new ArgumentNullException(nameof(controllerCreator));
                this.controllerReleaser = controllerReleaser ?? ((_, __) =&amp;gt; { });
            }

            public object Create(ControllerContext context) =&amp;gt; this.controllerCreator(context);
            public void Release(ControllerContext context, object controller) =&amp;gt;             
                this.controllerReleaser(context, controller);
        } 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Add the following extension method to &lt;code&gt;AspNetCoreExtensions.cs&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        public static void AddCustomControllerActivation(this IServiceCollection services,
            Func&amp;lt;Type, object&amp;gt; activator)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));
            if (activator == null) throw new ArgumentNullException(nameof(activator));

            services.AddSingleton&amp;lt;IControllerActivator&amp;gt;(new DelegatingControllerActivator(
                context =&amp;gt; activator(context.ActionDescriptor.ControllerTypeInfo.AsType())));
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Append the following to the end of &lt;code&gt;ConfigureServices&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;services.AddCustomControllerActivation(Resolve);&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Add another class to &lt;code&gt;Activators.cs&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        public sealed class DelegatingViewComponentActivator : IViewComponentActivator
        {
            private readonly Func&amp;lt;Type, object&amp;gt; viewComponentCreator;
            private readonly Action&amp;lt;object&amp;gt; viewComponentReleaser;

            public DelegatingViewComponentActivator(Func&amp;lt;Type, object&amp;gt; viewComponentCreator,
                Action&amp;lt;object&amp;gt; viewComponentReleaser = null)
            {
                this.viewComponentCreator = viewComponentCreator ?? 
                    throw new ArgumentNullException(nameof(viewComponentCreator));
                this.viewComponentReleaser = viewComponentReleaser ?? (_ =&amp;gt; { });
            }

            public object Create(ViewComponentContext context) =&amp;gt;
                this.viewComponentCreator(context.ViewComponentDescriptor.TypeInfo.AsType());

            public void Release(ViewComponentContext context, object viewComponent) =&amp;gt;
                this.viewComponentReleaser(viewComponent);
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  And another extension method in &lt;code&gt;AspNetCoreExtensions.cs&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       public static void AddCustomViewComponentActivation(this IServiceCollection services, 
            Func&amp;lt;Type, object&amp;gt; activator)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));
            if (activator == null) throw new ArgumentNullException(nameof(activator));

            services.AddSingleton&amp;lt;IViewComponentActivator&amp;gt;(
new DelegatingViewComponentActivator(activator));
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then call it form &lt;code&gt;ConfigureServices&lt;/code&gt; (should be the last invoked)&lt;/p&gt;

&lt;p&gt;This is what &lt;code&gt;ConfigureServices&lt;/code&gt; should look like now&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        public void ConfigureServices(IServiceCollection services)
        {
            // Other configurations

            services.AddSingleton&amp;lt;IHttpContextAccessor, HttpContextAccessor&amp;gt;();

            services.AddRequestScopingMiddleware(() =&amp;gt; scopeProvider.Value = new Scope());
            services.AddCustomControllerActivation(Resolve);
            services.AddCustomViewComponentActivation(Resolve);

        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Create an &lt;code&gt;ApplicationBuilderExtensions.cs&lt;/code&gt; with a static class in it
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    using System;
    using System.Globalization;
    using System.Linq;
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Http;
    using Microsoft.AspNetCore.Mvc.ApplicationParts;
    using Microsoft.AspNetCore.Mvc.Controllers;
    using Microsoft.Extensions.DependencyInjection;
    using Ninject;

    public static class ApplicationBuilderExtensions
    {
        public static void BindToMethod&amp;lt;T&amp;gt;(this IKernel config, Func&amp;lt;T&amp;gt; method)
 =&amp;gt; config.Bind&amp;lt;T&amp;gt;().ToMethod(c =&amp;gt; method());

        public static Type[] GetControllerTypes(this IApplicationBuilder builder)
        {
            var manager = builder.ApplicationServices.GetRequiredService&amp;lt;ApplicationPartManager&amp;gt;();

            var feature = new ControllerFeature();
            manager.PopulateFeature(feature);

            return feature.Controllers.Select(t =&amp;gt; t.AsType()).ToArray();
        }

        public static T GetRequestService&amp;lt;T&amp;gt;(this IApplicationBuilder builder) where T : class
        {
            if (builder == null) throw new ArgumentNullException(nameof(builder));

            return GetRequestServiceProvider(builder).GetService&amp;lt;T&amp;gt;();
        }

        private static IServiceProvider GetRequestServiceProvider(IApplicationBuilder builder)
        {
            var accessor = builder.ApplicationServices.GetService&amp;lt;IHttpContextAccessor&amp;gt;();

            if (accessor == null)
            {
                throw new InvalidOperationException(      
          typeof(IHttpContextAccessor).FullName);
            }

            var context = accessor.HttpContext;

            if (context == null)
            {
                throw new InvalidOperationException("No HttpContext.");
            }

            return context.RequestServices;
        }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following method in &lt;code&gt;Startup&lt;/code&gt; class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        private IKernel RegisterApplicationComponents(IApplicationBuilder app)
        {
            // IKernelConfiguration config = new KernelConfiguration();
            var kernel = new StandardKernel();

            // Register application services
            foreach (var ctrlType in app.GetControllerTypes())
            {
                kernel.Bind(ctrlType).ToSelf().InScope(RequestScope);
            }

            // This is where our bindings are configurated
             kernel.Bind&amp;lt;ITestService&amp;gt;().To&amp;lt;TestService&amp;gt;().InScope(RequestScope);            

            // Cross-wire required framework services
            kernel.BindToMethod(app.GetRequestService&amp;lt;IViewBufferScope&amp;gt;);

            return kernel;
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and call it from &lt;code&gt;Configure&lt;/code&gt; (in the beginning)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.Kernel = this.RegisterApplicationComponents(app);&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Create a &lt;code&gt;TestController&lt;/code&gt; to see if our DI works
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    [Route("api/[controller]")]
    public class ValuesController : Controller
    {
        private readonly ITestService testService;

        public ValuesController(ITestService testService)
        {
            this.testService = testService;
            this.factory = factory;
        }

        [HttpGet]
        public IActionResult Get()
        {
            var result = this.testService.GetData();

            return this.Ok(result);
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Place a breakpoint in the constructor of our &lt;code&gt;TestService&lt;/code&gt; and in the &lt;code&gt;Get&lt;/code&gt; action to see the magic.&lt;/p&gt;

&lt;h4&gt;
  
  
  I have compiled this article from &lt;a href="https://stackoverflow.com/questions/46693305/how-to-integrate-ninject-into-asp-net-core-2-0-web-applications"&gt;this&lt;/a&gt; answer on stackoverflow with a little help from this &lt;a href="https://github.com/dotnetjunkie/Missing-Core-DI-Extensions"&gt;dotnetjunkie&lt;/a&gt; repo.
&lt;/h4&gt;

</description>
      <category>dependencyinjection</category>
      <category>webdev</category>
      <category>coding</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
