teleren/devto huggingface dataset:
SRP for couples
Tags: programming, solid, srp
Published: 2021-01-03 15:09:29

Single Responsibility Principle is a well-recognized rule that all software developers (and, as you're going to see, others as well) should follow in order to make systems maintainable and easy to extend.

There are many definitions and ways to explain it. Here I'd like to lay out what I believe to be a comprehensive real-world explanation of how should this principle be applied. And to do that, we're going to visit a couple's bedroom.

# Bedroom drawers

When two people live with each other, in their bedroom, there usually are drawers with underwear. And there is not one, but two of them. It's common sense, but let's spend some time to find out why is it so. Why are there 2 separate drawers and, particularly, why is their responsibility split like that?

# Other setups

Let's ponder for a while and imagine that you're moving in with someone, and you need to find out how where to put your socks and underwear. Some of the possibilities are as follows:

* Socks in one drawer, underwear in the other one
* White in one drawer, colored in the other one
* His in one drawer, hers in the other one

# Problem setting

What we generally want to achieve when developing a working (software) system is loose coupling. In our example, we expect a solution that allows for maximum independence of both partners, so it is not acceptable that one person waits until the other one dresses up. 

If we, for instance, split responsibilities with the second solution we've listed above, out actors will encounter a problem when one of them will look for white socks, whereas the other one will be waiting for their turn to pick theirs.

# The principle

The only way to prove one solution better than other is to follow the Single Responsibility Principle, which states that "an entity should have only one reason to change".

This reason is that *a person wants to get dressed*. Putting both partners' socks in one drawer and underwear in the other one causes that for any drawer there are two reasons to change - it is that *any* of two partners wants to get something and it leads to obvious problems.

# Conclusion

Design your systems like bedroom drawers: let your code areas change independently by different reasons and you will find out that it is nothing more than the same common sense that leads to putting underwear in bedroom drawings in this well-known way.
Take MySQL Database Backup From Jenkins
Tags: mysql, backup, jenkins, databasebackup
Published: 2021-01-03 14:09:43

In this post, we will explain and practically show how you can configure MySQL database backup using Jenkins jobs. in easy words, you will automate the MySQL database backup process from Jenkins GUI.

 

1. Log to Jenkins default URL and port: http://192.168.56.21:8080/

If you want to install and setup Jenkins see this article

2. Go to New items

3.  Give some Name and select FreeStyle project

 

4.  In the build section click on Add build step radio button and select Execute shell.

5. Select boolean parameter for MySQL database host and database superuser password which is root password in MySQL database case.

 

6.  In this build part give the shell script name with full path and parameters like $HOST_IP & $Password

 

Shell Script

[root@master01 ~]# cat /opt/jenkins_scripts/mysql_full_db_backup.sh

#!/bin/bash

HOST_IP=$1

PASSWORD=$2

echo "starting mysql database full backup"

mysqldump -h $HOST_IP --all-databases --single-transaction --quick --lock-tables=false > /opt/jenkins_scripts/mysql_backup/full_backup_$(date +%F_%N).sql -u root -p$PASSWORD

echo "Backup has been done"

https://thedbadmin.com/take-mysql-backup-from-jenkins-job
How to quickly plan and estimate an MVP
Tags: software, softwaredevelopment
Published: 2021-01-03 14:56:34

---
title: How to quickly plan and estimate an MVP
published: true
description: A strategy for quickly planning & delivering MVPs
tags: software, softwaredevelopment
cover_image: http://joshhornby.com/assets/images/how-to-quickly-plan-and-estimate-an-mvp.jpg
canonical_url: https://joshhornby.co.uk/blog/how-to-quickly-plan-and-estimate-an-mvp
---

This post outlines my tried & tested strategy for quickly planning and estimating MVP projects.
This process departs a little from Agile/Scrum best practices. There are no guarantees on estimation quality which I believe is impossible to do for software projects, but it helps to provide a rough guide for new projects.

## Gather Requirements
In order to plan you need to know what you should be building.
The more questions you can ask in this step the easier you will find future steps. 

Some questions to ask are:

- Why are we building this?
- Who is the target audience?
- How many people do we expect to use this?
- What does "Complete" look like to you?  

## Break down the work

Now you have gathered some requirements and have a better understanding of what needs
to be build it's time to start breaking down the work.

I like to split the work into **Epics** & **User Stories**.

**Epics** = A group of related user stories

**User Stories** = Short requirements or requests written from the perspective of an end user

Normally I start with the CRUD *(Create, Read, Update, Delete)* stories, for example: Create User, View User, Update User Marketing Preferences. 

To continue reading visit https://joshhornby.com/blog/how-to-quickly-plan-and-estimate-an-mvp
Debugging Tips for A Complete Beginner
Tags: debugging, programming, beginners, codenewbie
Published: 2021-01-03 14:47:41

Debugging is hard; especially for those who are just getting into code. Often this leads these people to wave the white flag in the early stages of their programming life. So here I have brought you some tips which can help you get rid of bugs in your program:

## Clarify everything
Before doing anything, try to ask: `what do I expect to run?` Then, ask the following question: `what happened instead?`. Ideally, this should be documented, in detail. To begin solving the problem, the first thing you have to know is why is this becomes one.

## Reproducing the bugs
We should be able to track the bugs on our code, hence we need to reproduce them in our dev environment. Keep in mind that ‘aiming in the dark’ is not the best approach to solve the issue. It might solve the issue, but also might make the problem bigger. So, reproduce!

## Read & Google error message
Whenever you face any error, read carefully what the compiler tries to tell you. Often this error message comes with file location and even the line number of the error that happened. Jump into that line! This is a great clue before you start to fix the bugs.

## Print out every step
You have to be sure that every line of your code is working well. I mean, every single line. If you are not so sure about one or two, giving them print out (e.g console log) of a random string on every step is not a bad approach. As long as don’t forget to delete it once the problem is gone.

## Try and try
The substance of the debugging process is to identify the problems and solve those issues. Some of them would be harder than you have ever imagined. Keep trying and do code-run-repeat until it solved and you will learn a lot from this process.
Destructuring Tweets - Episode 1 - Set() Trickery
Tags: snippet, javascript, destructuring, reference
Published: 2021-01-03 14:39:06

---
title: Destructuring Tweets - Episode 1 - Set() Trickery
published: true
description: In this series, I pick a more or less random snippet from Twitter and analyze it in depth. It shall help me, and you understand the trickery behind it.
tags: snippet, javascript, destructuring, reference
//cover_image: https://direct_url_to_image.jpg
---
Hey, I thought about creating this series, where I (quickly) destructor one of those often shared snippet quizzes on Twitter. Welcome to the first episode!

[Snippet](https://twitter.com/SnippetsJs/status/1262990145336291329) from [@SnippetsJs](https://twitter.com/SnippetsJs):
```javascript 
const myList = [['❤️'], ['JSSnippets'], ['❤️']];
const mySet = new Set(myList);
console.log(mySet.size);
```
In the first line, they create a two-dimensional array. Meaning we have one (first dimension), holding numerous others (second dimension). All three of them contain a single item being a string. Remarkable here is that the first and last item is the same!
In the second line, they create a Set. You might not have heard of it, but it's an object to only store unique values. So whenever you pass an array, it automatically ditches all duplicated items. This API comes in handy at times. What we do in this example is constructing a new set from the array `myList`. 
What will the `console.log` be then? One might think the output will be `2` since the first and last array is equal. Well, surprisingly enough, this is wrong! The result is, indeed, `3`. 
Why so? _Cause an array is an object._
```javascript 
typeof [] // "object"
```
On a side-note: even the indexes are just properties. We access an index by its property-name like any other (e.g. `myArray[5]`).
However, important here is that an object is _assigned-by-reference_. Primitive types (String, undefined, Number, etc.) are _assigned-by-value_. So even though an object might hold the same properties and values, it's still not similar since it's another reference. Think about it in the sense that every object has its unique ID. Only if said IDs match they are the same.

#Snippet summary
- **Trickery:** one thinks one array gets ditched since it holds the same value
- **Key Learning:** objects are assigned by reference, not by value
- **Further reading:**
    - https://medium.com/@naveenkarippai/learning-how-references-work-in-javascript-a066a4e15600
    - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
    - https://developer.mozilla.org/en-US/docs/Glossary/array

See you next Sunday! 🖖
Good enough is fine...
Tags: webdev, python
Published: 2021-01-03 14:35:46

Still remember vividly, myself coding for some resume creation site in hospital's waiting room while my wife was doing her prenatal exercise. I was working on this site for 6 months by then but it was no where close to being ready for release in the wild! And unfortunately i was responsible for keeping it that way, like working on Jira like site so that i can create new bugs/improvement tickets easily and wasting one week behind it or pushing to create better UI and kept on delaying the release till Feb 2017, when my son was born and i don't remember working on this site for next 2 years. In 2 years,  I not only lost the momentum but also the interest to continue! Its been 4.5 years since i first started with this idea and this site is lying somewhere on my private repository. I no longer even wish to publish it!

Fast forward to Nov 2020, saw my wife who is very active on Instagram managing her hashtags in keep by creating multiple notes and then copy pasting it. There i got the idea of save tags. A website where you can categorize tags and then select them based on your post. Main reason for creating was just to create something but i still wanted it to be prefect but i learnt from last experience, so this time i just created site, wrote some tests for back-end, decent UI (i am back-end dev so i just used Bootstap and google), use only google oauth (last time i setup google, facebook, twitter and github) and good to go. I sent it to couple of friends but no one gave any feedback ☹️ something to keep in mind for next time. This site is created just for fun and not with intention on making business out of it so give it a try and share your feedback. 

Perfect product do not exist! Close to perfection takes time and good enough is okay for the most and you get valuable feedback which helps to shape product. In case you have half baked product try to release it as soon as possible. 

Updated:
~~Lastly, please checkout https://save-tags.com~~

I have taken down the site after running it for 3-4 months. But point of the post was, If you create something release it once you think it's good enough! You might never achieve the perfection you are looking for.
Are GUIs better for learning purposes?
Tags: watercooler, beginners, gui, learning
Published: 2021-01-03 14:22:41

---
title: Are GUIs better for learning purposes?
published: true
description: 
tags: watercooler, beginners, gui, learning
cover_image: https://blog.axosoft.com/wp-content/uploads/2019/03/GUI-vs-CLI_Hero.png
---
Many concepts like OS services, databases, version control, API testing, etc often come with both CLI and GUI, meaning you can use them via the terminal and graphical interface.

Do you prefer to use GUIs when learning a new concept?
My learnings
Tags: productivity, tips
Published: 2021-01-03 14:21:33

1. Don't shy away from lots of work to accomplish a task. If you do it anyway, the workload will come back even heavier.
2. Test critical code. That means when you don't know whether it's working properly, test it. But also don't test every little piece. That is just time-wasting.
3. One step at a time. When you do a task at a particular section of your code, focus onto it. When you see bugs, typos etc somewhere else, note it, but don't waste your focus fixing that issue quickly. Keep your focus.
4. Make a beautiful todo list of the ongoing tasks. Break them down and WRITE it down. Otherwise you will often lose your thread.
5. Plan new features thoroughly. Use pseudocode and think about what you could have missed in your first thinking phase. Think through the concept multiple times. It will save you time in the long run, as you won't make so much critical mistakes.
6. Celebrate working code pieces. Really. Do it. You have done great work, no matter how small or complex the code.
7. Don't expect your code to run without bugs the first time. However if it does, you are doing something really correctly (jump to tip 6).
8. When you encounter a problem, write it down. Really deal with it, so that you really understand what the problem is. Then start asking questions. What do you need to know to solve this problem. Find answers. The problem should start to crystallize into smaller parts. Ask again questions, until you know everything essential to solve the problem.
9. Beware of the edge cases. Those little nasty beats...
List Of Country Codes And State Codes For WooCommerce
Tags: wordpress, woocommerce
Published: 2021-01-03 14:20:31


Get The Country and State code from here: [https://www.scratchcode.io/list-of-country-code-and-state-code-for-woocommerce/](https://www.scratchcode.io/list-of-country-code-and-state-code-for-woocommerce/)
Learning To Learn [Efficient Learning]: The Lies
Tags: productivity, todayilearned, codenewbie
Published: 2021-01-03 14:12:09

Hello Fellow Codenewbies 👋

Some advice that is often given when we are learning turns out to be false.
So here are **The Lies**.

**Note:**
The 🗝 icon is the **takeaway note** of each part.

---

# The Lies

## Follow Your Passion

We might be passionate about something as a pure leisure activity. But when it turns into work instead of being fun, it becomes a chore.

🗝 What better is turning our intention from *following our passion* into *learning* a valuable skill and *getting better* by working hard.

We need a little bit of interest in a topic/skill and then have ***creativity, control, and impact***.

🗝 Doing self-improvement at something and getting recognized by other people because of their skill is what makes people enjoy their careers.

## You Can Avoid Risk

🗝 Risk is part of the process, and we *cannot* avoid it.
***We need to be able to tolerate and enjoy taking risks.***
Look at risks as a challenge that improves us and makes us better.

## Trust This One Person

Each person gives advice based on the things that work in their lives. And their advice might not work for us.

🗝 We need to learn to look at different opinions or resources from other individuals and not only from one.

## 10,000 Hours Rule

> To get good at something is all about hard work and putting thousands of hours into it.

Practicing is very important to sharpen a skill. However, many other factors are involved, such as genetics, personality, upbringing, etc. So there are [researches](https://www.vox.com/science-and-health/2019/8/23/20828597/the-10000-hour-rule-debunked) that debunk this theory.

We need to learn to be efficient learners, to learn smart.
🗝 We need to know how to strategize, use different techniques, and spend a decent amount of time of practice to take us to our goal instead of putting *too many hours* into practicing.

---

Thank you for reading!
Last but not least, you can find me on [Twitter](https://twitter.com/AdiatiAyu). Let's connect! 😊
Ajax Tutorial
Published: 2021-01-03 14:11:48

AJAX is a web development technology that is to create, fast, and better, and more interactive web applications using HTML, CSS, XML, and Javascript. With Ajax, web applications can send and retrieve data from a server asynchronously without interfering with the display and behavior of the existing page. Ajax is a web browser technology that is independent of web server software. If you are a beginner and learn more then visit Ajax Tutorial. Ajax Tutorial that is available online will help you understand the deeper level. http://www.phptpoint.com/ajax-tutorial/
Get Current User Outside an ASP.NET Controller
Tags: dotnet
Published: 2021-01-03 14:10:26

---
title: Get Current User Outside an ASP.NET Controller
published: true
description: 
tags: dotnet
//cover_image: https://direct_url_to_image.jpg
---

You can access the currently authenticated user from a controller action method in the following way:

```csharp
[Route("[controller]")]
public class InternalController : ControllerBase
{
  [HttpGet]
  [Authorize]
  public string GetCurrentUser()
  {
    return base.User.Identity.Name;
  }
}
```

To access it outside the controller, for example in a MediatR handler, you need to inject and use the `IHttpContextAccessor` service, which is already provided by [ASP.NET](http://asp.NET):

```csharp
[Route("[controller]")]
public class InternalController : ControllerBase
{
  private readonly IMediator _mediator;

  public InternalController(IMediator mediator) 
  {
    _mediator = mediator;
  }

  [HttpGet]
  [Authorize]
  public async Task<string> GetCurrentUser()
  {
    var response = await _mediator.Send(new GetCurrentUser.Request());
    return response.CurrentUserName;
  }
}

public class GetCurrentUser
{
  public class Request : IRequest<Response> { }

  public class Response 
  { 
    public string CurrentUserName { get; set; }
  }

  public class Handler : IRequestHandler<Request, Response>
  {
    private readonly IHttpContextAccessor _httpContextAccessor;

    public Handler(IHttpContextAccessor httpContextAccessor)
    {
      _httpContextAccessor = httpContextAccessor;
    }

    public Task<Response> Handle(Request request, CancellationToken cancellationToken)
    {
      return Task.FromResult(new Response 
      { 
        CurrentUserName = _httpContextAccessor.HttpContext.User.Name
      });
    }
  }
}
```

Finally, to make this work, you need to register the `IHttpContextAccessor` dependency in your `Startup` class:

```csharp
// ConfigureServices
services.AddHttpContextAccessor();
```
Arithmetic Operators in Python
Tags: python, programming, beginners, tutorial
Published: 2021-01-03 14:02:00

Operators are used to performing operations on any given data stored inside variables.

And **arithmetic operators** makes mathematical operations possible on operands in a program.

I know! I know! This is a basic concept! But let's make it fun!

## Starting with addition and subtraction
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/leo1kbrjuws486w872k9.png)
Output:
```
Addition 9
Subtraction 8
```

## Now, Multiplication and Division
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tx4rf8gox38kqvcm6beq.png)
Output:
```
Multiplication 314.0
Division 2.0
```

## Special arithmetic operators
* *Floor division - `//`*: rounds of the result to the nearest whole number.
* *Modulus - `%`*: produces the remainder of the numbers
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/maaha0m2g47zixz8i8a7.png)
Output:
```
Floor Division 3
Modulus 1
```
* Exponentiation - ** : produces the power of given numbers
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9sjkrv9yd11axwzg0m8s.png)
Output:
```
Exponentiation 0.025517964452291125
Exponentiation 37.78343433288728
```

### Best Resources

- [Python Blog Series](https://aswinbarath.me/category/programming/python-programming/): A Blog series where I will be learning and sharing my knowledge on each of the above topics.

- [Learn Python for Free, Get Hired, and (maybe) Change the World!](https://academy.zerotomastery.io/a/aff_tz1t0tpx/external?affcode=441520_dcwk-s8s): A detailed roadmap blog by Jayson Lennon (a Senior Software Engineer) with links to free resources.

- **Zero To Mastery Course** - [Complete Python Developer](https://academy.zerotomastery.io/a/aff_9khypm7v/external?affcode=441520_dcwk-s8s): A comprehensive course by Andrei Neagoie (a Senior Developer) that covers all of the above topics.

**Who Am I?**

I’m Aswin Barath, a Software Engineering Nerd who loves building Web Applications, now sharing my knowledge through [Blogging](https://medium.com/techsoftware) during the busy time of my freelancing work life. Here’s the link to all of my socials categorized by platforms under one place: https://linktr.ee/AswinBarath

**Thank you** so much for reading my blog🙂.
What tech do you use for audio/video streaming?
Tags: watercooler, audio, video, streaming
Published: 2021-01-03 13:58:40

---
title: What tech do you use for audio/video streaming?
published: true
description: 
tags: watercooler, audio, video, streaming
cover_image: https://webcastandbeyond.com/wp-content/uploads/Camera-in-Auditorium-1920x1080.jpg
---
Whether it’s streaming video to stay connected with customers, staying in touch with employees while they work remotely, or creating entertainment content, video content is booming right now.

What audio and video caption devices do you use for that?