teleren/devto huggingface dataset:
FACTORY MACHINES
Tags: cpp, computerscience, codenewbie, challenge
Published: 2020-10-11 05:10:06

<h2>PROBLEM STATEMENT:</h2>
A factory has n machines which can be used to make products. Your goal is to make a total of t products.

For each machine, you know the number of seconds it needs to make a single product. The machines can work simultaneously, and you can freely decide their schedule.

Find the shortest time to make t products.

<h2>APPROACH:</h2>
Let's assume that all the products are made by the maximum element present in the array, i.e., by the machine which takes the maximum amount of time just to make a single product.
Then use a binary search to calculate the correct time.
Consider an example, 2,3,5.
Assume all the products are made by 3rd machine having time 5 units. So, the total time would be 5*(number of products).
Here, we are using basic mathematics. One machine takes x unit of time to make a single product, then, in y unit of time, it will make y/x product.
We are going to use the same approach in a binary search.

<h2>BINARY SEARCH IMPLEMENTATION LOGIC:</h2>

<b>STEP 1:</b> Take two pointers, low and high. Set low = 0 and high = *max_element*total + 1.
<b>STEP 2:</b>  Create a while loop with a condition where low<=high.
Find mid-value of range low to high.
<b>STEP 3:</b>  Calculate the number of products that can be made in "MID" time. 
<b>STEP 4:</b>  Compare this and with the target value, if it is greater than the target, it means, we can reduce our time to some more extent, so decrement high = mid-1 and store the current answer in a variable, else if it is lower than the target, which means, we have to increase our time more, so increment low = mid+1.
<b>STEP 5:</b>  Output the final answer.

<h2>CODE IMPLEMENTATION </h2>

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7heol6arpgusdit3o9i1.png)

HAPPY CODING :)
How I am motivated my self?
Tags: motivation, developers, weeklyui, 100daysofcode
Published: 2020-10-11 04:59:38

As a developer, I want to share some experience with me. how I am motivated.
 ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1s3sixkk381ryocru13t.jpg)

sometimes you not know your worth and maybe you feel low. I recommend you never dishearted if you are sincere with your work, motivation comes from different sources.

you should try to do something new...like you can learn a language or you can make an open-source project that helps others.

The biggest source of motivation is when you helped others in work.
Never compare yourself with others. just try to do something better and better....then you will stay motivated.


**Success is nothing more than a few simple disciplines, practiced every day.  (Jim Rohn)**



you need to ignore naysayers, demotivational peoples, or everything that demotivates you.
keep patience and grow slowly...because a tree grows in years become like a tree.

Stay motivated.
Happy WeekEnd.
How to get started with Machine learning 
Tags: machinelearning
Published: 2020-10-11 04:34:14

Hello! Machine Learning is not difficult and you dont have to be a math expert. Actually Python provides many libraries which do the complex parts for you. A typical Machine Learning project looks like this:

1. Get the data
2. Analyze and visualize the data to gain insights.
3. Prepare the data.
4. Select a model and train it.
5. Fine-tune your model
6. Maintain your system
.
🤖If you want to get started with your first ML project, check out this link:

https://machinelearningmastery.com/machine-learning-in-python-step-by-step/

Also Google offers a free Machine Learning Crash course here:

https://developers.google.com/machine-learning/crash-course/ml-intro
Love towards coding
Published: 2020-10-11 04:30:40

               "Dream Until Your Dreams Come True"

I took a career break and completed my networking course and Java course and now I am seeking for employment as a software Engineer with focus in designing software applications.


With the love towards coding started learning java and I successfully completed my java certification. It gave confidence that I can learn coding and start my career as a developer. My career goal was clearly to become a Web Developer and Software Engineer. I got to know about the Flatiron school, which created interest in me and gave hope to fulfill my goal as a Web  Developer. 


When I was learning to code I realized that creativity and code are tied together. I firmly believe that great code is damn fun to write. Technology is evolving ….new tools, new concepts and new challenges. The only thing you can do is keep learning technologies, try finding better ways, think innovatively and different solutions to the challenges you find and adapt to this evolving environment. Learning is important and fun.


