teleren/devto huggingface dataset:
Logical assignments and their use cases
Tags: javascript, webdev, beginners, programming
Published: 2021-11-22 16:19:14

---
canonical_url: https://dpnkr.in/blog/logical-assignments
description: Binary operations and conditional rendering is something we do quite frequently while building applications. This article is about logical assignment operators that were introduced in ES2021.
---


Binary operations and conditional rendering are something we do quite frequently while building applications. This article is about logical assignment operators that were introduced in ES2021.

it's important to understand `truthy` & `falsy` before we get to the good part you can read my [blog](https://dpnkr.in/blog/truthy-falsy) on the topic if you want to.

## Logical OR ||=

You might have encountered a situation were you want to assign a default value incase the input is not provided. One of the ways to do this is:

```js
let input;
if (input === '' || typeof input === 'undefined') {
  input = 'Default value';
}
console.log(input);
```

This works and does assign the default value but we might also want to include the case of `null`, `false`, or basically `falsy` values. This is exactly where Logical OR comes in handy.

```js
let input;
input ||= 'Default value';
console.log(input);
```

`||=` would only assign only if the input is `falsy`.

## Logical AND &&=

Opposite of Logical OR is Logical AND which would assign only if the input is `truthy`.

```js
let input = 10;
input &&= undefined;
console.log(input);
```

This would assign input as `undefined`. This assignment operator can be helpful if we want to reset the value of a variable.

## Logical nullish ??=

The 2 operators we talked about are based on `truthy` & `falsy` values. But what if we only want to perform assignments based on `undefined` or `null` value.


> **NOTE**: `undefined` and `null` are `falsy` under Boolean context and are also referred to as being nullish values.


A really good example from MDN docs explaining this:

```js
let obj = {
  name: 'deepankar',
};
obj.language ??= 'javascript';
console.log(obj);

// OUTPUT:
// {
//     "name": "deepankar",
//     "language": "javascript"
// }
```

Since there's no language key in the object it will be `undefined` and hence performing the assignment.
Hello! It's been a while...
Tags: ux, design, webdev, a11y
Published: 2021-11-22 15:44:49

