teleren/devto huggingface dataset:
Join Virtual Coffee in the Creative Community Monthly Challenge!
Published: 2023-11-30 20:09:00

---
title: Join Virtual Coffee in the Creative Community Monthly Challenge!
published: true
description: As devs and people in tech, we often spend a lot of time doing tech things. This is why the Virtual Coffee Community takes the time every December to emphasize our creative side. 
tags: 
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q3y7a3kc3kdk2lnjz17j.png
# Use a ratio of 100:42 for best results.
published_at: 2023-11-30 20:09 +0000
---

:wave: Welcome to Virtual Coffee's Creative Community Challenge! Every December, we take time to honor the creative parts of ourselves. It's a time to discover creative hobbies and activities outside the tech sphere that we don't normally talk about.

We're not talking about a digital, although that's fine too. We're talking about connecting with each other over the creative sides of ourselves.

Maybe it will result in reducing screen time, which helps alleviate stress and can rejuvenate our minds, leading us to be more focused and productive when we return to our tech tasks. Maybe it's just exploring a new side of yourself or revisiting an old side you used to enjoy. No matter what, we're inviting you to share your creativity with us this month.

## Importance of Creativity

Creativity is a way of thinking, exploring, and solving problems. For those of us in tech, engaging in creative activities can be incredibly beneficial. It exercises different parts of our brains, enhancing our ability to think out of the box and tackle complex challenges in our day-to-day work. Whether it's painting, writing, playing music, or making moss art (that was my activity for the last two years) these activities make us better thinkers.

## Neurological Benefits of Cultivating Creativity

From a neurological perspective, creativity is a goldmine. When we engage in creative endeavors, our brain's reward pathways light up, releasing dopamine, which boosts our mood and motivation. These activities strengthen neural connections, improving overall brain function and cognitive flexibility. Additionally, studies have shown that regular engagement in creative activities can significantly reduce stress and bolster mental health.

## How to Participate in the Challenge

This month, we encourage you to pick one or two activities that spark joy for you. It's not about being perfect; it's about self-expression and enjoyment. If you're comfortable, share your creations or experiences with the community or in the comments below. Your participation might inspire others! Also, consider exploring new hobbies or interests – this could be the perfect opportunity to try something you've always been curious about.

This challenge is an opportunity to develop new skills, reduce stress, and enhance your cognitive abilities, all while having a great time. And if you have ideas for folks, drop them in the comments below! I know I'm still thinking about what I'm going to do, so I could use some inspiration.
Search Insert Binary Python
Tags: python
Published: 2023-11-30 20:01:29


[Search Insert Position](https://leetcode.com/problems/search-insert-position/editorial/?envType=study-plan-v2&envId=binary-search)

I wanted to count numbers inside of "target" and I could not write what I wanted.
```
class Solution:
    def searchInsert(self, nums: List[int], target: int) -> int:
        i = count.target.index
        return i
```
AI checked this code and answered like this.

```
class Solution:
    def searchInsert(self, nums: List[int], target: int) -> int:
        try:
            i = nums.index(target)
        except ValueError:
            nums.append(target)
            nums.sort()
            i = nums.index(target)
        return i
```
I have to practice try except.
How to deploy a custom template
Tags: webdev, javascript, programming, beginners
Published: 2023-11-30 19:59:41

A custom template in the context of Microsoft Azure is often an Azure Resource Manager (ARM) template that you develop to specify and deploy your infrastructure as code. ARM templates are JSON files that specify the Azure resources that you will need to deploy, such as virtual machines, storage accounts, and networking components.




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

To deploy a custom template, type in custom template, and it will bring you to this window. Click on the Linux virtual machine.


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

Go to the resource group and give it a name. Enter your username and password. Everything else can remain as it is, depending on what your needs are. Review and create.


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

Always make sure you have created a resource group and then deploy.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7eqarczuk71mra5uzikd.png)

Using ARM templates, you can deploy resources consistently across various environments, such as development, testing, and production. By implementing the same template across different stages of the development lifecycle, you can minimize errors and ensure that your infrastructure is uniform and reliable.

