teleren/devto huggingface dataset:
Use Tin to quickly Set up Jenkins
Published: 2022-01-04 10:40:47

Tin is a product of TeamCode that can generate executable applications instantly without manual environment configuration. Users can click to run project directly in the cloud. 

**Login to Tin and clone the Jenkins app**
1. Click the Tin URL of Jenkins app.
https://www.teamcode.com/tin/clone?applicationId=270270854740733952
Users who have not logged in should sign up first.
2. Log in to Tin with your email, Github account, or phone number.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2saixpz645pktya1ewwc.png)

3. (Optional) After logging in, you can change the “Application Name” or “Tag”.
4. Click "Clone" button to clone the Tin app to your workspace.
Note: Tin will give new users a free trial for a certain length of time, which is determined by the instance size. After the free trial time, the Tin app will automatically stop working. You will not be charged for the whole process. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e5v6eob2epaeops4ge8y.png)

5. Click "RUN NOW" to initiate the application.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36k7cb4orq8cf38ewl4p.png)

6. Click the "Endpoint List" button to go to the Endpoint list, with the entry points for all apps displayed. Click the URL of entry point.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hmsx739i7y22ha5h590h.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5y8utuxk7hwejagmslrp.png)

Now you can log in to Jenkins to use it.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c38okyrr0u4ydlsyj47g.png)

You can use the Tin to quickly access other excellent open source projects, see the guide: https://www.teamcode.com/docs/en-US/tin/create-tin
Power plant Commissioning in India

Tags: product
Published: 2022-01-04 10:37:42

Nowadays, [Power plant Commissioning](https://www.skvenergyservices.com/power-plant-commissioning/)  is critical for protecting and prolonging plant assets existence. Power plant maintenance is important for all power plant operations to guarantee the
safety of plant workers and keep all property and infrastructure in good working order. Without
the appropriate maintenance trial, key tools and machinery can fall into poor shape, resulting in
potentially risky situations on the job site and the untimely failure of classy equipment used in
power production.
How to find nth largest/smallest item from a List in Python
Tags: python, datascience, machinelearning, beginners
Published: 2022-01-04 10:36:21


Do you know you can find n largest/smallest items from a list using heapq python standard library?

Check out this example below: 

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

If you like this content consider following me.
Leetcode diary: 1561 - Maximum Number of Coins You Can Get
Tags: javascript, algorithms, devjournal, motivation
Published: 2022-01-04 10:34:01

This is a new series where I document my struggles of leetcode questions hoping seeing however small of an audience I get gives me the motivation to continue.  

This is definitely not a medium level question. Below are my thought process immediately
```
    // first we have 2 cases: 
    //1.) 3n % 2 == 0
    //2.) 3n % 2 != 0 
    
    // given the 2 cases, we should always work backwards,
    // that is after sorting array, add from largest to smallest
    // we aren't exactly every other number since it's 3-2-1-3-2
    // our loop can run like 
    // while piles.length
    // piles.pop();
    // sum += piles.pop();
    // piles.pop();

```

which gave me the code: 

```
var maxCoins = function(piles) {    
    piles = piles.sort(function(a,b){
        return a > b ? 1 : -1;
    });
    let sum = 0;
    while(piles.length){
        piles.pop();
        sum += piles.pop();
        piles.pop();
    };
    
    return sum;
};
```

This was simple enough! I ran with the given test case and passed. However, I failed my submission. Upon looking at the problem in detail, I noticed that the triplets does not have to be in order. It can be any 3. However, given the problem conditions, two numbers have to be the currently biggest and the third any be anything. Therefore logically it is just the smallest.

Therefore, we just shift the 3rd number instead.

That passed the submission with poor performance.

This is a submission with good performance: 
```
var maxCoins = function(piles) {
        piles = piles.sort(function (a, b) {  return a - b;  });
        let numOfCoins = 0;
        let numOfMyPilesLeft = piles.length / 3;
        i = numOfMyPilesLeft;
        while(numOfMyPilesLeft-- > 0) 
        {
            numOfCoins += piles[i];
            i += 2;            
        }
        return numOfCoins;
};
```

The lines that improved performance drastically are:
1.) piles.length/3
2.) is i+= 2

