teleren/devto huggingface dataset:
Velociraptor, an alternative to npm scripts for Deno
Tags: deno, packagejson, npm, scripts
Published: 2020-05-14 01:42:26

I've been playing around with [Deno](https://deno.land) in the last few months (if you haven't already, try it out, it's awesome) and one of the things that frustrated me the most was that I easily ended up writing _endless_ `deno` cli commands, like this:

```sh
deno run --allow-read --allow-write --allow-net --config tsconfig.json --importmap importmap.json --reload file.ts
```

I mean... I just wrote it and I've already forgotten it 🤦‍♂️

The instinctive reaction of my webdev-y brain was:

> Easy. Let's write it down in a package.json script.

Yeah, no. There ain't no package.json in the land of Deno.

So I left aside my acute `npm run` nostalgia and started working on an alternative for Deno, and after some weeks of coding here it is:

{% github umbopepato/velociraptor %}

To get started, install it with `deno install`:

```sh
deno install -qA -n vr https://deno.land/x/velociraptor/cli.ts
```

Then create a file called `scripts.yaml` (`.json` and `.ts` are supported as well) in your project folder

```yaml
scripts:
  start: deno run my-script-file.ts
```

and run the `start` command

```sh
$ vr start
```

In this form script files are essentially a remake of the `scripts` section of `package.json`: keys are script names, values are arbitrary shell scripts. But there's more.

### More script options

Use objects to superpower your scripts:

```yaml
scripts:
  start:
    cmd: deno run server.ts
    desc: Starts the server # This description is shown in the list
                            # of available scripts when running vr
                            # without arguments
```

### Compact deno run

When a script starts with a `.ts` or `.js` file, `deno run` is automatically prepended:

```yaml
scripts:
  start: server.ts # Equivalent to deno run server.ts
```

### Env variables

Use `env` to pass env variables to the scripts

```yaml
env: # Sent to all the scripts
  PORT: 80
scripts:
  start-dev:
    cmd: server.ts
    env: # script-specific override
      PORT: 8080
  start-prod: deno run server.ts
```

### Deno cli options

A subset of `deno` cli options can be passed to the scripts (to name a few: `--allow-*` permissions, tsconfig.json, import maps, lock files...)

```yaml
scripts:
  start:
    cmd: server.ts
    allow:
      - net
      - read
    tsconfig: tsconfig.json
    imap: importmap.json

allow: # Global options
  - write
```

### Compound scripts

A list of commands is executed in series

```yaml
scripts:
  start:
    - deno run one.ts
    - deno run two.ts
```

and parallel commands are supported as well

```yaml
scripts:
  start:
    pll:
      - deno run one.ts
      - deno run two.ts
```

### Bonus

Support for husky-style git hooks is coming soon! 🐶

Check out the documentation in the [repo](https://github.com/umbopepato/velociraptor) for more details.

Hope you'll find it useful! 🙌
Discussion: Hooks got ya hooked?
Tags: react, redux, discuss
Published: 2020-05-14 01:11:19

At Flatiron, we were introduced to React mainly using class components. And they're tricky to use, but I got used to them and thought they were the bees knees. I got really good at creating them super quickly and passing props down was a breeze, until I decided that Material UI was the frontend framework I was going to work with. 

Material UI had almost all of their components written as functional components, something I had seen in lecture but had not really experimented with myself. I dived in head first, fitting in the functional components with the class components, and everything seemed to mesh well. Until state came.

It was inevitable, but especially as I was using Redux, I found myself unsure how I could access the store from this foreign functional component. And that's where I was first introduced to hooks. I didn't quite understand the concept, but after more research I realized they were easier to use than class components! The amount of code needed to access the store was minimal compared to using connect, and the syntax was easier to make sense of. I was amazed and felt like it revealed a whole new side of React for me.

But there's pros and cons to both, and after a bit more research recently, I've listed some of my thoughts in the chart below:

| Category | Functional Component | Class Component |
|---|---|---|
| Functionality | A basic javascript function with state being accessible via hooks | An element of React that can contain state |
| Ease of Use  |  Definitely easier to understand and implement | More tricky in terms of boilerplate and use of "this"  |
| Length of Code  | Typically shorter, but can be longer depending on use of custom hooks | Typically more code overall due to boilerplate  |
| Problems | Hooks cannot be used inside of loops, conditions, or nested functions; lifecycle methods cannot be accessed without hooks | Steep learning curve and more-so if including Redux  |

And these are some of the resources I found most helpful about further understanding hooks and their implementation:

- https://react-redux.js.org/api/hooks
- https://blog.isquaredsoftware.com/2019/07/blogged-answers-thoughts-on-hooks/
- https://www.smashingmagazine.com/2020/04/react-hooks-best-practices/
- https://medium.com/@Zwenza/functional-vs-class-components-in-react-231e3fbd7108

So now I'm curious, with the recent official update including hooks in the newest version of React, where do you stand? Are you pro hooks all the way? Or are class components still your main thing?

Let me know in the comments below as I'm curious what's the community's stance on hooks. Do they got ya hooked?
Already Hacked - Security Environment of the System
Tags: security, serverless, hacktoberfest, saas
Published: 2020-05-14 00:43:36

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9q9jpy45qsd7o2i12o39.jpg)