Lately I've been transitioning from a front-end developer to a UX designer, and I haven't posted much on Dev.to since my popular "Implement Dark Mode on Your Website" article went viral, which now has received roughly 13,500 views. I greatly appreciate all the support from the Dev.to community, and though I have no plans to leave this platform, I just won't be writing as frequently on here, however, I do have another super neat programming tutorial in the works for here. In the mean time, if you want to read more of my design/development content then I'd suggest checking me out on [Medium](https://matthewmarquise.medium.com).

Today I just published my second major case study about my journey in designing and developing an entirely new website for a real estate and vacation rental agency in Maine. [Read it here](https://matthewmarquise.medium.com/working-with-island-property-to-bring-a-fresh-modern-look-to-their-website-and-brand-36e2b2874a3e?sk=da61b65800a3701494fa57bce7e7741a).

My previous case study was about designing a concept app that enables users to effortlessly pre-order food from food trucks so they didn't have to wait in line and could be guaranteed food. [Read it here](https://matthewmarquise.medium.com/street-side-an-app-to-change-how-everyone-eats-at-food-trucks-44f09091b091?sk=ab59dd6993f2a2643b84e5b0df8648c4).

Again, thank you all for your overwhelming support and stay tuned for the next programming tutorial!
1 line of code: How to get the average of an array
Tags: javascript, webdev, performance, codequality
Published: 2021-11-22 15:58:23

```javascript
const average = arr => arr.reduce((a, b) => a + b, 0) / arr.length;
```

---

**optimised code ([Benchmark](https://perf.link/#eyJpZCI6ImxsbDVhbXpiOGloIiwidGl0bGUiOiJGaW5kaW5nIG51bWJlcnMgaW4gYW4gYXJyYXkgb2YgMTAwMCIsImJlZm9yZSI6ImNvbnN0IGRhdGEgPSBbIC4uLm5ldyBBcnJheSgxMDAwKS5rZXlzKCkgXVxuY29uc3QgYXZlcmFnZSA9IGFyciA9PiBhcnIucmVkdWNlKChhLCBiKSA9PiBhICsgYiwgMCkgLyBhcnIubGVuZ3RoXG5jb25zdCBhdmVyYWdlMiA9IGFyciA9PiBhcnIucmVkdWNlKChhLCBiKSA9PiBhICsgYikgLyBhcnIubGVuZ3RoIiwidGVzdHMiOlt7Im5hbWUiOiJGaW5kIGl0ZW0gMTAwIiwiY29kZSI6ImZvciAobGV0IGk9MDtpPDEwMDtpKyspIGF2ZXJhZ2UoZGF0YSkiLCJydW5zIjpbNzA1LDcwNSw3MDUsNzY0LDcwNSw3NjQsNzY0LDc2NCw3NjQsNzA1LDc2NCw3NjQsNjQ3LDc2NCw3NjQsNzY0LDc2NCw4MjMsNzY0LDc2NCw4MjMsNzY0LDgyMyw3NjQsNzY0LDc2NCw4MjMsNzY0LDc2NC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jo3NzR9XSwidXBkYXRlZCI6IjIwMjEtMTEtMjNUMTA6MTk6NTkuNTk5WiJ9))**

```javascript
const average = arr => arr.reduce((a, b) => a + b) / arr.length
```

---
 
Returns the average of the sum of all items in a numerical array. 
Beware of JavaScripts Automatic Type Conversion if your `Array` contains something else than `Numbers`.

---

## The repository & npm package

You can find the all the utility functions from this series at [github.com/martinkr/onelinecode](https://github.com/martinkr/onelinecode)
The library is also published to [npm as @onelinecode](https://www.npmjs.com/package/@onelinecode/onelinecode) for your convenience.

The code and the npm package will be updated every time I publish a new article.

---
Follow me on [Twitter: @martinkr](http://twitter.com/_martinkr) and consider to [buy me a coffee](https://www.buymeacoffee.com/martinkr)

Photo by [zoo_monkey](https://unsplash.com/@zoo_monkey) on [Unsplash](https://unsplash.com/s/photos/fuji)

---
Project 3: Ruby+Sinatra and React Router v6
Tags: ruby, react, functional, devjournal
Published: 2021-11-22 15:58:15

What perfect timing for React Router v6 to be deployed as our next project begins! Honestly, this new version has been fairly simple to use. No more need for <Switch>, I only needed to use <BrowserRouter> and my <Routes>. It always feels incredible to have clean code for the beginning of your project.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lt3c4xxnwpi4zc48akls.png)
 
As seen above, you'll notice that my code is about musicians and their instruments. Using the functionality of Ruby, Object Orientation, Sinatra, and Active Record, I created a list of musicians with their assigned instruments. Active Record's use of associating tables together inspired me to create this as a test of my skills as an Object-Oriented developer. It was also fun to be able to put together my instruments that I own with my fiancée!

The best part is that I could simply add any new instruments or musicians to my list to be displayed! With the idea of the project being able to perform CRUD operations easily, I am able to create new instruments and musicians, read their information, update the instrument's owner (the musicians), and also delete either at any point in time.

Active Record and Object Orientation has been revolutionary as I begin to dive into more intricate projects like this. I've never been quite satisfied with any to-do lists or task managers for myself, as I've been searching since high school and when smart phones have begun their ascent into society. I've felt lost without one, but at this point, I think I can just create one using Active Record and Ruby! The two of these, with Object Orientation, have never made me feel like such an accomplishment could be so simple. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v82bwv1if1inj7w6smqy.png)
  
Onto the next one: Phase 4 - Rails, and putting it together with Ruby. I've heard a lot of bad things about Ruby on Rails, but if Ruby itself was this mind-blowingly amazing, I think this won't be any challenge at all.

Oh, and speaking of challenges, I passed my first ever live-coding challenges from Flatiron! The hard work I've put into this phase really shows, and it's only going to get better from here!
How does WordPress stack up against other website platforms?
Tags: programming
Published: 2021-11-22 15:51:49

W3Techs publishes this list every year and WordPress continues to dominate. For sites that only use content management systems, WordPress has 64.1% of the market share.

[WooCommerce](https://www.tvisha.com/blog/woocommerce-vs-magento-which-is-the-best-in-2022), an ecommerce add on that is installed onto [WordPress](https://www.tvisha.com/services/cms-wordpress-website-development-company.html) to provide online store functionality, powers 28% of online stores.

We love working with WordPress as straight out of the box it has brilliant features to make it fast, mobile responsive, secure, good for SEO and has a clearly structured user interface. There's so much you can do with it!

What's your website built with?
Release 0.3: Contributing to IPC144  
Tags: cpp, opensource, programming, beginners
Published: 2021-11-22 15:51:32

Follow the meta [issue-18](https://github.com/Seneca-ICTOER/IPC144/issues/18) me and my colleagues have a chance to contribute fixing and updating the docs for the [IPC144](https://github.com/Seneca-ICTOER/IPC144) project

## Fixing character-strings.md

This time, fixing the docs is quite different that what I have used to before. This time under the meta issue I have a huge checklist that suggested me to go through to make the docs accessible, imrpove readability and speed up the loading proccess of the docs.

In my [PR-121](https://github.com/Seneca-ICTOER/IPC144/pull/121). I try to catch any typo and unclear statments through Grammarly and keep reading one paragraph over and over each time if I could be able to understand the author point clearly. I fix invalid link to `ASCII` and `EBCDIC` markdown doc. I also fix all the code identation to not be double spaced. That is all the work I have done with this PR and I really happy about it where I did take a good look at all the details and trying to collaborate with the previous author idea .
Learning Tree Prototype
Tags: selftaught, tutorial, machinelearning, datascience
Published: 2021-11-22 15:51:07

Repost from Reddit, there is this application that allows for collaboration of study plan building for multiple topics, e.g. Machine Learning https://app.learney.me/

The Alpha testing Team is currently in Slack (hope they have one for Telegram or Discord soon) https://join.slack.com/t/learneyalphatesters/shared_invite/zt-q1rnj8tt-4895F06RAImSEDtMNE6sUg
3 Common Mistakes When Learning to Code
Tags: codenewbie, webdev
Published: 2021-11-22 15:37:07

## Mistake 1 - Not Focusing on One Language

When learning to code you should pick up one programming language at a time, trying to learn multiple programming languages at the same time is not realistic for beginners.

## Mistake 2 - Learning Too Passively

You can watch every single tutorial and read many books but you're not going to be a good programmer.

- Read the documentation
- Watch tutorials
- Mini Code
- Do your own project (Time to apply all that you learned in a cool project :D)

## Mistake 3 - Giving Up

Coding requires a lot of practice, consistency and patience! So never give up!

---

### Let's connect 💜

You can follow me on [Twitter](https://twitter.com/MrDanishSaleem), [Instagram](https://www.instagram.com/mrdanishsaleem/) & [GitHub](https://github.com/mrdanishsaleem/)

If you like this post. Kindly support me by [Buying Me a Coffee](https://www.buymeacoffee.com/mrdanishsaleem)

![Buy Me a Coffee](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fefzbxbnwww7tkght33w.png)
EP 01 - Criando uma janela para nossa Game Engine
Tags: java, gamedev, gameloop, engine
Published: 2021-11-22 15:30:43

{% youtube SoEyQAIPqbk %}

# Introdução

Hoje vamos começar a construir nosso motor de jogos, o famoso GAME ENGINE, esse motor de jogos é o responsável por desenhar e processar todos os objetos do nosso jogo em tempo de execução, vamos lá ?

Para nosso jogo começar a ter vida é necessário ter uma interface gráfica para mostrar os objetos do jogo, como jogadores, inimigos e tudo mais, então hoje vamos começar a dar vida para tudo isso.

# Construindo a Janela

A primeira coisa que iremos implementar é uma Janela, que será responsável por mostrar o nosso jogo ao usuário, para isso vamos começar construindo uma classe Windows que herda a classe JFrame do java, que constroi uma janela no sistema operacional para nossa aplicação, com isso vamos definir no construtor entrada de parametros para receber a largura e altura que essa janela deverá ter durante a execução.

```java
public class Windows extends JFrame {

    private String mNome;
    private int mLargura;
    private int mAltura;
    private boolean mExecutando;

public Windows(String eNome, int eLargura, int eAltura) {
        mNome = eNome;
        mLargura = eLargura;
        mAltura = eAltura;
        mExecutando = false;
        this.setSize(mLargura, mAltura);
        this.setTitle(mNome);
        this.setResizable(false);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }
 }
```

# Criando a Thread de Execução

Agora que temos uma janela para exibir coisas na tela, vamos implementar uma thread que será responsável por ficar chamando nosso laço de repetição de eventos infinitamente, o famoso GAME LOOP, que será implementado em mais detalhes no próximo artigo.
Para construir a estrutura de uma thread, vamos implementar a classe abstrata Runnable em nossa janela e construir o método run() para executar nosso game loop.

```java
public class Windows extends JFrame implements Runnable {
    @Override
    public void run() {

    }
}
```
best hosting option for a personal website
Tags: wordpress, help, static, webdev
Published: 2021-11-22 15:22:07

Hello,
I am wondering about the cheapest / free option to host a personal site where I publish tutorials and stuff that interests me to considerably a small audience. Most of which are written content.
Currently it is built using Wordpress, would making it a static site will be a good idea?
## A little bit of background
In black Friday 2018, I've purchased a 3-year package from HostGator which was not so expensive considering that I was making money back then.
Since I was used to write in various forums for Arab blind community, I used my new site to gather all of my tutorials and kept writing there since then.
## The situation now
My 3-year plan is expiring now, and I need to move the site. My domain from name.com is somewhat expensive and I can't afford much on the hosting. In the mean time I don't want to just close down the site. It has useful content especially for Arab blind users.
## looking for
I can do HTML, Javascript and even PHP or Python, I can use Github or any other technology in that matter.
Nonetheless, I don't know what is the best option in my case. I don't care about having comments on the site, I just love writing and helping others. Should I keep it on Wordpress as CMS or build a static website?
in either case, what are the options in term of hosting?
Keep in mind that I have content already, I am not starting fresh. So it is important to keep my old stuff.

Any help will be appreciated.
thanks.
First Python Project
Tags: python, gamedev, beginners, programming
Published: 2021-11-22 15:10:45

Created my first python project - Connect Four! Took 2 days and ~8 hours of work. Had to look up a few unfamiliar concepts like assertion within try statements, quit()/exit() commands, and of course refamiliarizing myself with syntax. 

Since I'm not working on my home computer, I used Google Colab to code the entire thing. This presented its own problems. There seems to be an issue with Colab where editing code doesn't actually reflect in runtime. You have to save, exit your browser, and re-open. This happens every few hours, so it's not a huge hassle, but still took awhile to figure out why old testcode was still printing!


Link to the project:
https://github.com/HydroDanno/connect_four
Deploying Elixir eBook
Tags: elixir, book, deploying, beginners
Published: 2021-11-22 14:03:19

---
title: Deploying Elixir eBook
published: true
description: Announcing the "Deploying Elixir" eBook
tags: elixir, book, deploying, beginners
//cover_image: https://direct_url_to_image.jpg
canonical_url: https://blog.miguelcoba.com/deploying-elixir-ebook
series: Deploying Elixir
---
I have compiled all the articles in the "Deploying Elixir" series in a handy eBook:

- All together in a single place
- Nicely formatted
- Searchable
- With improved wording
- With better source code highlight

But I have also added a *NEW, NEVER PUBLISHED BEFORE, BONUS* chapter about deploying to heroku.

And the best part:

**IT IS FREE TO DOWNLOAD!!!**

![Deploying Elixir book cover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sqo2j1poioem37btdg9v.png)

## [Download it now](https://store.miguelcoba.com/l/deployingelixir) 


## About

I'm [Miguel Cobá](https://miguelcoba.com). I write about Elixir, Elm, Software Development, and eBook writing.

- Follow me on [Twitter](https://twitter.com/MiguelCoba_)
- Subscribe to my [newsletter](https://newsletter.miguelcoba.com)
- Read all my articles on my [blog](https://blog.miguelcoba.com)
- Get my books:
    - [100 Elixir Tips](https://store.miguelcoba.com/l/100elixirtips) [FREE]
    - [Deploying Elixir](https://store.miguelcoba.com/l/deployingelixir) [FREE]
    - [Deploying Elixir: Advanced Topics](https://store.miguelcoba.com/l/advancedtopics)
    - [eBook Writing Workflow for Developers](https://store.miguelcoba.com/l/ebookwriting)
Coding Games
Tags: webdev, beginners, programming, javascript
Published: 2021-11-22 15:08:15

#Want to play games realeted to coding? 
#Well If you want to play copy and paste the 🔗 link in crome fast!!!!! 🔗 Link- https://classroom.google.com/c/NDM2NTMyMjczNzM4?cjc=uyuoahg
Manage your WordPress plugin without knowing SVN
Tags: actionshackathon21
Published: 2021-11-22 14:42:30

### My Workflow
Despite I started my web developer career using SVN, I changed job in 2 years and moved from SVN to git without returning back. I use daily git, both with a GUI and on the cli, but SVN...well, I have to use it only when I want to release the plugins that I have published on the WordPress repository (...so rarely!).
So, when I finally have will&time to work on my plugins, I also have to remember how to manage the SVN repository, what cli commands use, where I parked the SVN managed code, and usually I have to install it because in the mean time I have played with my OS.

I know, I know...you can say "SVN is easy", "The commands you need to remember are just 2", "You are complaining too much".
No, my answer is: I want a smarter way to manage my SVN repositories.

After the last OS change, I finally decided that came the time to find this smarter way and found a lot of GitHub Actions that I can use to deploy my plugin on the SVN repository starting from the GitHub repository...Fantastic, in this way I don't need to install SVN locally and host the repository to commit new versions to it, but we are missing a step for the final smart solution.

As a background information, you need to know that the WordPress SVN repository is meant to be a **release** repository, not a versioning repository, so you are warmly invited to remove the old tags and maintain inside the SVN only the current release.

The actions that I found only commit to SVN the new tag, but don't manage the removal of the old tags, leaving this step to be done locally, hosting the repository and committing the deletion of the old tags.

Here I introduce you the final housekeeping step for your SVN repository, my GitHub Action "WordPress SVN tag cleaner".

I can finally manage my plugins without ever knowing what is SVN!

### Submission Category: 

Maintainer Must-Haves


### Yaml File or Link to Code
You can already find an example workflow in the readme of the Action.
{% github dottxado/action-wordpress-svn-tag-cleaner %}
The action is not automatic on git hooks but requires as input the tag to remove.

### Additional Resources / Info

I use this workflow on my WooCommerce plugin, check it out here!
{% github dottxado/email-fields-for-woocommerce %}
For the First 70 Devs…
Published: 2021-11-22 14:39:34

Developers, Developers, Developers! To show appreciation to developers on Thanksgiving, which drives the robotic industry forward, we are offering 70% off to the first 70 developers who purchase a Misty II Standard Edition.  Feel free to share with other developers.

First 70 Developers - 70% Off
Online Discount Code =  “THANKYOUDEVS”
https://shop.mistyrobotics.com/
FastAPI Creator Sebastián Ramírez Interview
Tags: python, programming, opensource, productivity
Published: 2021-11-22 14:28:53

We are glad to have spoken to Sebastián Ramírez, an open-source enthusiast and the creator of FastAPI, Typer, and SQLModel. Sebastián is building products and custom solutions for data and machine learning systems and has led teams of developers around the world.

[Read the Interview here!](https://evrone.com/sebastian-ramirez-interview)
Angular: How I Broke ngOnInit
Tags: angular, frontend, development, design
Published: 2021-11-22 14:28:46

---
title: Angular: How I Broke ngOnInit
published: true
description: Recently I ran into an issue where one of my functions was not being implemented "at the correct time." In the process of fixing the issue I ran into another issue that I've seen before but not dug into.
tags: Angular, Frontend, Development, Design
series: Angular
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/buw4he7td61ln4llkter.png
---

So, recently I ran into an issue where one of my functions was not being implemented "at the correct time." The solution was to trigger it in another component via `ngOnInit`.

Moving the code was simple, but in the process I ran into an issue that I've seen before but not dug into.

## The Problem

The issue is that I like to use fat-arrow functions in my code (`() => {}`) and somewhere along the way I converted an `ngOnInit` to fat-arrow. I unknowingly broke the OnInit lifecycle hook complete.

```typescript
ngOnInit = async (): Promise<void> => {
  await this.init();
  ...
};
```

## The Resolution

The fix was actually pretty simple, I converted the code back to a traditional function pattern ...

```typescript
async ngOnInit(): Promise<void> {
  await this.init();
  ...
}
```

... and my function started working again.

## Conclusion

Be careful (yes, I am telling myself this) as you may inadvertently write code that does not execute correctly. It was a simple mistake and one that was hidden by some layers of async behavior.