teleren/devto huggingface dataset:
Golang: Test-Driven Development(TDD) with Gin and MySQL
Tags: webdev, go, unittest, beginners
Published: 2023-08-17 11:01:47

Test-Driven Development (TDD) is a software development technique in which **You write tests for a piece of code before you write the code.**

We write tests to define the desired behavior of the code and to ensure that the code meets those requirements. 

The process of writing the tests first helps to ensure that the code is testable and that it meets the requirements of the user or client.

TDD helps to catch bugs early in the development process and to ensure that the code is maintainable and easy to understand. 

It also promotes a test-first mindset and encourages the developer to think about the requirements and desired behavior of the code before writing it.

Throughout this blog, I’ll assume you’re familiar with the basics of Golang, like package importing and all.


## Table of Contents

- How TDD works?
- Define API Routes, Struct, and functions
- Create a User using TDD
- Get the User using TDD
- Update User using TDD
- Delete User using TDD
- Final Thoughts


**How TDD works?**
_TDD is an iterative process that follows these steps._
1. Write a test for a small piece of functionality that doesn’t exist yet.
2. Run the test, which should fail because the code doesn’t exist yet.
3. Write the minimum amount of code necessary to make the test pass.
4. Rerun the test, which should now pass because the code has been written.
5. Refactor the code if necessary, making sure that all tests still pass.
6. Repeat the process for the next piece of functionality.

Let’s examine the above steps with a basic example of a sum function, which calculates the sum of two values.

