teleren/devto huggingface dataset:
Fundamentos de TypeScript 🦆| #6: Enum
Tags: tutorial, beginners, spanish, webdev
Published: 2022-01-10 14:31:08

Los `enum` son un tipo de dato en TypeScript. Esta característica **no es** una extensión de JavaScript, sino **una peculiaridad propia de TypeScript**.

En pocas palabras un `enum` se encarga de **juntar en un solo tipo de dato un conjunto de constantes**.

Los `enum` también aparecen en otros lenguajes de programación como por ejemplo **C**.

## **Sintaxis**

```ts
enum nombreEnum {
  // valores
}
```
La sintaxis es un poco extraña puesto que no usamos en ningún momento un `=` o unos `:` para declarar un `enum`.

Ahora bien, los valores de un `enum` pueden ser numéricos o literales, como veremos a continuación:

## **`enum` numerico**

```ts
enum Dias {
  Lunes, //0
  Martes, //1
  Miercoles, //2
  Jueves, //3
  Viernes, //4
  Sabado, //5
  Domingo, //6
}

console.log(Dias.Martes) // 1
```
Los `enum` numéricos se declaran separando los valores con comas y a cada uno se le asigna un índice de posición único, muy similar a un arreglo.

Este índice empieza siempre desde `0` y se incrementa automáticamente para el resto de los valores. Es posible cambiar este comportamiento de la siguiente manera:

```ts
enum Dias {
  Lunes=10, //10
  Martes, //11
  Miercoles, //12
  Jueves, //13
  Viernes, //14
  Sabado, //15
  Domingo, //16
}

console.log(Dias.Martes) // 11
```
Basta con modificar el valor de inicio del primer valor que inferir cuales seran los valores posteriores.

## **`enum` de cadena de texto**
También podemos usar un `enum` como cadena de texto:

```ts
enum Dias {
  Lunes="Lunes",
  Martes="Martes",
  Miercoles="Miercoles",
  Jueves="Jueves",
  Viernes="Viernes",
  Sabado="Sabado",
  Domingo="Domingo",
}

console.log(Dias.Martes) // Martes
```
## **`enum` como tipo de dato**
Recuerda que como `string`, `number`, `boolean`, etc., `enum` es un tipo de dato y puede ser usado como tal:

```ts
enum Dias {
  Lunes="Lunes",
  Martes="Martes",
  Miercoles="Miercoles",
  Jueves="Jueves",
  Viernes="Viernes",
  Sabado="Sabado",
  Domingo="Domingo",
}

function imprimirSaludo(mensaje:string, dia:Dias):void {
  console.log(`${mensaje}, hoy es ${dia}. Feliz 2022!`);
}

console.log(imprimirSaludo("Hola mundo",Dias.Jueves))
//Hola mundo, hoy es Jueves. Feliz 2022!
```
Podemos usar un `enum` como parámetro de una función sin ningún problema.

> *Veremos funciones posteriormente.*

## **Conclusiones**
- Los `enum` son un tipo de dato que te permite crear un conjunto de constantes de una manera más ordenada.
- No son una característica que se extiende de JavaScript, o mejor dicho, no existen `enum's` en JavaScript de manera nativa.
- Puedes usar un `enum` con valores numéricos auto incrementales o como cadenas de texto.


## **Referencias**
{% youtube BwuLxPH8IDs %}
 * https://www.typescriptlang.org/docs/handbook/enums.html
Thirty Days of Rust: Day One
Tags: rust, 30days, challenge, programming
Published: 2022-01-10 14:20:06

I'll admit it, I've never really used Rust. It's interested me for a while, but I never gave myself an excuse to use it until I had this idea. It's not very original by any stretch of the imagination to do this kind of thing, but this is how I figured I'd get myself to do this. The first day is just going to be a simple setup of my environment. I'll be using VSCode as my editor, rustup as my version manager, and of course, cargo as my package manager.

