teleren/devto huggingface dataset:
Depois do Café - Episodio 8 - Começando a programar (com Claudson Oliveira)
Tags: podcast, programação, portugues
Published: 2020-04-20 15:42:04

---
title: Depois do Café - Episodio 8 - Começando a programar (com Claudson Oliveira)
published: true
description: Nesse episódio a gente fala sobre como começar no mundo da programação, quebrando a primeira barreira que encontramos no começo e mostrando que programação é complicada, mas não difícil.
tags: podcast, programação, portugues
---

{% spotify spotify:episode:7iZ72E6ovhb0h22TPTU9gC %}

Você também pode ouvir no seu aplicativo preferido: [iTunes](https://podcasts.apple.com/br/podcast/depois-do-caf%C3%A9-com-airton-zanon/id1480842641), [Breaker](https://www.breaker.audio/depois-do-cafe-com-airton-zanon), [Google Podcasts](https://www.google.com/podcasts?feed=aHR0cHM6Ly9hbmNob3IuZm0vcy9lMGU0MDU4L3BvZGNhc3QvcnNz), [Overcast](https://overcast.fm/itunes1480842641/depois-do-caf-com-airton-zanon), [Pocket Casts](https://pca.st/bpyo3i4y), [Radio Public](https://radiopublic.com/depois-do-caf-com-airton-zanon-6r2oLq), [Spotify](https://open.spotify.com/show/4cqX5o40bClwqtYHv9X7Lp)

Nesse episódio a gente fala sobre como começar no mundo da programação, quebrando a primeira barreira que encontramos no começo e mostrando que programação é complicada, mas não difícil.

Este foi um episódio da Série Corona Edition, na qual vamos lançar um episódio menor que o normal toda semana, durante este lockdown, para comentar o que estamos fazendo depois do café.

----------------------

**Participantes:**

Airton Zanon - [@airtonzanon](https://twitter.com/airtonzanon) (twitter)

Elisa Pedrosa Reis - [@liisapedrosa](https://twitter.com/liisapedrosa) (twitter)

Claudson Oliveira - [@cloudson](https://twitter.com/cloudson) (twitter) - [Quero ser Programador](https://www.youtube.com/channel/UCqa6i-EYjkIqVhu1CpsBOPQ)

----------------------

**Links comentados:**

Canal Quero ser Programador: [https://www.youtube.com/channel/UCqa6i-EYjkIqVhu1CpsBOPQ](https://www.youtube.com/channel/UCqa6i-EYjkIqVhu1CpsBOPQ)

Série: O que preciso pra ser programador: [https://www.youtube.com/watch?v=i2IrOgwXiDM&list=PLzehOqhpwpxh9GxGO2p_7reP8s3pof1IY](https://www.youtube.com/watch?v=i2IrOgwXiDM&list=PLzehOqhpwpxh9GxGO2p_7reP8s3pof1IY)

Série: Seus primeiros códigos de programação: [https://www.youtube.com/watch?v=a4455OS5vnI&list=PLzehOqhpwpxjRlQGlkrmwSTRRQJtnLANM](https://www.youtube.com/watch?v=a4455OS5vnI&list=PLzehOqhpwpxjRlQGlkrmwSTRRQJtnLANM)

Série: Testes práticos para vagas de programação: [https://www.youtube.com/watch?v=yNrY2ax1OCo&list=PLzehOqhpwpxh2iUcEkWaIijVRhbeiakrL](https://www.youtube.com/watch?v=yNrY2ax1OCo&list=PLzehOqhpwpxh2iUcEkWaIijVRhbeiakrL)

----------------------

 Para mais episodios e saber mais sobre o podcast acesse https://anchor.fm/depoisdocafe.

Siga-nos no twitter [@dpsdocafe](https://twitter.com/dpsdocafe)
Things we have learned
Tags: git, codeiscolorful, todayilearned, s2engineers
Published: 2020-04-20 15:41:07

Sharing is Caring! This is why [we](http://dev.to/s2engineers) would like to post new learnings from our Engineering colleagues at SinnerSchrader on a regular basis. Whether it is regarding a tool, a good read, git command, css pseudo-class, or something completely different. There are no boundaries, it just has to be something we have learned. 

---

## Toggle your mic
With ⌘/CTRL + D you can toggle your mic in Google Hangouts(Meet) and with ⌘/CTRL+SHIFT+M in MS Teams.

---

## The Rule of Three
“The Rule of Three” basically says you should only centralise a code functionality if it is used in at least three places in your code. This rule should help to rethink the constant mantra of developers of “don’t repeat yourself”. This mantra can have negative effects and yield to problem-ridden components that solve too specific problems. So maybe you want to apply this simple rule: when reusing code, copy it once, and only abstract the third time. Don’t we all like to be a little bit messy sometimes?

---

## Git reflog
Git reflog is perfect if you have lost all of your progress and / or need to recover lost commits. Reflog stands for Reference log. It records when the tips of branches and other references  in the local repository were updated. Reflog allows you to go back to commits even if they are not referenced by any branch or tag. After rewriting the history, the reflog contains information about the old state of the branches and allows you to go back to that state if necessary.

Learn more about [git reflog](https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog)

---

## Deno
The creator of node is working on a new Javascript runtime with focus on security. It is called ‘Deno’. Looks interesting and you may want to spend some time playing with it. Here’s an official page and an article explaining what it is:
* https://deno.land/ 
* https://blog.logrocket.com/what-is-deno/

---

## Git checkout last branch
If you switch often between branches “git checkout @{-1}” could be helpful for you. By using it you will jump to your last used branch. You can also use the alias “git checkout -” for it.

Learn more about [git checkout](https://git-scm.com/docs/git-checkout)

---
Css 3d Fancy rotate animation
Tags: codepen, css, html, 3d
Published: 2020-04-20 15:20:34

---
title: Css 3d Fancy rotate animation
published: true
tags: codepen, css, html,3d
---


Css 3d fancy animation.
I have built it with html,css.
3d css property I have used.
1. transform-style: preserve-3d;
2. perspective: 1500px;
and for rotate I have rotate the wrapper 1turn Y axis animation.

{% codepen https://codepen.io/nikhilroy2/pen/OJyRxPj %}
Day-8 Check if N and It's Double exists
Tags: python, challenge, discuss
Published: 2020-04-20 15:08:53

---
title: Day-8 Check if N and It's Double exists
published: true
description: 
tags: #python #challenge #discuss
---
This problem statement is a part of the Introduction to Data Structures Arrays-101 section in LeetCode.

##### Problem Statement
Given an array arr of integers, check if there exists two integers N and M such that N is the double of M ( i.e. N = 2 * M).

More formally check if there exists two indices i and j such that :

i != j
0 <= i, j < arr.length
arr[i] == 2 * arr[j]

##### Example 1
```
Input: arr = [10,2,5,3]
Output: true
Explanation: N = 10 is the double of M = 5,that is, 10 = 2 * 5.
```

##### Example 2
```
Input: arr = [7,1,14,11]
Output: true
Explanation: N = 14 is the double of M = 7,that is, 14 = 2 * 7.
```

##### Example 3
```
Input: arr = [3,1,7,11]
Output: false
Explanation: In this case does not exist N and M, such that N = 2 * M.
```

Constraints:

1. 2 <= arr.length <= 500
2. -10^3 <= arr[i] <= 10^3

##### Solution Approach
1. Check if there are 0's in the array. Anything multiplied by 0 would return 0. But, remember there is a condition mentioned in the problem statement. Indices i and j should not be equal.
2. Based on the indices statement. It can be concluded that output would be only true if the count of zero's in the array is greater than 1. Else output would be false.
3. Create a hash table (dictionary in python) where key is the element in the array. And value is 2*(value of element).
4. Iterate over the dictionary. And check if there exists a key whose value is equal to any value present in the dictionary.
 
##### Example:

```
L = [10,2,5,3]
D = {10: 20, 2: 4, 5: 10, 3: 6}

The answer returned would be true in this case as you can see there is a value 10 and key 10.
```

```
class Solution:
    def checkIfExist(self, arr: List[int]) -> bool:
        result = False
        D = {}
        if (0 in arr) and (arr.count(0) > 0):
            result = True
            
        for x in arr:
            if x not in D and x != 0:
                D[x] = 2*x
       
        for value in D.values():
            result = D.get(value, None)
            if result is not None:
                result=True
                break
        return result
```

NOTE: 

There are some edge cases to be taken care of.

1. [0,0] - output is True
2. [10,0,7,1] - output is False

##### Question
Is there a better approach to handle 0?
Multi language support in React Native apps
Tags: reactnative, react, javascript
Published: 2020-04-20 15:06:13

Hello everyone,

I had a look over at the following article to learn about how to create a multi language app in React Native:

https://medium.com/better-programming/creating-a-multi-language-app-in-react-native-9828b138c274

I thought to myself, there must be an easier way to do this. Let's make a Context provider and wrap the app inside of it:

```js
import React, {useEffect, useState, useContext} from 'react';
import * as RNLocalize from 'react-native-localize';
const LanguageContext = React.createContext<>();

const translationGetters = {
  en: () => require('../lang/translations/en.json'),
  dk: () => require('../lang/translations/dk.json'),
};

export const LanguageProvider: React.FC = ({children}) => {
  const [language, setLanguage] = useState('en');

  useEffect(() => {
    const fallback = {languageTag: 'en', isRTL: false};
    const {languageTag} = RNLocalize.findBestAvailableLanguage(Object.keys(translationGetters)) ||
      fallback;

    setLanguage(languageTag);
  }, []);

  const value = {
    ...translationGetters[language](),
  };

  return (
    <LanguageContext.Provider value={value}>
      {children}
    </LanguageContext.Provider>
  );
};

export const useTranslation = () => useContext(LanguageContext);

```

In the above code, I'm using the `react-native-localize` to grab the language of the device and then use to access the right language key inside my getter function. Now every component can call useTranslation() and grab the text they need.

Question is though if the above code is capable of doing the same as the code in the link. I'm not using a memoize function but really I'm just outputting text so is it really needed?

Hope somebody can shed some light on this! And if not, hopefully the code above is helpful in your next React Native app that needs multi language support 😄
Sliding Window Technique
Tags: computerscience, algorithms, datastructures, csharp
Published: 2020-04-20 03:10:34

## Resources:

1. [Video explanation](https://www.youtube.com/watch?v=MK-NZ4hN7rs)
1. [Leetcode problem](https://leetcode.com/problems/permutation-in-string)

Takeaways:
* The sliding window technique is where we use two pointers on a collection. We say that one pointer represents the start of the window and the other the end of the window. The space/elements between the two pointers is the window size.
* A sliding window can be of fixed length or it can be variable length (meaning the window expands/contracts dynamically).
   * Fixed length is often easier to grasp/think about. Both pointers, say `i` and `j`, in a loop are incremented by the same number each time our max window size is reached.
   * Variable length is where `i` or `j` change at a different pace to each other. Often questions requiring this technique don't provide a window size, but ask for the largest/smallest possible window given some constraints.
* Here are some questions we can use the sliding window technique on:
   * In an array of `n` integers, find a contiguous `k` length subarray that has the largest value when it's elements are summed.
      * We can use two pointers here and our window would be of size `k`.
   * What is the size of the minimum subarray that when summed will equal a target sum?
      * We can use two pointers here, but because we want the _minimum_ length subarray (i.e the question is asking how big/small the window is) the window can't be of fixed length.
   * What is the largest subarray of `k` distinct characters?
      * We can use two pointers here. This will again be a variable length window, as we are being asked what the size of the window is (largest subarray). We will also need to use an auxiliary data structure to keep track of how many distinct characters are in a given subarray.
* A less obvious question where sliding window would come in handy:
   * Given two strings `inputA` & `inputB`, determine if any permutation of `inputA` is a substring of `inputB`.
      * Here we can use two pointers and the window will be of fixed size/won't ever grow larger than the length of `inputA`. 

Below are solutions to all the problems mentioned. I have annotated the source code with time & space complexities for each solution:

{% gist https://gist.github.com/jbolton209/ed1e61b07b712cc526196f54847285df %}

As always, if you found any errors in this post please let me know!
Spring Boot : Enable CORS
Tags: java, springboot
Published: 2020-04-20 15:00:05

If you have client app running on `http://localhost:4200` and it make a request to API written in Spring Boot that is running on `http://localhost:8080`, You should get the below error because client app and API has a different origin (domain, protocol or port).

```
Access to XMLHttpRequest at 'http://localhost:8080/hello' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
```

![CORS Error](https://dev-to-uploads.s3.amazonaws.com/i/c3i4vj1b6mn4rq9pqzk1.PNG)


You can resolve this problem by enable CORS in Spring Boot.

* At Class or Method level

```java
@RestController
public class MainController {

    @CrossOrigin(origins = "http://localhost:4200")
    @GetMapping("/hello")
    public User hello() throws Exception {
        return User.builder().name("Mac").build();
    }
}

```

* Global
```java
@Configuration
public class WebConfig {
    
    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**").allowedOrigins("http://localhost:4200");
            }
        };
    }
}
```
About Ruby Hash#compact and Hash#compact!
Tags: ruby, hash, documentation
Published: 2020-04-20 14:50:57

---
title: About Ruby Hash#compact and Hash#compact!
published: true
description: 
tags: ruby, hash, documentation
---

Get more information and more examples at my AboutRuby project:
* [AboutRuby project](https://github.com/BurdetteLamar/AboutRuby/blob/master/core/Hash/api/markdown.md#compact)

Here's the write-up over at the Ruby project:
* [Ruby project](https://ruby-doc.org/core-2.7.0/Hash.html#method-i-compact)

My main page is [here](https://github.com/BurdetteLamar/AboutRuby#about-ruby).

TL;DR

I've been working on enhancements to the documentation for the Ruby project.  Getting these enhancements posted to the Ruby project has been very slow.  They're not actually meeting resistance;  I know because my many PRs for enhancing class ENV were accepted (though not rapidly).  It's just that everyone is busy.

Anyhow, I'm stashing all this stuff on in my own project, called AboutRuby.  The piecemeal migration from there to the Ruby project is not going to be completed in my lifetime (I'm 77 years old).

So:  I'm going to blow my own horn here on DEV, to encourage you to use the enhanced documentation.
Azure Private Link explained in plain English with a story and stepbystep demo
Tags: azure, beginners, networking, cloud
Published: 2020-04-20 14:49:28

---
title: Azure Private Link explained in plain English with a story and stepbystep demo
published: true
description: This is the ridiculously simple animated explanation of Azure Private Link (Private Endpoint and Private Link Service) in plain english with a juicy story
cover_image: https://csapodcast.blob.core.windows.net/images/thumbnail-privatelink.png
tags: #azure, #beginners ,#networking , #cloud
---


This is the ridiculously simple animated explanation of Azure Private Link (Private Endpoint and Private Link Service) using a story analogy and a step by step demo in less than 5 minutes for each of the concepts - I promise you won't get bored :) . 

{% youtube vVDql7IKneg %}

Here is part 1 of the video where I explain Azure Virtual Network Service Endpoints in plain english with a story and step by step demo - https://www.youtube.com/watch?v=gxsitRRgylI

For more animated Azure videos and simplified Azure content and podcasts please check out www.azuremonk.com
Great Python projects for Beginners
Tags: python, codenewbie, webdev, devops
Published: 2020-04-20 14:44:08

These quarantine days, I have a lot of time (quarantine time) on my hands.
So, I compiled a list of python projects that will be good for beginners .
Also, please correct me if there are any errors in the slides.



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

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

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

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

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

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vua9reoait89kv6531nw.png)
4 Major Cybersecurity Risks While Working From Home

Tags: remotework, cybersecurity
Published: 2020-04-20 14:37:10

A large number of people are working remotely and this will continue to grow in the nearest future. Our homes have become our workplaces, and in the race to keep things going, we’re using new systems and adhering to security policies such that are spotty at best. Simultaneously, the boundaries between work and private life are breaking. Business is being done over home ISPs, with unmanaged routers and printers, home automation systems in the background and even partners and children listening in on discussions or sharing machines while working for different organizations. And at the same time, new cybersecurity risks are also surfacing. Some old attacks are brought back now that we’re more vulnerable, and others are new scams that prey on our desires to get news, buy basic supplies, avoid infection and recover rapidly if we do get sick.

Traditional security measures that we are using every day for years can’t protect a completely remote staff without adaption. That implies we have to reexamine our mindsets and way to deal with security at this moment.

The necessary element of effective security in a time of change is to understand that while you can do anything, you can’t do everything. The job of security is not to eliminate all risks, because all threats are not equally risky or likely, and they won’t all be exploited at once. Discuss risk early and often, and revisit triage on a regular basis. The risks you face today won’t be the ones you face next week or the week after.

You can also know- Top 11 tips for safety and security of remote working.
**4 Major Cybersecurity Risks of Working From Home**

*1. Hackers can manipulate VPNs without a view of the whole-*

*Cybersecurity risks*
Virtual private networks, or VPNs, have become the new lifesaver for many businesses, extending encrypted networks to our homes. However, many home networks are already infected with malware or compromised hardware that can be abused for staging attacks through machines with VPN termini.

A compromised identity or a machine, particularly when behavioral baselining on the backend is in transition, can permit hackers to piggyback through the VPN. It’s critical to have endpoint integrity checking and strong authentication in place at this stage once the VPN is in place and active. There are also vulnerabilities for VPNs that require truly understanding and internalizing rather than blindly trusting, and numerous applications that are becoming the new critical IT infrastructure will see new vulnerabilities.

This isn’t reason for panic, yet it means you have to discuss with vendors and plan for patching and failover. Remember, vendors, also going through change and doing triage on their support and escalations, yet start the discussion now. Contact your hardware or software providers to ensure configurations and policies are in order, starting with the VPN, endpoint and identity solutions.

*2. Endpoint first, then mobile-*
Read more at- [https://solaceinfotech.com/blog/4-major-cybersecurity-risks-while-working-from-home/]
Flattening Lists In Python
Tags: python, beginners, tutorial
Published: 2020-04-20 14:32:26

---
title: Flattening Lists In Python
published: true
description: 
tags: #python #beginners #tutorial
---

1 A list of lists
2 Using list comprehension
3 A list of varying depth (deep flattening)
4 Using recursion
5 Flatten without recursion
6 Flatten nested lists
7 A list of tuples
8 Flatten 2d array
9 A list of NumPy arrays
9.1 numpy.ravel()
9.2 numpy.flatten()
9.3 numpy.reshape(-1)
10 Flatten JSON objects
11 Flatten a list of objects
12 Flatten a list of DataFrames
13 Flatten & remove duplicates
14 Flatten a dictionary into a list
15 Using reduce

https://likegeeks.com/python-flattening-lists/

Hope you like it.
Regards,
GraphQL on Next.js + Zeit Serverless Functions
Tags: zeit, graphql, serverless, nextjs
Published: 2020-04-20 14:27:47

I was a bit surprised that there wasn't a library dedicated to running GraphQL on Next.js. It's not terribly hard to do, but I just found myself copying code from project to project enough that it warrants its own library.

Announcing next-graphql, a drop-in solution for running GraphQL on Next.js (and Zeit Serverless Functions): https://github.com/ian/next-graphql

If you're unfamiliar with how Zeit Serverless Functions work, here's the announcement: https://zeit.co/docs/v2/serverless-functions/introduction

In it's simplest form it's a 1-page implementation by adding a `api/graphql.js` (or `pages/api/graphql.js` for next.js).

Example: 

```
import { createHandler } from "next-graphql"

let ITEMS = [
  { name: "First" }
]

const typeDefs = `
  type Item {
    name: String! 
  }

  type Query {
    getItems: [Item]!
  }

  type Mutation {
    createItem(name:String!): Item!
  }
`

const resolvers = {
  Query: {
    getItems: async () => {
      return db
    },
  },
  Mutation: {
    createItem: async (obj, { name }) => {
      const item = { name }
      ITEMS.push(item)
      return item
    }
  }
}

export default createHandler({
  typeDefs,
  resolvers,
})
```