teleren/devto huggingface dataset:
LWC – Using a Child Component
Tags: video, lwc, salesforce, webcomponents
Published: 2019-08-27 13:21:43

---
title: LWC – Using a Child Component
published: true
tags: Video,LWC,Salesforce,webcomponents
canonical_url: https://wipdeveloper.com/lwc-using-a-child-component/
cover_image: https://wipdeveloper.com/wp-content/uploads/2019/08/Screen-Shot-2019-08-25-at-10.18.01-PM.png
series: Lighting Web Components - First Look
---

{% youtube A3GxlsZGXjE %}

Hi, I’m Brett with WIPDeveloper.com, I wanted to take a quick look at using a child component and a custom Lightning web component.

So the first thing we have to do is make a component to hold the child component. So I’m going to make a new lightning web component.

I’m going to call this one parent. And then I will make a new one. The first thing we’re going to do is give it some markup. Give it a title of parent. So we know where we so we can see it on the page. And I misspelled parent, so let’s change that, or let me spell component.

So I’m going to deploy this, it doesn’t have the proper targets. So

first, I’m going to take the targets from the other one just so I don’t have to.

Deploy it.

Now we have to add a tour page. So refresh our list of components.

Drop it in there. So momentarily saw, it’s a child component, and that’s because of a dry run I did earlier. Now we refresh our page, we should see our parent component.

Now, we need to add a child component. So let’s go to to add a new Lightning web component called child.

And we’re going to mark this one as exposed, create it, give it some HTML. Going to give it a panning around small.

Now, this is deployed to our org, but we have to get it so that it shows up in the body of the parent component. And so what we need to do in the parent component is we’re going to add it like we would a normal HTML element.

So all custom web components require two names separated by or two words separated by a dash in the tag. Since we’re using Lightning Web Components, all our tags are prefixed with the namespace. So our child component that has one name is actually has a prefix of our namespace. So in this case, it’s `c`, and then `c-child`.

And we’ve added our child component to our parent component when we refresh the page again.

We will see our child of course it doesn’t look very good. Why does it not look very good?

Oh, because it’s outside of the card.

Oops.

No, it’ll be inside the card. Everything will be fine.

Now it’s our

Doesn’t look fine, the child isn’t padded enough.

Wrong. Oops. Wrong autocomplete.

`slds-p-around_small`.

Refresh the page.

There padding is a little better. Why don’t we make that medium

Now we can see the child lined up with parent.

And there you go. We are now using a child component in our parent component.

## That’s it for now.

