teleren/devto huggingface dataset:
Recursion in Javascript
Tags: javascript, beginners
Published: 2020-09-24 02:13:48

Functions are the cornerstone of Javascript programming. Nearly all applications of Javascript code are chock full of functions of all kinds. One type of function structure is the recursive function. 

By definition, a recursive function is a function that calls itself within it. This way the function creates a loop. 

```
function printRecursive(x) {
  console.log(x);
  printRecursive(x);
}
recursion(3);
```

This example will keep printing 3. But how do we end the loop? We do this by using a test. When calling the function recursively, change the arguments such that the test will eventually be passed. Then return the function and the loop will be broken. This test is called the base case.
```

function printRecursive(x, times) {
  if (times === 0) { // base case
    return;
  }
  console.log(x);
  printRecursive(x, times-1);
}
printRecursive(3, 3);
```

This example will print 3 three times. When `printRecursive(3, 3)` is called, the test fails because 5 does not equal 0 and 3 is printed. Then `printRecursive` is called again with the arguments `(x, times-1)`. Once again the test fails because 4 does not equal 0 and 3 is printed. This continues until times is 0 in which case the loop is broken.
api-mom an API online management tool
Tags: api, tool, webdev
Published: 2020-09-24 02:11:06

###Free, safe, easy to use and simple interface. Support team multi-person collaboration, just install the chrome browser api-mom extension to test the API.


1. Folders in the project, interface list, interface tabs all support mouse drag sorting.
2. When editing the interface, it supports common shortcut keys Ctrl + S to save.
3. The interface documents and test results are side by side, everything is right in front of you for easy proofreading.
4. With more and more interfaces, you can quickly find out with fuzzy search.
5. Browse mode / edit mode, safe operation.
6. You can join team members and do permission control.
7. There are two themes of day and night.
8. Currently supports English and Chinese