That’s what I decide to study Software Engineering. I’m truly passionate about it. It's because of all of the possibilities. I can’t wait to bring other people's ideas to life. You have to work hard, you can’t give up and you need to keep going no matter what.
python function brief
Tags: python, java
Published: 2020-10-11 04:27:48

python is a powerful programming language and simple in language as we speak everyday. with python programming language one can do any sort of task and applications present in software and IT field.

Syntax:
it as simple syntax to define function i.e.
```python
def name(parameters):
     pass#body code to perform function as required for you:

```
in this def keyword is used to define the function in python programming language,  every programming languages most of then uses flower brackets({}) are used to define the body of that function here colon(:) is used as it and indentation i.e. space in line from staring of the function defines the body of the function.

parameters are the members given by coder which will be used to perform some function using that values.

body present below the function is the key role where the total calculation and processing that is necessary for the application to be performed is written here.

example of function in python language:

```python
def sum(a , b):
     sum=a + b #adding two numbers
     return sum #returning the sum of numbers
add=sum(10,5) #initializing parameters by calling the function from #outside
print(add) #it will print the returned values from function.
```
output:
15

same program in java:

```java
public class sum
{
public static void main(String args[]){
    int a=10;//initializing  value of a to be 10 of datatype integer
    int b=5;//initializing value of b to 5 of datatype integer
    System.out.println(add(a , b));//sends the values of a and b and print the values for the calculations done in program.
}
public static int add(int a ,int b){
int sum =a + b; //adds the values of a and b and store the value in sum variable of integer datatype.
return sum;
}
}
```
output:
15

explanation:
in java one cannot write function directly without class name and one can write the function in python without class name also so its a big advantage to test each function easily in python then compared to other programming language.

in python one must not necessary to give the datatype of variables used in programming language. but it is necessary to give the datatype for each and every place you use variable the datatype has to be used in other programming languages.
they are: 

```
int
long
float
double
char
byte
string 
array

```
How to use Pacman
Tags: linux
Published: 2020-10-11 04:27:36

Good morning! One of the first differences you will notice after switching to Arch Linux is pacman, the package manager. To install a package you simply write `pacman -S packagename` in the console. And don't forget to also always keep your system up to date with the command `pacman -Syu`. Never do partial updates, because this may break your system.

To remove a package, leaving its dependencies installed, use `pacman -R pkgname` and if you want to delete the dependencies which are not required by other packages as well, type `pacman -Rs pkgname`. Sometimes you probably want to install packages from the AUR (Arch user repository). To do this, you need to:

1. Git clone the URL
2. cd into the directory of the package (normally simply cd and then the name of the package)
3. Build the package with `makepkg -si`. The flag -s installs the needed dependencies, the -i installs the package.
4. You can run the package by typing its name.

Which pacman commands do you find useful? Have a nice day. :)
Pass-by-value vs Pass-by-reference
Tags: codenewbie, beginners, c
Published: 2020-10-11 04:16:24

Good morning! What is the difference between pass-by-value and pass-by-reference? When we have a function with parameters, we have to call it with parameters, like in the following code(language C) e.g. :
```C
int fun(int x, int y)
{
x=1;
y=2;
}

int x=3, y=4;

fun(x,y);
printf(“x=%d,y=%d, x,y);
```
Lets first consider call by value. In this code the values of the parameters x and y will becopied and stored at a different memory location, meaning we have four places of memory here which store:
```
x=1
x=3
y=2
y=4
```
When the function fun() is done, the local variables x=1 and y=2 will be deleted from memory, so when we print now x and y, it will show 3 and 4.

