teleren/devto huggingface dataset:
You are going to fail
Tags: productivity, motivation, performance, beginners
Published: 2023-01-05 18:03:35

I pride myself on the fact that I have never had to ask for help. I have never felt overwhelmed or out of my depth. I've never made egregious errors that forced me to scramble for a quick solution. I've never faced a challenge so daunting that I began to question all of my life choices.

Do I have your attention? Your ire, perhaps? Good. Because everything I just said above is a complete lie and I have absolutely done all of those things on more than one occasion.

Writing code is *hard*. Writing good code is *really hard*. This is why so many of us experience burnout and imposter syndrome. We are the mental equivalent of professional athletes. We're competitive, always training, and always need to be at the top of our game. 

That kind of pressure lives in the back of our minds. We may take a look around and see just how much we *don't know* and feel inferior. After working in this field for 10 years I'm here to share a little secret:

Senior developers are just junior developers who have had more time to make more mistakes.

That's right. We're not smarter than you. We haven't tapped some mysterious force of knowledge or wisdom. We've just faceplanted so many times that we've finally learned a few lessons.

I still struggle with burnout and imposter syndrome. Only now, after having overcome so many hurdles, there's a small part of me that knows that I'll probably be fine and will figure things out.

Persistence is the #1 ingredient to being a successful software developer.

So fail my friends. Fail with enthusiasm. Because failure leads to learning and learning leads to growth.
Verilog: Mux 2 to 1 (Multiplexer)
Tags: verilog, beginners, programming, tutorial
Published: 2023-01-05 17:24:36

Understanding the low levels always helps me to know and learn better and touch the reality of computers, particularly when I am coding.

Mux 2 to 1 (Multiplexer) is one of the easiest digital circuits which is made by different gates such as AND and OR gates.

The point of the 2-to-1 multiplexer is that can help you to select your chosen input. For example, you have i0 and i1 as Input One and Input Two, and you need to select between inputs. You can set a Select to decide which inputs must transfer to output (F).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6o73q1xta98xon0k9gnn.png)


In the truth table you can see if you set your select equals to 0, then the first Input which is i0 (a) will choose and vice versa.

To implement this module you need to know what gates you need.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8v7n247emxiaqkl0ioz.png)

It consists of two AND, one OR, and one NOT gates.
The boolean logic equation for a 2-to-1 multiplexer is 
(A. ˉS)+(B. S)
where A is the first input and B is the second input.


```
embed module mux2to1(sel, i1, i0, f);
    input i0, i1, sel;
    output f;
    wire nsel, w1, w2;

    not(nsel, sel);

    and(w1, i0, nsel);
    and(w2, i1, sel);
    or(f, w1, w2);
endmodule
```

To evaluate the code you can check it manually or write a testbench for it.

```
module test_mux2to1;
  reg s, a1, a0;
  wire q;
  mux2to1 mux(.sel(s), .i1(a1), .i0(a0), .f(q));
  initial begin
    $monitor("sel = %b: i0 = %b, i1 = %b --> f = %b", s, a0, a1, q);
    s = 1'b0; a1=1'b0; a0=1'b0;
    #10
    s = 1'b0; a1=1'b1; a0=1'b1;
    #10
    s = 1'b0; a1=1'b1; a0=1'b0;
    #10
    s = 1'b0; a1=1'b1; a0=1'b1;
    #10
    s = 1'b1; a1=1'b0; a0=1'b0;
    #10
    s = 1'b1; a1=1'b0; a0=1'b1;
    #10
    s = 1'b1; a1=1'b1; a0=1'b0;
    #10
    s = 1'b1; a1=1'b1; a0=1'b1;
  end
endmodule
```