ARM templates are a powerful tool that enables the automation of resource deployment and management. With the help of tools like Azure PowerShell, Azure CLI, or Azure DevOps, you can easily automate the deployment and updates of your infrastructure. This not only saves time and reduces errors, but also ensures consistency across all your deployments.

By using ARM templates, you can easily scale your infrastructure by defining the desired state of your resources. This means that you have the flexibility to modify the template to add or remove resources as per your changing requirements without having to start from scratch. This makes it a highly efficient and time-saving process that can be done seamlessly.

This and many more are the reasons why we deploy resource templates in azure.
For...else in JavaScript
Tags: discuss, javascript, designpatterns
Published: 2023-11-30 19:46:52

A common pattern when using a `for` loop is to combine it with an `else` statement. This is possible in many template engines, such as [Twig](https://twig.symfony.com/doc/3.x/tags/for.html#the-else-clause), as shown below:

```twig
<ul>
  {% for user in users %}
    <li>{{ user.username|e }}</li>
  {% else %}
    <li><em>no user found</em></li>
  {% endfor %}
</ul>
```

Yet in programming languages like JavaScript, a `for...else` construct is not supported:

```js
for (const user of users) {
  console.log(user.username);
} else { // ❌ this is not working
  console.log("no user found");
}
```

The `else` keyword only works in combination with the `if` keyword. That's the limit, but also a solution:

```js
if (users.length > 0) {
  console.log("no user found");
} else {
  for (const user of users) {
    console.log(user.username);
  }
}
```

"Reversing" the logic let us approach the `for...else` pattern. Instead of writing the loop first then the `else`, we're checking the "no user" case first, to end up in the loop after the `else`. Here the `else` block only contains one statement: the `for` statement. We can remove some curly brackets and shorten the code:

```js
if (users.length > 0) {
  console.log("no user found");
} else for (const user of users) {
  console.log(user.username);
}
```

That's the closest I get from a `for...else` pattern in JavaScript. What do you think? Do you see a closer one?
Stop Taking Programming Notes
Published: 2023-11-30 19:37:05


Instead of just reading a million notes and trying to remember everything, let's make it way more exciting. Our friend, who's really good at coding, had a clever idea. Instead of spending hours writing notes and drawing fancy diagrams, they decided to do something way cooler.

Whenever they learned something new, like a fancy word or a special coding trick, they opened up their computer editor – that's like a magical place where you can create all sorts of cool stuff with code. Right next to it, they had a tutorial, like a guide that helps you understand things step by step.

Here's where the magic happens: If our friend didn't get something while reading, they didn't just scratch their head and feel stuck. Nope! They simply started writing the code right away. It's like turning learning into a game!

For example, when learning about Constructors (it's a bit like a special code recipe), our friend would copy some code into their editor, change a few things around, and see what happens. It's like experimenting with colors in a coloring book – you mix and match until it looks just right!

This way, they learned not just what Constructors are but also how to use them in real projects. It's like learning to ride a bike by actually riding, not just reading about it. Cool, right?

They called this way of learning "applied learning," which means you're not just reading and memorizing boring stuff. Instead, you're diving in and using what you learn right away. It's like learning to play a new game by actually playing, not just reading the rules!

## 🍡Figma can help you develop faster!
Figma is a fantastic tool for developers. The majority of designers use [Figma](https://psxid.figma.com/pq1612tcamkx) to transfer web and mobile app blueprints. Given this tendency, web and mobile developers need to familiarize themselves with Figma to work with UI/UX designers. If you don't know how to work with Figma Design, you will fall behind in modern coding projects, leading to unproductive website building, and you will have to learn it in the future. So [sign up now](https://psxid.figma.com/pq1612tcamkx) and play around with it before your colleagues or boss blame you. 👇

![Figma Design](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12oebiywuvtw77nr96cu.png)

So, in a nutshell, while notes and diagrams are helpful for big ideas, the absolute best way to remember cool things like coding is to get your hands dirty and have fun with it. It's like learning to make awesome art by actually painting, not just staring at pictures.

Comment below your thoughts. It might help someone in the world.

Happy coding!

**My Socials:** [Linkedin](https://www.linkedin.com/in/codewithshahan) | [X](https://twitter.com/shahancd)


Stay tuned for more valuable content, and if you find it helpful, you may also like my [YouTube channel](https://www.youtube.com/programmingwithshahan?sub_confirmation=1). 

**[Buy Me a Coffee](https://www.buymeacoffee.com/codewithshahan)**
GCD of Strings Fix
Tags: python
Published: 2023-11-30 19:30:07

GDC, Greatest Common Divisor.

1st.
```
class Solution:
    def gcdOfStrings(self, str1: str, str2: str) -> str:
        #get the same string on str1 and str2 and print
        result =""
        i,j = 0,0
        while i < len(str1) and j < len(str2):
            result = str1[i]
            result = str2[j]
            i += 1
            j += 1
        result += str1[i:]
        result += str2[j:]
        return result
```
I thought I could get through this coding test by using the same code we used last time. I was not sure how to write the prefix part, so I asked AI, but I could not get the correct answer.

I tried editing the code several times but I could not pass this test case.

> Input
str1 =
"ABABAB"
str2 =
"ABAB"
Output
"AB"
Expected
"AB"


This comment helped me.
https://leetcode.com/problems/greatest-common-divisor-of-strings/description/comments/1782570

I learned that it is better to divide a given string evenly.

```
class Solution:
    def gcdOfStrings(self, str1: str, str2: str) -> str:
        if str1 == str2:
            return str1

        # Find the length of the shorter string
        n = min(len(str1), len(str2))

        # Iterate over candidate string lengths
        for i in range(n, 0, -1):
            # Check if the candidate string is a divisor of both strings
            if len(str1) % i == 0 and len(str2) % i == 0:
                candidate = str1[:i]
                if candidate * (len(str1) // i) == str1 and candidate * (len(str2) // i) == str2:
                    return candidate

        return ""
```
How single responsibility of a function helps to write better code
Tags: webdev, javascript, tutorial, beginners
Published: 2023-11-30 19:28:28

Let's consider this example code,

```js
app.post('/user', (req, res) => {
  const userData = req.body

  if (!userData.name || !userData.email) {
    return res.status(400).json({ error: 'Name and email are required' })
  }

  User.create(userData, (err, newUser) => {
    if (err) {
      return res.status(500).json({ error: 'Failed to create a new user' })
    }
    return res.status(201).json(newUser)
  })
})
```

It does two things inside a single handler,

- validates the input data
- creates a new user

Let's refactor this code to follow the single responsibility principle. Separate the validation of user data and saving the user as separate functions,

```js
function validateUserData(userData) {
  if (!userData.name || !userData.email) {
    throw new Error('Name and email are required')
  }
}

function saveUserToDatabase(userData) {
  return new Promise((resolve, reject) => {
    User.create(userData, (err, newUser) => {
      if (err) {
        reject(new Error('Failed to create a new user'))
      } else {
        resolve(newUser)
      }
    })
  })
}
```

Now, keep the route handler as simple as possible,

```js
app.post('/user', (req, res) => {
  const userData = req.body

  try {
    validateUserData(userData)
  } catch (error) {
    return res.status(400).json({ error: error.message })
  }

  saveUserToDatabase(userData)
    .then((newUser) => res.status(201).json(newUser))
    .catch((error) => res.status(500).json({ error: error.message }))
})
```

Hope this article helps you to learn how single responsibility principle helps you to write self explanatory code 🚀
Is My Data Safe on JobForm Automator?
Tags: job, productivity, security, automation
Published: 2023-11-30 19:08:30

In today's digital world, the safety and privacy of your personal information are paramount. At JobForm Automator, we deeply understand this responsibility. That's why we've built our platform with industry-leading security measures.

Encryption and Secure Storage: Rest assured, your data is encrypted and stored securely. Our state-of-the-art encryption ensures that your personal information is protected from unauthorized access.

User Control and Privacy: We believe in giving you full control over your data. With JobForm Automator, you have the flexibility to delete your account at any time. When you choose to delete your account, we ensure that your data is permanently removed from our servers.

Ongoing Commitment to Security: We are committed to continuously improving our security measures. Our team stays up-to-date with the latest security trends and technologies to safeguard your information.

In conclusion, at JobForm Automator, your data’s safety is our top priority. We strive to provide a secure and reliable service, so you can focus on what matters most – landing your dream job.

Thank you for trusting us with your job application process.

Sincerely,
[Saurabh Belote]
Founder, Aiking Solutions
Ruby Syntax
Published: 2023-11-30 18:36:00

Ruby syntax looks like this:

```
2.add(3)
```
- The thing on the left side of the (.), is called the **object**.

- The thing on the right side of the (.), is called the **method**.

- There are two parts within the method (refer to example above):
1. _add_ is called the **name** of the method.
2. _(3)_ is called the **argument** to the method.

The object, method, and argument make up an **expression**

An expression is **evaluated** and the method **returns** another object, which replaces the expression.

----

Ruby evaluates expression by searching for the first _complete, self-contained_ expression.

In order to display the result of each expression we have to explicitly command it to print the lines that we want to see.
💰SAVE Up To 500$ on TW Elements❗️
Tags: webdev, javascript, programming, tailwindcss
Published: 2023-11-30 18:30:00

**📢Last Days of LIMITED Cyber Monday PROMO❗️**
💰SAVE Up To 500$❗️
🎁3 months 🆓#HOSTING Cyber Week Only🤖
⚡️Lifetime usage
⚖️non-AGPL Commercial License 
🔌12 months of updates
🧱 Powerful Components 
🖼️ Beautiful Design Blocks

**🎁3 months 🆓#HOSTING Cyber Week Only🤖**
_With every purchase of TW Elements commercial license during Cyber Week, you get an option to claim 3 months of Premium hosting for free. 1G RAM/project, custom domains, SSL support, Jenkins automations, 1G size/database & more! You will be able to claim the gift on the Thank You page, after the purchase._

🤖Cyber Week Offer ends 01.12⏬
[TW Elements](https://tw-elements.com/pro/)
Micro CLIs?
Tags: webdev, backend, cli
Published: 2023-11-30 18:24:47

CLIs (Command-Line Interface Applications in short) are a damn useful way to facilitate automation. It has one type of input (strings) and one type of output (again strings). Simple, but very fast and effective, also loved by productivity junkies.

This is a blog on asking whether CLIs can be used along with microservices effectively. Because I used it in one of my use cases, and it resulted in major performance and stability for the overall solution.

So why CLIs in the first place? ...
Well the list says
* Doesn't take up lots of space. Generally tiny binary sizes compared to GUI counterparts.
* Depending on the size of tasks, CLIs generally don't crash as OS usually switches to swap to free up memory when RAM is at full capacity.
* Easier to develop 

But we already have servers for that .... right?

Well, kind of .... even servers are bins and scripts running on the machine, but are very complex. A server has more points of failure than an installed binary. Also updating said binaries is a breeze, just replace the file with a new one.


So, does 1 BIG CLI app that can do all the necessary tasks on the server when deployed be enough? Well, it depends. If the number of tasks to be performed on the server is minimal, then yes. But, if there are 2 or more different tasks, that have a common task to be performed, then distributing the tasks into multiple CLI is beneficial. Let me explain this tho ... 

Let's say there is a pipeline setup where the repository is cloned, and built and the binary is uploaded to another path. There are 3 tasks on the top layer, they're clone, build and upload. These 3 tasks can be written into 1 binary. But, if you want to add another pipeline, with a bit different build and upload process, you may choose to add it to the same CLI using options. That will work, but in the long run, code maintenance will be complex. So, it's better to split the tasks into 2 different CLIs, one for the first pipeline and another for the second pipeline. This way, the code is easier to maintain and update.

So the clone part of the pipeline is common for both pipelines, so it can be written into a separate CLI. The build and upload part of the pipeline is different for both pipelines, so they can be written into 2 different CLIs. This way, the code for the clone can be maintained in only 1 place.

This is the basic idea of micro CLIs. They're small, simple and easy to maintain. They're also easy to update and deploy. They're also easy to test and debug. They're also easy to scale. They're also easy to monitor. They're also easy to secure. They're also easy to document. They're also easy to use. They're also easy to integrate. They're also easy to .... you get the idea.

This is how I used micro CLIs in my automation solution provided in my previous organization's hackathon. I automated a task that could be deployed by any server. The task to be automated was time-consuming and a few modules in it separately could be used by other teams' solutions to speed up their solutions. That's when I architected the solution to be a micro CLI. It worked like a charm.
Shared model memory
Published: 2023-11-30 05:24:50

## Java memory model
JMM is Java Memory Model, which defines the abstract concepts of main memory and working memory. The bottom layer corresponds to the CPU.
Registers, cache, hardware memory, CPU instruction optimization, etc.
JMM is reflected in the following aspects:
Atomic - Guarantees that instructions will not be affected by thread context switching
Visibility - Ensure instructions are not affected by CPU cache
Orderliness - ensures that instructions are not affected by CPU instruction parallel optimization

## Visibility

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


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/95s7je1y40st9b1lvrbp.png)

- Use volatile to solve visibility problems
Volatile can use Ali to modify member variables or static member variables. It can prevent threads from caching their own work.
To query the value of a variable in the main memory, you must obtain its value from the main memory. When threads operate volatile variables, they directly operate on the main memory.
live

- Locking can also solve visibility problems
Modifications of volatile variables by one thread are visible to another thread, and atomicity cannot be guaranteed.
The synchronized statement can not only ensure the atomicity of the code block but also ensure the visibility of the variables within the code block.
The disadvantage is that synchronized is a heavyweight operation with relatively low performance.
volatile is suitable for scenarios where one thread writes and multiple threads read.

## Orderliness
The JVM can adjust the execution order of statements without affecting the correctness. This feature is called instruction redundancy.
Arrangement, and instruction rearrangement under multi-threading will affect correctness.
Como e por que usar aria-live
Tags: webdev, screenreader, a11y, portugues
Published: 2023-11-30 18:20:26

_**Nota:** apenas traduzi o texto abaixo e postei aqui._

O que acontece se você tiver um conteúdo que muda dinamicamente em sua página? Como screen readers informam ao usuário que o conteúdo mudou?

Por exemplo, imagine que você tenha um input para os usuários digitarem seus nomes. Abaixo dele, você tem um elemento que exibe "Olá {nome do usuário}!" em runtime enquanto digitam. Como um usuário de screen reader sabe sobre a mensagem no #app element?

```html
<label for="name">Qual é seu nome?</label>
<input type="text" id="name">

<div id="app"></div>
```

De modo geral, screen readers não notarão ou anunciarão essas alterações, a menos que você lhes diga que precisam.

O aria-live attribute permite que os screen readers saibam que o conteúdo de um determinado element mudará dinamicamente e que eles devem prestar atenção a isso e anunciar essas mudanças.

Seu valor pode ser **off** (o mesmo que não usá-lo), **assertive** (no qual screen readers interrompem as ações do usuário para anunciar alterações) e **polite** (que diz ao screen reader para esperar até que o usuário termine de anunciar as atualizações).

De modo geral, devemos sempre usar **polite**.

Se atualizarmos nosso HTML para ficar assim, agora os screen readers anunciarão alterações no conteúdo do #app element.

```html
<label for="name">Qual é seu nome?</label>
<input type="text" id="name">

<div id="app" aria-live="polite"></div>
```

Saúde,

### Fonte

Newsletter de [Go Make Things](https://gomakethings.com/)