Lets now look at calling by reference. We also need four memory locations here, but there is an important difference:
```C
int fun(int *p1, int *p2)
{
*p1=1;
*p2=2;
}

int x=3, y=4;

fun(&x,&y);

```
Here with the “&”, we pass the memory adresses of x=3 and y=4 to the function and not the values. That means that the so called pointer parameters of the fun() function store the adress and not the values at their own memory adresses. So it would look for example like this:
```C
p1=1000 //memory address of x
p2=2000 // memory address of y
```
Inside the fun() function we write *p1, because we want to access the value of x. With *p1=1 we then change the value of x to 1 and with *p2=2 we change the value of y to 2. The * is also called the dereference operator. If you want more visuals with my explanation check out this video:
https://youtu.be/HEiPxjVR8CU
Have a nice day.😊
Automating the Deployment of Infrastructure in Google Cloud Using Terraform
Tags: googlecloud, terraform, deployment, infraestructure
Published: 2020-10-11 04:11:09

Google Cloud has its own Deployment Manager. However, some people are more habituated to Terraform. Terraform is now integrated into Cloud Shell. At this moment it includes Terraform v0.12.24.

In this example, we are going to create a VPC network, a firewall rule to allow HTTP, SSH, RDP, and ICMP traffic on the network. And two Compute Engine VM instances.

First, we need to define the provider:
```
provider "google" {}
```

Now, we define two resources (the google_compute_network resource is a VPC network, then we have the firewall rule) and two modules (VM instances):
```
resource "google_compute_network" "mynetwork" {
  name                    = "mynetwork"
  auto_create_subnetworks = true
}

resource "google_compute_firewall" "mynetwork-allow-http-ssh-rdp-icmp" {
  name    = "mynetwork-allow-http-ssh-rdp-icmp"
  network = google_compute_network.mynetwork.self_link
  allow {
    protocol = "tcp"
    ports    = ["22", "80", "3389"]
  }
  allow {
    protocol = "icmp"
  }
}

module "mynet-us-vm" {
  source           = "./instance"
  instance_name    = "mynet-us-vm"
  instance_zone    = "us-central1-a"
  instance_network = google_compute_network.mynetwork.self_link
}

module "mynet-eu-vm" {
  source           = "./instance"
  instance_name    = "mynet-eu-vm"
  instance_zone    = "europe-west1-d"
  instance_network = google_compute_network.mynetwork.self_link
}
```

Let's see the main.tf file. Here we have a google_compute_instance resource (which properties are applied to the Compute Engine instances) and four input variables with default values (optional)
```
variable "instance_name" {}
variable "instance_zone" {}
variable "instance_type" {
  default = "n1-standard-1"
  }
variable "instance_network" {}

resource "google_compute_instance" "vm_instance" {
  name         = "${var.instance_name}"
  zone         = "${var.instance_zone}"
  machine_type = "${var.instance_type}"
  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-9"
      }
  }
  network_interface {
    network = "${var.instance_network}"
    access_config {
      # Allocate a one-to-one NAT IP to the instance
    }
  }
}
```
Finally, execute the Terraform commands where we have the tf files:
```
terraform init
terraform plan
terraform apply
```
View source code:
{% github https://github.com/eidherjulian61/tfinfra/ no-readme %}
Week 19: Closures and the keyword 'this'
Tags: javascript, webdev, codenewbie, beginners
Published: 2020-10-11 04:09:55

---
title: Week 19: Closures and the keyword 'this' 
published: true
description: 
tags: javascript, webdev, codenewbie, beginners
---


####This week focus was on Closures and the keyword 'this'  from Colt Steele The Advanced Web Developer Bootcamp.


     -Intro to Closures
     -Closures in the Wild 
     -Intro to keyword 'this' 
     -'this' with Functions and "use strict"
     -Object/Implicit Binding 
     -Explicit Binding 

     
###Intro to Closures
A closure is a function that makes use of variables defined in outer functions that have previously returned

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/b2mgs1tv8ai23taacp4i.png)

###Closures in the Wild 
What are some use cases for closures? 

In other languages there exist support for variables that can not be modified externally. We call those private variables, but JavaScript doesn't have private variables built-in to the language. That is where closures can help. 


```javascript 

function classRoom() {
 var instructors = ["Elie", "Colt"]; 
return {
  getInstructros: function() {
    return instructors; 
}, 
addInstructors: function(instructor) {
   instructor.push(instructor); 
     return instructors; 
   }
  }
}

```

