teleren/devto huggingface dataset:
Eliminating Code Complexity by Finding Double Negatives
Tags: ruby, programming, webdev, softwareengineering
Published: 2024-02-13 02:55:48

I have been reading “A Philosophy of Software Design,” and almost the entire book is spent either explaining the dangers of complexity in a codebase, or eliminating complexity.

Code, especially Ruby code, should make its intent loud and clear to the reader. Clear code is the opposite of complex code. It’s easy to understand its purpose, so it’s easier and less risky to modify, extend, or remove.

## Double Negatives
One thing that I haven’t seen explicitly discussed in this book is double negatives.

Whether it’s spoken or written, double negatives make sentences less clear. Something like “There are not no eggs left at the store” is obviously poor grammar, but it also makes the sentence harder to understand.

When our code reads like a sentence (well written Ruby should), double negatives increase complexity. Things like unless !some_condition can be more clearly written as if some_condition.

Most programmers will find writing in-line conditionals like this to be straightforward, but it gets less intuitive when extracting this logic into methods.

## An example
A bit ago, I was writing some ruby code with a friend. We wanted to take an action if something was false, and like the good ruby programmers we are, we extracted that complex conditional into its own short method.

We found ourselves going around and around trying to make this as clean as possible. One of our first iterations contained a programming double negative - see if you can find it:

```
# Method call
return [] unless items_found(users)


# Method implementation
def items_found(users)
  no_items_found = false
  users.each do |volunteer|
    if volunteer.items.present?
      no_items_found = true
    end
  end
  no_items_found 
end
Contrast this to what we ended up with
# Method call
return [] if no_items_found_for(users)


# Method implementation
def no_items_found_for(users)
  no_items_found = true
  users.each do |volunteer|
    if volunteer.items.present?
      no_items_found = false
    end
  end
  no_items_found 
end
```

It’s a pretty small change, but I think it highlights what the code actually does much better than the first time around. I’m trying to be more intentional about writing my code with these things in mind.
HTTP response status codes
Tags: webdev, javascript, tutorial, statuscodes
Published: 2024-02-13 02:42:41

**HTTP response status codes**


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

**HTTP status codes are essential for communication between the client-side and server-side components of your application.**
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:

Informational responses (100 – 199)
Successful responses (200 – 299)
Redirection messages (300 – 399)
Client error responses (400 – 499)
Server error responses (500 – 599)

Informational responses (100 – 199)
Successful responses (200 – 299)

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

Redirection messages (300 – 399)
Client error responses (400 – 499)

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

Server error responses (500 – 599)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qjgxqd09ff58w80nuu30.jpeg)
Podcast Palooza— What are you listening to? (Comedy Edition)
Tags: podcast, discuss
Published: 2024-02-13 02:02:09

Hey hey y'all! 

I'm Rachel (they/them) and I am DEV's loyal Content Creator over here on the Community Team, it's nice to meet ya if I haven't already!

I have been a long-time fan (and sometimes contributor) of @michaeltharrington 's [Music Monday Series](https://dev.to/michaeltharrington/series/17887) and am coming to you all from my humble corner of the internet in search of folks who want to do the same... but with podcasts...

**I would love for y'all to share with me what you have been listening to as of late! Share with me your favorite comedy podcasts (episodes and full podcasts both welcome).**

![Image of a cartoon person nodding his head with headphones on](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cxbqum2il8qpskr25dwb.gif)

---

_Also— we have our own #podcast tag here on DEV! If you want to host any other podcast-related discussions, or even share your own podcasts, that's your place!_