## Rustup
I'm not going to lie, to find rustup I literally just looked up "Rust Version Manager" and chose it over rsvm because it seemed to have more documentation. That being said, to install it I just used the `curl` command from https://rustup.rs, ran it, and then immediately tried to use the rustup command, which didn't work because rustup did not automatically add itself to my zshrc path. I did that manually (the binary is at `~/.cargo/bin`), and the command worked just fine.
## Cargo
Cargo works a lot like basically every other package manager, whether it's npm, dotnet, or pip (although pip does much less than the rest). It allows you to install crates through https://crates.io, but like npm or dotnet, it also allows you to initialize a project and run said project. To start my project, I ran `cargo new day1`, and opened up the directory in VSCode.
## VSCode
There's an extension pack for VSCode that adds the features you're going to want from Rust programming, including a language server, a nice Cargo.toml (similar to package.json) helper, and better toml language support. You can swap out the language server for the alternative rust-analyzer extension, but I went with the main language server.
## App
You'll notice if you're following along with me that your new rust project already has a hello world program set up for you, but to explore the features of rust I tweaked it a bit.
```rust
// src/main.rs

use rand::seq::SliceRandom;
use rand::thread_rng;
use std::str;

fn main() {
    let mut rng = thread_rng();
    let mut string_to_shuffle: Vec<char> = "Hello, World!".chars().collect();
    let unshuffled: &str = &string_to_shuffle.iter().collect::<String>();
    println!("Unshuffled: {}", unshuffled);
    string_to_shuffle.shuffle(&mut rng);
    let shuffled: &str = &string_to_shuffle.iter().collect::<String>();
    println!("Shuffled: {}", shuffled);
}
```
This was a really stupid way of getting from "Hello, World!" to complete gibberish, but I learned about converting from strings to vectors and back again, so I consider it worth it.

```bash
$ cargo run
Unshuffled: Hello, World!
Shuffled: o! WHllo,rdel
```
I like Rust, I'll say it. I realize that's a very brave position to take because it's clearly as hated as PHP, but I like Rust and I look forward to the rest of these days. It's definitely going to be a challenge, even more than I would've thought, to do this, but I'm excited for it. I also might do some bigger projects over the course of multiple days later on in this challenge.
What are template literals ?
Tags: javascript, beginners, webdev, programming
Published: 2022-01-10 14:12:15

Prior to ES6, you had to use **single quotes** (‘) or **double quotes** (“) to wrap a string, and that’s pretty much everything you could do with strings.

ES6 added the possibility to create “**template literals**” by wrapping string between **backticks** like this :

```javascript
const myString = `My template literal`;
```

You can use single and double quotes inside template literals :

```javascript
const quote = `Say "hello" to my little friend!`;
``` 


You can also create **multi-line** strings as follow :

```javascript
const multilineString =
`Once upon a time, 
long,
long ago a king and queen ruled
over a distant land.`;
```

**String interpolation** allows you to put variables inside your string. :

```javascript
const count = 3;
const appleCount = `I have ${count} apples`;
console.log(appleCount) // "I have 3 apples"
```

And you can also put a whole expression inside your string like so :

```javascript
const amount = 3;
const total = `Total: ${(amount * 5).toFixed(2)}`;
console.log(total) // "Total: 15.00"
```

---

