teleren/devto huggingface dataset:
Learning How to Learn; Highly Recommended!
Tags: learn, brain, coursera, videos
Published: 2022-04-01 04:16:33

I recently completed [Learning How to Learn: Powerful mental tools to help you master tough subjects](https://www.coursera.org/learn/learning-how-to-learn), which is an excellent free offering from [Coursera](www.coursera.org). It is a series of videos with quiz and essay requirements and is taught by [Dr. Barbara Oakley](https://www.linkedin.com/in/barbaraoakley/) and [Dr. Terrence Sejnowski](https://www.linkedin.com/in/terry-sejnowski-b89b7b122/).

So far, I have recommended this course to quite a few people and I will continue to recommend it to others in the future. It is so brilliant and insightful. I genuinely liked it a lot, and learned quite a bit from it.

For those of you that would like to know more about this I will sum it up. Essentially, all those things they taught you in school are true, but now they have the hard science. 

- Sleep is of paramount importance to learning as your brain cells actually shrink while you sleep as your brain flushes toxins and strengthens neural connections made during the day. 
- Practicing or studying a little bit every day is far more effective than trying to learn a lot all at once. Spreading it out over time results in much better retention overall. 
- When attacking a difficult problem, it helps to utilize both the focused and diffuse modes of thinking. Focused mode is deliberately concentrating on a solution. Diffuse mode is when you let your mind wander a bit, letting the focus level drop, which allows more distant parts of your brain to make connections that would not happen in focused mode.

It's this diffuse mode of thinking that causes those a-ha! moments long after you've gone home for the day.

For those of you that like to learn, or have to learn, or just want to watch something interesting, I can't recommend this course enough. Check it out!
Strongly Typed JSON in TypeScript
Tags: typescript
Published: 2022-04-01 03:36:19

Someone in one of the Slack communities I'm a part of asked today how to type JSON in TypeScript, specifically importing JSON and then typing it. They wondered if casting the JSON to `unknown` and then casting to a known type when consumed was a good approach.

The solution is not that complicated. We need to get our hands a little dirty and dig into the TypeScript compiler options for our project.

By default, if you import JSON, TypeScript will mention that it can't import it with the following error message:

`Cannot find module './data.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.ts(2732)`

![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s5csqewe14a9n4kr523d.png)

So TypeScript tells us what to do. Add the `--resolveJsonModule` flag. This is helpful if we're running the TypeScript CLI, but that is not what we're doing. What needs to be done is to add the `resolveJsonModule` key to the compiler options in the tsconfig.json file and set it to `true`.

```json
{
  "compilerOptions": {
    "resolveJsonModule": true,
    // more awesome compiler options
  }
}
```

Once that's done, you'll notice that if you type `data.`, we have fully typed JSON data.

![data variable in VS Code displaying autocomplete with properties of the data object](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5o2nxl0hik2gwhpy6m1.png)

This is great for using data in a typed manner, but what if we needed the JSON type elsewhere in the project? We can create a type for it using `typeof`.

`type PersonalInfo = typeof data;`

![The type PersonalInfo displaying its shape in CodeSandbox](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g5sbz0a6386yfgwz7376.png)

You can play around with this CodeSandbox and have some fun seeing it all in action.

{%codesandbox zealous-marco-urxdvy %}
JS Exercise: Sum of a String
Tags: javascript
Published: 2022-04-01 03:15:46

Feeling confident in Javascript?

Well, given a string of lowercase letters, would you be able to sum them all up into 1 value? 
In one line of code?

Solution and explanations are below.

## The Solution

const lettersum = s => 
    s 
        .split('') 
        .map(c => c.charCodeAt(0) - 96) 
        .reduce((a, b) => a + b, 0);

Pretty concise, isn't it? 
Let's go over this step-by-step

## JS Arrow functions

> 'const lettersum = s =>' 

First, we use 'const' to declare a variable (named 'lettersum') whose value shouldn't change later.

Then we begin to declare a function using a compact definition called an 'arrow function expression'. 

## Splitting

> s 
>       .split('')

This is the same as `s.split()`
However, JS ignores newlines (line-terminators) when they separate bits of code (except in cases where it auto-inserts ';' like in return)

We do this so as we chain multiple functions, it stays easy to read

So what does 's.split('')' do?

Well, split() is a string method, that will divide the string into substrings, and returns them as an array.

In this case, '' means we want to divide the string at every character.

This gives us the string as an array of characters

## Mapping

>      .map(c => c.charCodeAt(0) - 96)


Map accepts a function and will return the array created from calling the function on every element in the array. 

Here we are going through our array of characters, and turning each one into a digit, subtracting 96 so a=0.

## Reduce

>      .reduce((a, b) => a + b, 0);

Lastly, this reduces the list down to a single value. 

It calls the function we pass on each item in the array, storing the result in 'a' and calling the function  again with  'b' set as the next value in the array.

Here we are summing up every element in the list.

## Closing

And that's it! So in summary, we

- Split the string into characters
- Go through each character, converting it into a number
- Sum up all the numbers

Thanks for sticking around, and stay tuned for the next JS lesson.
PHP Curl Get Request with Parameters Example
Tags: php, webdev, beginners, tutorial
Published: 2022-04-01 02:42:43

## What is cURL in PHP?
The Client for URLs is shortly called cURL, which was originally pronounced with a URL in uppercase to emphasize that it deals with URLs. It's pronounced as: see URL.

cURL, which stands for client URL, is a command-line tool that developers use to transfer data to and from a server. At the most fundamental, cURL lets you talk to a server by specifying the location (in the form of a URL) and the data you want to send. cURL supports several different protocols, including HTTP and HTTPS, and runs on almost every platform. This makes cURL ideal for testing communication from almost any device (as long as it has a command line and network connectivity) from a local server to most edge devices.

cURL is also the name of the software project, which encompasses both the curl command-line tool and the libcurl development library.

The curl_exec command in PHP is a bridge to use curl from the console. curl_exec makes it easy to quickly and easily do GET/POST requests, receive responses from other servers like JSON and download files.

## Role of cURL in PHP
This is a PHP module that allows PHP programs to use curl functions. When PHP's cURL support is turned on, the phpinfo() function's output will include cURL information. Before you write your first basic PHP program, you can double-check it.

### Example:
There will be times that you will need to pull out data from a web service using PHP’s GET method. This tutorial will demonstrate how you can make a GET request using cURL.

A cURL is software you can use to make various requests using different protocols. PHP has the option to use cURL, and in this article, we’ll show several examples. This tutorial will see how we can get API data using curl to get requests.

Have a look at some built-in curl function:
```
curl_init();      // initializes a cURL session
curl_setopt();    // changes the cURL session behavior with options
curl_exec();      // executes the started cURL session
curl_close();     // closes the cURL session and deletes the variable made by curl_init();
```

## PHP cURL Request Example Code
You can test cURL in your local server as it’s the same as using a standard form with an action.
```
$url = "https://api.github.com/users/hadley/orgs";

//  Initiate curl
$ch = curl_init();

// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Set the url
curl_setopt($ch, CURLOPT_URL,$url);

// Execute
$result=curl_exec($ch);

// Closing
curl_close($ch);

// Print the return data
print_r(json_decode($result, true));
```
Use **json_decode** if the return is in JSON format.

**Thank you** for reading this blog.
Programming Rust - 01
Tags: rust, beginners, books
Published: 2022-04-01 02:33:34

The book has come in! Programming Rust by Jim Blandy, Jason Orendorff and Leonora F.S. Tindall. Let's see how much I get through. No promises, it could just be the first page :)

The first step was installing rustup and I'm going to use my WSL2 Ubuntu. The only pain here was adding $HOME/.cargo/bin to my fish config file to get access to the rust commands. I wonder if there's a way to automate this where the rustup script checks which shell you're running and it will inject it in. There probably is a good reason for why it doesn't do that but does for bash. Once I got rust install, I created a new cargo project and everything looks to be compiling.

Time to open the book!

Interesting definition of systems programming as resource constrained programming. This is maybe why I want to learn rust, in my day job memory, cpu and storage is all basically infinite.

The opening of the chapter goes into undefined behavior and corrupting the call stack. Also mentions that struxnet used a bug in the true type parser in word processors to do its job. That's pretty cool. Safety and concurrency! Let's see where it takes me.

Something I learned in the first section was that return is reserved for early returns and that the idiomatic way of returning in rust is to simply have the expression at the end without a semicolon.

I can also write #[test] on top of a function and then run those functions with cargo test. That's pretty useful to know and definitely would have helped in other projects.

I really like the gcd example as it goes over many ideas like looping, throwing errors, references and dereferencing. I'm still on the first 10 pages! I'm going to have to start reading faster and only implement the parts that I care about to speed this up.
Stackoverflow introduces filters
Tags: discuss, news, watercooler, aprilfools
Published: 2022-04-01 02:18:18

On MARCH 31st 2022, Stackoverflow added **filters** to its site. There are 8 different styles, looks inspired by the OG GOAT, Windows 95, and Hot Dog mode

The [stackoverflow blog](https://stackoverflow.blog/2022/03/31/time-to-get-on-trend-filters/?_ga=2.110086597.1968084518.1648723952-1007413870.1641373395) was, hilariously, a whole vibe but ended with an april fools tag.

![confused meme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7j4pasoe9t33yo29c7n.png)

**What are your thoughts on the new trend?**
echo3D graduates from Intel Ignite - Building the backend of the Metaverse
Tags: unity3d, gamedev, 3d, cloud
Published: 2022-04-01 02:14:22

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

[**echo3D**](http://www.echo3D.co) officially graduated from [Intel Ignite](https://www.intel.com/content/www/us/en/now/ignite/overview.html), Intel’s startup growth program. Chosen out of hundreds of applicants, only 10 companies, including echo3D, made the final cut and participated in the 12-week intensive program, focused on innovative deep tech startups.

echo3D offers a cloud platform for 3D/AR/VR that provides tools and network infrastructure to help developers & companies quickly build and deploy 3D apps, games, and content. With Intel Ignite’s support, echo3D is working to build and support the backend of the Metaverse and streamline the 3D development process by providing a way to manage, store, and stream 3D data. echo3D’s 3D-first content management system (CMS) and delivery network (CDN) and a scalable BaaS infrastructure enable developers to build and deploy real-time 3D/AR/VR applications across platforms, headsets, and mobile devices, by connecting them to the cloud.


{% youtube yCAj_tAmD30 %} 


“_Intel Ignite’s commitment to authentic mentorship, collaboration, and giving back is like noting I’ve seen before in any other program I’ve encountered_,” Said Koren Grinshpoon, founder and COO of echo3D. “_It's what makes the impossible, possible_.” Intel Ignite provides startups with access to global experts in technology and business as well as a preferred path to seasoned investors.

**Applications for Intel Ignite’s next cohorts in** [**Tel Aviv**](https://www.f6s.com/intel-ignite-tlv-6/apply) **and** [**Munich**](https://www.f6s.com/intelignite/connect) **are now open!**

***

>_**echo3D** ([www.echo3D.co](http://www.echo3d.co/); Techstars 19’) is a cloud platform for 3D/AR/VR that provides tools and network infrastructure to help developers & companies quickly build and deploy 3D apps, games, and content._

![](https://miro.medium.com/max/1400/0*9sQLAWCD9hzFXH8y.png)
Why is it you can execute a function on the right side of an AND && operator in JavaScript
Tags: javascript, react
Published: 2022-04-01 02:12:52

I always assumed that operators like && and || are for comparing true and false statements on both sides.

But I'm seeing a pattern in React where, on the right side is a function and the left is a truthy statement that will then allow the right to be executed.

Example:

```
truthy statement && function
```
I understand that JavaScript will check this from left to right, so left being true will then allow it to check the right. But my assumption is the right should expect a true or false statement, but in this case it's just a function.

I'm so used to seeing the && operator in this context:

```
if (true && true) {
  // Execute this
}
```
That this:

```
true && execute this
```
Works at all.

I guess my assumption is that JavaScript will just evaluate anything next to an operator whether it returns a true or false.
QZ Tray: Impressão em impressoras térmicas pelo navegador com Javascript
Tags: javascript, webdev, print
Published: 2022-04-01 02:12:38

Neste artigo irei abordar a melhor maneira de imprimir em impressoras térmicas direto pelo navegador.

A solução do QZ é utilizada pela grande maioria de softwares do ramo de cardápio digital no Brasil.

Apesar do QZ vender licenças para domínios, ele é um open sourcer. Ou seja, precisamos alterar o código fonte do QZ e compilar novamente, de acordo com o nosso domínio.

1) Você pode realizar os testes direto no [demonstrativo do QZ](https://demo.qz.io/);

2) Ao realizar os testes, você verá os pop-ups do QZ aparecendo igual na imagem abaixo, informando sobre a licença. Por isso precisaremos recompilar o QZ com seu novo certificado.

![qz sem licença](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ch2zydom73zjysxyni2r.png)
 
3) Recomendo realizar o download do [JDK 7](https://www.oracle.com/java/technologies/downloads/) ou superior, [Apache Ant](https://ant.apache.org/) e Open SSL;

4) Faça o clone do repositório do [QZ Tray no github](https://github.com/qzind/tray);

5) Gere o certificado ssl com o Open SSL;

```
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 11499 -nodes
```

_OBS: quando perguntar o dominio, colocar o curinga, ex: *.seusite.com.br_

6) Gere a private key usando o certificado ssl;

```
openssl pkcs12 -inkey key.pem -in cert.pem -export -out privateKey.pfx
```

7) Coloque o arquivo `key.pem` gerado anteriormente na pasta do `tray-master`, na raíz, que foi clonado do github;

8) Agora, precisamos compilar o QZ com o Apache Ant, mas antes, lembre-se;

8.1) Depois de baixar o Apache Ant, coloque a pasta na variável de ambiente;

```
- ANT_HOME=caminho
- Path=[]caminho
```

8.2) Rodar o comando para compilar de acordo com seu sistema operacional;

