teleren/devto huggingface dataset:
What are some advantages of using plain JavaScript over JSX?
Tags: webdev, javascript, react, beginners
Published: 2023-06-23 16:18:23

While JSX simplifies the process of building user interfaces in React, there are some advantages to using plain JavaScript over JSX. Here are a few:

1. No need for a build step: When using plain JavaScript, there's no need for a build step to compile your code. This can simplify your development process, as you don't have to worry about setting up a build system or dealing with build errors.

2. Familiar syntax: If you're already familiar with JavaScript, using plain JavaScript in React can make it easier to understand and maintain your code. You don't have to learn a new syntax or worry about the quirks of JSX.

3. Better performance: While JSX is optimized for performance, using plain JavaScript can be more performant in some cases. This is because plain JavaScript doesn't have to go through the process of being compiled to JSX before it can be executed.

4. More control: When using plain JavaScript, you have more control over the structure and behavior of your components. You can write your code in any way you like, and you're not limited by the syntax of JSX.

5. Easier debugging: Debugging plain JavaScript can be easier than debugging JSX, as the code is more straightforward and easier to read. This can save you time and effort when trying to track down bugs in your code.

While JSX is a powerful tool that simplifies the process of building user interfaces in React, using plain JavaScript can have its advantages. Ultimately, the choice between JSX and plain JavaScript will depend on your specific needs and preferences.
Java-based console app as HTTP client
Tags: java, http, web, cli
Published: 2023-06-23 16:08:21

So here is "Ye another one http client" 🐱 that I created for personal use as practice and just to have own tool to test HTTP requests not to download CURL or HTTpie 🐱.

Source code: https://github.com/ahndmal/http-client-java-cli/

## JCurl (very hard to create name 🐱)

So this is the console app in Java to receive some arguments and perform HTTP / Socket requests to the passed web host as an URI. Here Java 11 HTTP client is used as a core. To perform more requests without blocking, async reactive processing of requests is used

```java
// client
 HttpClient client = HttpClient.newBuilder()
      .version(HttpClient.Version.HTTP_2)
      .build();
```