Closure exists when an inner function makes use of variables declared in an outer function which has previously returned 

Closure does not exist if you do not return an inner function and if that inner function does not make use of variables returned by an outer function. 

JavaScript will only remember values that are being used inside of the inner function, but not all variables defined in the outer function. 

We can use closures to create private variables and write better code that isolates our logic and application. 


     ###Intro to keyword 'this' 
A reserved keyword in JavaScript
Usually determined by how a function is called also known as execution context. 
Can be determined using four rules 
    -Global 
    -Object/Implicit
    -Explicit
    -New 

###Global Context 
When 'this' is not inside of a declared object 
console.log(this) 


###'this' with Functions and "use strict"
When 'this' is not inside of a declared object 

```javascript 

console.log(this); 

function whatIsThis() {
  return this; 
}

whatIsThis(); 

function variablesInThis() {
  this.person = "Elie"
}

variablesInThis() 

console.log(person); 

```

###Strict Mode 

```javascript 

"use strict"

console.log(this); 

function whatIsThis() {
  return this; 
}

whatIsThis(); 

"use strict"

function variablesInThis() {
 
this.person = "Elie"; 
}

variablesInThis(); 

```


###Object/Implicit Binding
When the keyword 'this' IS inside of a declared object 

```javascript 

var person = {
  firstName: "Elie", 
  sayHi: function() {
    return "Hi " + this.firstName; 
   }, 
determineContext: function() {
   return this === person; 
   }
} 
 
person.sayHi(); 

```
 
###Explicit Binding 
Choose what we want the context of 'this' to be using call, apply, or bind 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mva8gpusgz5j4yn3w32b.png)
Function Register Laravel Jetstream
Published: 2020-10-11 04:07:02

use Illuminate\Http\Request;

    public function register(Request $requies)
    {
        Validator::make($requies->all(), [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => $this->passwordRules(),
        ])->validate();

        return User::create([
            'name' => $requies['name'],
            'email' => $requies['email'],
            'password' => Hash::make($requies['password']),
        ]);
    }
SEO Bolton

Published: 2020-10-11 04:03:54