```
// win
ant nsis -Dauthcert.use="key.pem"

// linux
ant makeself -Dauthcert.use="key.pem"

// mac
ant pkgbuild -Dauthcert.use="key.pem"
```

9) Depois de compilado, abrir QZ em `/tray-master/out/dist/qz-tray.jar` e clicar em "+", pra gerar o certificado, será gerado o `digital-certificate.txt` e `private-key.pem`, copie os 2 e coloque no seu servidor, pro sistema poder utilizar os certificados;

![gerando key](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i9nc2g3xtkim1eqc39pd.png)

10) E quando for usar o QZ no seu website, basta utilizar os certificados gerados;

{% embed https://gist.github.com/xxdannilinxx/ed634720dea4cb00bd72a4179736139c %}

11) E o seu arquivo sign-message.php pode ser montado da seguinte forma;

{% embed https://gist.github.com/xxdannilinxx/526b61c33fcab3570bec3b4039f076a0 %}

12) Depois disso tudo, os pop-ups do QZ irão parar de aparecer e você irá conseguir imprimir sem problemas;

13) Não esqueça de dar uma olhada na [documentação do QZ](https://qz.io/wiki/getting-started), pois lá tem todas as configurações e opções de impressão;
Customize your terminal like a pro 🔥 on MacOS
Tags: terminal, macos, codewitharjun, zsh
Published: 2022-04-01 02:09:30

To customize your terminal like a pro you need to do 2 things. 

1. Install oh-my-zsh 
2. Install powerlevel10k 

I have shown the proper way how you can do that and make your default terminal customized as well. Watch this video. 

{% youtube Y9eBohzBcJ8 %}
Como faço uma Sprint Review.
Tags: scrum, scrummaster, sprint, sprintreview
Published: 2022-04-01 01:56:26

Scrum Guide diz que _“o propósito da Sprint Review é inspecionar o resultado da Sprint e determinar as adaptações futuras”_ e também que _“o Scrum Team deve evitar limitá-la a uma apresentação”_.

Além disso, informa alguns pontos indispensáveis:

1. A Sprint Review é o penúltimo evento da Sprint.
2. Durante o evento, o Scrum Team e os stakeholders revisam o que foi realizado (apresentação).
3. Com base nessas informações, os participantes colaboram sobre o que fazer a seguir (resultados e ações).
4. O Product Backlog também pode ser ajustado para atender a novas oportunidades (resultados e ações).

Consenso que Scrum  é uma forma de trabalho e não um método, **não diz como deve ser feito.**

Dito isso, durante a minha experiência profissional no setor da tecnologia da informação (T.I) utilizando Scrum percebi que apresentação em slides é uma ação que funciona para atender a revisão com o time técnico e pessoas de negócios. É uma forma de comunicação familiar ao contexto da maioria dos envolvidos. No meu caso, organizam a lógica de pensamento e informações visuais resumida em poucas frases é mais fácil de lembrar, importante informações sobre a evolução do produto, portando além de resultados, métricas de negócio devem estar presente. 

Em geral costumo organizar em tópicos:

**Resumo:** período da sprint, quantidade de dias úteis, pontos, quantidade de itens, pessoas envolvidas e a meta da Sprint definida na planning (Por que esta Sprint é valiosa?). 
Quantidade de Slides: 1.

**Entrega**: _“Tudo é item de trabalho, você pode ou não ter épicos, pode ou não ter subtarefas”_, IBM Rational Team Concert (RTV).

Todas as entregas são listadas, história de usuário, alguma tarefa (task/issue) técnica para adiantar a próxima Sprint, planos de teste… e o gráfico de pontos planejados x entregues e algumas métricas, como a porcentagem ocupada na Sprint por cada tipo de item. 
Quantidade de Slides: 1 a 2.

**Impedimentos e ações:** Relembrar situações que levaram o time a cumprir ou não meta da Sprint. 
Quantidade de Slides: 1.

**Resultado:** O ideal é responder com “sim” e “não”, mas pode dar a entender que o srcum team não entregou nada, portando utilizo o “parcial” para quando é acima de 70%. Pode firmar um acordo (DoD) com os presentes para porcentagem de sucesso. Nesse tópico tem alguma métrica do produto que a pessoa de negócio (PO) perceba interesse para exibir e os acordos do refinamento. 
Quantidade de Slides: 1 a 2.

**Finalização:** Os últimos assuntos são os que mais variam de Sprint a Sprint e time a time, no momento estou implementando revisão ágil, com informações básicas para garantir que os presentes estão com a mesma percepção sobre o desenvolvimento de novos incrementos. 
Quantidade de Slides: 1 a 2.
Avoiding `let` in TypeScript
Tags: typescript
Published: 2022-04-01 01:11:00

I sometimes feel I am forced to use `let` instead of `const` in TypeScript even I want to use `const` to prevent reassignments.

When we use `if` or `switch`, there are cases that seems we need to use `let`. However, we do not have to use `let` actually.

```typescript
const fruitNum: number = 0 // a number to represent a type of fruit
let fruitName: string = "Unknown"

switch(fruitNum) {
  case 0:
    fruitName = "Apple"
    break
  case 1:
    fruitName = "Banana"
    break
  default:
    break
}
```

Instead of the above code, we may want to use a anonymous function to make `fruitName` a `const`.

```typescript
const fruitNum: number = 0 // a number to represent a type of fruit
const fruitName: string = (() => {
  switch(fruitNum) {
    case 0:
      return "Apple"
    case 1:
      return "Banana"
    default:
      return "Unknown"
  }
})()
```

Hope this makes your code more cleaner!
GitHub's notifications on your Discord Server
Tags: discord, github, tutorial, integration
Published: 2022-04-01 01:02:09

I really love Discord and use it as a communication tool for personal projects with my friends and teammates. Sometimes I wonder: Do we have an App for Discord equivalent to GitHub App for Slack (former Pull Panda)?

So, I noticed that actually we don’t have it, for simple reasons: We can integrate GitHub Webhook to send events directly to Discord Webhook. Simple and functional. So, let's do it!

**1. Create the Webhook**

The first step is to create the Webhook on your Discord server to receive the events from GitHub:

- Go to your discord `Server Settings`;
- Click on the `Integrations` item on the sidebar;
- Hit the `Create Webhook` button;
- Fill the `name` field (I used `GitHub Integration`) and select a channel to post the messages;
- Click on `Save Changes` button;
- Then click on `Copy Webhook URL`.



![Set up your webhook on Discord](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7jnrflzg6hd9wlidftwc.gif)

**2. Set up the Webhook on GitHub**

Now, you’ll need to configure GitHub to send the events to Discord Webhook:

- Navigate to your organization (or repository) on GitHub
- Click the `Settings` tab;
- Click the `Webhooks` item on sidebar;
- Hit the `Add Webhook` button on the top of the page;
- Fill the `Payload URL` field with the URL copied in the step above (Step 1);
- Add `/github` at the end of the URL (**It’s very important!**);
- In `Content Type` select `Application/JSON`;
- You can leave the `Secret` field empty;
- In `Event Triggers` if you select:
    - `Just the push event` you’ll receive new pushed commits.
    - `Everything` you’ll receive everything, like new Pull Requests opened, workflows, etc.
    - `Let me select individual events` you can choose.
- Hit the `Add Webhook` button.
    
    
![Create your webhook on GitHub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v7ey0r70hv9zbtv1wwtr.gif)
    
You’re all set! You’ll get GitHub events notifications on your Discord channel.
    
    
![You're all set!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8f83arly89hdptrruv1.png)
    
If you have any questions, you can reach me on [Twitter](https://twitter.com/garaujodev), or you can just use the comments section below 🙂

I hope I was helpful, and thank you for reading.