teleren/devto huggingface dataset:
Begineer: Synchronous vs Asynchronous Programming
Tags: beginners, tutorial, javascript, programming
Published: 2023-07-25 23:01:53

## Synchronous Programming
Synchronous programming is perfect for when you have tasks that you know are non-time consuming and will simply run one after the other.  Each task has to fully finish executing before the next task is started when using synchronous programming. You can look at it as a queue, first task that enters the queue fully executes and then the next task in the queue repeats the same process until the queue is empty.

When utilizing synchronous programming you can easily predict the order in which each task will execute. However this can be very slow for certain tasks such as making multiple network requests or I/O operations such as reading from a file or writing to a file. This is because each task has to finish running before it continues.

## Asynchronous Programming
This is where Asynchronous programming comes into the picture. It allows you to offload time-consuming tasks onto another thread which means the code being executed on the main thread will not completely freeze in order to wait for our time-consuming code to execute.

In comparison to synchronous programming, asynchronous programming allows you to execute time-consuming tasks and return the result whenever it is ready without blocking other code from executing.

## Example Difference
While JavaScript itself does not use threads, because it uses a model called the "Event Loop" it can still be used to demonstrate the difference between synchronous and asynchronous with the use of promises.

**Synchronous**
```JS
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

console.log("Sync: Hello"); // This will run instantly
await sleep(5000); // This will block the execution of any code until 5 seconds have passed
console.log("Sync: World!"); // This will run after 5 seconds
```

**Asynchronous**
```JS
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

console.log("Async: Hello"); // This will run instantly
sleep(5000).then(() => console.log("Async: I am late :(")); // This will run after 5 seconds but will not block code execution
console.log("Async: World!"); // This will run instantly
```
Writing a NES game, day 13, no more moondance
Tags: assembly, 6502, nintend, gamedev
Published: 2023-07-25 22:59:17

Up until now, when I moved left or right, the character was just changing the positions, but the character itself didn't change at all, when it was going left it just felt like "moonwalking". At least I need the character to be able to look to another direction when waking left.
One problem with that is that creating new sprites for that can be kind of a "waste" because space is very limited, so, what I need to do is reuse the same sprites and flip them.

First in ZEROPAGE segment I need a new variable which is for the direction, so 0 is right, 1 is left.

```
pdir: .res 1 ;player direction 00 right, 01 left
```
The second thing that I need is to update the value every time **moveLeft **or **moveRight **is called

```
moveLeft:
    LDA p1x
    SEC
    SBC #01
    STA p1x
    LDA p2x
    SEC
    SBC #01
    STA p2x
    LDA #$01
    STA pdir
    RTS

moveRight:
    LDA p1x
    CLC
    ADC #01
    STA p1x
    LDA p2x
    CLC
    ADC #01
    STA p2x
    LDA #$00
    STA pdir
    RTS
```
And finally, this will affect the update of the sprites, so I needed to do some changes here for the character part:

```
 LDA #$00
    CMP pdir
    BEQ rightCharTiles
    LDA #$01
    STA $0201
    LDA #$00
    STA $0205
    LDA #$11
    STA $0209
    LDA #$10
    STA $020D
    LDA #$40
    STA $0202
    STA $0206
    STA $020A
    STA $020E
    JMP charTilesDone
    rightCharTiles:
    LDA #$00
    STA $0201
    LDA #$01
    STA $0205
    LDA #$10
    STA $0209
    LDA #$11
    STA $020D
    LDA #$00
    STA $0202
    STA $0206
    STA $020A
    STA $020E
    charTilesDone:
    LDA p1y
    STA $0200
    STA $0204
    LDA p2y
    STA $0208
    STA $020C
    LDA p1x
    STA $0203
    STA $020B
    LDA p2x
    STA $0207
    STA $020F
```
Now I can turn the character around:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0t140clrrp10ypp69foe.PNG)

