teleren/devto huggingface dataset:
Sort an array by boolean value
Tags: javascript, sorting, array, programming
Published: 2022-08-31 19:08:26

Hello guys, i hope you are doing really well and trying to solve bigger problems. But sometimes we get really difficult problem to solve in some interviews which can take our valuable chance 😥. Here we will be going through a problem to sort an array by boolean value without using any method and without creating and new array in O(n) time complexity.

This problem was appeared in Amazon interview and i think this will be much useful for you. So let's start 😎 -

> Let's assume we have an unsorted array like this -

`const response = [
    {
        id: 1,
        name: 'Phone',
        isChecked: false
    },
    {
        id: 2,
        name: 'Laptop',
        isChecked: true
    },
    {
        id: 3,
        name: 'Desktop',
        isChecked: false
    },
    {
        id: 4,
        name: 'Watch',
        isChecked: true
    }
];`

and we need to place all checked items first and unchecked items at last. Below is the code for this.



```
let lastElementUnchecked;
for (let i = 0; i < response.length; i++) {
    if (response[i].isChecked && lastElementUnchecked !== undefined) {
        let current = response[i];
        response[i] = response[lastElementUnchecked];
        response[lastElementUnchecked] = current;
        i = lastElementUnchecked;
        lastElementUnchecked = undefined;
    } else {
        if (!response[i].isChecked && lastElementUnchecked === undefined) {
            lastElementUnchecked = i;
        }
    }
}
```


This is very simple example to understand but while interviews it can be tough to reach over.

I hope you like this, thank you for reading 😊
Let's build a multiplayer movie trivia/quiz game with socket.io, svelte and node. devlog #13
Tags: webdev, devlog, svelte, socketio
Published: 2022-08-31 18:52:44