My system hacked by power (reference video) 
    

##  How to secure your system ( The mainly )
   
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/cmhcmwgutdzlx2ikylox.JPG)

##  Spring Boot Security ([source code](https://github.com/Urunov/SpringBoot-Projects-FullStack/tree/master/Part-6%20Spring%20Boot%20Security) )


1. Create User entity to store user information
2. Store the User in our database
3. Link our User with User Details Interface
  a. Link user with User Details interface
  b. Link User repository with User Details Service Interface
4. Integrate Database Auth in our configuration

#
Linking with Spring Security

UserDetails (interface) <--- UserDetailsService(interface)

Authentication - Create User Entity

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


## I have a Spring MVC. DO I need JWT to!?

* If your application provided business logic and all the necessary UI.
* And you just have one application being deployed(war/jar)
* And if this is all your customer needs 
* Then you do not need JWT. Form based security will work just fine.
#1 in Apimetrics COVID-19 tracking APIs ranking
Tags: android, ios, microservices, startup
Published: 2020-05-14 00:12:30

Hi there!

Just a super short post to celebrate with all of you that Nubentos' COVID-19 tracking API is listed at the top of the Apimetrics ranking!

![alt text](https://www.nubentos.com/wp-content/uploads/2020/05/Nubentos_COVID19_apimetrics.jpg "Apimetrics ranking for COVID-19 tracking APIs")

That deserves a "Wow!!", doesn't it. 🙌

[You can access the ranking here](https://www.api.expert/industry/covid19/).

Remember that [version 2.0.0 is now available in Nubentos API Store](https://apimarket.nubentos.com/store/apis/info?name=API-nCoV2019&version=2.0.0&tenant=nubentos.com&utm_source=devto&utm_medium=post&utm_campaign=apimetrics&utm_content=rank1), with new information and filters.

Almost 1,5M of requests in two months, and growing fast! Come on and use our APIs to build your amazing Apps!

Take care and happy integration!
How can I write a function to move a react component and make it move from a component to another?
Published: 2020-05-14 00:08:36

I have a react app where we need to build an online library, I have divided the application into different components 1.the main app component 2.the shelves component and inside it three shelves(three other components):currently,want to,read 
I have a project rubric that every book should have a button that makes a drop down list that redirects to each of the shelves and the input of the button should depend on the user input

what I need to know: 1.how to represent books in this app,should I make it as a variable or as a react component? and how to move that book between the three shelves? I have thought about using react router but problem is: the app should have a search bar and a feature to add new books so it still depends on how I represent a 'book' in my application which I still don't know how to do

can someone help me with this two points?
MySQL 8 The server requested authentication method unknown to the client
Published: 2021-09-18 08:56:40

---
title: MySQL 8 The server requested authentication method unknown to the client
published: true
date: 2020-05-13 23:50:02 UTC
tags: 
canonical_url: https://dcblog.dev/mysql-8-the-server-requested-authentication-method-unknown-to-the-client
---

On a new installation of MySQL 8 you may come across the error below when running application.

> The server requested authentication method unknown to the client

The simple fix is to go login to the MySQL shell:

```
mysql -uroot
```

then run:

```
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';
```

This updates the root user to be identified with no password (or the one you've specified).
I didn’t know how to solve this Leetcode Problem!😭😭😭
Tags: leetcode, algorithms, codenewbie, tutorial
Published: 2020-05-13 23:27:58

This is a medium [Leetcode 402](https://leetcode.com/problems/remove-k-digits/) question where you are asked to remove k digits from a number to make that number the smallest possible number. See problem description below:

![problem description]
(https://miro.medium.com/max/1400/1*onau0Cc28whWvAy4eNvtAg.png)

The question is quite understandable and straight forward but the issue is with knowing the numbers to remove. At first, I thought that sorting the numbers and keeping track of the positions and then removing the largest numbers would work but apparently that didn’t work.

After trying to no avail, I had to seek for solution online and came across two algorithms:

<h3><b>FIRST ALGORITHM</b></h3>
```
public static String removeKdigits(String num, int k) {
    Stack<Character> stack = new Stack<>();
    StringBuilder answer = new StringBuilder();
    if (num.length() == k) return "0";

  for (int i = 0; i < num.length(); i++) {
   while (k > 0 && !stack.isEmpty() && stack.peek() > num.charAt(i)) {
            stack.pop();
            k = k - 1;
        }
        stack.push(num.charAt(i));
    }

    while (!stack.isEmpty()) {
        answer.append(stack.pop());
    }

    if (!answer.toString().isEmpty()) {
        answer = answer.reverse();
        String s = answer.toString().replaceFirst("^0+(?!$)", "");
        if (k != 0)
            s = s.substring(0, answer.length() - k);
        return s;
    } else
        return "0";
}
```
To understand the algorithm above, please check [thecodingworld](https://www.youtube.com/watch?v=HXvxIth510g) on YouTube. He did a good job to explain the algorithm. His code was written in Python, so I had to translate to Java.

<h3><b>SECOND ALGORITHM</b></h3>
```
public static String  removeKdigits(String num, int k) {
    Stack<Character> stack =  new Stack<>();
    int length = num.length();
  for (int i = 0; i < length; i++) {
   while (!stack.isEmpty() && k > 0 && stack.peek() > num.charAt(i)) {
            stack.pop();
            k -= 1;
        }

        if (!stack.isEmpty() || num.charAt(i) != '0')
            stack.push(num.charAt(i));
    }

    //Now remove the largest values from the top of the stack
    while (!stack.empty() && k != 0) {
        stack.pop();
        k--;
    }


    if (stack.isEmpty())
        return "0";
    
    //now retrieve the number from stack into a string
    StringBuilder result = new StringBuilder();
    while (!stack.isEmpty()) {
        result.append(stack.pop());
    }
    return result.reverse().toString();
}
```
Also to understand the second algorithm above, please check [Tech Dose](https://www.youtube.com/watch?v=3QJzHqNAEXs) for the explanation. I also translated the code to Java.

<h3><b>OBSERVATION</b></h3>
I have learnt a lot from these algorithms especially from the way people think and I think that’s the fun of solving algorithm questions.
Thank you for reading. Please leave a comment or suggestion below.
[AWS EKS] Setup Kubenetes Dashboard
Tags: aws, eks, kubernetes
Published: 2020-05-13 22:57:38

### step 0 - install package in linuux

<code>sudo apt install jq curl</code>

### step 1 - deploy the K8s Metrics Server

{% raw %}<code>DOWNLOAD_URL=$(curl --silent "https://api.github.com/repos/kubernetes-sigs/metrics-server/releases/latest" | jq -r .tarball_url)</code>{% endraw %}


{% raw %}<code>DOWNLOAD_VERSION=$(grep -o '[^/v]*$' <<< $DOWNLOAD_URL)</code>
{% endraw %}


{% raw %}<code>
curl -Ls $DOWNLOAD_URL -o metrics-server-$DOWNLOAD_VERSION.tar.gz
</code>{% endraw %}


{% raw %}<code>
mkdir metrics-server-$DOWNLOAD_VERSION
</code>{% endraw %}

{% raw %}<code>
tar -xzf metrics-server-$DOWNLOAD_VERSION.tar.gz --directory metrics-server-$DOWNLOAD_VERSION --strip-components 1
</code>{% endraw %}



{% raw %}<code>
kubectl apply -f metrics-server-$DOWNLOAD_VERSION/deploy/1.8+/
</code>{% endraw %}


### step 2 - deploy the K8s dashboard
latest release of v2.xxx here: https://github.com/kubernetes/dashboard/releases

{% raw %}<code>
export DASHBOARD_RELEASE={{ latest releaseversion }}
</code>{% endraw %}

{% raw %}<code>
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/$DASHBOARD_RELEASE/aio/deploy/recommended.yaml
</code>{% endraw %}

{% raw %}<code>
kubectl apply -f admin-service-account.yaml
</code>{% endraw %}

{% gist https://gist.github.com/PanupongDeve/1d2d3bf473ecea9ce6c193eee8a0dd1c file=admin-service-account.yaml %}

### step 3 - access the dashboard

{% raw %}<code>
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret| grep {{ service_account_name }} | awk '{print $1}')
</code>{% endraw %}

copy token

{% raw %}<code>
kubectl proxy --address='0.0.0.0' --accept-hosts='^*$'
</code>{% endraw %}

open browser

{% raw %}<code>
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#!/login
</code>{% endraw %}
String to Integer program
Tags: python, beginners
Published: 2020-05-13 22:46:45

Hi there,

I’m trying to write a python code that takes in up to 5 inputs (words) and outputs out the sum of the inputs (after a conversion from string to integer). Specifically:

user inputs 5 words (Apple, Pear, Tomato, Banana, Toast)

Program substitutes each words using a defined conversion
Apple = 25
Pear = 72
Tomato = 87
Banana = 98
Toast = 2

Program outputs the sum of the 5 words in integer format (i.e. 25+72+87+98+2)

Would appreciate any help, thank you in advance
Mid Meet Py - Ep.7 - Interview with Nicolas Demarchi
Tags: interview, community, python, updates
Published: 2020-05-13 22:35:40

---
title: Mid Meet Py - Ep.7 - Interview with Nicolas Demarchi
published: true
description: We meet in the middle of the day in the middle of the week to chat about Python. Updates in the community and libraries. Also, interview with Nicolas Demarchi, organizer of PyAmsterdam.
tags: interview, community, python, updates
---
PyChat:

  [EP published their 1st set of talks](https://ep2020.europython.eu/events/sessions/)

  [CfP still open for Various time zones (anyone can apply)](https://blog.europython.eu/post/617552560206872576/europython-2020-second-call-for-proposals-cfp)

  [Naomi won't run for re-election for the chair of the PSF](https://twitter.com/NaomiCeder/status/1259301269694447618)

  [PyCon Us Hatchery Mentoried sprint this saturday](https://us.pycon.org/2020/hatchery/mentoredsprints/)

Hall of Fame:
  Interview with Nicolas Demarchi

  [Follow him on LinkedIn](https://www.linkedin.com/in/nicolasdemarchi/?locale=en_US)

  [Follow him on Twitter](https://twitter.com/gilgamezh)

PyPI highlights:

  [Events](https://pypi.org/project/Events/), a library that works as the Observer Design Pattern (or the Moderator, depending on your case).

  [Discord.py](https://discordpy.readthedocs.io/en/latest/) - perfect if you wanna build a Discord bot.

[Listen to MidMeetPy podcast](https://anchor.fm/midmeetpy)
My PyCon Colombia talk
Tags: python, pycon, talk
Published: 2020-05-13 22:22:32

This is the video of my presentation from the [PyCon Colombia 2020](https://2020.pycon.co/ponentes/carlos-villavicencio/) talk: "Using Type Annotations in Python".

The talk is in Spanish but you can follow this English tutorial (authored by me) published on the [website](https://www.stackbuilders.com/tutorials/python/using-types-in-python-with-mypy/) of the company I'm work for.

{% youtube izN-cMCOXO0 %}
[AWS EKS] Setup CloudWatch Metrics
Tags: aws, eks, cloudwatch, k8s
Published: 2020-05-13 22:15:54

### step1 - add policy to your nodegroup(s)

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

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

CloudWatchAgentServerPolicy -> attach policy

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

### step2 - deploy the cloudwatch agent
{% raw %}
<code>
curl https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/master/k8s-yaml-templates/quickstart/cwagent-fluentd-quickstart.yaml | sed "s/{{cluster_name}}/(( cluster name ))/;s/{{region_name}}/((region_name))/" | kubectl apply -f -
</code>
{% endraw %}


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

### testing - cloudwatch metrics

<code>kubectl run php-apache --image=k8s.gcr.io/hpa-example --requests=cpu=200m --limits=cpu=500m --expose --port=80</code>

<code>kubectl run --generator=run-pod/v1 -it --rm load-generator --image=busybox /bin/sh</code>

<code>
while true; do wget -q -O- http://php-apache.default.svc.cluster.local; done
</code>
hack.chat web chat
Tags: javascript
Published: 2020-05-13 22:12:47

{% github https://github.com/hack-chat/main %}

Some time ago, I found this nice application, and my contribution was to provide it with a syntax highlight which is pretty nice.

{% github https://github.com/hack-chat/main/pull/14 %}

Now I visited the project page again and my name is in the Credits section. I'm really proud of myself 😅
My first TypeScript open source contribution
Tags: typescript
Published: 2020-05-13 22:06:43

While working on a story, I was asked to upgrade the `openpgp` Node dependency, but bad luck a lot of tests broke.

After digging a bit and implement the included changes the code was not compiling due to some issues with the types. I forgot to mention that I'm using TypeScript for this one. So many types were outdated so I decided to open a PR to the types library DefinitelyTyped. Here's the PR:

{% github https://github.com/DefinitelyTyped/DefinitelyTyped/pull/30351 %}

It got merged really fast and now my name is part of the [authors](https://www.npmjs.com/package/@types/openpgp)

I found this bigger than the one I did for Babel:

{% github https://github.com/babel/babel/pull/7895 %}

Happy coding!
How to retry transactions in Sequelize
Published: 2020-05-13 22:00:30

You might be getting errors like "SequelizeDatabaseError: Deadlock found when trying to get lock; try restarting transaction" and wondering how you could restart the transaction as indicated.

*(Yeah, you could always catch the error manually, stringify it and look for a substring, but then you would have to check for every possible error you want to retry the query for in every catch clause - and we want our code to be [DRY](https://wiki.c2.com/?DontRepeatYourself))*

This behaviour can be natively enabled by adding a `retry` object to the list of options provided when initializing Sequelize:

```javascript
const sequelize = new Sequelize(process.env.REMOTE_DB_NAME, 
    process.env.REMOTE_DB_NAME, 
    process.env.REMOTE_DB_PW, 
    {
    host: process.env.REMOTE_DB_HOST,
    dialect: 'mysql',
    // Here:
    retry: {
        match: [Sequelize.ConnectionError]
    }
})
```

As you can see, we can pass native Sequelize errors to the `match` array.

Now you might be thinking "Ok, but the deadlock error is actually a “SequelizeDatabaseError” - so how can we specifically filter that one out?"
Well, the `retry` option also happens to accept regex parameters!
```javascript
retry: {
        match: [/Deadlock/i],
        max: 3
    }}
```
As seen above, we can specify the maximum number of retries to execute (`max`).

The `match` array also accepts strings, so here's a full example showing all valid error formats:
```javascript
retry: {
    match: [
        Sequelize.ConnectionError,
        Sequelize.ConnectionTimedOutError,
        Sequelize.TimeoutError,
        /Deadlock/i,
        'SQLITE_BUSY'],
    max: 3
}
```
_**(Note that neither regexes nor Sequelize errors are passed as strings)**_


You can find the full list of Sequelize errors here:
https://sequelize.org/v5/identifiers.html#errors
*(Bonus) And here’s the full list of options you can pass to `retry`:* https://github.com/mickhansen/retry-as-promised/blob/master/README.md

Feel free to hit me up on Twitter if you have any further questions! [@Anonyma_Z](https://twitter.com/Anonyma_z)
Introducing Electron Gatsby Boilerplate
Tags: electron, gatsby
Published: 2020-05-13 21:51:05


I was looking for a Gatsby Electron Boilerplate, but I didn't find any. Then I have decided to make one myself. This is what I have come up with till now. It is a simple, minimal Electron Gatsby Boilerplate. Create a new BrowserWindow easily and speed up your development experience. It also included Automatic Linting, Redux, TravisCI Configuration, and GitHub Release. 

GitHub Repo: [https://github.com/zonayedpca/electron-gatsby-boilerplate](https://github.com/zonayedpca/electron-gatsby-boilerplate)
Release Demo: [https://github.com/zonayedpca/electron-gatsby-boilerplate/releases](https://github.com/zonayedpca/electron-gatsby-boilerplate/releases)

![Demo Image](https://user-images.githubusercontent.com/18544717/80925067-b8a70180-8dae-11ea-98bc-e5b459a846f8.png)

Any kind of Recommendation, issue, PR is welcome.

Also, don't forget to give a star if you think it's useful. Thank You!
Day 137 : Closer
Tags: hiphop, code, coding, lifelongdev
Published: 2020-05-13 21:41:06

_liner notes_:
- Professional : Turned in my blog post for review with a few minutes before my deadline! Don't think I could have cut it closer. haha Whew! A huge weight off my shoulders! I think it came out the way I had in my brain. Now, just to get another professional editor set of eyes on it. Got to sit in on a talk prep session. Had a "get to know a random person in the company" meeting with a coworker. Got to do it over the Tic-Tac-Toe game with video chat. Worked really well. For the rest of the day, I worked on putting the finishing touches on my presentation for tomorrow. I looked back at the recording of my first practice and I think I figured out why my slides looked so small. My laptop's screen is pretty wide so when I shared my tab to present my slides, I think it was trying to compensate for the width so the slides looked smaller. Hopefully that made sense. haha So, I'm going to try and share my slides on a tab not as wide. Hopefully that will fix the issue. I want to try and get up super early and see if I can test it out before the event starts. 

- Personal : Pretty much worked on getting my blog post done last night.

![The mountains of Mont Blanc in France with a mountain goat looking at the camera](https://dev-to-uploads.s3.amazonaws.com/i/yyiy5ehsfk7bf7zlnm5f.png)

Going to spend the night going over my presentation and go to bed early so I'll be rested for tomorrow's event.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube kmp4bd6OY-g %}