{% embed https://dev.to/t/podcast %}

---

Okay!!! Thanks so much for being here. Please share with me your favorite silly little podcasts because I would love to listen to them (screams in WFH).
Working with Streams in Node.js
Tags: node, security, javascript, beginners
Published: 2024-02-13 00:29:47

## Introduction

Node.js is a popular open-source JavaScript runtime environment that is primarily used for building server-side applications. One of the key features of Node.js is its ability to handle I/O operations efficiently, thanks to its use of streams. Streams in Node.js are objects that facilitate the transfer of data between a Node.js program and its environment or between two parts of the program.

## Advantages

1. **Efficiency:** One of the major advantages of working with streams in Node.js is their efficient memory usage. Instead of loading large chunks of data into memory, streams process data in small chunks, making it memory-efficient.

2. **Real-time data processing:** With streams, Node.js can process real-time data without waiting for the entire data to be streamed. This is particularly useful for applications such as chat servers, where data is received and processed continuously.

3. **Flexibility:** Streams in Node.js provide flexibility in handling data. It allows developers to read, write, or transform data as it is being streamed, thus providing more control over the data flow.

## Disadvantages

1. **Learning curve:** Working with streams in Node.js requires a good understanding of asynchronous programming and callbacks, which can be challenging for beginners.

2. **Debugging:** If a stream is not handled properly, it can lead to memory leaks, making it difficult to debug.

## Features

1. **Four types of streams:** Node.js offers four types of streams: Readable, Writable, Duplex, and Transform, making it suitable for a wide range of use cases.

2. **Piping:** Streams can be connected through piping, allowing data to be read from a source and written to a destination in a single flow.

### Example of Using Streams

```javascript
const fs = require('fs');
const readStream = fs.createReadStream('./source.txt');
const writeStream = fs.createWriteStream('./destination.txt');

// Piping data from readStream to writeStream
readStream.pipe(writeStream);
```

This example demonstrates how to use streams to read data from a file and write it to another file, showcasing the efficiency and simplicity of handling data with streams.

## Conclusion

In conclusion, using streams in Node.js has many advantages, such as efficient memory usage, real-time data processing, and flexibility. However, it also has its challenges, such as a steep learning curve and potential memory leaks. Nonetheless, streams are a powerful tool for handling data in Node.js and should be incorporated into web applications that require efficient data processing. Understanding streams and how to use them correctly can greatly improve the performance of Node.js applications.
How to add a Pre-loader in your webpage
Tags: webdev, programming, devops, javascript
Published: 2024-02-12 22:46:44

Loader/Throbber/Spinner
GIFchrome-capture

Essentially, pre-loaders (also known as loaders) are what you see on the screen while the rest of the page's content is still loading. Pre-loaders are often simple or complex animations that are used to keep visitors entertained while server operations finish processing.

In this tutorial, I have used SVG (Scalable Vector Graphics) for pre-loading animation. It's resolution independent and responsive. Images can be scaled the same way we scale all other elements in responsive web design.

So, to design the SVG, I have used Figma which is used for web-based graphics editing and user interface design app.

After editing and importing your frame as SVG, you now need to animate it. For basic animations, you can either use svgartista or svgator. If you want your own custom animations you can do it by using @keyframes in CSS.

This is a Pre-loader Pen, which I created using above methods and used it in my own portfolio website.



Now, how do we add this on our website?

Follow these steps to add a pre-loader
Create a loader.html and loader.css file and copy over the code for both HTML and CSS and then create a wrapper around it.
HTML

      <div class="loader-wrapper">
         <div class="loader"> <svg /*svg code*/></svg></div>
      </div>

CSS

     .loader-wrapper {
          width: 100%;
          height: 100%;
          position: fixed;
          top: 0;
          left: 0;
          background-color: whitesmoke;
          display: block;
          justify-content: center;
          align-items: center;
          z-index: 999;
          overflow: hidden;
  }
If done correctly, this is what you should get.

Screenshot (74)

Load Event
The loading Animation is ready. Next we’ll need hide it when the loading is complete. We can do that by listening to window load event which will trigger when all the elements have been completely loaded. Then use jQuery fadeOut method to hide the loader.

Make sure you have jQuery included in your project.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> </script>

Then to include loading animation page in your other HTML document use a div tag with id="loading".
<body>
<div id="loading"></div>  
</body>
In CSS file, import loader.css using
@import url(/assets/css/loader.css);
In JavaScript file, you have to call loader.html using
$.get("/assets/html/loader.html", function(data){
  $("#loading").replaceWith(data);
});
Then to trigger the loading animation everytime you load a page use this code:
$(window).on('load', function(){
  setTimeout(removeLoader, 2000); //wait for page load PLUS two seconds.
});
function removeLoader(){
    $( ".loader-wrapper" ).fadeOut(500, function() {
      // fadeOut complete. Remove the loading div
      $( ".loader-wrapper" ).remove(); //makes page more lightweight 
  });   
}
And that’s it! Very simple and straightforward😉✌
It takes the drama out of open-source
Published: 2024-02-16 20:37:18

---
title: It takes the drama out of open-source
published: true
date: 2024-02-13 00:00:00 UTC
tags: 
canonical_url: https://www.oliverdavies.uk/archive/2024/02/13/it-takes-the-drama-out-of-open-source
---

As well as the code changes, such as adopting Symfony components and other third-party code, one of my favourite things about Drupal since D8 is the new release cycle.

Instead of "It'll be ready when it's ready.", since Drupal 8, Drupal releases new versions on fixed dates.

If a feature is ready by that date, it will be included.

If not, it will be included in a later version.

As well as regular bug fixes and security updates, there is a new feature release every six months.

Drupal 8.1 included features like the Layout Builder, which wasn't included in 8.0.

In earlier Drupal versions, it would have been deferred to the next major version, making it longer before users get its benefits.

A fixed release schedule makes it easier for users and Developers to plan their updates and prepare to upgrade to the major version.

As Ryan said on a [recent episode of Beyond Blocks](https://www.oliverdavies.uk/podcast/10-ryan-weaver-symfonycasts), "It takes the drama out of open-source".

 P.S. Are you still using Drupal 7 and don’t know what’s involved to upgrade to Drupal 10? [Book a Drupal 7 upgrade consultation call](https://www.oliverdavies.uk/call) or [an upgrade roadmap](https://www.oliverdavies.uk/drupal-upgrade).
Looking for Honest Feedback
Tags: webdev, saas, feedback
Published: 2024-02-12 22:58:42

Hey guys, recently started trying to branch out of the corporate world by launching a company. I've been an engineer for over a decade now, but most of my experience these past few years has been server side. I tried building our company site using a site builder, but it just didn't feel right. My primary skills don't reside with the frontend side of things, but I can still get it done. With that said, Im working to get back up to speed with where things are headed right now!

Im not trying to sell anything (would be kind of weird to sell consulting services to my own kind lol), just looking for genuine feedback on the design and feel of the new site I just put up for my company. Any feedback would be appreciated 😊

[Progenix Software](https://progenixsoftware.com/)
Imagine Something In Detail
Tags: programming, coding, developer, builder
Published: 2024-02-12 22:57:34

I love making stuff; it’s that simple.

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

In high school, my favorite class was Ag Mechanics (mech), a curriculum focused on manufacturing. We learned welding, cutting, and milling metal, designing and manufacturing components, and undertaking substantial projects like constructing horse trailers.

I learned a lot in mech class, but what stuck out was the thinking patterns. When you’re tasked with making a horse trailer from raw steel, four wheels, and some ball bearings you have to think about it. It’s a different way to think; a principle of resourcefulness. It was then that I began to imagine in detail.

I couldn’t explain this new thinking process or distill it into a quote. All I knew was my thought pattern had changed. I was left to observe more skilled creators, like my mech teacher, and explore my thoughts.

Fast forward 5 years. Post high school, I delved into programming and spent a lot of time learning about distributed ledgers. The more I learned about distributed ledgers the more I disliked the Blockchain/Bitcoin design. It was so slow and inefficient. I went looking for something better and seemed to find it. Hashgraph, an algorithm invented by [Dr. Leemon Baird](https://www.linkedin.com/in/leemon-baird/) now used in the Hedera platform.

I reached out to Dr. Baird and asked if he would join me and some others to discuss his new technology. He agreed and we formed a meetup. Speaking with Dr. Baird afterward, he said, “I always liked programming because if I could imagine something in enough detail, it existed.” Suddenly, everything made sense.

Dr. Baird had articulated the thinking pattern I had been learning for 6 years. I wasn’t able to explain it or harness it because I hadn’t fully grasped the scope of this thought pattern. Once Dr. Baird articulated this idea, I was able to fully explore this thinking pattern.

In the years since I started to imagine in detail, I’ve made a lot of things. Some good, and many bad, but all useful in the practice of thinking. With each new development effort, whether digital or physical, I start by imagining the product of my work in the greatest detail possible. From there I can quickly identify many of the problems I will face and address them ahead of time.

Imagining in detail is no silver bullet. When creating something sufficiently beyond your experience level you will run into unexpected issues. Nonetheless, framing your thinking patterns to image in detail will improve your abilities as a creator, whether that be a programmer, an architect, or an artist.

If you want to see the latest project I’ve been imagining in detail, checkout [GIGO Dev](gigo.dev). GIGO is our take on the best way to learn to code. GIGO focuses on reducing friction for new developers and making it as easy as possible to work on projects. We just released GIGO Bytes, bite-sized programming challenges with our AI code tutor Code Teacher baked in!

The next time you make something, imagine it in great detail.
3 Ways to restore your deleted files
Published: 2024-02-12 22:39:42

Accidentally Deleted Something?
We're talking about accidentally deleting important files using the Shift + Delete shortcut in Windows, which removes the possibility to simply recover them from the Recycle Bin.

Don't lose hope...
Let me tell you three different ways to recover the permanently deleted files on Windows 10.

Restore using CMD
Restore using older backup
Restore using Third Party App
Let's start recovering data...
GIFgif-vest
Restore using CMD
Step 1: Open the Start Menu.

Step 2: Type cmd, right-click on the top match and select Run as administrator.

Step 3: Type chkdsk X: /f and hit Enter on your keyboard. Replace X with the letter of your hard drive.

Step 4: Type ATTRIB -H -R -S /S /D X:*.* and hit Enter. Again, replace X with the letter of your hard drive.

What do these parameters in ATTRIB command mean?

-H: it gives the Hidden attribute to the files specified.
-R: it refers to the read-only attribute (files can be read but cannot be changed).
-S: it gives the System attribute to the files specified.
/S: it tells the system to search the specified path (including subfolders).
/D: it consists of process folders.

recover-files-using-cmd-2

The recovery process may take a while to finish, so be patient and don't interrupt it.

Restore using older backup
To restore files from a file backup that was created after the system image backup was created, follow these steps.

Step 1: Open the Start Menu.

Step 2: Search backup.

Step 3: Select the Go to Backup and Restore option under Looking for an older backup?.

Step 4: Click on the Select another backup to restore files from option and choose your backup.

Step 5: Click Next and follow the instructions to complete the recovery process.

Screenshot (104)

Restore using Third Party App
Step 1: Download and Install Disk Drill just like you would any other Windows application.

Step 2: Launch Disk Drill and click the Search for lost data button next to the hard drive which you want to recover permanently deleted files.

Step 3: From the list of results, select which files you want to recover.

Step 4: Click the Recover button to begin the recovery process.

MainScreenDiskDrill-1

Do you know more methods to recover our deleted data, please comment down below 👇🏻👇🏻
The-usage-of-artificial-intelligence-in-the-sitepoint-community/
Tags: webdev, javascript, beginners, programming
Published: 2024-02-12 22:36:38

We have noticed a significant spike in the usage of ChatGPT (or some other sort of AI tool) to provide answering posts. While we’re not sure the cause of the usage (English not being the native tongue, not being an expert on the topic, etc). there’s been a definitive increased pattern in its usage.

After much discussion privately, the community staff has decided that the drawbacks of using the tool at this time outweighs the benefits, and we’re going to be monitoring/removing posts which are obviously AI generated.

There are a number of reasons for this approach:

Since the AI cannot detect subtlety in questions asked (i.e. read between the lines an seeing what’s really being asked), the answers given, while technically correct, may not actually answer the question being given
The AIs depend on searching just like most of us do, and as we all know, the internet, while wonderful and powerful, doesn’t always give us what we’re asking for. The answers given may be out of date, erroneous, or incomplete.
As we all know, the AI responses SEEM really well written. This allows people to develop perceptions of “expertise” which may not be deserved. While that may seem harmless, answers which are given more credence due to this false sense of expertise may cause someone else’s valid (and more correct) guidance to be ignored because there might be a typo or a struggle because they’re not as strong at the English language.
How to improve Logic in Programming?
Tags: webdev, javascript, beginners, programming
Published: 2024-02-12 22:32:04

Your logics ain't working?
You can't deny the fact that logic is the fundamental key to become a good programmer. You might be getting frustrated when you don't get logics in programming or your logics aren't working. Don't worry...

How to get better at programming logic?
Until and unless your brain won't do a lot of practice, it's impossible to get the logic in programming.

Here are 5 steps by which you can improve your logic in programming...

1. Solve new problems everyday
Once you solve a specific problem don't repeat it for more than three to four times.
Your brain has to prepare itself for the new challenge to reduce the response time and get the logic in programming.
Get exposure to real-life problems and it will help you to write code for new challenging situations.
These are some popular websites on which you can practice coding:

LeetCode
HackerRank
HackerEarth
freeCodeCamp
GeeksforGeeks
CodeChef
W3Schools
Exercism
2. Learn about Data Structures and Algorithms
Data structures and algorithms (DSA) goes through solutions to standard problems in detail and gives you an insight into how efficient it is to use each one of them.
Developers also have to make the right decisions when it comes to solving the real world complex problems.
3. Moving on Level by Level
Practice enough for a variety of questions at the easy level, then move to some intermediate program.
Again move to the next level or more complex problem and solve a lot of problems.
There are different practice websites with different levels of problem sets, make sure to practice through that and improve your programming logic.
4. Divide problems in smaller chunks
First, try to understand the complete problem and find out what exactly needs to be done.
Think about the problem carefully and write down on paper what steps you need to take in order to solve a specific problem.
Think about all the case scenarios, steps, input or variables that you need to take in order to solve it.
Take your time to write a proper algorithm and then start coding the problem set.
5. Check other people's code
Check code written by other developers on Stackoverflow, GitHub, and learn from it.
You eventually need to think over it and use your brain or logic to solve a problem and get the correct solution.
It also helps you to find out the easier solution or various methods for the same problem.
6. Make Projects
Working on some real-life projects gives you more exposure and experience to become better at programming.
Make calculators, eCommerce projects, personal portfolio or anything that you love to build.
When you build a project, you go through a lot of difficulties and you debug a lot of problems that help in building the logic in programming.
Last but not the least don't lose motivation. Facing problems when using logic in programming should not affect the determination of programmers but instead motivate them to push harder, thus learning more and acquiring enhanced skills.

Hope this article helped you and gave you some insight on logic building.