teleren/devto huggingface dataset:
Avoid double negation, unless...
Tags: beginners, api, programming, design
Published: 2020-07-09 20:43:15

---
title: Avoid double negation, unless...
published: true
date: 2020-06-11 20:56:16 UTC
tags: beginners,api,programming,design
canonical_url: https://asawicki.info/news_1729_avoid_double_negation_unless
---

Boolean algebra is a branch of mathematics frequently used in computer science. It deals with simple operations like AND, OR, NOT - which we also use in natural language.

In programming, two negations of a boolean variable cancel each other. You could express it in C++ as:

```
!!x == x
```

In natural languages, it's not the case. In English we don't use double negatives (unless it's intended, like in the famous song quote _"We don't need no education"_ :) In Polish double negatives are used but don't result in a positive statement. For example, we say _"Wegetarianie nie jedzą żadnego rodzaju mięsa."_, which literally translates as _"Vegetarians don't eat no kind of meat."_

No matter what your native language is, in programming it's good to simplify things and so to avoid double negations. For example, if you design an API for your library and you need to name a configuration setting about an optional optimization Foo, it's better to call it "FooOptimizationEnabled". You can then just check if it's true and if so, you do the optimization. If the setting was called "FooOptimizationDisabled", its documentation could say: _"When the FooOptimizationDisabled setting is disabled, then the optimization is enabled."_ - which sounds confusing and we don't want that.

But there are two cases where negative flags are justified in the design of an API. Let me give examples from the world of graphics.

1. When enabled should be the default. It's easier to set flags to 0 or to a minimum set of required flags rather than thinking about each available flag whether or not it should be set, so a setting that most users will need enabled and disable only on special occasions could be a negative flag. For example, Direct3D 12 has `D3D12_HEAP_FLAG_DENY_BUFFERS`. A heap you create can host any GPU resources by default (buffers and textures), but when you use this flag, you declare you will not use it for buffers. (Note to graphics programmers: I know this is not the best example, because usage of these flags is actually required on Resource Heap Tier 1 and there are also "ALLOW" flags, but I hope you get the idea.)

2. For backward compatibility. If something has always been enabled in previous versions and you want to give users a possibility to disable it in the new version of your library, you don't want to break their old code or ask them to update their code everywhere adding the new "enable" flag, so it's better to add a negative flag that will disable the otherwise still enabled feature. That's what Vulkan does with `VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT`. There was no such flag in Vulkan 1.0 - pipelines were always optimized. The latest Vulkan 1.2 has it so you can ask to disable optimization, which may speed up the creation of the pipeline. All the existing code that doesn't use this flag continues to have its pipelines optimized.
My Mock Interview Experience with interviewing.io
Tags: career, whiteboarding, interviewing, computerscience
Published: 2020-06-11 20:40:04

**Anonymous and free (or paid) mock interviews online**: Free mock interviews are done peer-to-peer by members on the website. You can pay for a premium interview with an experienced interviewer from a FAANG company. I did the free one.

To sign up for [interviewing.io](https://iio.sh/r/NnMl), I had to pass a coding test, which was done through codility.com.

**Very Cool:** you can watch other people’s previous interviews before you do your own. You see their screen and hear audio from recorded interviews. https://start.interviewing.io/showcase This is incredibly valuable! Watching and listening to an interview on the platform helped a lot to get me oriented. I felt less awkward during my interview.

**Even Better!** You can watch a replay of your own mock interview watching how the interviewer makes annotations on your performance in real time!
LIKE: it’s audio and shared work space, no video.
LIKE: It’s anonymous unless you choose to reveal your identity, and they help you quickly create a catchy pseudonym.

…

I’m an anxious, jittery person, so doing a mock interview before a real one is a necessity. I just did my first mock interview with interviewing.io. It was a great experience! Although your mileage may vary.

I chose to do a coding interview (algorithms/data structures). The person doing the interview was another regular member like me. So theoretically this platform allows you do try out either side.
Their online coding environment is not quite like anything I’ve seen before, but it works. There are 3 columns of information, and there isn’t quite enough real estate, so you have to keep readjusting the columns to be able to read the text. **Tip:** *A very large monitor is helpful.* Also, there is no VIM or Emacs emulation.

So far I give [this platform](https://iio.sh/r/NnMl) a big thumbs up! You have no idea who you’ll get as a mock interviewer, so your experience will be different than mine. That’s luck of the draw. Keep trying!
Top 10 Keyboard Shortcuts for Visual Studio Code
Tags: vscode, tutorial, productivity
Published: 2020-06-11 20:39:25

_This post was originally published at [codepulse.blog](https://codepulse.blog/top-10-keyboard-shortcuts-for-visual-studio-code/?utm_source=devto) on June 11, 2020._

Visual Studio Code is a great code editor. I have been using it few years now and I love it! In that time I have picked up few keyboard shortcuts that I use daily. I think these keyboard shortcuts are worth knowing, I decided to share it with you guys!

So I uploaded a video where I share my top 10 VS Code keyboard shortcuts that I use daily and can't live without. Hope you enjoy it and also learn few new shortcuts! You can watch the video below or by clicking [here](https://www.youtube.com/watch?v=9Jo084i0Dzs).
{% youtube 9Jo084i0Dzs %} 

_Read also [If You Use GIT and VS Code - Read This!](https://codepulse.blog/if-you-use-git-and-vs-code-read-this/?utm_source=devto)_
Verifique se seus dados/informações vazaram!
Tags: security, personal, data
Published: 2020-06-11 20:38:54

Estava fazendo algumas pesquisas para melhorar a minha privacidade na internet e me deparei com o seguinte projeto: [HIBP - https://haveibeenpwned.com/](https://haveibeenpwned.com/).

Um projeto criado pelo [Troy Hunt](https://twitter.com/troyhunt), desenvolvedor especializado em segurança para que as pessoas possam, de forma simples, fazer uma verificação (inicialmente) pelo seu e-mail e então verificar se esse e-mail está atrelado a algum vazamento de dados/informações.

Vale a pena e não custa nada conferir!
Connect GitHub Pages to Your Namecheap Domain
Published: 2020-06-11 20:35:12

# Connect GitHub Pages to Your Namecheap Domain

This tutorial explains how to connect a custom domain registered with Namecheap to a GitHub Pages repository in GitHub.

## Contents

1. GitHub Pages Setup
2. Namecheap Setup

## 1. GitHub Pages Setup

If you've not yet created a repository for your site, log in to your GitHub account and create a new repository. Name the repository `<user-name>.github.io` – for example, `pauljwil.github.io`.

If you already have your HTML, CSS, and JavaScript files prepared, push them to your repository and visit your site at `<user-name>.github.io`.

From your GitHub repository, click on **Settings** and scroll down to the second-to-last section called **Github Pages**. In the **Custom Domain** box, enter the domain you registered with Namecheap, and click **Save**.

![Custom Domain](https://dev-to-uploads.s3.amazonaws.com/i/ui3sieet7k1n28b4nw8s.png)

Note that when you return to your repository's **Code** tab, a new file will have been created called `CNAME`. This file will include one line of code with the domain you added in the previous step – for example, `pauljwil.com`.

## 2. Namecheap Setup

If you've not yet registered your domain with Namecheap, do that now.

Once you've registered your domain, navigate to the **Domain List** and click on **Manage** to the far right of your domain name. From there, click on the **Advanced DNS** tab. Click **Add New Record** to add each of the following five records:

| Type | Host | Value | TTL |
| ---- | ---- | ----- | --- |
|CNAME Record | www | yourusername.github.io | Automatic |
| A Record | @ | 185.199.108.153 | Automatic |
| A Record | @ | 185.199.109.153 | Automatic |
| A Record | @ | 185.199.110.153 | Automatic |
| A Record | @ | 185.199.111.153 | Automatic |

Click **Save All Changes** and delete any additional records that may conflict with those you've just entered.

That's it! It should take approximately 30 minutes for the changes to go into effect. Once they do, you will be able to access the content in your GitHub Pages repository from the custom domain you registered with Namecheap.
Introducing minimylist - productivity assistant! 👨‍💻👩‍💻
Tags: showdev, webdev, react, codenewbie
Published: 2020-06-11 20:05:40

Every developer, literally every developer, dreams of building something that will help boost their productivity. 

Well, last weekend I made that. Hopefully, it will make me (and other users) productive. 👻

--- 
### Requirement Analysis 🤪
- It should be easy to use - most important! 😇
- Design should be !ugly - wait, this is most important! 🎨
- Should have DARK theme - I'm a fan 🖤
- Simple Notes feature - to hold phone numbers, web links, adresses, etc 📝
- Simple Task list - Quickly create, check, delete tasks from the list ✅
- Should give me a daily inspirational quote - just in case I'm running low on fuel some day 😔

---
### Technical Requirements
- Reactjs - because I wanted to learn it 🙈

--- 
### Options on what to build
- Website 
- Web Extension

---

Website is good option, but several constraints would creep in. Of which, following 2 bothered me the most:
 - where to store user data
 - is a website an accessible option to serve the purpose?

After giving in some thought, I decided to build a Web Extension instead.
 - Data is stored in Browser (syncing across multiple browsers is taken care of)
 - Web Extension can be a "New Tab" replacement. It cannot get easier than this.

Hence, **minimylist** was born! 
![](https://media.giphy.com/media/116seTvbXx07F6/giphy.gif)

---
### Screenshots?

![Light Theme](https://dev-to-uploads.s3.amazonaws.com/i/rkzmx2e0rkvtp3bbzclp.png)

![Dark Theme](https://dev-to-uploads.s3.amazonaws.com/i/qirkub5nbdkwozg54bgx.png)

---

Here are links to the plugin: 
[Chrome](https://rb.gy/vdhlo2)
[Firefox](https://rb.gy/ot5bba)

**minimylist** just serves the right purpose for me, hoping you guys will like it. Please share your thoughts in comments and all suggestions are welcome. Ciao! 👋🏻

```
The best way to learn anything in Tech is by building something!
```
Configurando um Cluster Kubernetes em Alta Disponibilidade (5/5)
Published: 2020-06-11 20:02:38

Continuando o post [anterior](https://dev.to/silvio_silva/configurando-um-cluster-kubernetes-em-alta-disponibilidade-4-20cl)

# Adicionando os `workers` ao Cluster

Agora que terminamos o `Control Plane`, podemos adicionar os `workers` e o processo é bem parecido com o que fizemos para os  `masters`.

Você precisa mudar para a janela `2-workers` no `TMUX` e para isso pode usar o comando `C-b 2` ou o modo mouse para clicar no nome da janela.

Assim como nos `masters`, a janela `2-workers` terá três painéis cada um com o comando `./conn.sh` pronto para executar.

Vá em frente e pressione `ENTER` para executar o comando e conectar nos três `workers`.

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

Para realizar o `join` dos `workers`, você precisará usar somente os dois primeiros tokens (`--token` e `--discovery-token-ca-cert-hash`) obtidos anteriormente para compor o comando abaixo:

```shell
NODE_NAME=$(hostname --short) && \
sudo kubeadm join lb:6443 \
  --node-name "${NODE_NAME}" \
  --token wx6o8y.mdmkxmj9gfeiq1fe \
  --discovery-token-ca-cert-hash sha256:65446ecd54074326caff65fdbbac91118dd591593930eae0842f5ea2a72e2bdf \
  --v 1
```

Join dos `workers` iniciando:

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

Concluído com sucesso:

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

Agora você pode retornar à janela `master-1` e observar o status do Cluster.

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

---

No próximo post, mostrarei algumas operações no Cluster usando `Deployment`, `Rollout`, `Services` (com `ClusterIP` e `NodePort`) e `HAProxy Ingress Controller`.

Até mais!
The real world is messy, consequences of code.
Tags: testing, startup, career
Published: 2020-06-11 20:02:34

Watch this video, it is an important example of the responsibility we have as software developers.  

Politics aside, think about the users' experience, how do you think they feel?  
  
- A person sees all of these "cryptic" error messages.  
- The system is difficult to use.  
- The system constantly kicks you out.  
- There is a helpline, that no-one is going to use.  
- There is a lack of trust in the system, what happens when the page changes?  
- A person tried the system **4 times** throughout **40 days**.  
  
{% youtube ualUPur6iks %}

Due to the horrible **user experience** this fueled a sentiment of a lack of trust toward the Floridian Government.  
  

This lack of trust will cost millions to them and the local economy.  
  

Some of us will be in a position where our code will have real life-changing consequences to the public. Our code could make somebody homeless, our code could kill somebody.  
  

Let that sink it.  
  

Everyone relies on software to do everything for them, as we enter a world of greater automation the responsibility is going to lie on our shoulders.  
  

The right to accessibility, the right to ease of use, and any future rights of software consumers is our collective responsibility.  
  

There are other examples of software errors and although some are unavoidable most of the time it is the lack of foresight and testing.  
  

- [https://royal.pingdom.com/10-historical-software-bugs-with-extreme-consequences/](https://royal.pingdom.com/10-historical-software-bugs-with-extreme-consequences/)  
- [https://www.fastcompany.com/3053000/volkswagens-cheat-software-will-kill-59-people](https://www.fastcompany.com/3053000/volkswagens-cheat-software-will-kill-59-people)  
- [https://en.wikipedia.org/wiki/Therac-25](https://en.wikipedia.org/wiki/Therac-25)  
  

Next time a client expects a quick return on their investment, remember that recklessness could destroy their company and your work could hurt somebody.  
  

I admit that early in my career I've personally been pressured, sometimes this was self-inflicted, to deliver quickly, and to cut corners. I regret those decisions but being young, ego-driven, learning as I go I was trying to impress.  
  

We all learn and grow.  
  

This is why you should test, this an article I wrote which focuses on [bang for the buck testing method](https://worldclassremote.com/save-client-money/) I default to.  
  

Reach out to me.  
  

Matt.
AzureFunBytes - Episode 2 - Azure Active Directory with Phoummala Schmitt - @ExchangeGoddess
Published: 2020-06-11 19:59:40

AzureFunBytes - A Twitch show on how to use all the fundamentals that are Microsoft Azure.

I am joined by Phoummala Schmitt to discuss Azure AD, Governance, food and dogs. We cover Azure Active Directory and solve three problems using it.

{% youtube xBQxoVborF8 %}


## [How do I create an Active Directory tenant on Azure?](https://youtu.be/xBQxoVborF8?t=610) 


Phoummala and I discuss a TV show I really enjoyed called DEVS.  We talk about the fictional company Amaya's need for an active directory to store information and logins of the characters on the show 

## [How do I move my spreadsheet of users into Azure Active Directory?](https://youtu.be/xBQxoVborF8?t=1413) 

Our fictional company, Amaya currently has it's employees in an excel sheet.  We need to build add our employees, their roles and departments into Azure Active directory.  We'll also ensure that every user has a password to login by default so they can create a new one.

## [How do I ensure my Azure AD users have the right permissions?](https://youtu.be/xBQxoVborF8?t=1997)

Forrest works in DEVS, Lilly in InfoSec and Kenton is in Corporate Security.  Each role at the company will require their own role within Azure Active Directory to ensure that once people are authenticated, they only access resources their role permits. 



We take questions and gives you a start with procedures to deploy a new AD tenant.

Follow AzureFunBytes on [Twitter](https://twitter.com/azurefunbytes) and [Twitch](https://www.twitch.tv/azurefunbytes) for updates on future episodes.

---

Links for you!

[Azure Active Directory Overview](https://azure.microsoft.com/services/active-directory/?WT.mc_id=itopstalk-blog-jagord)
[Microsoft LearnTV](https://docs.microsoft.com/learn/tv/?WT.mc_id=itopstalk-blog-jagord) 24*7 streaming Azure content
[Get $200 in free Azure credit along with 12 months of free services](https://azure.microsoft.com/en-us/free/?WT.mc_id=itopstalk-blog-jagord)
[What is Azure Active Directory?](https://docs.microsoft.com/azure/active-directory/fundamentals/active-directory-whatis?WT.mc_id=itopstalk-blog-jagord)
Client side user details, what is okay?
Tags: help
Published: 2020-06-11 19:55:09

I have been hoping to bring some convenience to a shop I'm building. My day job is security based but what I am about to ask hasn't really been exploded yet. Client side login or in other words device based login. How safe is it to use this as a sort of 2 stage profile. You can login without a password but and store your name and maybe view recent orders. However to actually edit sensitive details or make purchases you need to enter a password which will go to a server for processing.

Is this silly complex?
Understanding == comparison operator in JavaScript
Tags: javascript, webdev
Published: 2020-06-11 19:24:59

In JavaScript there are two operator you can use to compare values == and ===.

Let's understand few examples of == to understand how it works.

{% gist https://gist.github.com/bhandwalkar/b9b3dd99acb5d009d9d8b6783112e7f5.js %}


# Algorithm of ==
1. If one of the operands is Object and other is not return false
2. If both operands are Object if reference is not same, return false
3. If One of the operands is NaN returns false
4. Check if Operands can be converted to Same primitive types and then compare.
Android app to browse and share incidents during protest for George Floyd 
Tags: 2020policebrutality, blacklivesmatter, justiceforgeorgefloyd, androidapp
Published: 2020-06-11 19:17:30

---
title: Android app to browse and share incidents during protest for George Floyd 
published: true
description: Android app to browse and share violence committed by law enforcement on peaceful protesters during the protests & riots of 2020 following the murder of George Floyd.
tags: 2020PoliceBrutality, BlackLivesMatter, JusticeForGeorgeFloyd, AndroidApp
---

![Android App for 2020 Police Brutality Incidents](https://dev-to-uploads.s3.amazonaws.com/i/8ej5jtggsaobg9k1zrlw.png)

In the midst of COVID-19, the past 2 weeks have been horrific from many fronts, especially after the murder of `#GeorgeFloyd` on May 25h. It gives me hope to see how the issue resonated among Americans and Canadians. It IS time to speak up, to be silent is to be complicit.

As an engineer, I am overwhelmed to see how communities came together both online and offline. One online community that is trying to actively [document](https://github.com/2020PB/police-brutality) and preserve all #PoliceBrutality incidents during peaceful  protest is on Reddit at [r/2020PoliceBrutality/](https://www.reddit.com/r/2020PoliceBrutality/)

I also wanted to participate in spreading the words `#BlackLivesMatter` `#JusticeForGeorgeFloyd` by making a simple Android app that uses data collected by the subreddit [r/2020PoliceBrutality/](https://www.reddit.com/r/2020PoliceBrutality/) community. I hope more people become aware and take smaller actions towards making the world a better place.

Currently, the app is pending approval to be published in Google Play store, however, if you want to test drive it, it's available on [GitHub](https://github.com/amardeshbd/android-police-brutality-incidents) to manually download and install on your phone.

https://github.com/amardeshbd/android-police-brutality-incidents/releases
4.2 Documentation
Published: 2020-06-11 19:16:25

•	<h1>Why do you think documentation is important?</h1> – Documentation is super important because you can see the function and purpose of a line of code quickly and easily. Coding in general like HTML, CSS, and JS, have websites dedicated to their functions and archive a large amount of how to use it. I have not really seen an equivalent to lets say, MDN, for Swift. This isn’t the same thing, but extremely helpful.

•	<h1>Which are different ways of accessing documentation?</h1> – there are a few methods, Control-Shift-Zero, the Xcode Help Menu on the right side, or option click a code, and the popover should have a link to the documentation.
Road to Genius: beginner #9
Tags: javascript, beginners, computerscience
Published: 2020-06-11 19:08:23

Each day I solve several challenges and puzzles from Codr's ranked mode. The goal is to reach genius rank, along the way I explain how I solve them. You do not need any programming background to get started, but you will learn a ton of new and interesting things as you go.

![programming challenge](https://dev-to-uploads.s3.amazonaws.com/i/k0ey24u1bk3acfzkkxh2.png)

This challenge is a bit more complex than all previous ones we had. Solving it is very easy because you don't need to fully read the code. We need to fix the bug 💧, which is used near the end of the code. It seems to be just a variable name, whose value is obtained from calling a function. To find 💧, we can look at the next line, where there's a variable `out` which hasn't been declared yet, so 💧 has to be `out`.

![programming challenge answer](https://dev-to-uploads.s3.amazonaws.com/i/xc9fljmnk2e2jz71gvmb.png)

Solving the challenge was a piece of cake, but let's analyze the code, in particular the function `range`. This function takes two arguments `x` and `y`. It declares an empty array, then there's a while-loop which runs as long as `x < y`. Inside the loop, it adds a number to the array which is `x + arr.length`, and then it increments `x`'s value by one. Finally it returns the array `arr`. So 💧 (=`out`) points to the array (by reference).

---

If you feel inspired and motivated to upgrade your coding + debugging skills, join me on the Road to Genius at https://nevolin.be/codr/