As always, the code can be found at [my github repo](https://github.com/Draculinio/rindelia1).
Embracing the Power of Open Source:My Journey from Confusion to Collaboration
Tags: 100daysofoss, opensource, javascript, react
Published: 2023-07-25 22:33:10

As a coding enthusiast with over a year of experience, I can't believe it took me so long to truly understand the significance of open source in the tech world. When I first heard about open source, I was utterly confused and overwhelmed. But now, as I delve into its world, I can't help but be amazed by the power of collaboration and innovation it embodies. In this blog post, I'll share my personal experience as a newbie to open source, hoping to shed light on the path for others who might find themselves in the same position.

**Understanding Open Source**
Before now, The concept of open source seemed foreign and complex to me. I couldn't fully understand how software could be open for anyone to modify and contribute to. However, as I read and made more research,I came to understand that open source is about empowering individuals and fostering collaboration.

**The Power of Collaboration**
One of the most incredible aspects of open source is the collaboration it encourages. As someone who had mostly worked on personal projects, I was amazed at the idea of developers, designers, and enthusiasts coming together to build something greater than the sum of its parts. This collective effort leads to the creation of robust and innovative solutions that benefit everyone involved.

**Benefits of Open Source**
The benefit of open source is that it promotes collaboration and transparency. It allows anyone to view, modify, and distribute the source code of a software or project freely. This fosters a community-driven approach to development, encouraging innovation, and enabling collective problem-solving. As a result, open source often leads to higher-quality software, faster development cycles, and greater adaptability for various applications.

**Contributing to Open Source**
The notion of contributing to open source initially appeared daunting. I believed that only seasoned programmers could truly make a difference. However, I soon uncovered that open source projects extend a warm welcome to contributions from individuals with diverse skill sets. Whether it entails testing, documenting, or providing feedback, every contribution is held in high esteem.

**The Right Time to Leverage Open Source**

As a relative newcomer to open source, I wondered when the right time would be to leverage its power. Looking back, I now realize that the answer is simple: anytime is the right time. Regardless of your coding experience, open source provides an environment that nurtures growth and learning. Even as a beginners.

**Conclusion**
My journey into the world of open source has been eye-opening and transformative. I've come to appreciate the significance of open source in driving innovation and building a supportive global community. As I continue to explore and contribute, I encourage fellow coding enthusiasts not to relent in embracing open source. The 
power of collaboration and wealth of knowledge it offers are waiting to be tapped into.
Chesterton's Fence: Its Significance in Software Engineering
Tags: refactoring, programming, codequality, softwareengineering
Published: 2023-07-25 22:32:09

## A cautionary tale:
Allow me to set the scene. Two software engineers are in a Slack huddle as they discuss a refactor to the codebase they have been working of weeks:

**Me:** "This code is completely useless. It must be outdated and left over from a previous iteration of the app. I'm going to delete it."

**My smarter, better-looking coworker:** "What did it do?"

**Me:** _blank, empty stare recognizing I have no idea_

And that is when my coworker introduced me to the concept of Chesterton's Fence.

## The Analogy
From the man himself, G. K. Chesterton:

> There exists in such a case a certain institution or law; let us say, for the sake of simplicity, a fence or gate erected across a road. The more modern type of reformer goes gaily up to it and says, “I don’t see the use of this; let us clear it away.” To which the more intelligent type of reformer will do well to answer: “If you don’t see the use of it, I certainly won’t let you clear it away. Go away and think. Then, when you can come back and tell me that you do see the use of it, I may allow you to destroy it.”

The principle can be summarized as something like this: If you come across a fence that seems to have no purpose, rather than rushing to tear it down, first seek to understand why it was built in the first place. It may be that there was a good reason for its existence that isn't immediately apparent.

## The Application
As programmers, we often encounter "fences" in our codebase that seem outdated, unnecessary, or downright illogical. The eager, reformist, instinct is to refactor or eliminate them immediately. But applying Chesterton's wisdom, we should first take the time to understand why that piece of code exists.

Could it be solving a problem that is no longer present but may reappear? Could it be supporting functionality that seems irrelevant but is, in fact, vital in certain edge cases? Could it be a necessary 'ugliness' due to hardware constraints, business requirements, or tech debt that we should be aware of?

Just as Chesterton warned against tearing down fences without understanding their purpose, we should caution ourselves against altering code without fully grasping why it was written that way. An apparent 'messy' piece of code might be a brilliantly crafted solution to a problem you've yet to encounter.

## The Take Away
So, the next time you encounter a piece of code that seems like an outdated 'fence', remember Chesterton's advice: understand it before you rush to dismantle it. Our job as software developers isn't just to write code - it's to read, understand, and respect the wisdom that often lies in the lines written by others before us.

Or perhaps it is simply just out of date code that should have been deleted months, or even years, ago. However, you would be smart to ensure that you have an understanding of its purpose, and any continued use, before removing said code.
Introducing the Warm Welcome Badge! 🌟🎉
Tags: meta, design, welcome, badges
Published: 2023-07-25 22:24:31

It is with great enthusiasm that we share this post today, because we are coming at you live with a new badge.

## Presenting... our Warm Welcome badge!


![Warm Welcome Badge](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8imevtjrbcnk10hedqny.png)



**This exclusive badge recognizes our outstanding online contributors and dedicated members who consistently engage with our Welcome Thread.**

---

_Not familiar with the Welcome Thread yet? No worries! Here's the link for you to explore:_
{% embed https://dev.to/welcome %}

---

**Here's how it works**: Every week, we'll handpick individuals based on their active participation in the thread and their overall contribution to our fantastic community. So, the more you engage in the Welcome Thread and help welcome new members, the higher your chances of receiving the Warm Welcome badge! 😊

**Why did we create this badge?** Recent data has shown that engaging with folks in the Welcome Thread fosters a sense of welcome and excitement to participate in our community. This affirms our commitment to inclusivity, and we're thrilled to set tangible goals to make our newbie DEV members feel at home.

We are genuinely thrilled by the enthusiasm in the Welcome Threads and hope this new badge expresses our deep appreciation for each one of you. Together, we're building an inclusive tech community that we can all be proud of! 👏💬

**Cheers,
The DEV Team**
🔍 Top 10 Websites Every Developer Should Know 🔍
Tags: webdev, beginners, programming, productivity
Published: 2023-07-25 22:22:28



👩‍💻 Being a developer means staying up-to-date with the latest tools and resources. Here's a thread with ten must-know websites that will boost your skills and productivity. Let's dive in! 👇

1️⃣ GitHub (github.com):
A treasure trove of open-source projects, collaboration, and version control. Contribute, discover, and showcase your work on the world's largest developer platform. #GitHub #OpenSource

2️⃣ Stack Overflow (stackoverflow.com):
The go-to place for developers to seek solutions and share knowledge. Ask questions, find answers, and get involved in the thriving developer community. #StackOverflow #DeveloperCommunity

3️⃣ MDN Web Docs (developer.mozilla.org):
An extensive resource for web developers with in-depth documentation on HTML, CSS, JavaScript, and more. Stay ahead in web development with MDN. #MDNWebDocs #WebDevelopment

4️⃣ CodePen (codepen.io):
A playground for front-end developers to experiment with HTML, CSS, and JavaScript code snippets. Showcase your creations and get inspired by others' work. #CodePen #FrontEndDev

5️⃣ Dev.to (dev.to):
A welcoming platform for developers to share knowledge, experiences, and insights. Engage with the community, learn new concepts, and level up your skills. #DevCommunity #Learning

6️⃣ HackerRank (hackerrank.com):
Sharpen your coding skills through challenges and competitions. Improve problem-solving abilities and get noticed by top tech companies. #HackerRank #CodingChallenges

7️⃣ Smashing Magazine (smashingmagazine.com):
A fantastic resource for web designers and developers. Stay updated with the latest trends, tips, and best practices in the industry. #SmashingMagazine #WebDesign

8️⃣ CSS-Tricks (css-tricks.com):
The ultimate place to learn and master CSS tricks and techniques. Enhance your front-end development skills with valuable tips and tutorials. #CSSTricks #FrontEndTips

9️⃣ LeetCode (leetcode.com):
Crack coding interviews and enhance problem-solving skills with real coding questions. Prepare for technical interviews and land your dream job. #LeetCode #CodingInterviews

🔟 Awwwards (awwwards.com):
For web designers seeking inspiration and recognition, Awwwards showcases outstanding website designs that push the boundaries of creativity. #Awwwards #WebDesignInspiration

💡 Bookmark these websites and explore them regularly to stay at the forefront of the developer community. Happy coding! 🚀 #DeveloperResources #WebDevelopment #Programming

(Note: URLs are fictional and provided as examples. Please use the actual URLs of the mentioned websites.)
Resetting MySQL Root Password in Ubuntu: A Step-by-Step Guide
Tags: mysqlpasswordreset, mysql, ubuntu, webdev
Published: 2023-07-25 22:14:18

***Introduction:***
Losing or forgetting the MySQL root password can be a stressful situation, but don't worry; there's a way to regain access to your MySQL database in Ubuntu. In this article, I will walk you through a step-by-step guide on how to reset the MySQL root password on your Ubuntu system. We will use a method that involves stopping the MySQL service, creating a temporary configuration file, and setting a new password for the root user.

**Step 1: Stop the MySQL Service**
The first step is to stop the MySQL service to ensure we can safely proceed with the password reset process. Open your terminal and run the following command:

```
sudo service mysql stop
```

**Step 2: Create a Temporary Configuration File**
Next, we'll create a temporary configuration file to start the MySQL service without password authentication. This will allow us to reset the root password. Run the following command to create the file:

```
sudo nano /etc/mysql/mysql.conf.d/reset-mysql-password.cnf
```
**Step 3: Add Configuration to the File**
In the nano editor, add the following lines to the reset-mysql-password.cnf file.

```
[mysqld]
skip-grant-tables
```
To save the changes and exit the editor, press CTRL + X, then type Y, and finally, press Enter.

**Step 4: Start MySQL Service in Safe Mode**
With the temporary configuration file in place, start the MySQL service in safe mode:

```
sudo mysqld_safe --skip-grant-tables &
```

*Step 5: Connect to MySQL Without Password*
Now, we can connect to the MySQL server without entering a password. Open a new terminal window and run the following command:

```
mysql -u root

```

**Step 6: Set a New Password for Root User**
Once you are connected to the MySQL prompt, it's time to set a new password for the root user. Execute the following SQL commands:

```
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'YOUR_NEW_PASSWORD';
```
Replace 'YOUR_NEW_PASSWORD' with your desired password. The FLUSH PRIVILEGES; command ensures that the changes take effect immediately.

If you get the following error while using weak password
```
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
```
You can fix this like below, if you want to use weak password(Not recommended)

```
SHOW VARIABLES LIKE 'validate_password%';
SET GLOBAL validate_password.policy=LOW;
```
Now again run the password update sql:

**Step 7: Exit MySQL and Remove the Configuration File**
After setting the new password, exit the MySQL prompt:

```
exit;
```
Remove the temporary configuration file:

```
sudo rm /etc/mysql/mysql.conf.d/reset-mysql-password.cnf
```

**Step 8: Restart MySQL Service**
Finally, restart the MySQL service to apply the changes:

```
sudo service mysql restart
```
Congratulations! You have successfully reset the MySQL root password on your Ubuntu system. Now you can access your MySQL database using the new password you set. Always make sure to keep your MySQL root password secure .
Exploring Database Interaction in elm-pages-v3 (nextjs/remix for elm)
Tags: elm, elmpagesv3, webdev, nextjs
Published: 2023-07-25 22:09:00

Let's examine the persistence in the TODO app example (https://github.com/dillonkearns/elm-pages/tree/master/examples/todos).

## Overall project structure

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

* `app/Route/` files - one per page, has `pages`, `data`, and `view` functions; `pages` runs at build time (or on server); `data` runs at build time (or on server); `view` runs at build time (or on server) and on client (e.g. Visibility__.elm, Login.elm)
  * `data` function can refer to `Backend.Custom` tasks, which call out to functions exposed from local node js libraries. In particular, there is a `custom-backend-task.ts` file which defines functions wrapping prisma db calls.

* `app/` files contains sitewide utilities like layout, menu messages, and global state

* `prisma/schema.prisma` defines the database schema

* `src/*` contains local elm libraries of functions that route modules and others can use. elm-pages-v3 recommends using `app` for well known files required by the framework, and using `src` for additional elm source code

## Interaction with backend persistence

reads

* Receive any necessary parameters as data from front end, encode as a parameter object and send to backend custom functions. (`Backend.Custom.run "getTodosBySession" (Encode.string parsedSession) resultDecoder` where `parsedSession` is the parameter in this case.)

* The custom backend function receives arguments, runs call, responds with result.

* The response is decoded back to elm types, using the `resultDecoder`. The result is used building out a `Data` instance and eventually invoking `Server.Response.render` with this `Data` instance.

writes

* something triggers an update action, which reaches `performAction`

* receive data from action, encode it and other arguments to send to backend custom function (`BackendTask.Custom.run "createTodo" (Encode.object [ ( "sessionId", sessionId |> Encode.string ) ] ) noopDecoder`)

* the custom backend function receives arguments, runs call 

* the response is decoded to elm types, which results in no value in this case, and then `Server.Response.render` with a populated `ActionData`
How to use Autoclass in Cloud Storage
Tags: cloudstorage, cloudcomputing, gcp, cloud
Published: 2023-07-25 22:00:18

Autoclass is quite a powerful feature from Cloud Storage that many users are still not aware of!

If you missed the [announcement post](https://cloud.google.com/blog/products/storage-data-transfer/learn-about-google-clouds-latest-storage-product-innovations), I am borrowing a quote from the post:

> To make it easier to manage storage and help you optimize your costs, we’ve developed a new Cloud Storage feature called Autoclass, which automatically moves objects based on last access time, by policy, to colder or warmer storage classes. We have seen many of you do this manually, and are excited to offer this easier and automated policy-based option to optimize Cloud Storage costs.

It is quite simple to enable it from Cloud Console UI:

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

## How does Autoclass work?

- Objects are initially created in Standard storage.
- After a period of 30 days without any access, they are automatically moved to Nearline storage.
- If an object remains untouched for 90 days, it is then transferred to Coldline storage.
- If the object continues to be inactive for 365 days, it is finally moved to Archive storage.
- However, should an object be accessed at any point during this process, it will return to Standard storage, and start the process again from the beginning.

## What about the Autoclass cost?

The only cost for Autoclass is a management fee of $0.0025 for every 1000 objects stored within them.

So if you are looking to reduce storage costs and achieve price predictability in a simple and automated way, Autoclass might help you!
Day 790 : Uknowhut?
Tags: hiphop, code, coding, lifelongdev
Published: 2023-07-25 21:43:54

_liner notes_:
- Professional : Whew... got up super early to take my father for a doctor's appointment. Made it back in time to take a quick nap before starting work. Spent the day refactoring some demo applications so that they are a little easier to use and understand what they are doing. Made some pretty good progress.

- Personal : Last night I went through some tracks for the radio show. I also did some quick layouts for the front end of my side project. Uknowhut? I realized there are less pages I need to make, so that's good. Went to bed early because I had to get up early in the morning.

![Inside Redwood Nat'l Park, CA, USA looking at moss covered tree barks and branches with some sunlight shining through.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ro0qa6lg75c2d30jbqnh.jpg)

Going to eat dinner, go through tracks for the radio show, start creating the front end for my side project. I want to watch some anime to end the night.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube CyDJZERI0n4 %}