So the lesson here is that I should learn to approach the problem more mathematically rather than doing it straight out like a brute. I was kind of blocked by the fact I did not realize it should be shift for the third number though. 

So the second lesson is go back to the drawing board after realizing I misunderstood the problem.

Let me know anything on your mind after reading through this, THANKS!
Want to learn types of trees in Data Structure?
Published: 2022-01-04 10:33:11

Are you looking to learn about types of trees in Data structure? If yes then you have landed at the right place. Help me study bro is the one-stop destination for everyone who wants to learn from basic to advanced level of data structure topics. Visit Help me study bro and learn about the types of trees in Data Structure and other related topics. 
Visit@ https://www.helpmestudybro.com/introduction-to-tree-data-structure/	

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1sezkhn5ubq0q7nxjt20.jpg)
How do I dispute a transaction on Cash App? And Apply For A Refund?
Published: 2022-01-04 10:28:41

Yes, it is very necessary to understand [How do I dispute a transaction on Cash App](https://www.contactmail-support.com/blog/can-i-dispute-a-cash-app-payment/)? Once you file a dispute, you will have to wait until the official review your claim. If everything goes in the right direction, you will be able to get your money back to your account with ease.
Create beautiful highlights cover for Instagram
Tags: javascript, webdev, programming, devops
Published: 2022-01-04 10:21:12

We provide you with an user-friendly tool that lets you make beautiful highlights covers for Instagram. Choose from a variety of templates within the **[Cover app](https://coverhighlights.com/)** and make your own custom covers. Free editing tools are available to customize readymade templates according to your choice. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6jgaecdmeknnhrxv3rbm.png)
How do I dispute a transaction on Cash App? Without a Card If Seeking Refund Of Your Money
Published: 2022-01-04 10:18:06

Have you sent your [**How do I dispute a transaction on Cash App?**](https://www.numbersforsupport.net/blog/cash-app-dispute/) Are you looking for an instant discount of your deducted amount of cash without having to face any sort of hassle? In such a case, you ought to just take necessary guidance on Can You Dispute A Cash App Transaction without a card effortlessly.
PHP Interfaces Explained
Tags: php, interfaces, explained
Published: 2022-01-04 10:16:55

Recently I wrote this blog [PHP Abstract Classes Explained](https://dev.to/eelcoverbrugge/php-abstract-classes-10eh). Today I'll tell you about the basics of Interfaces.

## Interfaces
Interface classes are used to describe the requirements for other classes to implement. Used as a contract or blueprint for objects with the same behavior.

Interfaces exists of methods and possibly constants. Methods are defined, but not implemented. To better understand I'll explain this by an example.

## For example
Let say I own a dog and a cat and their behavior is making noise when getting hungry:
```
class John
{
    public function bark()
    {
        echo 'Woef!';
    }
}

class Jane
{
    public function meow()
    {
        echo 'Meow!';
    }
}
```

Obviously dogs and cats make different noises... However their need for food is equal and so this behavior can be captured in an interface:
```
interface Dog
{
    public function eat(string $food);
}

interface Cat
{
    public function eat(string $food);
}
```

In order to use our interface we add `implements` to our classes:
```
class John implements Dog
{
    public function bark()
    {
        echo 'Woef!';
    }

    public function eat(string $food)
    {
        echo sprintf('I love eating ', $food);
    }
}

class Jane implements Cat
{
    public function meow()
    {
        echo 'Meow!';
    }

    public function eat(string $food)
    {
        echo sprintf('I love eating ', $food);
    }
}
```

Let's confirm if John is a dog or cat:
```
$john = new John;

if ($john instaceof Dog) {
    echo $john->eat("bones"); // I love eating bones!
}
```

Well thanks but why the need to check? Great question.

## The power of interfaces

Whenever using our instances (dog or cat) in a function to feed, it is usable to check if it is a dog or cat cause their differences in diets. My dog loves eating bones, but my cat not!

Lets type-hint our class instance when passed into a function:
```
public function feedDog(Dog $dog)
{
    $dog->eat('bones');
}

feedDog($john); // I love eating bones!
```

By doing this we ensure that whatever is passed to this function is an implementation of the Dog interface. If we wouldn't type-hint the interface, I could potentially pass a class instance in the future that doesn't have an eat() method and my pet wouldn't survive for long. So we protected our code with the requirement of eat() method to every new Dog instance.

## Let me know
This gave you the basic understanding of interfaces. Please let me know if I missed something or you think this code can be better. Or what I should write about next time!
Tips For building Production Ready Applications
Tags: tips, webdev, programming, codenewbie
Published: 2022-01-04 10:16:10

Have you ever been stuck building a product that you wish to put into the market, but you don’t know if you are doing it the right way? I guess we all are. Here’s an extensive list I compiled to provide you with tips on building your application the right way. 

## Tips for building production-ready applications


###Employ Proper Architecture 

There are different architectures when it comes to building applications. They vary with different architectural designs and patterns. Choosing the best architecture makes your codebase look cleaner and even saves you the stress of debugging it. 


Read [tips for building production-ready apps](https://syntaxexplained.com/building-production-ready-applications/) by  @geekyahmed
Portfolio template using React
Tags: react, javascript, webdev, tutorial
Published: 2022-01-04 09:59:00

Hello everyone! I recently created a portfolio template using React and React Router. 
It's quite simple to understand and easily customizable.

## **The App.js**
In the App.js through react-router I render the pages:

![App code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ncffkp6x1h98fcpbvh0.png)

## **Home page**

The home page simply contains a background image and strings automatically generated with [typed.js](http://mattboldt.github.io/typed.js/).

![Home page code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7pcstiyisjbth0ph84ks.png)

## **About page**

The about page, as the name implies, contains personal information and skills and in the [_icons_]((https://github.com/Saverio683/portfolio-template/tree/main/src/assets/icons)) folder, in the _assets_, there are already many icons of programming languages and other ready-to-use icons.

![About page code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/757xmwnkq4zy8f6c9h1p.png)

## **Projects page**

The projects page is used to show your projects accompanied by a description.

![Projects page code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wzqb1tvfl5mff8yqp7ck.png)

## **Contact page**

On this page you can show your main profiles and through [Emailjs](https://www.emailjs.com) you can send emails directly from the page itself. Here too in the [_icons_](https://github.com/Saverio683/portfolio-template/tree/main/src/assets/icons) folder there are already icons of the main social networks

![Contact page code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w8d02prc44jl60zi8zun.png)

## **Customization**

All you need to do to modify the various personal fields in the project is contained in the [datas.js](https://github.com/Saverio683/portfolio-template/blob/main/src/assets/datas.js) file and that's it!

[Here](https://main.d1r809nyzjf6ax.amplifyapp.com/) you can see the live project and here the [github repo](https://github.com/Saverio683/portfolio-template).

I hope you liked the post, I invite you to comment and leave a review. Thank you.
Django Customer User Model
Tags: django
Published: 2022-01-04 09:55:22

# Django - replace username as primary key with email

Django is a great tool, but nothing in this world is perfect.

Having a username could be fancy in the early web, but today, with tons of site and consequently credentials, people tend to simplify things to remember (at least, I do).

Generally, when I start a Django project I immediately create a Customer User Model (it's a [Django best practice](https://docs.djangoproject.com/en/dev/topics/auth/customizing/#using-a-custom-user-model-when-starting-a-project)).

But the process is a bit tedious, because you have to:
* Extend the Django User class
* Modify settings.py to use the new user model
* Configure the managers (or they will broke when you create user from cli)
* Modify the admin view

You can skip [to the official documentation](https://docs.djangoproject.com/en/dev/topics/auth/customizing/#a-full-example) and copy and paste based on your needs

Here are some useful links that helps me in this process:
* https://www.fomfus.com/articles/how-to-use-email-as-username-for-django-authentication-removing-the-username/
* https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model
* https://docs.djangoproject.com/en/dev/topics/auth/customizing/#substituting-a-custom-user-model
* [A full example](https://docs.djangoproject.com/en/dev/topics/auth/customizing/#a-full-example)
Function components in Elixir
Tags: elixir, webdev, phoenix
Published: 2022-01-04 09:51:16

I have been a fan of React for a long time. I like the short, composable syntax of components, and I like that I can extract functionality into small bits and compose my UI of atoms and molecules.

Lately, I have started to find joy in creating apps and web experiences using server-side frameworks. In particular, I have used Blazor, Laravel, Lucky-Framework and Phoenix (elixir).

Of the four, the only thing that could keep my attention for a prolonged period of time was Elixir. 

I cannot tell you why.

## Great stuff, but what about the components?

What I missed in all the frameworks mentioned above was the single file all included React component.

And now in Phoenix Liveview 0.17 we can do that!

Let's compare React and Elixir.

## Elixir
```elixir
defmodule Layout do
  use Phoenix.LiveComponent

  def header_bar(assigns) do

    reversed = String.reverse(assigns.title)

    ~H"""
      <div>
        <%= reversed =>
      </div>
    """
  end
end
```

### React
```react
const headerBar = (props) => {
  const reversed = props.title.split("").reverse().join("");

  return (
    <div>
      {reversed}
    </div>
  );
}

```

In a lot of ways, the two are the same. They are terse, self-explanatory and contained. These kind of functions can then be used for creating parts of a larger UI.

In Phoenix liveview, there are things you need to know. Since most of the work is done server-side, there are some things that will be hard to do.
Most noticeably, interacting with the DOM through JavaScript will be difficult.

There are, however, plenty of solutions to this. As an example, below I will show how to create a toggle menu in elixir as a component.

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

Something to notice here, is that `phx-click` is an annotation which tells phoenix that this is special. Earlier you would use this when you would send events back to the server to do logic and return data.

In Liveview 0.17, however, we can invoke functions directly from our module. Furthermore, it is assumed that we have created a function component that can render a menu item given some meta data.

The magic here happens in the `JS.toggle` call in the `toggle_menu` function. We use a dom selector to target the element with id menu and toggle it. All this is executed locally for the user in the dom.

## References:
[Phoenix Framework](https://www.phoenixframework.org/)
[Phoenix LiveView](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html)
Tips for working remotely
Tags: productivity, workstations, motivation, career
Published: 2022-01-04 09:39:15

I don't want to start a discussion about the difference between Smartworking, Remote working and stuff like that. This post is useful for everyone who work remotely.
I have tried to collect some tips and suggestions from my last 4 years as remote worker.
And of course, I did a lot of mistakes and I continue to do mistakes.

## Equipment and hardware
- Remeber to have your laptop batteries charged
- Remember to have a backup for your mouse batteries (if you have a wireless mouse)
- A backup line data is a plus (the connection is everything for you)
- Configure at least one communication channel with your coworkers on the phone. You can tell them if your connection or your power is down
- An external webcam is better than the built-in laptop cam. For the quality but people want to see your entire face, not only the nose or your keyboard.
- A microphone with a good quality or at least an headset for the calls
- Sometimes try the company VPN even you don't need it every day

## Calls, communication and presentations
- Turn on your video when you are in a call. Non-verbal communication is important like the verbal one.
- During a call or a meeting, wait for a few seconds after the question "do you have any comments about that?". People need time to un-mute themselves.
- Avoid too much calls in a day. If you read the subject of the call request and you think it's not your topic or not interesting for you, ask to the organizer if your presence it's really important.
- Record all the meetings. Sometimes you have to drop a call early for urgent stuffs or just because you have 4 overlapping meetings.
- If you are a the presenter, preload all the links and presentations. It's annoying to see a web page loading screen for your attendees.
- During a presentation, remember to zoom your screen or change your resolution to Full HD. A lot of meeting software are optimized for a full hd streaming.
- Eating during a call is not a bad thing. You can work with people with different timezones.
- Dress your favorite clothes but don't work with your pigiama.
- At the end of a call, summarize the actions items and the responsible for each item.

## Lifestyle and habits
- Invest on your home studio and your enviroment. Your productivity is more higher if you have a clean room and you like to stay there.
- Sometimes you feel lonely at home. Music, Podcast, TV (but not in front of you) can help to reproduce the office noises.
- Go our for fresh air time to time. It helps to stay healty and it's good to have new ideas and for solving problems.
- Don't work in the dark. Good light in the room is important. Even the hackers have the lights in the room.
- Create your habits to have a good start in the morning and during the day. Habits increase the productivity and you don't feel like lazy.

**Do you have any additional tips or suggestions?**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rxwqk1goa97juszm5bn.png)
Closure in JavaScript
Tags: javascript, beginners, webdev, programming
Published: 2022-01-04 09:30:50

Most of us, as soon as they read/hear the name of **closure**. either immediately skip the topic or find it very difficult to understand the concept. In this post I will try my best to simplify the concept of closure.

before coming to definition, look at the below code snippets.

![Closure demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0y0iqhitfuvwd3shum9u.png)

When the above code is executed, then first `outerFunc()` get into callstack. `outerFunc()` will return `innerFunc()` and `outerFunc()` is pop out from callstack means all variables present inside `outerFunc()` is get garbage collected. but if now we call `innerFunc()` a.k.a `closureDemo()` it will print value of outerVar (which is member of outerFunc()). when running above code, you will see below output.

```
Outer Variable
```
But how it's possible? `outerVar` which is defined inside `outerFunc()`. and now  `outerFunc()` is no longer available in callstack. but still `innerFunc()` have access to variable `outerVar`.

> outerVar is declared with **let** and we know let variable are function scoped.

So, here comes the concept of closure. 

> The closure is a function that closes over ( a.k.a. capture, remembers) the variables from it's lexical scope.

so even after executing function from anywhere (even outside of it's lexical scope) it remembers the variables/function from the place where it's defined.

In above code, add the below line in last

```
console.dir(clouserDemo);
```
after running the code, you will see below output in console.

![closure demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sagkqahvs13k3em7dptl.png)

## Key Notes

1. If any variables/function from their lexical scope is referenced inside inner function. then only closure is created else closure will not created

2. Closure function will remember variable reference not value.

![Closure demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8o49yl6gm6nqjp31u49y.png)

if we run above code it log `Changed Value` in console


> I am newbie in writing technical content, So may be this post will not clear your closure concepts. For more detailed explanation & information about closure, I would suggest you to please go through the articles mentioned in References
 
## References

1. https://dmitripavlutin.com/simple-explanation-of-javascript-closures/

2. https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch7.md#you-dont-know-js-yet-scope--closures---2nd-edition

3. https://www.youtube.com/watch?v=qikxEIxsXco&t=1197s
How to create a random word generator program
Tags: java, algorithms, webdev, beginners
Published: 2022-01-04 09:29:26

One use of a word generator application is to generate new website domain names
A word generator works like this:
1. You store all the consonants in box A
2. You store all the vowels in box B
3. You let computer randomly pick some consonants from box A into a new box called box C
4. The computer also randomly picks some vowels from box B into box C
5. Now box C contains both consonants and vowels.
6. Finally, you let the computer randomly arrange the content of box C. Whatever is the result of this arrangement is the 'generated word'