URL: [api-mom](https://www.api-mom.com/?from=devto)


![IMG](https://static.cnodejs.org/FgO14r8qJM50ZX26aBt4JJzYdd0Y)

![IMG](https://static.cnodejs.org/Frjrsb-Eup88tVubsR3VzFlEkm4i)

![IMG](https://static.cnodejs.org/FsZvIXZ2-i7mCASJKLvVZGu13SZ4)
Issues are hard, Or: How I learned to Stop Worrying and Love the PR-bomb
Tags: opensource, github, git
Published: 2020-09-24 02:03:06

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

Dr. StrangePush strikes again. 6 issues? *Really*? With **my** code? Can I speak to your manager? Do you know how long I’ve been doing this for? Almost 2 years now. Damn that’s kind of embarrassing now that I’ve said it out loud.

Today I got some really great suggestions (and even 2 PRs!) from a classmate of mine. One of the things I’ve dreaded about throwing myself into the Open Source community turned out to be… not that big of a deal?

So for this week’s activity we have to fork, analyze, and suggest issues for our fellow classmate’s [release 0.1](https://github.com/Seneca-CDOT/topics-in-open-source-2020/wiki/release-0.1). So, [I found someone who decided to do their release 0.1 in Java](https://github.com/pyvelkov/DeadLinkage), a language which I hate lack familiarity in, and with a framework (Selenium) on top of that too! Very interesting approach, two things which I’m unfamiliar with. We went back and forth a bit, turns out he didn’t have a partner either and admittedly hates Python (_Really?_) but agreed to review my code if I did his in turn.

The first problem was that the code just would not run. At all. We were both stumped. [@pyvelkov](https://github.com/pyvelkov) reached out to [our professor](https://blog.humphd.org/), turns out in order to run Selenium’s Chrome backed web driver I had to have Chrome actually installed on my desktop. It’s okay Chrome fanatics, we all have our faults ([wait a minute...](https://news.ycombinator.com/item?id=24563698)) Anyway, once Chrome was installed the program worked as expected. Eh, it’s not god-tier snek, but it works, I guess.

My first action was to make a [PR and edit his README.md](https://github.com/pyvelkov/DeadLinkage/pull/5/files#diff-04c6e90faac2675aa89e2176d2eec7d8R12) to clarify that Chrome must be installed in order for his project to work as expected. Following that I “fixed” an ambiguous error catch and made another [PR](https://github.com/pyvelkov/DeadLinkage/pull/5/commits/4d4337b5fd0186a30a8244a13ed69630bb4c6e31#diff-7ce9ef673a172003c72b985ac57360b7R118). A few other typos and minor changes and that was about all the issues I could find.

Conversely, my partner also [found very similar issues](https://github.com/chrispinkney/He-s-Dead-Jim/issues?q=is%3Aissue+is%3Aclosed) with my project, and even made a really insightful (well, I think it’s insightful) [PR to variable names](https://github.com/chrispinkney/He-s-Dead-Jim/pull/9/files#diff-fa17c82405b7c59ad36ab94cc418ddfaL26) in a for-in loop I was using- despite not knowing Python. Well done!

I might have saved changes to my local fork before making a new branch and adding- but that’s okay, that’s what `git revert` is for. Something-something pencils have erasers. All in all, it was a very pleasant experience. My partner was great. We learned, we laughed, we grew. And now we probably hate each other.

Looking forward to more contributions!

-Chris
🎮 CSS Nintendo Switch (Box Shadow & Gradient Practice)
Tags: codepen, css, sass
Published: 2020-09-24 02:00:18

<p>Hello world. I've missed you all. I hope you all are happy, healthy, and well ❤️</p>
                           
<p>After some major life changes and enormous projects, it's great to be back! I'm conjuring up on a new animation video involving the Nintendo Switch 😊 I wanted to improve my use of box-shadows, so I challenged myself to make a realistic looking Switch. My fiancé then had the splendid idea of showing gameplay on the screen--what an ideal opportunity to spread more ACNH euphoria!</p>

{% codepen https://codepen.io/cybercountess/pen/PoNXEqL %}

<p>It was gratifying to apply box-shadows meticulously. I look forward to sharing the Switch animation when it's done. There were some fun challenges and learning outcomes I'm itching to share with this animation video. 

I'll document my process differently, with an accompanying article on DEV. Now that my schedule's subsided, I can't wait to share more content with you all. 

Please don't hesitate to reach out if you have any questions 😊 Have a great day! 

<table>
  <tbody><tr>
<td>🖼 <a href="https://www.codepen.io/cybercountess">CodePen</a>
</td>
<td>🎥 <a href="https://www.youtube.com/c/Cybercountess">YouTube</a>
</td>
<td>👩🏾‍💻 <a href="https://www.github.com/acupoftee">GitHub</a>
</td>
<td>🎀 <a href="https://www.instagram.com/cybercountess">Instagram</a>
</td>

</tr>
</tbody></table>
GitHub to replace 'master' with 'main' starting next month
Tags: github
Published: 2020-09-24 01:38:03

All new Git repositories on GitHub will be named "main" instead of "master" starting October 1, 2020.

Starting next month, all new source code repositories created on GitHub will be named "main" instead of "master" as part of the company's effort to remove unnecessary references to slavery and replace them with more inclusive terms.
I learned about Microsoft's Hummingbird library today. 1000x performance??
Tags: machinelearning
Published: 2020-09-24 01:37:30


tl;dr Hummingbird is fast, but I didn't see the 1000x claim they posted today in MS Ignite. That too with their sample code and dataset (only slightly modified).

[My Colab notebook](https://colab.research.google.com/drive/12tuRaEWFlBX0cdzGd_Tv4VUNee6nK5xQ?usp=sharing) for your cloning purposes.

--- BEGIN

![1000x Faster!!!11!oneone!](https://dev-to-uploads.s3.amazonaws.com/i/v6dmh47lmnp2akcpgcvf.png)

This scrolled past today during [MS Ignite](https://myignite.microsoft.com/) (which you should totally be watching). 

It seemed too good to be true (spoilers spoiled), and I wanted to try it out ASAP.

I took their sample code from [Github](https://github.com/microsoft/hummingbird) and tweaked it to spit out times for each model's prediction, as well as increase the number of rows to 5 million. I used Google's Colab and selected GPU for my hardware accelerator. This gives an option to run code on GPU, not that all computations will happen on the GPU.

Snippet of code below, you can find the entire code on the link above to my notebook.

```
start_time = time.time()
# Use SKLearn to convert the model to PyTorch
skl_model.predict(X)
print("--- %s seconds to predict on CPU w/o HB ---" % (time.time() - start_time))

# Use Hummingbird to convert the model to PyTorch
model = convert(skl_model, 'pytorch')

start_time = time.time()
# Run predictions on CPU
model.predict(X)
print("--- %s seconds to predict on CPU w/ HB ---" % (time.time() - start_time))

start_time = time.time()
# Run predictions on GPU
model.to('cuda')
model.predict(X)
print("--- %s seconds to predict on GPU w/ HB ---" % (time.time() - start_time))
```

    --- 3.707867383956909 seconds to predict on CPU w/o HB ---
    --- 8.640001058578491 seconds to predict on CPU w/ HB ---
    --- 0.5877633094787598 seconds to predict on GPU w/ HB ---

Hummingbird converts SKLearn's trained RandomForestClassifier model to a PyTorch neural network (NN). When you run the regular ML model for 5million predictions on a CPU, it runs in 3.7 seconds. When you run the NN on 5million predictions on a CPU it took 8.6 seconds. On a GPU the NN took .06 seconds for the 5 million predictions.

Could anyone help me understand where I went wrong? Under what scenario will I get the claimed 5x on CPU and 1000x on GPU?

I'm still amazed it went from 3.7 to .6 seconds (6x?), but that's still far from 1000x. 

I'll try out a couple more datasets and see if I can't reproduce the claim.
Bootcamp Java Developer Day #4
Tags: java, bootcamp
Published: 2020-09-24 01:37:16

#### Day 4:

Today I finished course 5 and finally started a course about Java! But I did the software installation only.

#### 5) Completed: Fundaments of Systems Architecture

- Fourth section: Essential Data Architecture

Today the course was focused on Relational Data Bases, the Entity-Relationship Diagram, Normalization, **SQL** (DDL, DML, DQL), the ACID transactions. Finalized with the creation of a database in **PostgreSQL**.


#### 6) Started: Basic Development in Java

- Topic: Java - Installation and Environment 

Today I only installed the following:
1. **Java** JDK
2. **Gradle** Build Tool 
3. Apache **Maven**
4. **IntelliJ** Idea!

Installed wrapper to Gradle and to Maven.
How to avoid feeling overwhelmed when starting in IT
Tags: beginners, overwhelm
Published: 2020-09-24 01:17:48

---
title: How to avoid feeling overwhelmed when starting in IT
published: true
description: Some small tips on how to avoid feeling overwhelmed when starting in IT
tags: beginner, overwhelm
//cover_image: https://direct_url_to_image.jpg
---

Some people feel frustrated when they start in the field of IT, due to amount of existing technologies and the feeling of confusion when they trying to choose the best one to start. The Internet is full with information, which is a blessing, but sometimes it might be overwhelming as well. In this post I would like to talk about my personal experience and give some small tips that have helped me with this issue:


**1. Find your interests.** Think about the area or areas in IT that interest you the most. Are you fascinated about IOT? Machine learning? Or maybe you would like to learn to do web applications? Having in mind in which area or areas you would like to focus will help you find the best technologies to learn.


**2. Choose the technologies.** Once you have decided in which area you would like to focus first, take your time to do some research in the different technologies in that area. This is probably the most overwhelming part (Java, Kotlin? Flutter, Xamarin? Vue.js, React.js?). Make a list of all the technologies and inform yourself well about them. Choose one of them to start with. 


**3. Find resources to learn.** Look for online courses or good articles about the technologies you want to learn. Try to put in practice the things you learn, maybe making a small project.


**4. Don't be afraid to go back.** You started learning a technology and didn't like it that much... No problem! Go back to number 2 and find some alternatives.


**5. Be constant.** Finally, be constant with your learning, and set realistic goals. Eventually, you will master that IT area!
Conversação de texto em binário, linguagem C/C++.
Tags: programming, beginners, cpp
Published: 2020-09-24 01:09:13

# Conversação de texto em binário.

Para esse ponto vamos por passos para que seja possível entender o que aconteceu aqui.

---

### Passo 1

Aqui a variável *letra* recebe 'x' como seu principal argumento.

```c
//Definindo variaveis
	char letra = 'x';
```

---

### Passo 2

Agora uma condicional simples mostrará o primeiro resultado a ser exibido na tela.

![https://i.imgur.com/sAWnCe2.png](https://i.imgur.com/sAWnCe2.png)

Resultado da primeira impressão.

```c
//condicional simples
	if (letra == 'x'){
		printf ("\nA 'letra' é x.\n");		
	}
```

---

### Passo 3

### Convertendo em número:

Para se converter uma variável char em um número binário e necessário apena que transforme ela em um valor inteiro.

```c
//Condicional numérica
	printf("\n\tCodigo da letra = %d. \n\n",letra);
```

*No exemplo acima a variável 'letra' e '=' (igual) a um número inteiro que seu número hexadecimal.*

---

Resultado:

```c
#include<stdio.h>
#include<stdlib.h>
#include <locale.h>

int main()
{

	setlocale(LC_ALL, "Portuguese");
	
	//Definindo variaveis
		char letra = 'x';
	
	//condicional simples
		if (letra == 'x')
			{printf ("\n\tA 'letra' é x.\n");}
	
	//Condicional numérica
		printf("\n\tCodigo da letra = %d. \n\n",letra);
	
	system ("pause");

}
```
Drawbacks of Laravel's ORM - Eloquent
Published: 2020-09-24 00:39:18

# Day 2 of #100DaysOfCode

1. Finished writing [migrations](https://laravel.com/docs/8.x/migrations) for HypeTracker's database in Laravel.

2. Working on adding the mutators for each `Model` class because I decided to give Laravel's ORM, Eloquent, a shot.

# Learnings

Found out that even though [composite (primary) keys](https://beginnersbook.com/2015/04/composite-key-in-dbms/) are available in migrations, it's not an available option for Eloquent ORM Model classes?

Very interesting block and decided to look into it.

Found this [thread on stackoverflow](https://stackoverflow.com/questions/43086722/composite-primary-key-with-eloquent) explaining its non-supported use and a workaround (it's been asked about for over 5 years!).

Of course, because it's an open source project, I wanted to take a look on the repository to see if this has been implemented since that time.

Relevant GitHub issue [1](https://github.com/laravel/framework/issues/5355) and [2](https://github.com/laravel/ideas/issues/1699)

Basically nothing has been done yet.

But that's just the nature of open source projects, the bigger the project, the slower things are going to move. Especially when they see this as a non-issue.

Of course, I'm not going to just give up and scrap all my current work. I just used the workaround for now and see how it goes.

# Moral of the story? 

ORMs can help in abstracting database queries and makes your program "database-agnostic", but you are depending on the upstream or basically "vendor-locked" if any issues arise.

# Afterwords

Let me know if you use an ORM or raw SQL in the commets!

Follow my journey on DEV or twitter!


Read why I'm refactoring a 2 year old project
{% link https://dev.to/justinhodev/coming-face-to-face-with-my-worst-code-3ln %}

HypeTracker Repository
{% github justinhodev/hype-tracker %}
Day 223: Infrastructure
Tags: hiphop, code, coding, lifelongdev
Published: 2020-09-24 00:24:59

_liner notes_:
- Professional : Had a couple of quick meetings and attended a Talk Prep session. It was on AI. Pretty cool stuff. Spent the day integrating my Web Component into the demo I made yesterday. Ran into some issues and had to add a new feature to my Web Component. Looks to be working in pure JavaScript. I just have to throw it into Vue 2 and Vue 3 projects and write the blog. Got some good feedback on the script and shot list I submitted for the video I'm recording. Going to start doing some screen recordings.

- Personal : I hooked up my Youtube stream key to my side project so now in addition to streaming to the site itself, I'm streaming to YouTube at the same time. That way, once the event is over, I'll use the YouTube recording for the archive. Did a couple of test runs and it worked. Next, I want to work on the chatroom and ask a question sections. I think I got a good amount of the infrastructure of the application in place.

![View from a lake with a small island with tall pine trees and mountains in the background in Two Jack Lake, AB, Canada](https://dev-to-uploads.s3.amazonaws.com/i/6odeo13ixotjbwlfd6k3.png)

Going to work on getting the recording from the radio show to the station so it can be played this week. Then I'll probably spend the rest of the night doing some screen recordings for my video. Also, got the email that my order for the stuff to put the solar panels on my roof has shipped and should get here on Friday. I'll be staying at my folks place till it comes so I can install it.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube tCRrBXSepj4 %}
How to Run Django Shell in IPython
Tags: python, django, shell
Published: 2020-12-01 13:21:17

---
title: How to Run Django Shell in IPython
published: true
date: 2020-09-24 00:00:00 UTC
tags: python, django, shell
canonical_url: https://tech.serhatteker.com/post/2020-09/run-django-shell-with-ipython/
---

First of all make sure you have installed [IPython] in your environment.

```bash
$ pip install ipython
```

Then simply run:

```bash
$ python manage.py shell -i ipython
```

That's all. The `-i` option argument

```bash
 --interface {ipython,bpython,python}, -i {ipython,bpython,python}
```

specifies the shell to use. As we can see the options are ipython bpython or (plain) python.

By default, Django will use IPython or bpython if either is installed. If both are installed, specify which one you want like so.

For more info you can look at: [django shell]

All done!




[IPython]: https://ipython.org/
[django shell]: https://docs.djangoproject.com/en/dev/ref/django-admin/#cmdoption-shell-interface
JWT Signing Algorithms
Tags: jwt, jsonwebtokens
Published: 2020-09-27 03:36:56

---
title: JWT Signing Algorithms
published: true
date: 2020-09-24 00:00:00 UTC
tags: JWT,JSONWebTokens
canonical_url: https://www.loginradius.com/engineering/blog/jwt-signing-algorithms/
---

Deciding between which signing algorithm to use.

   
[Read On](https://www.loginradius.com/engineering/blog/jwt-signing-algorithms/)
How to get the length of the string as bytes in Nodejs?
Tags: node
Published: 2020-09-24 00:00:00

---
  title: How to get the length of the string as bytes in Nodejs?
  published: true
  tags: Nodejs
  date: Thu Sep 24 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/get-string-length-bytes-nodejs
  cover_image: https://melvingeorge.me/_next/static/images/main-e27730f14d854b7b1ccef318325ee12c.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/get-string-length-bytes-nodejs)
  
To get the string length in bytes in Node.js, you can use the `byteLength()` method in the `Buffer` class.

Let's say you have a string called `Hello World!`,

```javascript
// string
const str = "Hello World!";
```

Now let's use the `Buffer.byteLength()` to get the bytes of the string.

```javascript
// string
const str = "Hello World!";

// get string length in bytes
const bytes = Buffer.byteLength(str, "utf-8");

console.log(bytes); // 12
```

- The method accepts types of `Buffer`, `String`, etc as the first argument.
- The second argument is the encoding, the default is `utf-8`.
- The method returns the size of the bytes as an `integer`.

See this example live in [repl.it](https://repl.it/@melvin2016/string-length-as-bytes).

### Feel free to share if you found this useful 😃.

---
Start writing Vue3 now
Tags: vue, vue3, javascript
Published: 2020-09-23 23:30:49

### This is about how to create a setup using online tools such as  jsfiddle to start coding in Vue3 right away.

Vue v3 finally has a public release, which might get a lot of people wanting to try it out. The issue I find with these frameworks is that there is a bit of a setup to go through to get going, so I like when there's a way to just start using it with minimal setup. 

In this case, I've been using jsfiddle to skip the setup of local environment for smaller tests or examples. You can use this in most REPL-style coding environments lie jsbin and codepen. Of course, if you want to setup a full-fledged project follow the [official docs](https://v3.vuejs.org/guide/installation.html).

### Here is a quick setup

add js resource (either via script tag or settings)
https://unpkg.com/vue@next/dist/vue.global.js

this should always get the latest version (3.0.0 at the time of writing), however the downside is that breaking changes may be introduced, so locking it in at a working version for posterity may be worthwhile for you.

Using vue.global.js (or the prod version vue.global.prod.js) will make the Vue object available as a global variable, and is IMHO the easiest way to do this

```html
<script src="https://unpkg.com/vue@next/dist/vue.global.prod.js"></script>
<div id="app"></div>
```

```js
const app = Vue.createApp({
  template: `
    <h1>App</h1>
    <my-component></my-component>
  `
})

app.component('my-component', {
  template: `A component`
})

app.mount('#app')
```


This is pretty straight forward, and a common way of setting these up without ability to include Single File Components. And while you can put the template content of `#app` into the HTML DOM element, it is going to render before the html is loaded, and is not usable for components, so what I do is use the `template` tag and `document.getElementById` to get the content

And voila:

```html
<script src="https://unpkg.com/vue@next/dist/vue.global.prod.js"></script>
<div id="app"></div>

<template id="appTemplate">
  <h1>H1: App</h1>
  <my-component></my-component>
</template>

<template id="componentTemplate">
  A component
</template>
```

```js
const app = Vue.createApp({
  template: document.getElementById("appTemplate").innerHTML
})

app.component('my-component', {
  template: document.getElementById("componentTemplate").innerHTML
})

app.mount('#app')
```


Note that Vue 3 doesn't require you to have a single top level component, which allows you me to skip the extra `div` to wrap the `h1` and component tags in the app template.


link https://codepen.io/scorch/pen/yLOZyxg

Vue 3 docs: [v3.vuejs.org](https://v3.vuejs.org/)

_Image Credit: [Paweł Czerwiński](https://unsplash.com/photos/slJUHpQEC0k)_