The code is available on my [GitHub](https://github.com/iw4p/). Here is the [link](https://github.com/iw4p/Verilog/blob/master/mux2to1.v).
C# - Day 3: Conditional-Statements - 30 Days of Code HackerRank
Published: 2023-01-05 17:17:32

**Task**
Given an integer, , perform the following conditional actions:

1. If  is odd, print Weird
2. If  is even and in the inclusive range of  to , print Not Weird
3. If  is even and in the inclusive range of  to , print Weird
4. If  is even and greater than , print Not Weird
5. Complete the stub code provided in your editor to print whether or not  is weird.

using System;

class Solution
{
    public static void Main(string[] args)
    {
        int N = Convert.ToInt32(Console.ReadLine().Trim());
        if(N%2==0)
        {
        if(N>=2 && N<=5){
            Console.WriteLine("Not Weird");
        }
        else if(N>=6 && N<=20){
            Console.WriteLine("Weird");
        }else{
            Console.WriteLine("Not Weird");
        }
    } else{
        Console.WriteLine("Weird");
    }
    }
}
One-page Java cheat sheet
Tags: interview, cheatsheet, java
Published: 2023-01-05 17:17:26

Hello everyone 👋

I am glad to present you with the One-page Java cheat sheet.

Link (google doc): [One-page Java cheat sheet](https://docs.google.com/document/d/1j3Rhs2X53_w6NDHzIb1sn39h-M_kwP7G5L98fHemGjU/edit?usp=sharing)

Feel free to leave your comments on the google doc or below the post.

Sources:
https://www.geeksforgeeks.org/equals-hashcode-methods-java
https://www.baeldung.com/java-string-pool
Must know — Container Security Constructs: Namespace, SecComp, Control Groups, SELinux
Tags: containers, aws, security
Published: 2023-01-05 17:12:49

## SELinux
SELinux (Security-Enhanced Linux) is a mandatory access control system for processes. Linux kernel uses SELinux to protect processes from each other and to protect the host system from its running processes. Processes run as a confined SELinux type that has limited access to host system resources.

Condition that brings SELINUX into action. Check or configure file /etc/selinux/config for possible SELINUX values:

- SELINUX=disabled or
- SELINUX=enforcing or
- SELINUX=permissive

## Seccomp

> Seccomp stands for secure computing mode.

The seccomp() system call operates on the Secure Computing
       (seccomp) state of the calling process.
*Man page definition

Seccomp limits how processes could use system calls. Seccomp defines a security profile for processes, whitelisting the system calls, parameters and file descriptors they are allowed to use. SecComp defines which system calls should and should not be allowed to be executed by a container. It restricts the calls a process/continer able to make from userspace into the kernel.

## Namespaces
The kernel can isolate specific system resources, usually visible to all processes. This is done by placing the resources within a namespace. Inside a namespace, only processes that are members of that namespace can see or utilize those resources. Namespces help apply security restrictions to containers. Below mentioned are major 7 namespaces that help achieve boundaries and restrictions:

- Cgroup — Cgroup root directory
- IPC — Inter Process Communication, POSIX message queues
- Network — Network devices, stacks, ports, etc.
- Mount — Mount points
- PID — Process IDs
- User — User and group IDs
- UTS — Hostname and NIS domain name

## Control groups (cgroups)

Control groups partition sets of processes and their children into groups to manage and limit the resources they consume. Control groups place restrictions on the amount of system resources that processes can use. Those restrictions keep one process/container from using too many resources on the host.

CGroups Examples:
— cpu-shares
— cpuset-cpus
— memory-reservation
— kernel-memory
— blkio-weight (block IO)
— device-read-iops
— device-write-iops

For more information on this topic listen recorded session [here](https://www.youtube.com/watch?v=tpTes7IgRJ4). 

Thankfully AWS EKS and other AWS container services are security hardened and therefore cannot be mis-used by essential container constructs.
C# - Day 2: Operators - 30 Days of Code HackerRank
Published: 2023-01-05 17:11:40


class Result
{

    /*
     * Complete the 'solve' function below.
     *
     * The function accepts following parameters:
     *  1. DOUBLE meal_cost
     *  2. INTEGER tip_percent
     *  3. INTEGER tax_percent
     */

    public static void solve(double meal_cost, int tip_percent, int tax_percent)
    {
        // write the code here
        double tip = meal_cost * tip_percent / 100;
        double tax = meal_cost * tax_percent / 100;
        int total_cost =(int)Math.Round(meal_cost + tip + tax);
        Console.WriteLine(total_cost);
    }

}
how improve my code skill after learn basic ?👨‍💻
Tags: kotlin, android, mobile, beginners
Published: 2023-01-05 17:01:00

I learnt basic Kotlin and I could make simple app like Facebook but what next , I need some sources like website and something could me improve my skill And by specifying in mobile apps 
Thank you 👨‍💻
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxaqgl8bxf7ejfqt0tan.jpeg)
Day 4: Voice Activity Detection with Python
Tags: 100daysofcode, challenge, python, beginners
Published: 2023-01-05 17:00:00

When it comes to speech recognition, most only know about Automatic Speech Recognition (ASR). Voice Activity Detection (VAD) is an important and fundamental piece in any product related to speech. Voice AI vendors integrate VAD into their ASRs but do not offer it separately. Picovoice also built Cobra for internal use initially. Then make it public due to the market demand as there is no alternative to Google’s WebRTC VAD, which does not work on all platforms.

You can read more on what [voice activity detection](https://picovoice.ai/blog/what-is-voice-activity-detection/) is, but today is the day to learn how to detect voice activity with [Cobra VAD Python SDK](https://picovoice.ai/docs/quick-start/cobra-python/):

**1. Install VAD SDK**
```
pip3 install pvcobra
```
Sign up for [Picovoice Console](https://console.picovoice.ai/) if you haven't already done (it's free) to grab your AccessKey.

**2. Implement in Python**
```
import pvcobra

handle = pvcobra.create(access_key)
```
When initialized, the valid sample rate is given by handle.sample_rate. The expected frame length is handle.frame_length. The engine accepts 16-bit linearly-encoded PCM and operates on single-channel audio.

```
def get_next_audio_frame():
    pass
while True:
    voice_probability = handle.process(get_next_audio_frame())
```

Congratulations!
Day 4 / #100DaysOfCode
Tags: webdev, javascript, beginners, 100daysofcode
Published: 2023-01-05 16:57:10

Day 4 of #100DaysOfCode is complete!
 
Today's coding was short, but I did finish a Scrimba module; which involved creating a Chrome extension. Then I worked on modifying it, or rather, looking at various APIs to modify it, and I got a little carried away.
 
I also spent some time brainstorming ideas for CS50, Problem Set 0. It requires you to create a project in Scratch (link). I have no imagination or tendency to overthink, so it's a bit of a challenge for me, and everything I see I think, "Oh, I cannot do that now; it's like cheating, right?" even if it's just inspiration, and since I looked at a few games, it feels like so many are locked out for my own implementation.
 
Big day today: I also put up my solo project, a movie watch list. It's not perfect, but I will improve it as I learn more.
Another thing I also did was dip my toes into React, it was momentary, but oh my goodness, React looks freaking awesome, and I cannot wait to jump into that 100%.
 
Overall, it was a productive fourth day that included non-code activities (Math!).
 
Onwards to day five, which will have a focus on CSS and responsive design!
 
**// Movie Watch List**

⚜️ Repo: [https://github.com/ofthewildfire/MovieWatchList ](https://github.com/ofthewildfire/MovieWatchList )
⚜️ Live link: [https://ofthewildfire.github.io/MovieWatchList/ ](https://ofthewildfire.github.io/MovieWatchList/ )

Repo also has a README with a task list that I am still working on/known problem!
169. Majority Element
Tags: java, leetcode, array
Published: 2023-01-05 16:55:11

**Problem Statement:**

Given an array nums of size n, return the majority element.

The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.

 

**Example 1:**

**Input:** nums = [3,2,3]
**Output:** 3

**Example 2:**
**Input:** nums = [2,2,1,1,1,2,2]
**Output:** 2
 

**Constraints:**

- n == nums.length
- 1 <= n <= 5 * 104
- -109 <= nums[i] <= 109

**Solution:
Algorithm:**

- Initialize a HashMap with key and value as Integer.
- Iterate over the given input array.
- Adding elements to HashMap
- - If the element is already present in the HashMap, increment its count by 1
- - If the element is not present in the HashMap, add it to the HashMap with count 1
- Find the key with the highest value
- Iterate over the HashMap to find the key with the highest value
- If the value of the current key is greater than the value of the maxKey, update the maxKey
- Return the key with the highest value

Code:
```
public class Solution {
    public int majorityElement(int[] nums) {
        // 1. HashMap
        HashMap<Integer, Integer> map = new HashMap<>();
        //Adding elements to HashMap
        for (int i = 0; i < nums.length; i++) {
            // If the element is already present in the HashMap, increment its count by 1
            if (map.containsKey(nums[i])) {
                map.put(nums[i], map.get(nums[i]) + 1);
            }
            // If the element is not present in the HashMap, add it to the HashMap with count 1 
            else {
                map.put(nums[i], 1);
            }
        }
        // 2. Find the key with the highest value
        int max = 0;
        int maxKey = 0;
        // Iterate over the HashMap to find the key with the highest value
        for (Integer key : map.keySet()) {
            // If the value of the current key is greater than the value of the maxKey, update the maxKey
            if (map.get(key) > max) {
                max = map.get(key);
                maxKey = key;
            }
        }
        // Return the key with the highest value
        return maxKey;

    }

}

```
⚡️Luos and Freedom Robotics have partnered up
Tags: opensource, tooling, edge, luos
Published: 2023-01-05 16:49:09

⚡️Luos and Freedom Robotics have partnered to create a bridge that enables efficient monitoring of embedded systems fleet data from the cloud.

💬“All it takes is adding one line of code to Luos” - said Nicolas Rabault, CEO and co-founder of Luos.

This will be particularly useful for edge deployment situations where it is difficult to physically connect to the devices. The Freedom Robotics platform allows users to manage multiple devices through a single application, providing real-time visibility of each devices status and performance.

Read more about the collaboration between the two companies in [this article] (https://www.edgeir.com/luos-freedom-robotics-collaborate-to-provide-remote-access-to-edge-devices-20230104) published by Edgeir
Choosing between Scrum and Kanban
Tags: agile, management, productivity
Published: 2023-01-05 13:23:56

Managing any process means having to constantly look for ways of improvement. Which often entails trying out new practices and approaches. 

Since my team has experimented with the best ways of managing tasks, I thought of sharing the biggest differences of Scrum and Kanban, as well as which I would choose for what process.

## Agile project management
As you may know, implementing Agile practices can mean different things for different teams. There are various applications and frameworks to choose from as well as simply upholding the principles and creating your own rules. The [manifesto](https://agilemanifesto.org) does not specify any particular way of implementation, thus allowing you to choose which path to take.

Having said that, a few of implementations seem to be the most popular and today I want to explore 2 of them - Scrum and Kanban.

### Scrum
Scrum is an Agile project management framework that organizes the teams work into iterations called Sprints. This approach defines specific roles and responsibilities for the team members, meetings to be taken as well as their duration. Teams working in fixed-time iterations to deliver the result.

### Kanban
Kanban is another Agile framework that is based on visualizing the teams work on a Kanban board. Contrary to Scrum, there are no specific roles or meetings to be taken. Instead, the team plans on the demand basis. Plans when the backlog is empty and finishes an iteration when substantial value is delivered.

## Choosing between Scrum and Kanban
When starting out with Agile, many of newcomers pose the question "So which should I choose?" Or even more often, we can hear something like "Which is the best?"

The answer to this question really depends on the team, but in most cases, Scrum is easier to start with. as it offers more rules and structure. Kanban on the other hand, is more suited to those that already have some experience and want to have more freedom over the process. And most teams will try both before deciding which is best for their needs. 

So, what are the strengths of each? Let's see.

**Choose Scrum For**

1. Predictable delivery dates. Working with predefined Sprints allows to estimate more precisely.
2. Formal process to organize your team and project around.
3. Steady pace for delivery, planning, and all other activities.

**Choose Kanban For**

1. Continuous work that does not have predefined pace or delivery dates that must be followed.
2. Process visualization and monitoring on a Kanban Board with [swimlanes](https://teamhood.com/kanban-resources/kanban-swimlanes/) and WIP limits.
3. Support or any client-related operations where there is a need to react quickly.

Here is a full story on why our development team chose to [move from Scrum to Kanban](https://teamhood.com/kanban/moving-from-kanban-to-scrum/). And if you are looking for Agile tools, here is a review of the best [Kanban board software](https://teamhood.com/kanban/best-kanban-board-tools/).
452. Minimum Number of Arrows to Burst Balloons
Tags: programming, beginners, tutorial
Published: 2023-01-05 16:48:30

## Intuition
It’s told that a balloon with xStart and xEnd gets shot from x if xStart <= x <= xEnd.
The arrow will continue through its path and if the balloons are on its past, then surely the balloon will burst.
Now here we actually need to find how many balloons are present in an overlapping xStart and xEnd.

So thus it boils down to the number of nonoverlapping intervals such that all the balloons which are in the interval which are also overlapped by some other intervals can be shot from a position x and with just 1 arrow all those balloons can be burst.

## Approach
Blindly going with the approach of finding the count of nonoverlapping intervals.

* Sort the intervals based on the end time. (Can also be done using start time but then we have to do it in reverse).

* Point to an end node, let's say `currentEnd=Long.MIN_VALUE`.(Here long is used as in the constraints -2^31 <= xstart < xend <= 23^1 - 1. So if we use int, we will get wrong answer for the last test case).

* Traverse through the array and see if the starting point > the currentEnd, if yes then it's not overlapping and till that interval, we can shoot all the balloons with one arrow. Just increment the arrow count and set `currentEnd = nextEnd`.

## Complexity
- Time complexity:
We are sorting the array + traversing through the array.
So time complexity will be O(nlogn) + O(n) where n = length of array.

- Space complexity:
No extra space is used even though the sorting might use some space.
But we can say space complexity is O(1).

## Code
```java
class Solution {
    public int findMinArrowShots(int[][] points) {
        if (points == null || points.length == 0) {
            return 0;
        }
        int length = points.length;
        int minimumNumberOfBalloons = 0;
        Arrays.sort(points, (p1, p2) -> Integer.compare(p1[1], p2[1]));
        long currentEnd = Long.MIN_VALUE;
        for (int [] point : points) {
            int nextStart = point[0];
            int nextEnd = point[1];
            if (nextStart > currentEnd) {
                currentEnd = nextEnd;
                minimumNumberOfBalloons++;
            }
        }
        return minimumNumberOfBalloons;
    }
}
```

Please feel free to suggest other approaches or mistake in any of my understanding.
Thanks
The Auth Boys
Tags: ruby
Published: 2023-01-05 16:24:58

Authorization and authentication are important concepts in security, and are often implemented in web applications to control access to  resources or functionalities. 

Authentication refers to the process of verifying the identity of a user or client, often through the use of a username and password. In a Ruby application, authentication can be implemented using the Devise gem, which provides a flexible and easy-to-use authentication solution.

To use Devise, you will first need to install it by adding it to your Gemfile and running the bundle install command. Next, you will need to run the Devise generator to create the necessary configuration files and routes:


```
rails generate devise:install
```

After running the generator, you will need to set up your application to use Devise by adding it to your model (e.g. User) and specifying the authentication strategies you want to use (e.g. :database_authenticatable, :registerable, etc.).

Once you have configured Devise, you can use its helper methods to authenticate users in your controllers and views. For example, you can use the authenticate_user! method in a controller to require that a user be signed in before accessing a certain resource:

```
before_action :authenticate_user!
```

You can also use the current_user helper method in your views to display information about the currently signed-in user.

Authorization, on the other hand, refers to the process of determining whether a user or client has the necessary permissions to access a certain resource or perform a certain action. In a Ruby on Rails application, authorization can be implemented using the CanCanCan gem, which provides a flexible and easy-to-use authorization solution.

To use CanCanCan, you will first need to install it by adding it to your Gemfile and running the bundle install command. Next, you will need to run the CanCanCan generator to create the necessary configuration files:

```
rails generate cancan:ability
```

After running the generator, you will need to define the abilities of your users in the Ability class that was created. This is typically done using a block syntax, where you specify the actions that a user is allowed to perform and the conditions under which they are allowed to perform them:


```
can :read, Article, published: true
can :create, Article, user_id: user.id
can :update, Article, user_id: user.id
```

You can then use the authorize! method in your controllers to ensure that a user has the necessary permissions to access a certain resource or perform a certain action:


```
authorize! :read, @article
```

In summary, Devise and CanCanCan are useful tools for implementing authentication and authorization in a Ruby on Rails application. Devise provides a flexible and easy-to-use authentication solution, while CanCanCan provides a flexible and easy-to-use authorization solution. Together, these tools allow you to control access to resources and functionality in your application, helping to ensure the security of your application and its users.