Remember to sign up for **[The Weekly Stand-Up!](https://wipdeveloper.com/newsletter/)**  and you can get updated with any new information we have on WIPDeveloper.com.

The post [LWC – Using a Child Component](https://wipdeveloper.com/lwc-using-a-child-component/) appeared first on [WIPDeveloper.com](https://wipdeveloper.com).
A simple way to distribute jobs in Sidekiq queues
Tags: ruby, rails, sidekiq
Published: 2019-08-26 12:16:25

This option implies that jobs of one context are executed sequentially in one queue, and jobs of different contexts in parallel in different queues.

Let's look at the following example.
There are investment funds for which we want to make time-consuming reporting calculations. Jobs for calculation within the same fund are carried out sequentially so that there are no errors in the calculations, jobs of different funds are performed in parallel.

We automate the distribution of jobs in queues so as not to specify a queue manually.
Specify the queues in the `sidekiq.yml` configuration file:

```yml
:queues:
  - fund_processor_0
  - fund_processor_1
  - fund_processor_2
  - fund_processor_3
  - fund_processor_4
```

It is important that the queues are numbered from 0.

Now, when starting the worker, we indicate in which queue we will set the job depending on the fund. To do this, we use the operation of obtaining the remainder from dividing the fund ID and the count of queues. So we get the queue number.
```rb
# 5 queues
# fund ID % count of queues = queue number
# 1 % 5 => 1
# 2 % 5 => 2
# 3 % 5 => 3
# 4 % 5 => 4
# 5 % 5 => 0
def queue_name(fund_id)
  queue_number = fund_id % 5
  "fund_processor_#{queue_number}"
end
```

Start the worker, indicating to him the received queue name. 
This can be done using the [Sidekiq API](https://www.rubydoc.info/github/mperham/sidekiq/Sidekiq%2FClient:push "Sidekiq::Client.push")

```rb
Sidekiq::Client.push(
  'queue' => queue_name(fund_id),
  'class' => Fund::ReportCalculator,
  'args' => [fund_id]
)
```
React Reverse Portals
Tags: react, javascript, webdev, showdev
Published: 2019-08-26 12:02:00

---
title: React Reverse Portals
published: true
description: New React library to help with performance & simpler state management
tags: react, javascript, webdev, showdev
---

Hey Dev.to!

I've just built a new library for React: https://github.com/httptoolkit/react-reverse-portal

It lets you define, mount & render a component once, in one place, and then place it in the React & DOM tree somewhere totally different, move it up/down/around the tree later, or even pull it out of the page entirely and put it back, all without remounting or necessarily rerendering.

It's similar to the built-in React portals (and it uses them internally), but effectively the opposite. Instead of defining some content within your tree and pushing it elsewhere via raw DOM, you define your content elsewhere and then pull it into the React tree where you want it to appear.

No DOM work required: just get a node, place an `InPortal` somewhere with your content & the node, and an `OutPortal` elsewhere with the node, and your content is magically sent from one to the other.

Useful if you want to avoid unnecessary recreation of components. That lets you avoid losing react state or DOM state (e.g. playing video elements), avoid recreating expensive-to-initialize components, and generally separate here your component is define from where it's used.

There's an example in [the readme](https://github.com/httptoolkit/react-reverse-portal#react-reverse-portal) and a [storybook of live examples](https://httptoolkit.github.io/react-reverse-portal/) too.

Let me know what you think!
How To Excel At Your Job As A New Developer
Tags: communication, beginners
Published: 2019-10-28 23:52:12

---
title: How To Excel At Your Job As A New Developer
published: true
tags: communication,beginner
canonical_url: https://letterstoanewdeveloper.com/2019/08/26/how-to-excel-at-your-job-as-a-new-developer/
---

Dear new developer,

I think that there are only really four tasks you need to do to do a good job as a new developer.

- Say what you are going to do, then do it. This is all about communicating what you are working on. You can do this explicitly (via face to face communication or slack) or implicitly (via moving cards on a Trello board or Jira). The important part is to keep other people (who likely will have a better idea of the big picture) in the loop. Oh, and then you actually have to **do** the work.
- Ask questions. [Don’t be afraid](https://letterstoanewdeveloper.com/2018/12/03/dont-be-afraid-to-ask-questions/). This will help you do the work.
- Don’t make the [same mistake twice](https://letterstoanewdeveloper.com/2018/11/26/making-mistakes-is-ok/). Learn from any that you make. This will help you do the work better in the future.
- Show up [consistently](https://dev.to/mooreds/consistency-is-key-390-temp-slug-7795145). Sometimes you just have to grind. To do the work. (Is there an echo in here?)

If you can do these four things, you will stand out as a new developer. Why? It’s sad to say, but there are a lot of developers who aren’t very good. I’ve seen a few in my time. I’m not sure if they weren’t good because they were burned out, just didn’t care, didn’t have the skillset or the desire to learn, or were just in it for the money. Other times, I’ve seen developers get complacent, which is a foolish thing to do in this day and age (and a luxury that most new developers do not have). See also [this comment thread](https://news.ycombinator.com/item?id=20673437) on Hackernews about 20% of developers failing to be able to write [fizzbuzz](https://www.hackerrank.com/challenges/fizzbuzz/problem).

So, you don’t have to be brilliant to stand out. You do have to be good and consistent. And do the work.

Make sure you do all these, especially [during the first few months](https://letterstoanewdeveloper.com/2018/09/25/over-index-in-your-first-few-months/), and you’ll gain a reputation as a delight to work with. This reputation will follow you for years and continue to help you.

Sincerely,

Dan
When you can’t relax
Tags: motivation, productivity, webdev, agile
Published: 2019-08-28 11:33:42

---
title: When you can’t relax
published: true
tags: motivation, productivity, webdev, agile
cover_image: https://i1.wp.com/cubiclebuddha.com/wp-content/uploads/2019/08/fox-1284512_960_720.jpg?zoom=2&resize=375%2C232&ssl=1
canonical_url: https://cubiclebuddha.com/when-you-cant-relax/
---

So the weekend is over, and you don’t feel relaxed. What happened? Maybe you even “stayed home and did nothing,” and yet you didn’t really replenish your energy. Well, today I’ll share a little guidance that will hopefully give you a booster shot to help you truly rest the next time you get a chance.

It turns out that Thich Nhat Hanh describes this exact scenario of resting but not really resting:

> Calming allows us to rest, and resting is a precondition for healing. When animals in the forest get wounded, they find a place to lie down, and they rest completely for many days. They don’t think about food or anything else. They just rest, and they get the healing they need. When we humans get sick, we just worry! We look for doctors and medicine, but we don’t stop. Even when we go to the beach or the mountains for a vacation, we don’t rest, and we come back more tired than before. We have to learn to rest.

Did you notice that part about all animals needing to rest? You need to rest too. You need to replenish your mental energy from many hard days of work.

### So how do we learn how to rest?

There are many ways to learn to disconnect, but most mindfulness practitioners point to breathing techniques. I had to employ it myself last night when I couldn’t get to sleep. [Click here for our article on breathing techniques and their values.](https://dev.to/cubiclebuddha/mindfully-breathing-to-prepare-for-a-big-meeting-

{% link https://dev.to/cubiclebuddha/mindfully-breathing-to-prepare-for-a-big-meeting-19im %}

### Hey, is this article over already?

Yes, it is. Sorry, but I needed a rest this weekend too. So I gave myself a break. I used the time that I would normally be researching psychology studies and combing through Buddhist text to instead doing nothing but stare out my window.

### What can you “slack on” to make time for rest?

So that’s my challenge for you. Is there one thing in your life that you can give up or put down for five minutes? Try installing a screen time app on your phone to see where you’re spending your time. Then you can audit the results and say, “hmm, maybe I don’t need to spend 4 hours on facebook.” All you need to do is carve out [5 minutes to doing nothing](https://dev.to/cubiclebuddha/doing-nothing-the-cure-for-procrastination-47ik).

{% link https://dev.to/cubiclebuddha/doing-nothing-the-cure-for-procrastination-47ik %}

And if you’re finding it difficult to really enjoy the calm and quiet, you need a positive voice in your head. When your brain is telling you that “you shouldn’t be resting” please try to insert my voice saying “you deserve it.” Because you really do.
Top Python Posts from August 19 week
Tags: python, bestofdev
Published: 2019-08-26 11:26:06

Hi! I'm Vicente, your friendly Filipino mod for the python tag. Today, is another episode of the Top Python Posts of the week!

Hope you'll follow along!

# 1.) I Built a Bot to Try and Get Money Back From My Internet Provider 

I didn't want to sit spamming speedtest.net to check when my speeds were getting low. I wanted to know if there had been dips. Were the dips at the same times? Was there a pattern? I needed data and some data visualization to know if/when I might be eligible for any discounts and whether it was worth pursuing.

{% link https://dev.to/healeycodes/i-built-a-bot-to-try-and-get-money-back-from-my-internet-provider-33ip %}

# 2.) Web Scraping 101 in Python 

In this post, which can be read as a follow up to our ultimate web scraping guide, we will cover almost all the tools Python offers you to web scrape. We will go from the more basic to the most advanced one and will cover the pros and cons of each. Of course, we won't be able to cover all aspect of every tool we discuss, but this post should be enough to have a good idea of which tools does what, and when to use which.

{% link https://dev.to/daolf/web-scraping-101-in-python-5aoj %}

# 3.) Building Your First Website With Flask — Part 1 (Hello World and Beyond) 

Just to quickly get our feet wet, we are going to create the classic “Hello World” web page. This program will also help you check that you have properly installed Flask.
It’s pretty amazing but the Hello World! program in Flask is seven code lines long. Those seven lines of code are sufficient to create a simple web page.

{% link https://dev.to/seattledataguy/building-your-first-website-with-flask-part-1-hello-world-and-beyond-53ik %}

# 4.) 4 Basic Python Tips to Automate Your Workflow 

Automation. It’s supposed to make work easier. So, why not help it along?

{% link https://dev.to/seattledataguy/4-basic-python-tips-to-automate-your-workflow-3l8l %}

# 5.) A Gentle Introduction to Kubernetes 

We will start by developing then deploying a simple Python application (a Flask API that returns the list of trending repositories by programming language).

{% link https://dev.to/eon01/a-gentle-introduction-to-kubernetes-52en %}

See you again next week!
Mouse connections
Tags: javascript
Published: 2019-05-31 03:01:50

Is *Mouse connections* the right name for this program? … or maybe should be named *Spider legs*?

The program works by displaying a series of balls that are bouncing from the edges of the canvas. Connections are created on the fly from the mouse cursor to each ball that is in a certain range from the cursor.

{% youtube qtMG1XbadLY %}

#Source code

This cool effect is actually very easy to implement. We only need to work on the canvas using a 2D graphical library such as p5.js

In this case we will use the [codeguppy.com](https://codeguppy.com) environment which is comes with p5.js included.

Try to copy the following source code in the code [editor](https://codeguppy.com/code.html)

```
var noBalls = 100;
var speed = 1;
var distBalls = 100;

var balls = [];

function enter()
{
    createBalls();    
}

function loop()
{
    clear();
    
    updateBalls();
    displayBalls();
    displayConnections(mouseX, mouseY);
    
    displayInstructions();
}

function createBalls()
{
    for(var i = 0; i < noBalls; i++)
    {
        var ball = {
            x : random(width), 
            y : random(height), 
            dx : random([-1, 1]), 
            dy : random([-1, 1]),
            speed : speed
        };
        
        balls.push(ball);
    }
}

function updateBalls()
{
    for(var i = 0; i < balls.length; i++)
    {
        var ball = balls[i];
        
        ball.x += ball.dx * ball.speed;
        ball.y += ball.dy * ball.speed;
        
        if (ball.x > width || ball.x < 0)
            ball.dx *= -1;
            
        if (ball.y > height || ball.y < 0)
            ball.dy *= -1;
    }
}

function displayBalls()
{
    for(var i = 0; i < balls.length; i++)
    {
        var ball = balls[i];
        
        fill(255);
        stroke(150);
        circle(ball.x, ball.y, 3);
    }
}

function displayConnections(fromX, fromY)
{
    for(var i = 0; i < balls.length; i++)
    {
        var ball = balls[i];

        var d = dist(fromX, fromY, ball.x, ball.y);
        if (d < distBalls)
        {
            var color = map(d, 0, distBalls, 0, 150);
            stroke(color);
            fill(color);

            circle(fromX, fromY, 3);
            circle(ball.x, ball.y, 3);
            line(fromX, fromY, ball.x, ball.y);
        }
    }
}

function displayInstructions()
{
    push();
    fill(0);
    noStroke();
    text("Move your mouse inside the canvas area", 10, 590);
    pop();
}

```

#Draft

This article is a draft. If you are interested how the program above works, please leave a comment.
Should comments in code be considered failures in coding?
Tags: code, comments, failure, discuss
Published: 2019-08-26 10:35:39

---
title: Should comments in code be considered failures in coding?
published: true
description: Do code comments ALWAYS indicate a failure somewhere?
tags: code, comments, failure, discussion
---

Uncle bob says:

<blockquote class="twitter-tweet"><p lang="en" dir="ltr">A comment is a failure to express yourself in code. If you fail, then write a comment; but try not to fail.</p>&mdash; Uncle Bob Martin (@unclebobmartin) <a href="https://twitter.com/unclebobmartin/status/870311898545258497?ref_src=twsrc%5Etfw">June 1, 2017</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

 - Should code be written in a way that's expressive enough on it's own?
 - If you disagree, what are your thoughts on keeping comments up to date with changes?
 - Is there a grey area?   Examples?
Know your Linux 05: Services and daemons
Tags: linux
Published: 2019-08-26 10:31:55

---
title: Know your Linux 05: Services and daemons
published: true
description: The fifth entry in the “Know Your Linux” series. This time let’s talk about Linux's services and daemons.
tags: Linux
cover_image: https://thepracticaldev.s3.amazonaws.com/i/6dybnj1ufyr5p24lpbmx.jpeg
canonical_url: http://bassemmohamed.me/Post/know-your-linux-05-services-and-daemons
---

Hello and welcome to the fifth entry in “Know Your Linux“ series. This time let’s talk about Linux’s services.

Before we dive right in 🏄‍♂️, make sure to check out the previous entry.

{% link https://dev.to/bassemmohamed/know-your-linux-04-processes-1d6m %}

Do you have your diving mask on? Let’s go.

# WTF is a service or a daemon?

Daemons are a kind of non-interactive process that runs in the background. They basically are detached from the keyboard and display.

Services also do not need a terminal. They run in the background to provide some service like apache.  

## All good and dandy, but what could we do?

I would like to introduce you guys to *`systemctl`.* What’s that? It’s a super cool program used to inspect and control services running on your machine. When it comes to services *`systemctl`* is your friend.

There is so much that you can do with *`systemctl`.* We will discuss the most famous use cases. If you want to know more, you should definitely visit the *man* pages. If you don’t know what the *man* pages are. Take a quick look at my second entry.

{% link https://dev.to/bassemmohamed/know-your-linux-02-know-your-commands-23k7 %}

*`systemctl`* is a command-line program. All you need to do is type the command in terminal.

``` shell
systemctl COMMAND SERVICE
```

The service here is the command’s target. Basically, it is the service you want to manage using *`systemctl`.*

What about the command? There is a list of commands you can do.

| Command | What it does? |
| --- | --- |
| status | Returns the status of the service |
| start | Attempts to start the service 🙏 |
| stop | Stops the service | 
| restart | Restarts the service |
| reload | Reloads the service’s configuration. This applies the new configuration. | 
| enable | Enables autostart on boot |
| disable | Disables autostart on boot |

# Service’s status

Now, Let’s see the different statuses that every service could have. 

| Status Name | Status Description |
| --- | --- |
| loaded | The service’s configuration files have been loaded successfully |
| active | The service is running or waiting for a certain event to run. |
| inactive | The service is not currently running |
| enabled | The service will start at boot |
| disabled | The service will not start at boot |

That’s all from my side. ✋

If you enjoyed the post, please let me know and checkout the next entry. 🙄

{% link https://dev.to/bassemmohamed/know-your-linux-06-logs-4d9e %}

As always,
**Happy coding 🔥🔥**
“**كود بسعادة”**
Trying to make a graph of nodes but shorted my own brain
Published: 2019-08-26 10:11:00

Hello everyone,,
This semester I'm taking a Combinatorics and Graph theory class and I thought to prep making an application that graphs nodes and their connections would be cool. So far so good. I decided to base the application on the board game Scotland Yard and had almost no issue until I decided to include the functionality of checking which nodes would be along a bus path.

For those who haven't played you have a map of a city, and you can travel between points via taxi, train, or bus, if train passes through nodes someone else is on you're fine, but if a bus does you get caught (those might be house rules but it's how I played https://capread.com).

Trying to check a very specific path along this graph is what caused the hold up. Because I initially was gonna do like breadth first searching but I realized that's not specific enough I need to check this path specifically. So I decided to make a travel path object connecting the nodes and now I've fried my brain even more trying to think "how do I set up all these connections in a clean randomly generated way instead of a tangled mess.

The above to problems are what I'd enjoy other people's thoughts on:

How would you check what nodes lie on a very specific path within a graph? Does having path objects seem like a decent alternative to some search algorithm?

When generating a graph of nodes and connections what is a good way for one to limit connections in such a way that say node 1 can't connect to node 100 because it's too far or to node 5 because there is already a Bus/train/taxi connection between the two?

Part of me wants to say "the scope of this project ballooned to quickly and you should reassess" but with how much I enjoy graphs and programs that deal with them these are questions I'm going to want to answer eventually