teleren/devto huggingface dataset:
How to Use Git Rebase in a Practical Situation
Tags: git, devops
Published: 2020-10-14 20:15:55

Imagine that there are two pull requests open on a project repository.
Each change has its own branch like this:

- master
- feature/add-base64-endpoint
- feature/add-user-agent-endpoint

The challenge is to use git rebase to add both changes to master. When you finished, your master branch should have three commits in the following order:

>* feat: add user-agent endpoint
>* feat: add base64 endpoint
>* init

Okay, let’s go!
```bash
git clone repo_url
git status
git checkout feature/add-base64-endpoint
git rebase master
git status
git checkout master
git merge feature/add-base64-endpoint
git status
git checkout feature/add-user-agent-endpoint
git rebase master
```
Oops! You should see `rebase conflict`!
You need to check the conflicted parts and fix it. Fortunately VS Code provides some great hints for you to do that.
I personally use Vim as my IDE because I'm a huge fan of Vim!
Do not forget to check if the code base is functionable even after you resolve the conflicts, i.e. all the tests should be green, app should be functional eventually.
Once you finish resolving conflicts, follow these steps:
```bash
git add .
git rebase --continue
git checkout master
git status
git checkout master
git merge feature/add-user-agent-endpoint
git status
git log
```
Boom! You must be done!
Happy gitting! 😉
Day 90: Design Implementation
Tags: 100daysofcode, vue
Published: 2020-10-14 20:12:19

My work in progress.

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

Turns out I know nothing in Vue. The struggle is real, but i'm figuring it out on the way.

_Day 90_
Evita la excepción "Ambiguous Column"  en Eloquent.
Tags: laravel, eloquent, spanish
Published: 2020-10-14 20:10:35

---
title: Evita la excepción "Ambiguous Column"  en Eloquent.
published: true
description: Maneja las relaciones para obtener unicamente las columnas que necesitas en Laravel.
tags: Laravel, Eloquent, spanish
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/c5vik4dlgowawfh51h6t.png
---

Escenario: tienes dos modelos con relaciones y deseas obtener  algunas columnas de la relación.

# Modelos:

## User:

```php
public function teams()
{
    return $this->belongsToMany(Team::class);
}
``` 

## Team

```php
public function users()
{
    return $this->belongsToMany(User::class);
}
```

Ahora puedes hacer un "attach" de los teams:

```php
Team::users()->attach(auth()->user());
```

y obtener la colección de usuarios por equipo:

```php
$users = Team::users;
```

Ok en este punto todo esta bien, es posible que pases datos por una API o a una vista pero tu modelo User sea muy amplio o tenga datos sensibles que no deseas que sean publicos.

posiblemente deseas mostrar solo el nombre y el email de los usuarios de cierto equipo:

```php
$team = Team::first();
$team->users()->select(['name', 'email'])->get();
```

En este punto tendras una excepción de eloquent, esto es porque el modelo User puede tener una columna que se llame "name" y el modelo Team tambien, esto es facil de evitar pasandole explicitamente el nombre de la tabla y la columna esperada. 

```php
Team::users()->select(['users.name', 'users.email'])->get();
```

La misma idea aplica cuando deseas usar un metodo "where":

```php
Team::users()->where('users.email', $request->get('email'))->get();
```
Hacktoberfest Success
Tags: hacktoberfest
Published: 2020-10-14 20:02:53

I started contributing this year to open source and got to know more about Hacktoberfest. As soon as I came to know it, I decided I'll complete the challenge. As the clock struck 00:00 on 1st October, I quickly made 4 PRs and all have been accepted. Since then, I have made 8 PRs just so I don't miss the chance of wearing this T-Shirt and also I have started loving open source more and more due to Hacktoberfest.
@DigitalOcean
Genesis Of My Open Sourcing
Tags: hacktoberfest, digitalocean
Published: 2020-10-14 19:37:00

## What I Learned From Hacktoberfest

<!-- What did you learn that can help others contribute to the project you worked on? What did you learn that can help the users of that project?! -->
Imposter syndrome is something we all struggle with to one degree or another. Imposter syndrome is the fear of exposure as a fraud. If you’re anything like me you have felt like your work was not good enough to show. Or you weren’t far along enough in your journey as a developer to have much to contribute.