It is a **Native** and **JDK** based HTTP client. To build the app as a native executible, we use GraalVM (https://www.graalvm.org/).

### Gradle GraalVM plugin
As a build tool we use Gradle and Gradle GraalVM plugin (https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html) that is flexible and fast to build (relatively 🐱) due to cahing.

```gradle

graalvmNative {
    binaries {
        named("main") {
            javaLauncher.set(javaToolchains.launcherFor {
                languageVersion.set(JavaLanguageVersion.of(19))
            })
            mainClass.set("com.andmal.Main")
            verbose.set(true)
        }
    }
}

```

### Build manually

To build the app as a JAR file:
```bash
gradlew build
```

Then we can run it as usual JAR file with JRE.

Build as native executable:
```bash
./gradlew nativeCompile
```

### Run
1. As Java
  ```bash
  java -jar build/libs/http-client-java-cli-19.jar --url http://example.com --method GET
  ```

2. As CLI app
  ```bash 
    jcurl --url http://example.com --method GET
  ```

So the signature is:

``` jcurl [arguments] ```

#### Arguments
request **URI**:
```bash
  --url 
``` 
**Method** (GET / POST / PUT / DELETE / HEAD)
```bash
 --method 
``` 
**Authorization**:
```bash
 --auth 
``` or 
```bash
 -A 
```  
as 'USER:PASSWORD'. e.g. 
```
 --auth admin:admin 
```
**Headers**:
```bash
 --headers 
``` 
request Headers in format of: 
```
 key:value, key2:value2 
```
**query parameters**
```bash
 --query 
```  
for the request.  will be passed as 
```
 ?query= 
```

## Examples

### GET

```bash
    jcurl --url http://example.com --method GET
```

### POST

```bash
    jcurl --url http://example.com --method POST --body '{"name": "Vasyl"}' --headers 'Content-Type: application/json'
```
DILI #4
Tags: cpp, minion, beginners, help
Published: 2023-06-23 15:56:01

**VECTOR**

Vector! You might heard of this name if you are really into math or into "Minions". But in C++, it's not what you might think. It's similar to an array ...  BUT BETTER. Do you ever find it annoying that you have to type in that 100 or 1000 or even 10000 for the size of the array? Well Vector got you covered with his "Shrink ray". 



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


Just like in the film, Vector in C++ can resize itself depending on the number of elements you add in or take away. Which is really frickin' convenient! And it's even in STL so no need to call for it. The only downside is it's a bit lengthy to initialize: 	

```c++
vector< object_type > vector_variable_name;
```
Here are a few frequently used fuctions for vectors all of which are used via vector_name.funcion():

size() - self explanatory
assign() – It assigns a new value to the existing elements of the vector.
push_back() – It pushes the element from back in the vector.
pop_back() – It removes elements from the back of the vector.
insert() – It inserts an element before a specified element in the vector.
erase() – It is used to remove elements from a specified element or a range in the vector.
swap() – It is used to swap the contents of two vectors of the same datatype. The sizes of vectors may differ.
clear() – It is used to remove all the elements from the vector.

For demonstration purposes, this is me after fidgeting for a bit of time to do this problem on LeetCodes:

You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively.

Merge nums1 and nums2 into a single array sorted in non-decreasing order.

The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a length of m + n, where the first m elements denote the elements that should be merged, and the last n elements are set to 0 and should be ignored. nums2 has a length of n.

```
Input: nums1 = [1], m = 1, nums2 = [2,7,6], n = 0
Output: [1,2,6,7]
```

My solution:

```c++
void merge(vector<int>& nums1, int m, vector<int>& nums2, int n) 
{
        for (int i = 0; i < n; i++){
            nums1.push_back(nums2[i]);
        }
        sort(nums1.begin(), nums1.end());
}
```
Very sort and definitely brute force but hey, I used vectors. Anyways, if you can do better, better solutions in the comments are very welcomed!

As always, I need all the advices I can get on coding or blog-writing or even life (this would be most appreciated)!

**REFERENCE:**
[GeeksforGeeks](https://www.geeksforgeeks.org/vector-in-cpp-stl/)
[Chapter 11.17](https://www.learncpp.com/cpp-tutorial/an-introduction-to-stdvector/)
[The Problem above](https://leetcode.com/problems/merge-sorted-array/description/)
Fix The ERR_TOO_MANY_REDIRECTS Error
Tags: wordpress, errtoomanyredirections, redirectionerror, usermetapro
Published: 2023-06-23 15:12:41

The ERR_TOO_MANY_REDIRECTS error is a common issue for web developers and users. Besides, it occurs when a website enters an infinite redirection loop, causing browsers to display an error message. In this blog post, we will explore the causes of this error and provide step-by-step instructions on how to fix it. We’ll also include relevant code snippets where necessary to help you resolve the issue effectively.

**UNDERSTANDING THE ERR_TOO_MANY_REDIRECTS ERROR:**
This error typically occurs when a website is misconfigured. Also, when there is an issue with the server-side redirect setup. It can be frustrating, but there are several methods to resolve it. Let’s dive into the solutions below.

**SOLUTION 1: CLEAR BROWSER CACHE AND COOKIES**
Sometimes, the error is caused by cached or stored redirect information. By clearing your browser’s cache and cookies, you can eliminate any outdated data that might be triggering the redirection loop. Here’s how you can do it:

- In Google Chrome, click on the three-dot menu in the top-right corner and select “Settings.”

- Scroll down and click on “Advanced” to expand the advanced settings.

- Under the “Privacy and Security” section, click on “Clear browsing data.”

- Select “Browsing history,” “Cookies and other site data,” and “Cached images and files.”

- Click on “Clear data” to remove the selected items.

**SOLUTION 2: CHECK WEBSITE URL SETTINGS**
Incorrect website URL settings can also lead to this error. Make sure your website’s URL is configured correctly by following these steps:

- Access your website’s files through FTP or cPanel File Manager.

- Locate the “.htaccess” file in the website’s root directory.

- Download a backup copy of the file for safety.

- Open the “.htaccess” file and look for any redirect rules.
Remove or modify any redirect rules that might be causing the infinite loop.

- Save the changes and re-upload the file to the server.

**SOLUTION 3: VERIFY SERVER-SIDE REDIRECTS**
Server-side redirects, such as those implemented using PHP or Apache configuration files, can cause an error. Follow these steps to troubleshoot:

- Locate the server-side file responsible for the redirects (e.g., “.htaccess” or a PHP script).

- Open the file in a text editor or an integrated development environment (IDE).

- Review the code and check for any misconfigured or excessive redirects.

- Make the necessary corrections to ensure the correct redirections.

- Save the changes and upload the updated file to the server.

In conclusion, encountering the error is frustrating, but with the troubleshooting methods, you can resolve it effectively. Remember to clear your browser cache and cookies. As well as, review your website’s URL settings, and verify any server-side redirects. By following these steps and paying attention to the specific needs of your website, you can overcome the ERR_TOO_MANY_REDIRECTS error and ensure a smooth browsing experience for your users.

https://user-meta.com/blog/fix-err_too_many_redirects-error/
📢 Uplifting Black Technologists: Spotlight on Black Tech Pipeline
Tags: juneteenth, blacklivesmatter, community, career
Published: 2023-06-23 15:00:00

In honor of Juneteenth, we’re uplifting initiatives and organizations that center Black and African-American technologists. Black Lives Matter, and we celebrate these orgs for their contributions toward creating futures for Black people and African-Americans while shaping our industry for the better.

In this post, we shine a spotlight on **Black Tech Pipeline.**

[Black Tech Pipeline](https://blacktechpipeline.com/about/) is a talent recruitment platform focused on Black professionals in the tech industry. It was founded in 2020 by [Pariss Chandler](https://twitter.com/ParissAthena), a software developer turned tech recruiter who discovered her passion for empowering Black technologists when she mobilized the hashtag [#BlackTechTwitter](https://twitter.com/ParissAthena/status/1068873547005812737) in 2018.

Today, Black Tech Pipeline is home to a job board and newsletter aimed at connecting Black tech workers with roles, opportunities, and resources to support them in thriving in the tech industry. According to the BTPipeline FAQ:

> Black Tech Pipeline partners with companies who truly practice safety, diversity, equity and inclusion internally and externally. We promote companies and organizations who are taking actionable steps to support their team members from marginalized communities in visible and impactful ways.

---

**Black Tech Pipeline Job Board**
If you're a Black technologist seeking new opportunities, consider checking out the [Black Tech Pipeline job board](https://blacktechpipeline.com/) for open roles!

If you're hiring — and your company is committed to the above values — you can submit your open roles for consideration using [this AirTable form](https://airtable.com/shrMZCJIGqqRcn45Y).

---

To hear Pariss share more about her experience building and growing Black Tech Pipeline, check out [Season 23 Episode 8 of the CodeNewbie Podcast](https://www.codenewbie.org/podcast/empowering-the-next-generation-of-black-tech-talent)!

{% embed https://dev.to/codenewbie/s23e8-empowering-the-next-generation-of-black-tech-talent-pariss-chandler %}

---

As this final week of June comes to a close, we encourage you to support the work that organizations like [CODE2040](https://dev.to/devteam/uplifting-black-technologists-spotlight-on-code2040-56o3), [Black Girls CODE](https://dev.to/devteam/uplifting-black-technologists-spotlight-on-black-girls-code-5dee), and Black Tech Pipeline are doing to advance racial equity in the tech industry all year round. Together, we can shape a better, more inclusive future for all. 🙌
Desktop application in C language
Tags: c
Published: 2023-06-23 14:56:10


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

To create a desktop application in C, you can make use of frameworks and libraries that provide GUI (Graphical User Interface) functionality. One popular framework for developing desktop applications in C is GTK+ (GIMP Toolkit). GTK+ is a cross-platform toolkit that allows you to create GUI applications that can run on different operating systems such as Windows, macOS, and Linux.

Here's a step-by-step guide to creating a simple desktop application in C using GTK+:

Install the necessary tools:

Install a C compiler such as GCC (GNU Compiler Collection) for your operating system.

Install the GTK+ development libraries. The installation process may vary depending on your operating system.

Set up your development environment:

Create a new directory for your project.
Open a text editor or an Integrated Development Environment (IDE) to write your C code.
Write the C code:

Start by including the necessary GTK+ header files in your code:


```
#include <gtk/gtk.h>
```

Write the main function and initialize the GTK+ library:


```
int main(int argc, char *argv[]) {
    gtk_init(&argc, &argv);
    // Rest of your code goes here
    return 0;
}
```

Create a callback function that will be triggered when the application's window is closed:

```
static void on_window_closed(GtkWidget *widget, gpointer data) {
    gtk_main_quit();
}
```

Create the application window and connect the callback function to the "destroy" signal:

```
GtkWidget *window;

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(window, "destroy", G_CALLBACK(on_window_closed), NULL);
```

Add additional GUI elements to your window, such as buttons, labels, or text fields, using GTK+ functions.

Display the window:

```
gtk_widget_show_all(window);
```

Start the GTK+ main loop:

```
gtk_main();
```

Compile and build the application:

Open a terminal or command prompt and navigate to your project directory.

Use the C compiler to compile your code, linking against the GTK+ libraries:

```
gcc -o your_application_name your_code.c `pkg-config --cflags --libs gtk+-3.0`
```

Run the application:

Execute the compiled binary file from the terminal or command prompt:

```
./your_application_name
```

This is a basic example to get you started with creating a desktop application in C using GTK+. You can explore the GTK+ documentation and tutorials for more advanced features and functionality. Additionally, other frameworks like Qt and wxWidgets also provide options for creating desktop applications in C, so you may consider exploring those as well.
Unveiling the Single Responsibility Principle's Magic
Tags: php, solid, webdev, phpdevelopers
Published: 2023-06-23 14:55:42

---
title: Unveiling the Single Responsibility Principle's Magic

published: true
description: Discover the benefits of the Single Responsibility Principle in web development. Simplify your code and enhance organization.

tags: php, solid, webDevelopment, phpDevelopers
cover_image: https://anastasionico.uk/img/blog/the-art-of-code-design-unveiling-the-single-responsibility-principle-magic.jpeg
# Use a ratio of 100:42 for best results.
# published_at: 2023-06-23 14:48 +0000
---

As someone who is passionate about web development, I'm always thrilled to share valuable insights and techniques that can elevate your skills.



Today, I want to delve into the fascinating world of code design and introduce you to a powerful principle that can transform the way you write software: 



the Single Responsibility Principle (SRP). 



This principle possesses an almost magical ability to enhance your code's elegance, maintainability, and scalability.



In my latest blog post, "The Art of Code Design: Unveiling the Single Responsibility Principle's Magic," 



I dive deep into the concept of SRP and its remarkable impact on code quality. 



This post explores how adhering to SRP empowers you to create cleaner, more maintainable code that withstands the test of time.



Here's a glimpse of what you'll discover in the article:

Understanding the Single Responsibility Principle: Gain a solid grasp of what SRP entails and why it plays a crucial role in code design. 

Discover how this principle emphasizes the idea of assigning a single responsibility to each class or module, fostering code clarity and reducing complexity.

Unleashing the Benefits: Explore the incredible benefits of following SRP. 

From improved code readability and maintainability to easier testing and code modularity, you'll learn how SRP enhances your development process and boosts the overall quality of your projects.

Practical Examples in Code: To help you grasp the practical implementation of SRP, I provide real-world PHP examples that illustrate how you can effectively apply this principle in your own projects. 

By examining these examples, you'll gain insights into structuring your codebase with clarity and intention.





Visit my blog to dive into the fascinating world of code elegance and discover how SRP can elevate your programming skills.



If you have any comments or questions about this topic of PHP don’t be afraid to mail me or answer to this email.



Let's continue our journey of mastering the art of code design together!

Nico

[The Art of Code Design: Unveiling the Single Responsibility Principle's Magic
](https://anastasionico.uk/blog/the-art-of-code-design-unveiling-the-single-responsibility-principle-magic)
method (instance), @classmethod and @staticmethod
Tags: python, beginners
Published: 2023-06-23 14:46:37

In a class we can have method, normal method without decorator. We also can have classmethod and staticmethod.


the normal method is a method that is bound to the instance. It has `self` as its first argument.
classmethod is bound to the class itself. It's usually used as a factory. It has `cls` as its first argument.
staticmethod is not bound to either instance or class. It's a general function and it doesn't have either `self` or `cls` as its argument.

```
>>> class Shape:
...     def __init__(self, name, height, width):
...         self.name = name
...         self.height = height
...         self.width = width
...     def __str__(self):
...         return f"shape: {self.name}, height: {self.height}, {self.width}"
...     @staticmethod
...     def area(height, width):
...         return height * width
...     @classmethod
...     def rectangular(cls):
...         return cls("rectangular", height, width)
...     @classmethod
...     def square(cls):
...         return cls("square", height, height)
```

wait, is my code correct...?
Rust Testing Material
Tags: rust, testing, learning
Published: 2023-06-23 14:34:01

Hey Rustaceans,

We recently published a new repository. A curated list of testing material in the Rust ecosystem. If you know good testing resources for Rust, please feel free to contribute! If you're interested you can also support the initiative by giving us a star!

{% github https://github.com/owlduty/rust-testing-material %}
How to highlight a code block on dev.to
Published: 2023-06-23 14:26:49

I found that this code was generally more pleasing to the eyes

```javascript
const name = 'Ifeoluwa'
function Welcome() {
console.log(`Welcome ${name} you made it here!`)
}
```
To this below
```
const name = 'Ifeoluwa'
function Welcome() {
console.log(`Welcome ${name} you made it here!`)
}
```
What's the secret? Nothing too complicated. To achieve this, you only need to specify the language the code is written in.

Normally when you open a code block it goes something like 

![block code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cvoox4a1ak4j30axkt71.png)

Add the name like this

![block code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f2eit5bjvv4fuo54r9vu.png)

And it will render this
```javascript
const msg = 'You did it!';
```
##Conclusion
Congratulations! Now your blog post would have a nicer look from today onward, thanks for reading.
Appscript library on Google workspace
Tags: googlecloud, gcp, data, appscript
Published: 2023-06-23 14:09:42

__Build my first library.
Calculates the sale price of a value at a given discount. The sale price is formatted as US dollars.

https://script.google.com/macros/library/d/1aEP2kDTebNGgyaT3_x-_tcwvLzzWn0m2093S3ZQ1YDMJYeE6HSXRknS9/1

In order to deploy in on Workspace market need to enable Google Cloud Platform.
Perl Weekly Challenge #222 - Checking Against My List of Members
Tags: perl, perlweeklychallenge
Published: 2023-06-23 13:58:11

Hi everybody! Just doing the first weekly challenge task again this week. This week we're sorting a list of numbers and then checking whether the number matches the same position in the unsorted list. It's a very simple challenge and easily written in about 4 actual lines of clean code.

Here's the code:

    #!/usr/bin/perl
    use strict;
    use v5.24;
    my @sorted = sort @ARGV;
    my $matches;
    for (my $i = 0; $i <= $#ARGV; $i++) {$matches++ if $ARGV[$i] == $sorted[$i]}
    say $matches // 0;

This obviously doesn't have any error-checking to make sure the values are integers, so they could be text that's sorted differently, but we're assuming the input is trustworthy. For anyone new to programming reading this, _**never**_ assume user input is trustworthy. Always do your safety checks and sanitize inputs.

Very simply, we're making a sorted copy of the inputs to the script, initializing $matches, looping through both lists checking for identical values (for which we need an index counter, which is why we use the 3-part loop structure) and add to $matches if we find one. Then we print either the number of matches or 0 if we didn't find any. The `// 0` is necessary just so it doesn't print an empty line if the variable is still uninitialized.

Hope to see you all again next week with the next weekly challenge! Join the challenges if you find them interesting to read about.
How To Use Basecamp’s MRSK With AWS and GitHub
Tags: rails, deployment, kamal, aws
Published: 2023-06-23 13:57:12

---
title: How To Use Basecamp’s MRSK With AWS and GitHub
published: true
description: You may have already encountered MRSK - the latest deployment tool developed by the Basecamp team. In this article, I'll delve into its functionality and highlight the reasons why it's gaining so much popularity.
tags: Rails,Deployment,MRSK,AWS
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9qem1yolggho5aox9gpf.jpg
# Use a ratio of 100:42 for best results.

---

Hey fellow devs! 👋 Just published a new article on deploying Rails apps like a breeze! 🚀 Check it out here: [How to Use Basecamp's MRSK with AWS and GitHub](https://jetrockets.com/blog/how-to-use-basecamp-s-mrsk-with-aws-and-github).

I spill the beans on how you can leverage MRSK, AWS, and GitHub to streamline your Rails deployments. No more headaches or complicated setups! 😎

Read the article to discover practical tips, tricks, and insights to make your deployment process smooth and efficient. Let's level up our dev game together!

Join the conversation in the comments. Can't wait to hear your thoughts and experiences. Happy deploying! 💻💪