Each month, an average of 20 to 200 people looking for a [Bolton SEO agency](https://seoreq.com/bolton/).  Bolton is a large town in Manchester with over 194K population. Every month Bolton based 20 to 200 companies are looking for an SEO agency. In this content, you can find your requirement. If your website isn’t on the first pages, customers are suffering to find your business online. Here at SEOReq, we can help you to manage all SEO process. Search engine optimisation is the best digital marketing method.

You can get traffic from search engines which users are already looking for your service. To be honest this is not easy way to go the first position on Google, But the most efficient. SEO is the process of optimisation for search engine visibility. Search engine optimisation traffics often called organic results. Because you don’t need to pay for any click etc.

If you are looking for results-driven SEO projects and technical search engine optimisation in Bolton, here we are.
Difference between Angular and React
Published: 2020-10-11 04:00:23

Out of all Javascript Frameworks and Libraries Angular and React are the most popular.
Angular: Created by Google; Allows Two Way data binding; Uses browsers DOM; Built to use Typescript; Harder to learn because of Typescript; Has a hybrid version for mobile platforms, but not as good as React native which is fully mobile; Easier to Set a formal structure MVP to your project.
React: Created by Facebook; Allows One Way data binding; Uses Virtual DOM; Built to use JSX but also can use Typescript; JSX is a lot more simplified and makes React easier to learn; React Native is great, the syntax is only slightly different; The structure the developer is in charge off, though sometimes of use could be hassle.
How to make wiggly div in React
Tags: react, javascript, css
Published: 2020-10-11 03:13:45


![](https://i2.wp.com/blogreact.com/wp-content/uploads/2020/09/wiv.js-1.gif?resize=344%2C172&ssl=1)

Making Wiggly div is most interesting and at the same time a complex thing. It will be good for cases for like some cool portfolio, a landing page with some important text etc. Its more like making a div more funny. In this article we will gonna learn how we can create a wiggly div in React.

## react-wiv

This package is a react version of wiv.js. It uses a library named wiv.js internally. It super simple and easy to create wiggly div using react-wiv. In just few lines of code we can accomplish our task without need to worry about the complexity.

## Installation and Usage

Like any other npm package we can install it using npm command.

```
npm install --save react-wiv
```

Once this package is installed. You need to import this package using below code.

```
import Wiv from 'react-wiv'
```

and we are good to use it.

```
<Wiv color="#00FF00" height={4} tightness={6} thickness={2} speed={0.55}>
        Blogreact
      </Wiv>
```

We just provided few props like color, height, speed etc and got this output.

![output](https://i0.wp.com/blogreact.com/wp-content/uploads/2020/09/image-3.png?resize=125%2C63&ssl=1)

Checkout the live demo using below link.

[![Edit o4pw9](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/nostalgic-tereshkova-o4pw9?file=/src/App.js:156-260)

[More demos](https://ndresselhaus.github.io/react-wiv/)

Feel free to comment your thoughts.

[How to send SMS using Bandwidth in Node](https://blogreact.com/send-sms-using-bandwidth/)
Why I study Software Engineering: From the perspective of a Software Engineering Student during week 2 of their program.
Tags: student, beginners, flatiron, bootcamp
Published: 2020-10-11 03:08:09

Originally, I wrote this day 1, week 1 of my Software Engineering program at the Flatiron School Boot Camp. It actually turned out to be very shallow, with several ramblings on advancing technology forward, and emphasizing my upbringing from a third-world underdeveloped nation as a catalyst for my interest in coding/machine learning, and how they work and why. *However*, upon finishing my meeting with my cohort lead, I realized that the link never submitted, which means I could either submit the original piece or start fresh. 

**A change in perspective through Experience**

My aforementioned reasons for learning Software Engineering seemed pretty standard and concrete, but let's be real, the only person I needed to convince as to *why* I am doing what I am doing now is **me**. Internal dialogues often lead you to believe that you are correct almost every time, otherwise we wouldn't be the person we are. When hit with the question, it seemed very simple to answer. *"I love computers."* *"Coding is the future"* "My home country's highest network speed is still dial up in the year 2020"*. *"It pays well."*. Normally for me, that's a days worth of good answers and submitting and letting go of the idea. **BUT**, upon reaching week 2 of the boot camp, I suddenly felt a change of mind and heart. Money, understanding of computers and having an understanding of language(s) in which we could communicate with computers, were no longer the sole motivators in dipping my toe in the water of coding/boot camps. 

Phase 1 assignments started of simple, with a very evenly distributed level of difficulty across topics and concepts. It was always in the back of my mind that I am genuinely fascinated by advanced technology, automation and machine learning, particularly how we are able to communicate with said systems. Whilst working through these tasks, and the perennial instant gratification we, the students, feel when our terminal outputs all green test cases, it dawned on me. 

**I am learning how to deduce problems and solve them using code, the language(s) we use to code are irrelevant in a conceptual manner.**
My fascination of coding/Software Engineering stems from the fact that I am fascinated by what I *don't* know, and using coding as a medium to apply logic, critical thinking and problem solving skills is ,at least to me, the best to prove that I fully understand the problem, why it is a problem, and how to solve it. The terminal doesn't lie, either it passes the tests, or it doesn't.

While I still posses the "shallow" reasons as motivators in doing this, I have found much more meaningful and methodical reasoning for getting involved in this program.

Perhaps our greatest interest as humans, regardless of the field in question, is purely knowledge and understanding, but not bound by a single skill or attribute.
NPM Worker
Tags: github, npm, actions, workflows
Published: 2020-10-11 03:03:17

Sometimes you're working on a repo and you don't want to clone it down to your local machine, init npm, install some packages and then push it all back up.

Now there's [NPM Worker](https://github.com/marketplace/actions/npm-worker). A Github Action that lets you _init_, _install_, _update_, and _uninstall_ npm package on your repo. All from a single configuration file.

It also supports logging activity to an issue, so you can see what's changed from a glance.

{% github https://github.com/mudlabs/npm-worker %}