## Busy days...
Not gotten that much done I guess, been bz with boring some school work (making super tacky website with all annoying things u don't want as teacher thinks that is nice web design) and watching Korean drama series.

## Note to self
Remember to implement the features I forgot about.
- Add accurate answer times in backend in case want to use it in future.

- Send all round scores after round ends so can show placement of players while game is going on.

- Update the todo-list so don't forget it again.

## Progress...
Hmm, have done some here n there.. added some array sorting in the backend so clients don't need to be bothered with it.

Did some more work on the game over screen. Added the last round results seen below.
![Game_results](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5m72hi37ax9264bi9zcx.PNG)

Other than that, mostly been staring at the thing. The UI sux and I  still don't really know what I should do about it.. Been thinking about having like a status bar at top that always show the players and their score.. Think that wld make sense, but how wld I implement that so looks nice on mobile? Maybe just use the avatars there... Will think about it some more..

That's all for now I guess.. Progress gonna be slow in the near future, got too much boring school work that need to try to get motivation to do.
Naming Conventions
Published: 2022-08-31 18:50:45

This is part of a brief series on [Good Habits For Java Programmers](https://dev.to/mbrubin56/good-habits-for-new-java-programmers-1n2).

Java allows you a lot of flexibility in how you name classes, variables, methods, etc. But there are conventions that Java programmers follow. Obeying these conventions is important: it makes it much easier for all of us to comprehend each others' programs quickly and easily.

## Class and Interface names begin with an _uppercase_ letter

Your class and interface names should always begin with an uppercase letter. Java does not _require_ this -- you won't get a syntax or compiler error if you start your class name with a lowercase letter. But it's just how things are done. Not following this convention will ultimately lead to confusion.

## Variable, method, parameter names should always begin with a _lowercase_ letter

Again, this is not required by Java, and your Java programs will compile and run if you break this convention. Nonetheless, convention has value.

## Use [CamelCase](https://en.wikipedia.org/wiki/Camel_case) for class, variable, parameter, and method names

Examples:
`double sellerCost;`
`double buyerPrice;`
`double getProfit(double sellerCost, double buyerPrice)`
`void displayDataAsTable()`
`class ProfitCalculator`

[Meaningful names](https://dev.to/mbrubin56/meaningful-names-bh1) for your classes, variables, methods, and parameters are generally multiple words stuck together in sequence to make a small phrase that describes what they do or what they're for. You should be able to get the idea from the examples above.

If it's a class or interface name, you start with an uppercase letter; if it's a variable, method, or parameter name you start with a lowercase letter. Then you lowercase the rest of the letters in the first of the jammed together words, and then capitalize the first letter of the next word, lowercase its remaining letters, capitalize the first letter of the next word, and so on. The examples are easier to understand than the explanation.

## There are other rules
These cover most everything you'll use early on. 

There are rules for so-called constants in Java, which use a capitalized [SNAKE_CASE](https://en.wikipedia.org/wiki/Snake_case): e.g.
```java
public static final double MAX_PRICE = 100.0;
```
and more constructs. I only mention this for completeness. Don't sweat them. Focus on the rules for class names, variables, methods, and parameters, and you'll be in great shape.
== true and == false are Redundant
Published: 2022-08-31 18:50:38

This is part of a brief series on [Good Habits For Java Programmers](https://dev.to/mbrubin56/good-habits-for-new-java-programmers-1n2).

Consider this:
```java
        if (isValid == true) {
            System.out.println("The input is valid.");
        }
```
This won't do anything differently from this variant:
```java
        if (isValid) {
            System.out.println("The input is valid.");
        }
```

Similarly,
```java
        if (isValid == true && isNew == true) {
            System.out.println("The input is valid and new.");
        }
```
won't do anything differently from
```java
        if (isValid && isNew) {
            System.out.println("The input is valid and new.");
        }
```

Use the versions that don't tack on the `== true`. That's what Java programmers do, conventionally, and the shorter expressions are simpler to read. Well, they're simpler to read once you get the hang of things. Admittedly, you might find it easier to insert a secret "equals true" when reading these boolean expressions to yourself. I did when I was starting out. But, conventionally, we don't write our boolean expressions that way.

Similarly, for `false` checks, we don't, conventionally, write
```java
        if (isValid == false && isNew == false) {
            System.out.println("The input is not valid and not new.");
        }
```
We write
```java
        if (!isValid && !isNew) {
            System.out.println("The input is not valid and not new.");
        }
```
Out loud, professionally, we read this as "if not isValid and not isNew then..." But if you need to mentally adjust that to "if isValid is false and isNew is false then..." that's perfectly fine. Lots of folks do. But the Java is written using the not operator, `!`.
Always Use Braces For if/else
Published: 2022-08-31 18:50:36

This is part of a brief series on [Good Habits For Java Programmers](https://dev.to/mbrubin56/good-habits-for-new-java-programmers-1n2).

Yes, it's true, you don't _need_ curly braces to introduce a scope for a bit of Java such as

```java
        if (isValid)
            System.out.println("The input is valid.");
```
or even for
```java
        if (isValid)
            System.out.println("The input is valid.");
        else
            System.out.println("The input is not valid.");
```
But it's dangerous and introduces style inconsistencies not to.

## The danger
The danger comes from the fact that it's far too easy to add a second thing to do when those `if` or `else` conditions are met and not realize you need to now add the curly braces to make sure both things are done when the condition is met. Consider

```java
        if (isValid)
            System.out.println("The input is valid.");
            System.out.println("It sure is."); // This will always execute, even if isValid is false.
```
Oops. That second line will always execute, regardless of the whether `isValid` is `true` or `false`. The author probably wanted to add curly braces:
```java
        if (isValid) {
            System.out.println("The input is valid.");
            System.out.println("It sure is."); // This will only execute if isValid is true.
        }
```
Similarly for
```java
        if (isValid)
            System.out.println("The input is valid.");
        else
            System.out.println("The input is not valid.");
            System.out.println("It sure isn't."); // This will always execute, even if isValid is true. 
```
The author probably wanted to add curly braces:
```java
        if (isValid) {
            System.out.println("The input is valid.");
        } else {
            System.out.println("The input is not valid.");
            System.out.println("It sure isn't."); // This will only execute if isValid is false.
        }
```
## Style consistency
A lot of our ability to read programs easily comes from the authors' obeying conventions and their being consistent in their coding style. 

For example, if a file is formatted inconsistently with different indentation patterns everywhere, it's hard to take in. You wouldn't want to read this:
```java
// Don't do this!
        if (isValid) {
     System.out.println("The input is valid");
        } else {
            System.out.println("The input is not valid");
                System.out.println("It sure isn't"); 
        }
```

Sometimes adding curly braces for `if` statements and sometimes not introduces inconsistency. Always using braces introduces consistency, and consistency increases readability and maintainability. The less work we have to do when understanding a program, the better.
Default To private Access Modifiers
Published: 2022-08-31 18:50:29

This is part of a brief series on [Good Habits For Java Programmers](https://dev.to/mbrubin56/good-habits-for-new-java-programmers-1n2).

Access modifiers really do matter. It's hard to appreciate that with the small programs you're writing all by yourself when you first learn to program. But as programs get bigger and as more people work on them over time and together, the access modifiers matter more and more.

Why is a large topic, and it may be hard to appreciate with the programs you've been writing. So I'll just be brief about one of the main reasons. So much of the trouble of hunting down bugs in our code is caused by its not being obvious when and why a variable changes state during the execution of the program or when and why a method is called during that execution. And even when it's obvious, there may be so many potential places that variable or method are accessed, we can't keep track of them all in our heads easily to help us think through the potential problems, especially over time and the larger the codebase gets. So one of the ways we combat this is by _restricting_ access to those variables and methods. It reduces the surface area of what could possibly go wrong and what we have to think about when hunting down a bug: "Since this variable is private, it can only be modified by methods in this class, so I can restrict myself to thinking about only what this class does to find my bug." It also restricts the possibility of our _making_ errors: you can't mistakenly call a method on a class from another class if it's not accessible to that second class.

But I fear this may be one of those nuisance topics where your instructors always hassle you to update your access specifiers to be more restrictive and take off points when you don't, and it seems pointless to you. It might be one of those things where you'll just have to develop the habit of doing it the "right" way, according to your instructors, just to get them to stop bothering you and to give you higher grades before you come to experience why this is so valuable a practice.

So default to specifying modifiers on methods as `private`. That's the habit you want to develop. Make them `public` only if you need to.

And always make member variables `private`. If you need to somehow expose the ability to set or get their values, create methods that provide a way for a user of your class to set or get the value from the method. Okay, there are exceptions, but none we need to talk about here, except if you're making a constant: e.g. `public static final double MAX_SALARY = 100.0;`.
[Fivem] [RageUI] - Script Location De Voiture
Tags: lua, fivem, programming, github
Published: 2022-08-31 18:28:52

Preview :

[Vidéo de présentation](https://youtu.be/LCFB_of1w_0)

Serveur Discord avec le lien du script :[Le repère des tanches](https://discord.gg/yQcMBUUkNc)

Voici mon script de location de voiture disponible sur mon Discord !

Features :

➤ Prix différent pour chaque véhicule
➤ Plaque avec écrit "Location"
➤ Temps de location modifiable
➤ La langue (FR/EN)
➤ La position du ped
➤ La position du spawn du véhicule
➤ Le temps pour afficher le message d'alerte

En cas de question et/ou de problème venez me contacter sur mon discord : p0p0_l4_t4nch3#1847

Réseaux Sociaux :

➤ [Twitch](https://www.twitch.tv/p0p0_l4_t4nch3)
➤ [Instagram](https://www.instagram.com/p0p0_fivem/)
➤ [Dev.to](https://dev.to/p0p0)
➤ [Twitter](https://twitter.com/L4P0p0)

✉️ Mail Pro : popodevfivem@gmail.com
[Fivem] [RageUI] - Script de test d'un véhicule au concessionaire
Tags: lua, fivem, programming, showdev
Published: 2022-08-31 18:21:20

**Preview :**

[Vidéo de présentation](https://youtu.be/E3s-Rd_5bZ4)

Serveur Discord avec le lien du script : [Le repère des tanches](https://discord.gg/yQcMBUUkNc)

Voici mon script en **RageUI** pour tester un véhicule au concessionaire disponible sur mon Discord !

Features :

➤ Essai impossible tant que quelqu'un test un véhicule
➤ Prix de test configurable
➤ Plaque avec écrit "Essai"
➤ Le temps pour afficher le message d'alerte
➤ La langue (FR/EN)
➤ Temps de test modifiable
➤ Blips et spawn de voiture modifiable

En cas de question et/ou de problème venez me contacter sur mon discord : **_p0p0_l4_t4nch3#1847_**

------------------------------------
Réseaux Sociaux :

➤ [Twitch](https://www.twitch.tv/p0p0_l4_t4nch3)
➤ [Instagram](https://www.instagram.com/p0p0_fivem/)
➤ [Dev.to](https://dev.to/p0p0)
➤ [Twitter](https://twitter.com/L4P0p0)

✉️ Mail Pro : popodevfivem@gmail.com
Accessibility in Front-end
Tags: javascript, webdev, react, vue
Published: 2022-08-31 18:18:20


One of the skills that people are not interested in, and I personally did not give it the utmost importance.



I was talking to one of my colleagues at the office and I asked him from his point of view, what are the skills that distinguish one person from the other?

In the midst of a lot of talks, he said the Accessibility, at the time, frankly, I was not interested in it





Let me explain, the Accessibility in Front-end is how I can control the components through any external device, such as the mouse, the keyboard, or maybe a tablet pin or headphones.

and guess what maybe from voice recognition





Ask yourself how to make the components easily accessible for any user, from any device the user can use, and how to make it easier for him to use it.



For example, if he eats and wants to move through the keyboard, how to understand which part he wants to go to it first? 

How do I make this part accessible through the keyboard; because there are tags, the attribute tabindex must be entered, also sometimes it is necessary to put a keypress event for example.



Suppose he is blind!! Shouldn't we make him able to use the site?

maybe we can add voice recognition to grasp what he wants.



there are a lot of examples but I'll leave it to your imagination ;)



these details distinguish one developer from another, however, it adds fun to the work.



Have a productive day ❤️
I used the Courier API to send secret morse code messages!
Published: 2022-08-31 18:15:22

I followed along with this [amazing tutorial from the Courier team](https://dev.to/shreythecray/nodejs-tutorial-sending-secret-messages-with-the-courier-api-n64), and I was able to send my own secret message!


I sent an email...
![Email with secret code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4g3ibd83zrs23108f6kz.png)

And a text!!

![Text with secret morse code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w35m14uzz3mh6zd4bntq.png)

(Video to come but wanted to share this now!)

And here's my repo! https://github.com/brittanyjoiner15/cascadia
Welcome Thread - v189
Tags: welcome
Published: 2022-08-31 17:56:25

---
title: Welcome Thread - v189
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
canonical_url: 
---

![Hand waving hello in different languages](https://media.giphy.com/media/26xBwdIuRJiAIqHwA/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
are you new to Programming? Here are some few tips !
Tags: python, programming, css, webdev
Published: 2022-08-31 17:06:19

are you new to Programming? Here are some few tips you'll like if you are a beginner at programming..

TIP NO. 1 

Don't watch tutorials like a Netflix series
Do more Practice than watching videos.

TIP NO. 2

Don't switch languages again and again.
master one language first.

TIP NO.3 

Be consistent
do coding everyday, even if you don't have much time, give atleast 30mins.

TIP NO.4

Find a coding buddy
someone who can challenge you so that you don't loose motivation.

TIP NO.5

Don't hide from difficult topics
start from easy problems and work your way up, but don't skip problems that looks difficult.
How to get the ubuntu code name from elementary os?
Tags: ubuntu, codename
Published: 2022-08-31 16:58:45

---
title: How to get the ubuntu code name from elementary os?
published: true
description: Often when we try to install the apt will look for a valid ubuntu version by executing `lsb_release -cs`. And it will return code name of elementary os but not the ubuntu code name. But what is required is ubuntu code name. 
tags: ubuntu,codename
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

Often when we try to install any software in elementary os using the terminal commands like the following:
```
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install vagrant
```
The script looks for a valid ubuntu version by executing `lsb_release -cs`. And it will return code name of `elementary os` but not the `ubuntu code name`. But what is required is `ubuntu code name`. The following script does not exactly solve the issue. But it is handy to fetch the ubuntu code and replace it where needed.

```
# Reads the /etc/os-release file and reads the file into a dictionary named os_release. 
# Please read https://unix.stackexchange.com/a/433245/298979 to understand why sourcing and awk are poor ideas to replicate the same in those methods.
if test -r /etc/os-release
    then
        declare -A os_release
        while IFS="\=" read -r key value
            do
                os_release[$key]=$value
        done < /etc/os-release
        alias uc="echo ${os_release[UBUNTU_CODENAME]}" #Get ubuntu code name
    else
        echo "Unable to read /etc/os-release file to get ubuntu code"
fi
```
Anotações e "one a one".
Published: 2022-08-31 15:58:28

Tenha sempre a sua disposição uma maneira para realizar pequenas anotações, seja em formato digital ou físico.

Eu tenho usado o [LogSeq](https://logseq.com/), pois a proposta de resgatar pontos importantes para mim faz muito sentido, além do hábito de anotar pensamentos.

Se sua empresa tem hábito de realizarem “one-a-one”, isso é reunião entre duas pessoas, anote o que gostaria de conversar com essa pessoa e o que ela trouxe de feedback para você.

Essas reuniões desse tipo ajudam você conhecer melhor o amigo, mas é muito usada para saber como você está se sentindo em relação aos seus amigos de time e também como estão seus relacionamentos na empresa. 

As vezes alguma situação pode ser algo que sua percepção não tenha conseguido ver o quadro inteiro do contexto, ou você perceber que não é um sentimento só seu, e outros amigos tem o mesmo sentimento.

Esse momento deve ser um espaço seguro, seja integro e verdadeiro, mas mantenha uma certa dose de coragem para tratar assuntos incômodos.

Deixo aqui um link legal para você ter como parâmetros para suas primeiras reuniões 1:1 na sua carreira, se sua empresa ou time ainda não realizam esse tipo de cerimônia, eu te indico conversar sobre com sua liderança e encontrarem um momento para isso.

https://luiholleben.com/people/101-perguntas-1-1s/
You ain't a beginner developer no more!
Tags: webdev, programming, javascript, beginners
Published: 2022-08-31 16:51:01



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

## 1. Not afraid of learninig something new ! 
You just be like "give me some time , this shit can be done!". You will just bypass the fear of learning something new. 

At the end of the day you just work with what suits your needs and learning new is the part of development.

## 2. Syntax ain't a problem
You are far better with your syntax skills even when learning the new language.

## 3. You Stop watching Youtube/Tutorial Videos
You directly go to the docs where you would find stuff easily and complain about inconsistencies in the docs. 

You prefer reading rather than watching a video because ultimately you develop the habit of finding what you need when reading easily.

## 4. You start exploring other things beyond coding.
Such as writing a documentation/blogs for what you do , writing test cases , automating a testing flow and cloud related things.


_Peace_ 🕊

--- 

If you are here it means you may have enjoyed reading this blog. Just follow me @shrihari which will motivate to write more, contribute open source.

You can make a drink [Buttermilk 🥛](https://www.buymeacoffee.com/shriharimohan). Small support comes a long way!

Subscribe If you want to receive these blogs in your mail from @[Medium](https://medium.com/@shriharimohan) for free!

---
## Try Our new product for free!
[DocsAI](https://docsai.app/) - Create AI support agents with your documents in the most affordable price, starts at **0$**. Don't need a bot , but need ai help on your docs just upload and start chating !

Using for a company ? [Check out our pricing](https://docsai.app/pricing) Just contact me for personalized pricing !

![docsAi](https://firebasestorage.googleapis.com/v0/b/shrihari-personal-storage.appspot.com/o/banner-docs-jpeg.jpeg?alt=media&token=45c47666-de2a-4e02-8881-beb6e43ce581)

---

## More Free Articles From me 

{% embed https://dev.to/shrihari/the-chrome-dev-tool-you-are-missing-feat-recorder-4ao5 %}

{% embed https://dev.to/shrihari/top-ui-frameworks-for-angular-and-react-1951 %}

{% embed https://dev.to/shrihari/colors-design-inspiration-websites-for-new-comers-1lcb %}