teleren/devto huggingface dataset:
gyp: No Xcode or CLT version detected macOS Catalina
Tags: commandlinetools, macos, xcode, devops
Published: 2020-01-20 14:47:54

##gyp: No Xcode or CLT version
Did you recently update your macOS Catalina to version 10.15.2? If you did, then you probably in the same boat too. What I immediately noticed from my terminal is this new shinny error about gyp: No Xcode or CLT version detected any time I ran either yarn install or npm install
```gyp: No Xcode or CLT version detected!
gyp ERR! configure error```

Well if you are wondering if that was my entire error? It is not even close. The line goes on and on. The funny thing is am so sure I have command line tools installed. The result of ```xcode-select --install``` should start the reinstallation process but if you get the result in the image below then you already have command line tools installed

![xcode-select: error: command line tools are already installed, use “Software Update” to install updates](https://thepracticaldev.s3.amazonaws.com/i/nxz6m4kbmlwqhzvkyeug.png)

##Solution
Reinstall [command line tools](https://anansewaa.com/install-command-line-tools-on-macos-catalina/) by removing the previously installed version

###Step 1
First, get the location of the installed command line tools by running the command below:
```
xcode-select --print-path
``` the result of the above command ```/Library/Developer/CommandLineTools ```

###Step 2
Knowing the path to the currently installed command line tools from the previous step, You can now go ahead and remove it from the system. For the next set of commands, you need sudo privileges to run successfully.

```
sudo rm -r -f /Library/Developer/CommandLineTools
```

Provide the root password to remove the command line tools. If you already have git installed, you would get a prompt to guide you through the installation of command line developer tools.

![Prompt to reinstall command line developer tools](https://thepracticaldev.s3.amazonaws.com/i/t8ndwr9a87kml4fr3i1c.png)

Click on install and follow the rest of the instructions in prompt to reinstall command line developer tools. If for some reasons, you do not get the prompt right after uninstalling your previous command line developer tools, no need to panic. Run the following command to get the prompt.

```
xcode-select --install
```

![Prompt after running xcode-select -instal](https://thepracticaldev.s3.amazonaws.com/i/8m78e94b4k4hh6bud6ll.png)

Click on install and then agree to the licence to proceed with the installation. Depending on your internet speed it will take some time for the system to complete the download of the command line developer tools. The installation process should proceed immediately after a successful download. Look out for the done button as shown in the image below to confirm command line tools is successfully installed.

![Done](https://thepracticaldev.s3.amazonaws.com/i/knsp5k32uar87r2yaa3k.png)

With the reinstallation of the command line developer tools the gyp: No Xcode or CLT version detected error message should disappear when you run any yarn or npm commands from the command line.
Laravel 6 Authorization using Gates
Tags: laravel, authorization, gate
Published: 2020-01-20 14:45:36

In addition to providing authentication services out of the box, Laravel also provides a simple way to authorize user actions against a given resource. Like authentication, Laravel's approach to authorization is simple, and there are two primary ways of authorizing actions: gates and policies.

https://www.codechief.org/article/laravel-6-authorization-using-gates
What is Object Orientated Programming (Part-three) Polymorphism?
Tags: ruby, oop, beginners
Published: 2020-01-20 14:29:03

This blog post will cover the object-orientated principle of polymorphism. Some of the concepts in polymorphism will also relate to inheritance. 

<h1>What is Polymorphism?</h1>
Polymorphism means many forms. In OOP, this allows us to create a Superclass with a method that is inherited by its subclasses but the method in the subclass will perform a different action. 


```ruby
class Mammal
 def live_birth
  puts "We give birth to live animals"
 end
end

class Platypus < Mammal
  def live_birth
    puts "We lay eggs."
  end
end


duckBill = Platypus.new

duckBill.live_birth

#output 
"We lay eggs"

```

The above method of using polymorphism uses inheritance. The superclass and the subclass both contain the method live_birth but the Platypus class has changed the output of the method. This allows flexibility in your code. 

In our Mammal class, it made sense to inherit that method because most mammals do give birth to live young, however, for the platypus class polymorphism has allowed us to override that method. 

<h2>Summary</h2>

Polymorphism allows a subclass to use a method that is inherited from the superclass and to change it to meet the needs of the subclass.

The next blog post will still be about polymorphism but also include super and Modules.
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2020-01-20 13:53:28

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---
Every Monday we round up the previous week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week. ❤️

#1. Transform Your Life

Prosper encourages all of us to invest in ourselves by building connections with others. 

{% link https://dev.to/unicodeveloper/who-is-speaking-on-your-behalf-2c5e %}

#2. Not About The Looks...

Desiré walks us through the design process. In this post, we design a few screens of a CMS together.

{% link https://dev.to/helleworld_/a-simple-design-process-for-developers-or-non-designers-ip7 %}

#3. Fun & Collaborative

Sam explains what system design interviews are, and why they're important. In this post, they share a guide to answering system design interview questions.

{% link https://dev.to/techdebtor/get-hired-the-system-design-interview-explained-32j4 %}

#4. Can't Commit

Ryan shares their perspective on JavaScript frameworks, taking web standards and components (and more) into considerations.

{% link https://dev.to/ryansmith/the-cost-of-investing-too-heavily-in-a-javascript-framework-2121 %}

#5. Unordered List

Patrik shared a list of fifteen icon libraries for the web. The community responded with a few more suggestions, and now the list is up to twenty!

{% link https://dev.to/weeb/15-of-the-best-and-largest-icon-libraries-4p5n %}

#6. People First

Daniel stresses the importance of human code -- code that has been written with a people first approach.

{% link https://dev.to/d_ir/clean-code-dirty-code-human-code-6nm %}

#7. Clear & Concise


Reed put together the ultimate visual cheatsheet for React concepts - clear and concise, with practical examples.

{% link https://dev.to/codeartistryio/the-react-cheatsheet-for-2020-real-world-examples-4hgg %}

_That's it for our weekly wrap up! Keep an eye on dev.to this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Monday!_
#Day2 of #100DaysOfCode: Keep writing!
Tags: writing, javascript, 100daysofcode
Published: 2020-01-20 13:50:32

When I first committed myself to the #100DaysOfCode, I tried to follow the challenge rules religiously. After a few missed days I gave up on it completely and felt disappointed as a result. Now I will try to adapt the challenge to my own needs so I keep going. I realized that what I truly care about is to keep coding and to write more about it, not some missed days. 

I want to use this as a journal of my coding journey. I want to document the things I learn along the way, the websites I build, the interviews I have and what I learn from them (yes, I'm actively interviewing and looking for a front-end or full stack role in Berlin 🙋🏻‍♂️) and I want to document the challenges I face as a queer person in the industry.

### Why do I want to write? There's even more to it:
1. I love it! 💖
2. I think you learn a lot by just writing. When I'm writing about code, I find myself revisiting some of the concepts so I make sure I am saying the right thing. 👨🏻‍🎓
3. The only way to improve your writing is to keep doing it. I'm more than open to feedback so please reach out. ✍🏻
4. I want to hold myself accountable. Yes, there are going to be some missed days but what's important is to keep doing it. 🙋🏻‍♂️
4. You make new friends along the way and that is really fun. 👯‍♂️

** cover photo is generated from one of my React projects: https://emoji-artwork-generator.herokuapp.com/
Databases revisted
Published: 2020-01-20 13:50:18

A database index is a data structure that improves the speed of data retrieval operations on a database table at the cost of additional writes and storage space to maintain the index data structure. Indexes are used to quickly locate data without having to search every row in a database table every time a database table is accessed. Indexes can be created using one or more columns of a database table, providing the basis for both rapid random lookups and efficient access of ordered records.
Indexes are created using a few database columns.
The first column is the Search key that contains a copy of the primary key or candidate key of the table. These values are stored in sorted order so that the corresponding data can be accessed quickly.
Note: The data may or may not be stored in sorted order.
The second column is the Data Reference or Pointer which contains a set of pointers holding the address of the disk block where that particular key value can be found.


Two primary methods of constructing indices are clustered and non-clustered:
A non-clustered index (or regular b-tree index) is an index where the order of the rows does not match the physical order of the actual data. It is instead ordered by the columns that make up the index. In a non-clustered index, the leaf pages of the index do not contain any actual data, but instead contain pointers to the actual data
A clustered index is a special index which physically orders the data according to the indexed columns. The leaf nodes of the index store the data for the rest of the columns in the table so when a lookup is performed on this type of index there are no other structures that need to be referenced.
Some other key facts to remember about indexes are:
Indexes take additional disk space.
indexes slow down INSERT,UPDATE and DELETE, but will speed up UPDATE if the WHERE condition has an indexed field. INSERT, UPDATE and DELETE becomes slower because on each operation the indexes must also be updated.

Suppose a database contains N data items and one must be retrieved based on the value of one of the fields. A simple implementation retrieves and examines each item according to the test. If there is only one matching item, this can stop when it finds that single item, but if there are multiple matches, it must test everything. This means that the number of operations in the worst case is O(N) or linear time. Since databases may contain many objects, and since lookup is a common operation, it is often desirable to improve performance.
Indexing is an easy way to improve the performance of our databases
Hopefully this brief look into indexing helped to clear up the concept.
Difference Between CMD and ENTRYPOINT in Dockerfile
Tags: docker
Published: 2020-01-20 13:49:10

I'll try to explain the differences through a simple example.

Let's suppose we want to create an Ubuntu-image that will always run a sleep command when it starts. We'll create our own image and specify a new command:

```sh
FROM ubuntu
CMD sleep 10
```

Now, we build the image:

```sh
docker build -t custom_sleep .
docker run custom_sleep
# sleeps for 10 seconds and exits
```

What if we want to have more sleep? Since the value is hardcoded in our `Dockerfile`, we'll need to edit it or override the whole command:

```sh
# "sleep 20" is the command we now pass
docker run custom_sleep sleep 20
```

Hmmm... Since the container's **main purpose** is to sleep, it sounds a bit ridiculous to pass the "sleep" command to it.

Now let's try using the `ENTRYPOINT` instruction:

```sh
FROM ubuntu
ENTRYPOINT sleep
```

This instruction *specifies the program that will be run when the container starts*.

Now we can run:

```sh
docker run custom_sleep 20
```

Ah! Much better. But what about a default value? Well, you guessed it right:

```sh
FROM ubuntu
ENTRYPOINT ["sleep"]
CMD ["10"]
```

The `ENTRYPOINT` is the program that will be run, and the value passed to the container will be appended to it. It can be overridden by specifying an `--entrypoint` flag, followed by the new entry point you want to use.
Weather Application using React Hooks and open weather map API
Published: 2020-01-20 13:48:36

In an attempt to understand how to use external API's as well as react hooks for state management, I built a simple weather application using react hooks and the open weather map API (https://openweathermap.org/api), it was a really educative experience.
Here's how i built the application:
Due to the simplicity of the application we would not bother ourselves with the styling of the application only the functionality.
First we declare the hooks we want to use for the state:
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/wgk5pg8lbgxwyki8gfyy.PNG)
After which we create a getWeather function which set's the state of the parameters I wanted to get from the API. Here's the code which is embedded in the App.js:
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/6072w4kfntggmkr2b0ra.PNG).
After setting the state we now attempt to pass them down as props to our Weather and Form component:
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/zhlouz6i4lwfe3tgsbvu.PNG).
Going inside the Weather component, we have our passed down props to the Weather Component which we use to dictate what/how the data would be displayed on the web page, this component looks like this:
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ycvoit62acn0rl5w1ic5.PNG).
With these we're almost done with our application, remaining our Form component and what it looks like on the web.
The very simple Form component looks something of the nature:
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/qsifu2h8yx1izvpzqld8.PNG).
And finally we get to see what our app looks like after we've completed the project.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/i0qx0k8guzuig38j79kb.PNG).
The styling of this project can be done in any form or style as the reader wishes. My CSS is not the best, so i just did a simple styling for the application.
This is what the folder structure looks like for anyone interested.
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/gx1i6wt0rizbjvzehabx.PNG).
Here's a link to the project on github: https://github.com/sammieeblaq/weather-app
This is my first ever blog post, so please like and leave a comment for feedback. Thank you
Daily Challenge #166 - Cat and Mouse
Tags: challenge
Published: 2020-01-20 13:47:12

---
title: Daily Challenge #166 - Cat and Mouse
published: true
series: Daily Challenge
description: You need to find out if the cat can catch the mouse from it's current position. The cat can jump (j) characters.
tags: challenge
---

You will be given a string (x) featuring a cat 'C', a dog 'D' and a mouse 'm'. The rest of the string will be made up of '.'.

You need to find out if the cat can catch the mouse from its current position. The cat can jump (j) characters.

Also, the cat cannot jump over the dog.

So:

if j = 5:

`..C.....m.` returns 'Caught!' <-- not more than j characters between

`.....C............m......` returns 'Escaped!' <-- as there are more than j characters between the two, the cat can't jump far enough

if j = 10:

`...m.........C...D` returns 'Caught!' <--Cat can jump far enough and jump is not over dog

`...m....D....C.......` returns 'Protected!' <-- Cat can jump far enough, but dog is in the way, protecting the mouse

Finally, if all three animals are not present, return 'boring without all three'

***
_This [challenge](https://www.codewars.com/kata/57ee2a1b7b45efcf700001bf) comes from A.Partridge on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
I made a portfolio! Feedbacks are welcome 
Tags: webdev, react, discuss
Published: 2020-01-20 13:30:59

---
title: I made a portfolio! Feedbacks are welcome 
published: true
description: 
tags: #webdev #react #discuss
cover_image: https://thepracticaldev.s3.amazonaws.com/i/bd9d5cdlxcftmo7fxdfi.PNG
---
I made a portfolio to improve my chances of getting hired, it's pretty minimal highlighting the things I've done so far.
I would love to get feedback on things that I can improve on, also things that are annoying.

The website is made using nextJs, x-styled and react-spring. Designed using Figma, Hosted on now.sh.

https://portfolio.elouartinra.now.sh
How to deploy an Express app for free?
Tags: help, deployment, devops, node
Published: 2020-01-20 13:28:56

---
title: How to deploy an Express app for free?
published: true
description: How do I deploy an Express app for free?
tags: help, deployment, devops, nodejs
---

Hi, I'm trying my hand at some simple deployment. I'm new to deployment and DevOps in general.

I'm trying to deploy this [repo](https://github.com/davinaleong/proj-graphql-js) on Heroku, but the app keeps crashing when I run the logs:

```
heroku logs --tail
```

Logs:

```
2020-01-20T13:22:48.461520+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-01-20T13:22:48.530567+00:00 heroku[web.1]: Process exited with status 143
2020-01-20T13:22:49.039979+00:00 app[web.1]: Welcom to GraphQL JS!
2020-01-20T13:23:47.885144+00:00 heroku[web.1]: State changed from starting to crashed
2020-01-20T13:23:47.785166+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-01-20T13:23:47.785166+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-01-20T13:23:47.868166+00:00 heroku[web.1]: Process exited with status 137
2020-01-20T13:25:22.662912+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-cove-11715.herokuapp.com request_id=45fc8325-868d-4daa-b67e-177a355ecfe5 fwd="116.14.82.68" dyno= connect= service= status=503 bytes= protocol=https
2020-01-20T13:25:23.026635+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-cove-11715.herokuapp.com request_id=6444cb61-eae0-4116-9b36-861ad1aef465 fwd="116.14.82.68" dyno= connect= service= status=503 bytes= protocol=https
```

What is happening, and how to I resolve this? I'm also trying to follow this [tutorial](https://devcenter.heroku.com/articles/getting-started-with-nodejs?singlepage=true) on Heroku.
Security best practices for Go & Java
Tags: todayilearned, security, go, java
Published: 2020-01-20 13:00:17

*TL;DR notes from articles I read today.*

### [Top security best practices for Go](http://bit.ly/2G6TR0p)

- You should validate user entries (using native Go packages or 3rd party packages) not only for functionality but also to avoid attackers sending intrusive data. 
- Use HTML templates to cover the vulnerability of XSS. You can use the *html/template* package to sanitize JavaScript executables. 
- Ensure each database user has limited permissions, that you are validating user inputs and that you are using parameterized queries to protect yourself from SQL injections.
- Make the best use of Go’s *crypto* package to encrypt sensitive information. 
- Enforce HTTPS communication and implement in-transit encryption even for internal communication.
- Remember that error messages and error logs can expose sensitive information. Use the native library in Go for logs or third-party options like logrus, glog or logo. 

*[Full post here](http://bit.ly/2G6TR0p), 6 mins read*

---

### [Tips to power-up your Java security](http://bit.ly/2ufQYaW)

- Protect against SQL injections by binding variables in prepared statements, using the *prepareStatement()* function to validate inputs.
- Returning mutable objects leaves you vulnerable to unexpected changes in your class state. Instead, use an unmodifiable/immutable collection or a copy of a mutable object to return.
- Avoid including XSS characters in log messages. Manually sanitize each parameter and configure your logger service to replace such characters.
- Always validate user input, especially when dealing with files whose location might be specified by user input.
- Replace predictable random values (java.util.Random) based on clock tickets or other predictable parameters with a secure random class and functions. 
- Eliminate dynamic class loading.  

*[Full post here](http://bit.ly/2ufQYaW), 4 mins read*

---

### [Ways to secure your applications](http://bit.ly/36bF1Au)

- More than 70% of exploited applications are due to outdated dependencies. Ensure dependencies are up to date by using the latest packages and automating dependency management. 
- Explicitly declare acceptable user payloads and use database-level constraints, like maximum column size, refusing null values, etc. 
- Assert safe regular expressions.
- Limit requests by IP address or user agent. 
- Store credentials outside your codebase, separating application configuration from code.
- Disable HTTP requests to your server unless very specific use cases demand it. Enable certificate checking for outgoing connections so that communication with third-party APIs or services are also secured by HTTPS. 

*[Full post here](http://bit.ly/36bF1Au), 9 mins read*

---

*[Get these notes directly in your inbox every weekday by signing up for my newsletter, in.snippets().](https://mailchi.mp/appsmith/insnippets?utm_source=devto&utm_medium=post08&utm_campaign=is)*