Originally posted on my [blog](https://blog.ludivineachouri.com/). Check out my [instagram ](https://www.instagram.com/la.dev/)account to learn more about web development.
How Flok (YC W21) Uses No-Code
Published: 2022-01-10 14:11:58

Hey everyone! I sat down with Jared Hanson, CTO of Flok (YC W21) who shared how Flok uses no-code tools, as well as the insight that led him to, found the company.

If anyone is curious about Retool, the second half of the article is a deep-dive into their setup.

https://www.whalesync.com/blog/how-flok-uses-no-code
Top 3 Platforms to Practice Code
Tags: programming, career, beginners
Published: 2022-01-10 14:07:23

Part of being a developer is constantly learning and improving our skills. Developing projects is always a safe bet, but sometimes we just want to practice for code interviews or maybe just knock out some challenges that gradually get harder. Luckily for us, theres plenty of platforms out there to help us with that! 

![hackerrank logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eyz5dv37bbglzcjaldxy.jpeg) 
* HackerRank

HackerRank is great for beginners, job searchers, and anyone in between. It offers tutorials and explanations to aid you on your journey. It's also designed to help developers get noticed by employers - you can get certified in various technical skills, compete in contests, and even participate in their career fair.

![leetcode logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwfigdgnoytsuhozk20i.png) 
* LeetCode

With support for 14 coding languages and over 2150 questions to practice, LeetCode makes a great option for those wanting to prepare for a coding interview. They even have cases from companies such as Google and Amazon. The community on LeetCode is a key feature, after completing a problem you can check out the discussion section and read through others solutions.

![codewars logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1271rpa7sy5gygeuins9.png)
* Codewars

Codewars helps to strengthen and master your code skills. This is great for preparing for interviews and sharpening your critical thinking skills. The structure of codewars lets you complete challenges to rise in rank. Upon completion of a challenge, you can view other users solutions and vote on your favorites.


Overall, all three are amazing options when it comes to practice. Try them out and see which one gets you hooked!
How I switched from PHP to Node.js
Tags: node, javascript, programming, engineeringmonday
Published: 2022-01-10 14:00:57

I've been a PHP developer for a couple of years now and I love PHP. However, I believe that learning other programming languages can only make you a better developer. That is why I decided to tackle the fun new world of Node.js. (note: maybe not so new, but bear with me, I am a PHP developer after all)

After my first 'node.js for beginners courses' google search, I realized I'm missing some basics and that there is a lot that I'll have to tackle. There are millions of tutorials out there and it all can be a bit overwhelming when you're starting to learn something new.

I wanted this to be as simple as possible so I picked my favorite for each 'category'. 

###JavaScript###

Node.js is a JavaScript runtime. If you don't know what runtime is at the moment, just ignore it for a while.

Node.js is JavaScript [insert something]. That means you'll have to learn JavaScript.

[Learn JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript)

This was a documentation that proved as the most useful to me. It covers the basics as well as some advanced concepts. I had a hard time switching to async and in my opinion this documentation explains it so that you can sufficiently understand how JavaScript utilizes asynchronous programming.

###TypeScript###

Use TypeScript. I won't even explain why, just use it. TypeScript is JavaScript with some added functionalities (like, you've guessed it, types). 

[Learn TypeScript](https://www.typescriptlang.org/docs/handbook/intro.html)

Official docs are concise and they should give you an idea what are the differences between using TypeScript to JavaScript. But like I said, it's actually JavaScript so while learning JavaScript you're also learning TypeScript.

###Node.js###

And finally, we are here :) Now you'll learn what is a runtime or V8 and what Node.js actually is.