After learning about Hacktoberfest last year, I wanted to contribute. But I felt overwhelmed, and imposter syndrome began to take hold.

I told myself I was too inexperienced as a developer and I worried that my commits wouldn’t be worthwhile. Unfortunately, I let those fears get the better of me, and I didn’t even bother signing up.

This year I forced myself to set my fears aside, studied this post on Hacktoberfest, and I dove in. I’m going to share a little of what I worked on and the benefits of getting involved. Benefits that go far beyond getting a shirt and can be had 12 months out of the year!
AWS Data Services
Tags: aws
Published: 2020-10-14 19:26:33

Earlier this year, I updated one of my AWS courses on LinkedIn learning -> ['AWS Data Services'](https://www.linkedin.com/learning/amazon-web-services-data-services-2).

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

In addition to the course, I created a GitHub Repo with example scripts, small datasets and other materials, so that you can quickly try out the majority of the available data services on AWS.

I updated my course in 2020 (from 2018).  Additionally, I update the examples in my repo more **frequently** - for example, I recently tried out [AWS Braket (Quantum Computing as a Service)](https://aws.amazon.com/braket/) and added info about my initial test of the service into the Repo.

Shown below is the folder structure in my [example GitHub Repo](https://github.com/lynnlangit/Hello-AWS-Data-Services).

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/jgmgf4po4gulni1bt2ur.png)
Circuit a list, a useArray hook
Tags: react, javascript, reacthooks
Published: 2020-10-14 19:23:13

So recently I had to create a react component that cycles through a list using two arrows. The catch here is the next arrow must go back to the first index after reaching the end and the previous arrow must go to the first item when it reaches the last item.

This being react and using hooks gave me the following result

```javascript
// useArrayNavigator.js
import { useState } from 'react';

export function useArrayNavigator(arrayLength) {
  const [currentIndex, setCurrentIndex] = useState(0);

  const previousIndex = () => {
    const index = currentIndex === 0 ? arrayLength - 1 : currentIndex - 1;
    setCurrentIndex(index);
  };

  const nextIndex = () => {
    const index = currentIndex === arrayLength - 1 ? 0 : currentIndex + 1;
    setCurrentIndex(index);
  };

  return { currentIndex, previousIndex, nextIndex };
}
```

To use it in the component:
```javascript
// widget.js
const Widget = ({ array }) => {
  const { currentIndex, nextIndex, previousIndex } = useArrayNavigator(array.length);

  return (
    <div>
      <span className="text-lg">Top in {array[currentIndex].label}</span>
      <span>
        <button onClick={previousIndex} />
        <button onClick={nextIndex} />
      </span>
    </div>
  );
};
```

And the result is: 
![useArray](https://dev-to-uploads.s3.amazonaws.com/i/x69vhogokbj5yu4vdkr3.gif)

Notice how I can go through the list continuously.

*Till next time!*
Avoid Ambiguous Column Eloquent Query Exception in Laravel
Tags: laravel, eloquent, relationships
Published: 2020-10-14 19:15:25

---
title: Avoid Ambiguous Column Eloquent Query Exception in Laravel
published: true
description: Handle this relationship to get only the columns that you need from a relationship.
tags: Laravel, Eloquent, relationships
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/c5vik4dlgowawfh51h6t.png
---

Scenario: you have some relationship and you want to get only a few columns.

# Models:

## User:

```php
public function teams()
{
    return $this->belongsToMany(Team::class);
}
``` 

## Team

```php
public function users()
{
    return $this->belongsToMany(User::class);
}
```

Then you can attach users to teams like this:

```php
Team::users()->attach(auth()->user());
```

and now you can get a collection of users by teams like:

```php
$users = Team::users;
```

Ok here all fine, maybe you need to pass data to an API or just to a view but, User model has sensitive data or maybe your User model is huge and its a better approach to get only the data that you need, maybe you want the name and email only, you are probably doing something like this:

```php
$team = Team::first();
$team->users()->select(['name', 'email'])->get();
```

Here you would see some eloquent exception, this is because the User model has a column name and Team model could have a column name too, but dont worry like all in Laravel is really easy, just be explicit with the table and the columns that you need:

```php
Team::users()->select(['users.name', 'users.email'])->get();
```

The same idea apply when you need to add a "where" method:

```php
Team::users()->where('users.email', $request->get('email'))->get();
```
Basic commands
Published: 2020-10-14 19:11:14

**_Echo_** - Used to print a line of text on the screen
eg: echo hi

**_ls_** -lists contents of a directory
eg: ls

**_cd directoryName_** - change the directory you're working in.
eg: cd /home/Files

**_pwd_** - prints the directory you are working on.
eg: pwd

**_mkdir directoryName_** - Creates a new directory
eg: mkdir Python
Chinese ExerciseBook v2.0 (Google Play)
Published: 2020-10-14 18:35:54

💬💬 "Chinese ExerciseBook" has been updated again. This version is v2.0. Besides adding some new functions 🗚, it also adds a new mode called "Sophistical Exercise Page" 📝, in this mode it is one character per page, according to different templates designed 🔖, You can insert images, radicals, strokes, stroke order , description, etc ...



🔎 【Chinese ExerciseBook ver 2.0】
1. Add Sophistical Exercise Page PDF mode (SEP)
2. Add eight template designs [SEP]
3. Add three type of fonts [CEP]
4. Add correction area [VEP]
5. Add dotted line on full page
6. Add four frame style of "回"
7. Change App LOGO icon
8. Change PDF icon
9. Change custom background can use independently
10. Fix reported BUG
11. Fix text color BUG [CEP]
12. Optimize App UI and User Experience

📲 Google Play (App link):
https://play.google.com/store/apps/details?id=com.smallgcok.chineseexercisebook

🎥 YouTube (Demonstration video):
https://youtu.be/msz0g6G5EPk

---------------------------------------------------------------------

📌 *Share with your friends~~~

📌 Group (BUG Report/Function Discussion)：
https://www.facebook.com/groups/SmallGCOk.Programmer

📌 More SmallGCOk App：
https://blog.smallgcok.com/p/appshare-android-google-playpowered-by.html

📄 *繁中、简中、Español、English

⏩ 中文練習簿 >>> 快速製作出中文練習頁 App (生字、書法和精美)
⏩ 中文练习簿 >>> 快速制作出中文练习页 App (生字、书法和精美)
⏩ Chinese ExerciseBook >>> App to quickly generate flat (Vocabulary, Calligraphy and Sophistical)
⏩ Libro de Ejercicio en Mandarin >>> App para generar rapidamente plana (Vocabulario, Caligrafia y Sofisticado)

#⃣ #SmallGCOk #Android #GooglePlay #smallgcok #android #googleplay #中文練習簿 #中文练习簿 #Chinese_ExerciseBook #Libro_de_Ejercicio_en_Mandarin #chinese_exercisebook #libro_de_ejercicio_en_mandarin

© com.smallgcok.chineseexercisebook
Why I failed?
Published: 2020-10-14 18:11:25

I failed as a software developer. When I started learning,I dont know where to start and what to start. Even before I started learning basics I was pushed to debug the codes. There where I failed at first... No wonder you will lose hope in leaning when you stuck in between 1000 lines of code. First thing comes in your mind "ask people for help". This phase keep on repeating in mind every single time. So that why I failed.
New Career Hunt
Tags: codenewbie, beginners, career
Published: 2020-10-14 18:01:10

I'm terrible! I missed my post last week. The week just slipped right past me! Now, it's already mid-week and I haven't shared anything with you. 

So here's what I've been  up to. 

I'm about two and a half months in my coding journey and starting to look what kind of jobs are out there for me in the Dev world. I want to be realistic but also challenge myself to learn what employers are looking for. 

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

Searching for jobs is extremely daunting especially since I've been in a very different career for the last 10 years. I am pretty sure that Pharmacy Program Director `!==` Web Developer in any way. At least I haven't done any dev stuff as a part of my job in the pharmacy. The closest I got to web development was customizing a little HTML in course modules for my students. Now look at me! I'm here learning full on web design and development and I'm really loving it. 

###Where do I start looking? 

We have your major job search engines like [Indeed] (indeed.com), [Monster] (monster.com), and [Glassdoor] (glassdoor.com). I think that all of these are great to find something in your area. There are remote jobs that are available in there as well (more so because of the pandemic), but I think that most seeking employers on these sites are local and remote work is temporary. I did found a couple of local dev jobs that could be suitable for my level of experience! Yay!

My cousin gave me a great website if you're strictly looking for remote jobs called [Remote OK] (remote.io). There's also [Remote.co] (remote.co). I absolutely love these. I am open to working in an office, but I've grown very fond of working remotely. The opening I did find that stood out to me had already closed a couple days before which is a bummer. 

###My online portfolio.

I have started to build my online portfolio and it's going great. I'm learning a lot and brushing up on a lot of code that I've learned so far. I've also been creating more code cards to go onto my site for reference. It's going to be amazing! I can't wait to share it with you once it's all done.

###Help a fellow dev!
If anyone knows of employers in the Las Vegas area or remote employers hiring someone who loves design, learning code, and willing to grow--please send them my way! Or if you have any advice, suggestions, or pathways for a beginner dev looking for a job, I would appreciate the help so much. 

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

Well, I'm going to get back at it and I wish the best of luck to everyone looking for new careers in the dev world and to those building their never-ending portfolios!

Until next time,
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7vj0g7fqs4d1d444t0da.png)
Create Azure API Management API Operation with Azure CLI
Tags: azure, cli, api
Published: 2020-10-14 17:58:08

To create an Azure API Management API or Operation you have to use the current version of Azure CLI:

## Install Azure CLI

_Check installed version_:

```
az --version
```

Install or update [Azure CLI](https://docs.microsoft.com/de-de/cli/azure/install-azure-cli "Install the Azure CLI")


## Login
Before creating the API you have to be logged in. Maybe you have to select the correct tenant.

```bash
az login
```

## Script

Please find the Microsoft documentation here:


[az apim api create](https://docs.microsoft.com/en-us/cli/azure/apim/api?view=azure-cli-latest#az_apim_api_create "az apim api create")

[az apim api operation create](https://docs.microsoft.com/en-us/cli/azure/apim/api/operation?view=azure-cli-latest#az_apim_api_operation_create "az apim api operation create")

The script requires an existing API Management:

```bash
$resourceGroupName = "eval.datatransformation"
$serviceName = "mm-sample"
$apiId="lorem-ipsum"
$apiDisplayName="Lorem Ipsum"
$apiId="Lorem"
$apiPath="/lorem-ipsum"
$operationPath="/"
$operationDisplayName="Get"
$operationDescription="Gets the data"

az login

# create the API
az apim api create --service-name $serviceName  -g $resourceGroupName --api-id $apiId --path $apiPath --display-name $apiDisplayName

# create the Operation
az apim api operation create --service-name $serviceName  -g $resourceGroupName --api-id $apiId --url-template $operationPath --method "GET" --display-name $operationDisplayName --description $operationDescription

```

## Result

The API and operation is created:


![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1602652090471/-5xThU46d.png)
No comment...
Published: 2020-10-14 17:37:53

---
title: No comment...
published: true
description: Social
tags: 
//cover_image: https://direct_url_to_image.jpg
---

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

Available at [Google Icons](https://material.io/resources/icons/?search=coronavirus&icon=coronavirus&style=baseline)
New to web scraping? Here is a challenge for you

Published: 2020-10-14 17:36:21

We at TeraCrawler.io do a lot of web crawling and web scraping. We write a lot about it too here as well as on our blog. Every day is a new challenge. When a new developer joins our team, we throw a few challenges at them to test their ability to think through a quagmire that is web scraping.

We thought we will expose one such challenge here so you can have fun with it. This will help you rack your brains, force you to research, and think outside the box and in the end you will find you now know 5 new things about scraping than you knew before. Please post your answers as comments to see all the various ways you can approach this problem. Don't worry, we will post our answer in a week's time as a follow-up post.

The scenario:

Suppose you are a phone retailer who wants to keep tabs on all the prices of phones on Flipkart, the eCommerce website in India (there is a reason we picked Flipkart and not a global website like Amazon as you will see) and their prices, ratings and especially, the percentage discounts they are offering.

What you have to do:

You will have to crawl product data from Flipkart.com for the product category phones and extract the following details:

Title of the product, URL, Rating, Price, and discount percentage.

What's challenging about this:

As you will discover, Flipkart happens to have no obvious way to point at the data we want. Generally, websites like Amazon are easily scrapable because of the way the HTML and the CSS classes are meaningfully laid out. You can use CSS selectors to point at data and simply scrape them. None of that will fly with Flipkart because as shown below, the CSS classed are all auto-generated gibberish. Also, from having scraped with the website before, we know you will need to jump through different hoops for different pieces of data on this website. So have at it:

What you will learn

You will learn how to use creative ways to reliably point at data you want. A sort of web scraping parkour if you will. You will fail, fail, fail and then you will learn.

Tools you can use

Ideally, you can use Python and Beautiful soup to do the scraping. We are not strict about the language or the library as long as it gets the job done, but our answers a week from now will using Python and Beautiful Soup.

Enjoy the hunt. See you a week later :-)
Practicing On The Small Stuff
Tags: programming, testing
Published: 2020-10-14 15:51:31

[_originally posted on [alanwsmith.com](https://www.alanwsmith.com) by [@TheIdOfAlan](https://twitter.com/TheIdOfAlan)_]

---

I spent a [couple hours last night](https://www.alanwsmith.com/stream-notes-2020-10-13/) modifying a script to do the same thing it was already doing.

Refactoring, but not really. I was trying something different. Trying to get better at test-driven development. Testing everything.

The script is small. Just 100 lines. I could have written it in half that and been done in 20 minutes. Instead, I’ve spent hours on it. I’m not only okay with that, I’m embracing it. I’m practicing. Practicing on the small stuff so my skills are sharp when I get to the big stuff.

I felt foolish at first, spending so much time on such a small script. But, I’m over that. It’s like a musician doing scales. It’s how you get the notes in your fingers and the chords in your head.

It’s how you get better.
Scraping World Indices data from Yahoo Finance with Python and Beautiful Soup

Published: 2020-10-14 17:24:22

Today we are going to see how we can scrape World Indices data using Python and BeautifulSoup in a simple and elegant manner.

The aim of this article is to get you started on a real-world problem solving while keeping it super simple so you get familiar and get practical results as fast as possible.

So the first thing we need is to make sure we have Python 3 installed. If not, you can just get Python 3 and get it installed before you proceed.

Then you can install beautiful soup with...

We will also need the libraries requests, lxml and soupsieve to fetch data, break it down to xml and to use CSS selectors. Install them using...

Once installed open an editor and type in...

Now let's go to the Yahoo World Indices page and inspect the data we can get.

This is how it looks:

Back to our code now... let's try and get this data by pretending we are a browser.

Save this as yahoo_indices_bs.py.

If you run it:

You will see the whole HTML page.

Now, let's use CSS selectors to get to the data we want... To do that let's go back to Chrome and open the inspect tool.

We notice that all the individual rows of data are contained in a with the class that begins with 'data-row'. We can get BeautifulSoup to select that data.

This prints all the content in each of the rows.

We now can pick out classes inside these rows that contain the data we want. The currencies are in elements with the class which increments from data-col0, data-col1, data-col2. This makes life easy for us.

If you run it it will print out all the symbols.

Bingo!! we got the symbols.

Now with the same process, we get the other data like Name, the last price, change, change percentage, volume, etc.

When we run it it will print out every detail we want like this.

We even added a separator to show where each symbol data ends. You can now pass this data into an array or save it to CSV and do whatever you want.

If you want to use this in production and want to scale to thousands of links then you will find that you will get IP blocked easily by Yahoo. In this scenario using a rotating proxy service to rotate IPs is almost a must.

Otherwise, you tend to get IP blocked a lot by automatic location, usage, and bot detection algorithms.

Our rotating proxy server Proxies API provides a simple API that can solve all IP Blocking problems instantly.

With millions of high speed rotating proxies located all over the world,
With our automatic IP rotation
With our automatic User-Agent-String rotation (which simulates requests from different, valid web browsers and web browser versions)
With our automatic CAPTCHA solving technology,
Hundreds of our customers have successfully solved the headache of IP blocks with a simple API.

The whole thing can be accessed by a simple API like below in any programming language.

We have a running offer of 1000 API calls completely free. Register and get your free API Key here.