For detailed posts with code examples, check out our [Canopas Blog.](https://blog.canopas.com/golang-test-driven-development-tdd-with-gin-and-mysql-e3d353b978f8)

The goal of TDD is to ensure that the code meets the requirements and behaves as expected by constantly testing the code during the development process.

This can help to catch bugs early on, improve code quality, and increase confidence in the software.

TDD is an iterative process that begins with writing a test, running it to confirm it fails, then writing the minimum amount of code to make the test pass and repeating this process until the feature is complete.
Free Tailwind CSS Marketing Components
Tags: tailwindcss, css, react, reactjsdevelopment
Published: 2023-08-17 11:00:14

## **Quick One**
I would like to introduce you to a website where you can glance through free tailwind css components for usage in your project in this post.

Although the platform offers elements that are not exclusive to marketing websites, they will nonetheless enable you to quickly create your next project.

Before copying the scripts to use in your project, you will have the chance to see how a component will appear on various screen sizes when you choose it.

Find the link below!!!

## **Useful Links**
{% embed https://www.hyperui.dev/components/marketing %}
Efficient Deep Cloning of Objects in JavaScript: A Comprehensive Guide
Tags: javascript, web3, beginners, programming
Published: 2023-08-17 10:53:11

Creating a deep clone of an object in `JavaScript `is a critical skill, ensuring data integrity and preventing unexpected side effects. In this comprehensive guide, we'll explore the most efficient methods for deep cloning objects, complete with code examples and insights into their pros and cons.

## Understanding Deep Cloning:

Deep cloning involves creating a new object with the same structure and values as the original object, without any reference to the original. It's especially useful when working with complex data structures.

`1. Using JSON.stringify and JSON.parse:`

![json](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wo0n3gzln1259ppe7wes.png)
`2. Using a Custom Recursive Function:`

![javascript](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t0qgijl3ju79zbft8ty4.png)
`3. Using Lodash Library:`

![javascript](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bc57d07vapl1qh6hoedg.png)

## Comparing the Methods:

`JSON.stringify and JSON.parse:`

`Pros`: Simple and easy to use.
`Cons`: Loses custom object methods and handles only JSON-serializable values.

`Custom Recursive Function:`

`Pros`: Handles all types of objects, including custom objects.
`Cons`: Requires custom implementation and can be slower for large objects.

`Lodash Library:`

`Pros`: Handles deep cloning efficiently with minimal code.
`Cons`: Adds a dependency to your project.

## Best Practices:

Choose the Right Method: Depending on your use case, pick the method that suits your project's requirements.

Performance Consideration: Deep cloning can be resource-intensive, so be cautious when dealing with large objects.

Testing: Test the deep cloning method with various data structures to ensure it meets your expectations.

## Conclusion:

Deep cloning objects in JavaScript is a critical skill for maintaining data integrity and avoiding unexpected issues. By understanding the available methods and their pros and cons, you can confidently select the most efficient approach for your project's needs.

`LinkedIn Account` : [LinkedIn](https://www.linkedin.com/in/matthew-odumosu/)
`Twitter Account `: [Twitter](https://twitter.com/iamcymentho)
**Credit**: Graphics sourced from [JS Copy an Object](JS Copy an Object)
Install PHP on Ubuntu using the terminal
Tags: php, ubuntu, devops, linux
Published: 2023-08-17 10:47:40

To install PHP on Ubuntu using the terminal, you can follow these steps:

1. **Update Package List:**
   It's a good practice to start by updating your package list to make sure you're installing the latest version of PHP available in your repositories.
   
   ```bash
   sudo apt update
   ```

2. **Install PHP:**
   You can install PHP along with commonly used extensions by running the following command:

   ```bash
   sudo apt install php
   ```

3. **Install Additional PHP Extensions (Optional):**
   Depending on your project's requirements, you might need additional PHP extensions. You can search for available extensions using the following command:

   ```bash
   sudo apt search php- | grep '^php-'
   ```

   Then, install the desired extension(s) using a command like:

   ```bash
   sudo apt install php-extension-name
   ```

4. **Check PHP Version:**
   After installation, you can check the installed PHP version using:

   ```bash
   php -v
   ```

5. **Restart Web Server (if applicable):**
   If you're planning to use PHP with a web server like Apache or Nginx, you'll need to restart the server to apply the changes.

   For Apache:
   ```bash
   sudo systemctl restart apache2
   ```

   For Nginx:
   ```bash
   sudo systemctl restart nginx
   ```

That's it! PHP should now be installed on your Ubuntu system. You can test it by creating a simple PHP file and running it through a web server, or you can use the built-in PHP CLI (Command Line Interface) to execute PHP scripts directly from the terminal.

I apologize for any confusion. The "php-extension-name" in my previous response was a placeholder for the actual name of the PHP extension you want to install. Let me clarify:

When installing PHP extensions on Ubuntu, you need to provide the correct package name for the extension you want to install. Here's how you can search for available PHP extensions and install them:

1. **Search for Available PHP Extensions:**
   To find available PHP extensions, you can use the `apt search` command followed by "php-" as a prefix. This will list all the available PHP-related packages.

   ```bash
   sudo apt search php-
   ```

2. **Install the Desired PHP Extension:**
   Once you've identified the extension you want to install from the search results, use the `sudo apt install` command to install it. Replace `php-extension-name` with the actual name of the extension.

   ```bash
   sudo apt install php-extension-name
   ```

For example, if you want to install the GD extension for image manipulation, the command would be:

```bash
sudo apt install php7.4-gd  # Replace "7.4" with your PHP version
```

Please replace `php7.4-gd` with the actual name of the extension you want to install. If you're unsure about the correct package name, you can refer to the search results from the `apt search` command.

Remember to adapt the version number (like "7.4") to the version of PHP you have installed on your system. If you're not sure about the PHP version, you can check it using the `php -v` command.
Running x86 containers on your M1 Mac with Docker and Rosetta
Tags: docker, containers, tutorial
Published: 2023-08-17 10:41:28

## Installation

First you need to install Rosetta:

```sh
softwareupdate --install-rosetta
```

Then install [Docker Desktop](https://docs.docker.com/desktop/install/mac-install/) (Podman does not support this feature).

After installing Docker you need to change a few settings:

- `General` -> `Use Virtualization Framework`
- `General` -> `VirtioFS`
- `Features in Development` -> `Use Rosetta for x86/amd64 emulation on Apple Silicon`

## Creating a container

Now you can create an Ubuntu container:

```
docker pull --platform linux/amd64 ubuntu:22.04
docker create --platform linux/amd64 --interactive ubuntu:22.04 bash
```

Now open the `Containers` section of the Docker Desktop Dashboard and start the newly-created container (it will have a random name). After it started you can click `...` -> `Open in Terminal` to get a shell.

## Running a temporary container

To run a container that will be deleted on exit, use the following command:

```
docker run --platform linux/amd64 --interactive --rm ubuntu:22.04 bash
```

## References

- https://stackoverflow.com/a/76784548/1806760
- https://stackoverflow.com/q/69861107/1806760
Must-Know Tech Terms Explained
Tags: webdev, cloud, bigdata, cybersecurity
Published: 2023-08-17 10:40:32

In today's fast-changing tech world, understanding important tech terms can be a game-changer, whether you're a tech pro or just starting out. Let's break down some key tech words to help you grasp their meanings and importance.

Let's jump right into the topic.

## Edge Computing
Edge computing is like having a mini computer right where you need it. Instead of sending info far away, it's processed nearby for super quick results, like when a self-driving car makes instant decisions.

## Cybersecurity
Cybersecurity is like a digital lock that keeps hackers out of your computer stuff. It's all about protecting your info and making sure it stays private.

## Artificial Intelligence (AI)
AI means smart machines that can do things humans usually do – like solving problems and learning from info. Think self-driving cars and chatbots. It's like computers getting a brain!

## Blockchain
Blockchain is like a super secure digital notebook that keeps track of deals and transactions. It's not just for money – it can help with tracking things like where your food comes from or who owns what.

## Cloud Computing
Cloud computing is like renting computer stuff online. You can use it whenever you need it, without having to own the actual gear. It's like borrowing a powerful computer from the internet.

## Internet of Things (IoT)
IoT is when regular things (like fridges, lights, and cars) get smart and talk to each other. Imagine your fridge telling your phone you're out of milk!

## Augmented Reality (AR) and Virtual Reality (VR)
AR adds extra digital stuff to what you see – like putting a funny hat on your face through your phone's camera. VR is like putting on special goggles and jumping into a whole new digital world.

## 5G
5G is the newest, fastest way to connect to the internet. It's like upgrading from a slow bike to a rocket ship – everything online becomes super quick.

## Quantum Computing
Quantum computers are like super brains that can solve really tough problems, like super complex math. They work differently from regular computers, using tiny particles to think.

## Big Data
Big Data is like having a lot of puzzle pieces to put together. It's huge amounts of info that computers sort through to find cool stuff, like predicting what you might like to buy.

Knowing these simple tech words can help you understand what's happening in the digital world around you. Whether you're chatting with friends or thinking about your future career, a little tech know-how goes a long way!

Mohammad Daniyal
Open Source ABCs: Hacking
Tags: opensource, discuss, 100daysofoss
Published: 2023-08-17 10:29:00

---
title: Open Source ABCs: Hacking
published: true
description: Join our #100DaysOfOSS blog series as we explore the world of Open Source Software (OSS) from A to Z! Every week, we'll discuss two new letters of the English alphabet. Share your thoughts, ideas, and favorite OSS projects for each letter. Let's celebrate the power of open source together! 
tags: opensource, discuss, 100DaysOfOSS
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxwg4ygmybnni1tpwdx3.png
# Use a ratio of 100:42 for best results.
published_at: 2023-08-17 10:29 +0000
series: 100DaysOfOSS
---

Welcome to our [#100DaysOfOSS series](https://dev.to/opensauced/100daysofoss-growing-skills-and-real-world-experience-3o5k). Until October 31, we'll be doing  Open Source Software (OSS) terms from A to Z. We'll be diving into a different letter of the English alphabet, uncovering OSS concepts, and sharing our thoughts on them.

Today, we're covering the letter "H" for Hacking. 

**Hacking**: Open source encourages the exploration and modification of software code, allowing for innovation and creative problem-solving. This creates a sort of "hacking" culture.

Now, we want to hear from you! What other OSS terms can you think of that start with the letter "H"? 

Remember to use the hashtag #100DaysOfOSS if you share on social media, and don't forget to tag us [@saucedopen](https://twitter.com/saucedopen) so we can follow along.
🌟 8 Tips for Junior Software Developers 🚀
Tags: softwareengineering, softwaredevelopment, development, programming
Published: 2023-08-17 10:26:41

Are you a budding software developer eager to make your mark in the tech world? 🖥️ Whether you're fresh out of school or transitioning into a new career, here are 8 valuable tips to help you navigate your journey as a junior developer:

Embrace Continuous Learning 📚: The tech landscape is ever-evolving. Stay ahead by keeping up with new programming languages, frameworks, and industry trends. Online courses, tutorials, and coding communities are your best friends!

Code Consistently 💻: Just like any skill, practice makes perfect. Devote time each day to coding, building projects, and refining your problem-solving skills. Consistency is the key to improvement.

Seek Feedback 🔄: Don't be afraid to show your code to experienced developers. Constructive feedback is a treasure trove of knowledge that can propel your skills forward. Be open to learning from mistakes.

Collaborate and Communicate 🤝: Software development is rarely a solitary endeavor. Learn to work effectively in teams, communicate your ideas clearly, and collaborate using version control systems like Git.

Master the Basics 🧩: While the latest technologies are enticing, ensure you have a strong foundation in programming basics. Algorithms, data structures, and design patterns are the building blocks of elegant solutions.

Document Your Journey 📝: Keep track of what you learn, the challenges you overcome, and the projects you undertake. This documentation serves as a valuable resource and showcases your growth.

Stay Curious and Problem-Driven 🤔: Great developers are inherently curious problem solvers. Approach challenges with a curious mindset, and break down complex problems into smaller, manageable tasks.

Network, Network, Network 🌐: Attend meetups, conferences, and engage with the developer community online. Building a strong network opens doors to learning opportunities, mentorship, and potential job prospects.

Remember, every step you take as a junior developer contributes to your growth and expertise. Embrace challenges, stay curious, and don't hesitate to share your knowledge with others along the way. Your journey is just beginning, and the tech world is eagerly awaiting your contributions! 💡🌟
Beyond Conformance: Elevating User Experience with Section 508 Compliance Services
Published: 2023-08-17 10:21:25

Discover how [Section 508 compliance services](https://www.acadecraft.com/accessibility/508-compliance-service/) go beyond conformance, elevating user experiences to new heights. Explore the tools and techniques that harmonize technology with inclusivity, resulting in seamless and accessible digital interactions.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ais69bdzqrv6bla5fpco.jpg)
Node.Js, Npm, Npx, Yarn - Huh?
Tags: webdev, javascript, react, npm
Published: 2023-08-17 10:18:31



**Framework/Language:** Node.js
**Level:** Beginners


What you will build/learn
This Codelab includes concepts/tools explanation and code snippets. To keep it simple, I have tried my best to explain things in the easiest way possible. Also, I have added some GIFs so that you can see those snippets in action.


Scope & Preferred for: 
This Codelab has been designed especially for those who are just beginning with Node and have some confusion about buzz words like **npm, npx, node **etc. 


Things you will learn

What is:

**Node.js
NPM
Yarn 
NPX**

**Tools you will require**
A computer/laptop with an internet connection.
Install WordPress on Ubuntu using the terminal
Tags: wordpress, linux, devops
Published: 2023-08-17 10:09:22

To install WordPress on Ubuntu using the terminal, you can follow these steps. This guide assumes you have a LAMP (Linux, Apache, MySQL, PHP) stack already set up on your Ubuntu server. If not, you'll need to set up the LAMP stack first.

Here's how you can install WordPress:

1. **Update and Upgrade Packages:**
   Open a terminal and update the package list and upgrade existing packages:
   ```bash
   sudo apt update
   sudo apt upgrade
   ```

2. **Install Additional Packages:**
   Install the required packages for WordPress:
   ```bash
   sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
   ```

3. **Create a MySQL Database and User:**
   Log into MySQL and create a database and user for WordPress:
   ```bash
   sudo mysql
   ```
   ```sql
   CREATE DATABASE wordpress;
   CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
   GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
   FLUSH PRIVILEGES;
   EXIT;
   ```

4. **Download and Configure WordPress:**
   Navigate to your web server's root directory (usually `/var/www/html`):
   ```bash
   cd /var/www/html
   ```

   Download the latest WordPress package:
   ```bash
   sudo wget https://wordpress.org/latest.tar.gz
   ```

   Extract the archive:
   ```bash
   sudo tar -xzvf latest.tar.gz
   ```

   Rename the WordPress directory:
   ```bash
   sudo mv wordpress your-site-name
   ```

   Set ownership and permissions:
   ```bash
   sudo chown -R www-data:www-data your-site-name
   sudo chmod -R 755 your-site-name
   ```

5. **Configure WordPress:**
   Copy the sample configuration file:
   ```bash
   cd your-site-name
   sudo cp wp-config-sample.php wp-config.php
   ```

   Edit the configuration file:
   ```bash
   sudo nano wp-config.php
   ```
   Set the database details you created earlier:
   ```php
   define('DB_NAME', 'wordpress');
   define('DB_USER', 'wordpressuser');
   define('DB_PASSWORD', 'password');
   ```

   Save and close the file (`Ctrl+O` to save, `Ctrl+X` to exit).

6. **Access WordPress Installation:**
   Open a web browser and navigate to your server's IP address or domain followed by `/your-site-name` (e.g., `http://your_server_ip/your-site-name`).

   Follow the WordPress installation wizard to complete the setup.

7. **Complete the Installation:**
   Provide the site title, admin username, password, and email address.

8. **Access the WordPress Admin Dashboard:**
   Once the installation is complete, you can access the WordPress admin dashboard by going to `http://your_server_ip/your-site-name/wp-admin`.

That's it! You've successfully installed WordPress on your Ubuntu server using the terminal. Remember to configure any additional settings and security measures as needed.
Best Immigration Consultants
Published: 2023-08-17 10:08:13

Due to its comparatively open and well-regulated immigration system, Canada continues to be a well-liked destination for immigrants and refugees. So, give Aram Visas a call if you're considering moving to Canada. It ranks as one of the <a href="https://aramvisas.com/">Best Immigration Consultancy</a>
out there.

<a href="https://aramvisas.com/">Best Immigration Consultants</a>
Code Splitting in React
Tags: webdev, javascript, react, programming
Published: 2023-08-17 10:08:08

## Introduction
 
In the ever-evolving landscape of web development, optimizing the performance of your React JS applications is paramount. Imagine a scenario where your application's bundle size is minimized, initial load times are slashed, and user experiences are elevated to new heights. This is precisely where the art of code splitting enters the stage.

**Lazy Loading with lazy():** Gone are the days of loading entire scripts upfront, slowing down the initial user experience. With the lazy() function, React enables you to load components only when they're actually needed. We'll unravel the mysteries of this dynamic method, understand its syntax, and witness how it dramatically impacts load times.

**Embracing Suspense:** Imagine creating suspense not just in movies, but also in your application's loading behavior. Suspense allows you to gracefully manage asynchronous rendering and loading states, resulting in smoother transitions and reduced time-to-interactivity. We'll learn how to implement Suspense to its full potential, optimising user engagement and experience.

**Crafting Fallback UIs:**While code splitting and lazy loading enhance your application's speed, what happens if something goes awry? Fallback UIs step in as a safety net, ensuring users are met with a visually pleasing and informative interface even when components fail to load. We'll explore strategies to design elegant fallbacks, preserving user satisfaction in the face of loading uncertainties.

## Comprehension

As our web app grows, the javascript bundle size increase. To avoid larger javascript bundle we can use the concept of splitting.
In react, there is a feature to support code splitting and lazy loading. It allows dynamic imports on the react components using lazy() function. For the dynamically imported components, we can wrap them in the suspense component to show a fallback UI while we wait for the component to load. 

```
import React, {Suspense, lazy} from 'react';
const NavB= lazy(()=> import('./navB'));
function Page(){

return (
  <div>
    <Suspense fallback={<div>Loading...</div>}>
      <NavB/>
    </Suspense>
  </div>
);

}

```
14 MB log file and you want to split it into multiple 5 MB files using Linux commands
Published: 2023-08-17 10:07:50

If you have a 14 MB log file and you want to split it into multiple 5 MB files using Linux commands, you can use the `split` command. Here's how you can do it:

```bash
split -b 5M yourlogfile.log prefix_
```

In this command:

- `split` is the command used to split files.
- `-b 5M` specifies that you want to split the file into chunks of 5 MB each.
- `yourlogfile.log` is the name of the input log file you want to split.
- `prefix_` is the prefix you want to use for the output files. The command will generate files named `prefix_aa`, `prefix_ab`, and so on.

After running this command, your log file will be split into multiple 5 MB files with the specified prefix. If you have a total of 14 MB of data, you will get three files: `prefix_aa` (5 MB), `prefix_ab` (5 MB), and `prefix_ac` (4 MB). The last file will be smaller if the input file size is not evenly divisible by 5 MB.