[Learn Node.js](https://nodejs.dev/learn/introduction-to-nodejs)

These are official docs and they are great. While you can find a lot of free or paid courses on the internet I really think these docs should be more than enough to understand what can be done with Node.js. 

###Extra###

Learn a Node.js framework! I've had the opportunity to work with Nest.js and I really liked it. Lots of people use Express.js so that is another possibility. 

[Learn Nest.js](https://docs.nestjs.com/)

Nest.js also has great official docs.

###Keep in mind###

While writing this article I realized most of my favorites are official docs. Maybe that is something we all should remember: taking courses is great, there are a bunch of helpful resources and people out there and we should take advantage of it. However, when learning something completely new, stick to the basics and RTFM. 

If you are wondering what to do next, do something that excites you with your new set of skills! If you can't come up with an idea for a personal project, google 'project ideas for backend'. Find something that sounds interesting and happy coding :)
YT channel recommendation for neovim and zsh users
Tags: vim, zsh
Published: 2022-04-18 09:02:11

---
title: YT channel recommendation for neovim and zsh users
published: true
date: 2022-01-10 13:32:00 UTC
tags: [vim, zsh]
canonical_url: https://www.geewiz.dev/2022/01/10/i-dont-think.html
---

I don’t think I ever copied more vim or zsh configuration from anyone than from ChrisAtMachine. Looks like I found a soulmate. 😊 His [YouTube channel](https://www.youtube.com/channel/UCS97tchJDq17Qms3cux8wcA) is well worth watching!
Arduino subString() function
Published: 2022-01-10 13:21:43

I had to use substring to parse information from software Serial. here is what I learned. 

Syntax::
`myString.subString(from)`
`myString.subString(from, to)`

This function is used to search for a specific substring in a string, 'myString'. 
The search is inclusive of the from index but exclusive of the to.
When you use from without the to, it will search from the index indicated to the  end of the string. 

Example:
`String me = "essy here now"
return me.subString(8);`

This will return 'now' as it is the substring in the eight index till the end of the sentence.

'`String me = "essy here now"
return me.subString(4,9);
`
This returns 'here'.
[SportBuddy]
Tags: atlashackathon
Published: 2022-01-10 13:17:55

# SportBuddy
Ever wanted to play some sports but find that your friends are too busy? With **SportBuddy**, you can find Buddies to enjoy your favourite sports together! Just create a new posting with your desired Sport, and await other users to join the group. You can chat with them in the live chat section for more details. Visit the site now at https://SportBuddy-Elle.netlify.app!

# Link to Code
https://GitHub.com/Elliott-Chong/SportBuddy
# Submission Category

***Choose Your Own Adventure***
# Technologies Used
This is my first serious full stack project using the **MongoDB**, **React**, **Express** and **NodeJS** (*MERN*) Stack. Featuring a custom authentication system using **JSON Web Tokens** for session management, and Google OAuth for SSO. 

## Features

 - *Custom* **theme** and **design**, layout preplanned in Inkscape, a vector based graphics editor.
 - *Custom* CSS implemented using **TailwindCSS**, a utility based CSS framework.
 - *Fully* **responsive** design for a better User Experience.
 - *State management* involved React's **useReducer** hook and their **Context** **API**.
 - *Live chat feature* uses **WebSockets**, implemented by the NodeJS package socket.io, allowing for full-duplex communication channels over a single TCP connection. This allows for all clients to receive socket messages at the same time and update thier state accordingly.
 - **Mongoose**, a MongoDB wrapper, was used as a *Object Relational Wrapper* (ORM) to simplify the process of reading and writing to the database.

# Screenshots
![](https://i.imgur.com/9cKWVQe.png)
![enter image description here](https://i.imgur.com/nZ8LN6Y.png)
![enter image description here](https://i.imgur.com/f3Upowa.png)
Arduino-conditional operator ? :
Tags: cpp, c, arduino
Published: 2022-01-10 13:08:59

This might sound surprising but after close to 2 years working in the IoT field, I am yet to fully understand the ternary operator. Today I was forced by a project I am doing to read and understand it. So here is what I understood.

The ternary operator is some kind of conditional statement. 

`relayState ? Relay_ON : Relay_OFF`
This means that if relay state returns true, turn on the relay, else turn it off.

`a>b ? a : b`
If a is greater than b, return a else return b. 

Simple as that.
destroying git push --set-upstream origin with vim
Tags: vim, vimscript, git
Published: 2022-01-10 13:07:57

I hate that everytime I need to push a new branch to my origin I need to go through the painful process of 
`git push --set-upstream origin ${branch-name}`.  
The problem is worse because I need to type and tab complete the branch name too, just too much hassle.  
Now with vim I had the thought to one day just make a remap, which I did, and what that did was basically just type out the statement  
`:Git push --set-upstream origin` and allowed me to just type the branch name.  
I think today even that was too much repetition for me, so I had the idea to see how more could I reduce this. I mean I wanted to learn vimscript anyhow, so was a nice thing to do.  
## The Vim Magic
```
" For new branch
" gets branch name
" sets upstream origin automatically
function! GitPushUpsOrgBranch()
  let branch = system("git branch --show-current")
  let push_str = "git push --set-upstream origin ".branch
  let conf_msg = "Do you want to execute\n".push_str
  let conf_res = ConfirmBox(conf_msg)
  if conf_res == 1
    let push_str_out = system(push_str)
    echo push_str_out
  endif
  return 1
endfunction

" git push set upstream remap
nnoremap<silent> <Leader>gpsu :call GitPushUpsOrgBranch()<CR>

```

What this beautiful set of commands does is that upon hitting <spacebar>gpsu it makes vim call the function **GitPushUpsOrgsBranch()**.

### GitPushUpsOrgsBranch
This does 3 things:
1. Gets my current branch which git 6.6+ allows (I think, don't remember) via  
`
git branch --show-current
`
2. Appends it to a string and forms the actual bland repetitive command I so hate  
`git push --set-upstream origin ${branch_name}`  
3. Before pushing it actually prompts me and then allows me to push. (see image below)

![Git destroys set upstream](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z48u8rzz6v0iuaovel24.png)

## Conclusion
This was a comfortable way to get into vimscript, but also was a nice personalization I deeply enjoyed. Pretty cool stuff.
What is Google Season of Docs ?
Tags: javascript, webdev, beginners, html
Published: 2022-01-10 12:56:31

###Introduction to GSoD
Season of Docs provides support for open source projects to improve their documentation and gives professional technical writers an opportunity to gain experience in open source. Together we raise awareness of open source, of docs, and of technical writing.
###How does GSoD works?
for Google Season of Docs  you have to  submit project proposal to open source organizations not to google for this you have submit your proposal with  include a proposed budget, timeline, and metrics. Accepted organizations hire technical writers directly. The Season of Docs grants will be disbursed in two payments; 40% upon hiring a technical writer, and 60% after receiving the final evaluation and case study.
### Creating your Organization Proposals
The creation of your organization proposal includes different phases as follows: 
#####1.Project Title
#####2.About your organization
#####3.About your project
#####4.Your project’s scope
#####5.Measuring your project’s success
#####6.Project budget
The above phase are include to your project proposal for GSoD.
###Requirements to participate into GSoD
1.You have knowledge about Technical Writing field.
2. GSoD is six month program so make sure you have time to complete works with deadlines.

3. Interested to contribute into open source with reliable documentation.

[Visit official Google GSoD Rules and Regulations Guide ](https://developers.google.com/season-of-docs)
Thankyou for reading and if you getting this article useful comment below and follow me I write about web development, freelancing and Entrepreneurship.
if you have any thing to ask my inbox is waiting for you...!! 
conn with me on [Twitter](https://twitter.com/PatilGanesh1010)
Who wrote this shit?
Tags: codereview, programming, beginners, career
Published: 2022-01-10 12:38:23

It is a beautiful right of passage for a bright-eyed junior developer to join a team, take some tasks full of enthusiasm, and have the life and joy sucked out of them one sprint at a time. Soon enough, they sit in planning meetings, miserably complaining, accusingly asking who wrote that shit. 
Their transformation to a full team member is complete. They have become one of us.

I was once that bright-eyed junior developer. Many encounters with PHP4 later could no longer look forward to creating new features. Instead, I looked back and complained about old ones. Trashing legacy software is fun. It creates camaraderie. Who wrote this? What were they thinking? Looking at the commit log showed names that meant nothing to me. Ghosts that moved on long ago, leaving nothing but their shit code.

One day, I was pair programming with my friend Torben. Torben was a senior developer who introduced me to the team months earlier. When I found some weird code, I followed the tradition. Who was dumb enough to write this? I opened the commit log, and for the first time, I recognized a name: "Torben."

Since then, I remind myself that legacy software is written by people like me. Torben had constraints I knew nothing about. He worried about deadlines long past. Torben had learned a lot since then. Development workflows had evolved, infrastructure had gotten better.

And to all the junior developers who have complained to my face about my trash code: I forgive you, I understand.

[This post was originally posted on my website, https://heltweg.org if you like it you might want to look at what else I write :)](https://heltweg.org/posts/)

You can reach me online at [https://heltweg.org](https://heltweg.org).
What is "typeof" operator in JavaScript
Tags: javascript, node, webdev
Published: 2022-01-10 12:37:36

### `typeof` operator determines the type of the input

For example,
```js
console.log(typeof 9.8)
```
The output will be - `"number"`

```js
console.log(typeof "Gravitational acceleration of Earth is 9.8ms^-2")
```
The output will be - `"string"`

```js
console.log(typeof true)
```
The output will be - `boolean`

***
Thank you for reading, have a nice day!

- Follow me on Twitter - [@codewithsnowbit](https://twitter.com/codewithsnowbit)
- Subscribe me on YouTube - [Code With SnowBit](https://www.youtube.com/channel/UCNTKqF1vhFYX_v0ERnUa1RQ?view_as=subscriber&sub_confirmation=1)