teleren/devto huggingface dataset:
[Fix] Rails server is already running
Tags: rails
Published: 2021-06-28 08:15:19

## Error

"A server is already running. Check **.../tmp/pids/server.pid**"

This error means that the server is already running in the port you are trying to start the rails server on; normally 3000.

## Reasons for Error

This error can occur in two cases:

1. You are running the Rails server on port 3000 in another tab of the terminal

2. You suspended the server abruptly
     
    This normally happens when you stop the server with `ctrl+z` instead of `ctrl+c` to exit the Rails server. `ctrl+z` suspends the process but doesn't close the server running on port 3000 meaning the server is still running on background.

    This can also happen when you close the terminal that the rails server was running on.

## Solution

### Rails server is running on port 3000 in another tab of the terminal

You can just close the server running on another tab on port 3000 to resolve this issue.

### Server suspended abruptly

Solution for this case is to kill the process running in the background on port 3000

1. Find the process id for the rails server port
   
     If the port you are running the rails server is different than 3000, you should replace 3000 with the port number as required.

     ```cmd
       lsof -wni tcp:3000
     ```

     You should be able to see the output like this:

     ```cmd
      COMMAND   PID USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME
      ruby    16660 cool   14u  IPv4 0x89786e1f70a36a3      0t0  TCP 127.0.0.1:hbci (LISTEN)
      ruby    16660 cool   15u  IPv6 0x89786e1d82f7aeb      0t0  TCP [::1]:hbci (LISTEN)
     ``` 

2. Copy value in PID column, here **16660**

3. Kill the process

     ```cmd
       kill -9 16660
     ```

     You should see the following output:

     ```cmd
       [1]  + 10975 killed     rails s
     ```

4. Try running the server again
      

## Conclusion

Rails server should be up and running without any errors now.

Thank you for reading. Happy Coding!

## References

- <a href="https://stackoverflow.com/a/64998938/9359123" target="_blank" rel="noopener">A server is already running (Stack Overflow)</a>

## Image Credits

- Cover Image by <a href="https://unsplash.com/@olav_ahrens?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText" target="_blank" rel="noopener">Olav Ahrens Røtne</a> on <a href="https://unsplash.com/s/photos/solution?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText" target="_blank" rel="noopener">Unsplash</a>
My experience up-to now as a GSOC mentor with Xfce
Tags: opensource, xfce, gsoc, mentor
Published: 2021-06-28 08:12:18

## What is Google Summer of Code ?

>_The Google Summer of Code, often abbreviated to GSOC, is an international annual program in which Google awards stipends to students who successfully complete a free and open-source software coding project during the summer._

## What is Xfce ?

>_Xfce or XFCE is a top most liked, free and open-source desktop environment for Unix-like operating systems with aims to be fast and lightweight while still being visually appealing and easy to use._

### How I got into it
For the first time in 2021, xfce submitted to be a hosting organization for GSOC. Alexander Schwinn and Yousuf Philips provide me this amazing opportunity to mentor the project **'Sample Plugin for xfce panel in all GOI supported languages'**. I was very excited for it from the starting as I love to work with highly motivated students, helping them to learn. I always considered it as a valuable activity.

### Journey up-to now.
In the starting I was very nervous with the things as it is my first time as a mentor in GSOC, Yousuf and Alex always helped and Guided me at every stage. Last month I faced a lot other issues because of the pandemic but some how manage to get back.

After Xfce successfully securing 3 slots (where new organizations only get 1 or 2) I got a slot to mentor Vishal Sharma. Vishal is a highly motivated and curious guy who always try to learn max from the things.

### Approach as a mentor
We started working on the project during the community bonding period because there were a couple of things we need to test before getting to the actual feature implementation. We talked on telegram (and sometime on whatsapp) 4-5 days per week and also I gave home detailed feedback for his work. Overall we were in a friendly working relationship and Vishal will probably continue as a member of Xfce community in future.

### My Takeaway from the experiences up-to now.
I'm enjoying my interaction this year, it was smooth at the beginning and getting even better. Student did an excellent job and I'm  also very happy with the way things work here.
Difference between QA and UAT testing
Tags: qa, uat, uattesting
Published: 2021-06-28 08:04:01

What is User Acceptance Testing (UAT)? 
It is the last period of the structure and working of web items. Before your web item goes live, the UAT is the place the test group will pay special attention to everything that isn't right and could turn out badly. It guarantees that the look, feel, and capacity of your site is checked in reference to the concurred extent of work. 

What is Quality Assurance (QA) testing? 
It confirms the nature of the item, that it meets determined necessities in the test plan obtained from the concurred extent of work. The QA group is free of, however, underpins the improvement group. It doesn't have to test the web item's ease of use comparable to the shopper experience.

Main Difference between QA and <a href="https://www.testingxperts.com/blog/uat-testing">UAT testing</a>

Both Quality assurance testing and user acceptance testing are critical parts of a product venture. The two of them have various intentions and targets, and the two of them work in an unexpected way, however, toward the day's end, the two of them work to guarantee that the product is liberated from any blunders. 

The significant distinction between both of these is the way that quality assurance guarantees that the product is without mistake, while client acknowledgment testing guarantees that the product is giving the clients simply the experience and usability that they were searching for. The two of them work inseparably to guarantee that the product is of acceptable quality. The one principal advantage that the two of them give is that the customer is happy with the finished result. 

A product organization can possibly succeed if the customers are happy with the organization's nature of work. It likewise assists set aside with timing and cash. In case you're uncertain what type of testing to utilize and are searching for somebody with ability in the zone of <a href="https://www.testingxperts.com">software testing</a> and the distinctive programming testing philosophies, at that point visit Performance Lab. They can assist you with the entirety of your product testing needs. With their involvement with the field of programming testing (both client acknowledgment and quality affirmation), you can be guaranteed that the product you convey to your customers will be sans bug and precisely what your customers need.
How I parsed sitemap.xml to save the links in database and make the sitemap dynamic in laravel
Published: 2021-06-28 07:57:55

Below is the code snippet I used for this. 

```
$xmlString = file_get_contents(public_path('sitemap.xml'));
    $xmlObject = simplexml_load_string($xmlString);
    $json = json_encode($xmlObject);
    $phpArray = json_decode($json, true);

    $usLinks = array_filter($phpArray['url'], function($linkData) {
        return strpos($linkData['loc'], '/us/') != false;
    });

    $usLinks = array_values(array_map(function($linkData) {
        return ['status' => 1, 'link' => $linkData['loc'], 'priority' => $linkData['priority']] ;
    }, $usLinks));

    array_unshift($usLinks, ['status' => 1, 'link' => 'https://sugarwish.com/', 'priority' => 1.00]);

    \App\DB\Sitemap::insert(
        $usLinks
    );
```
Differentiate between integration testing and system testing
Tags: integrationtesting, systemtesting
Published: 2021-06-28 07:52:42

System Testing:
While developing a software or application product, it is tested at the final stage as a whole by combining all the product modules and this is called System Testing. The primary aim of conducting this test is that it must fulfill the customer/user requirement specification. It is also called an end-to-end test, as is performed at the end of the development. This testing does not depend on system implementation; in simple words, the system tester doesn’t know which technique among procedural and object-oriented methods is implemented.

This testing is classified into functional and non-functional requirements of the system. In functional testing, the testing is similar to black-box testing which is based on specifications instead of code and syntax of the programming language used. On the other hand, in non-functional testing, it checks for performance and reliability through generating test cases in the corresponding programming language.

Integration Testing:
This testing is the collection of the modules of the software, where the relationship and the interfaces between the different components are also tested. It needs coordination between the project level activities of integrating the constituent components together at a time.

The integration and <a href="https://www.testingxperts.com/blog/integration-testing">integration testing</a> must adhere to a building plan for the defined integration and identification of the bug in the early stages. However, an integrator or integration tester must have programming knowledge, unlike system testers.
Java Thread Programming: Lesson 1
Tags: java, thread
Published: 2021-07-03 07:44:14

---
title: Java Thread Programming: Lesson 1
published: true
date: 2021-06-26 04:01:00 UTC
tags: java, thread
canonical_url: http://bazlur.com/2021/06/java-thread-programming-lesson-1/
---

When we run a java program, we are given an execution environment that runs our code one by one. When we have only one execution environment, things are pretty straightforward. All the code runs the same way we write. However, when we have many things to run simultaneously, this single environment will not help us much. That’s where Thread comes into the picture.

We can write our program in a way; it can do multiple things simultaneously in different threads. Each Thread is a unique execution environment.

Creating a thread is easy. In java, we have a class called Thread that can be instantiated and provided a job to it, and it will run independently. Let’s see an example- 

```java
package com.bazlur.threads;

public class Playground {
  public static void main(String[] args) {
    Thread thread1 = new Thread(() -> {
      System.out.println("Running from: " + Thread.currentThread());
    });

    Thread thread2 = new Thread(() -> {
      System.out.println("Running from: " + Thread.currentThread());
    });

    thread1.start();
    thread2.start();
  }
}

```

When we create a thread, we pass a lambda expression to its argument. In the expression, we put our code that we want to run independently.

In the above code, we have created two threads. Each Thread will run independently and simultaneously. Although we have started two threads one by one, we can never tell which one would run first. That’s the nature of the Thread. They are independent and depend on how the operating system schedules them to run.

So far, we have just seen how to create a thread and how to run them. They are super helpful when we have some independent work to be done. For example- we have to write a web server where multiple clients connect to it. If the server runs with a single thread, then at a time, it will be able only to serve one client. That’s not super useful. The server should handle multiple clients at a time, and that’s the point of having it.

Let’s see in the code-

```java
package com.bazlur.threads;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Playground {
  public static void main(String[] args) throws IOException {
    var serverSocket = new ServerSocket(4040);
    System.out.println("Started server on port " + 4040);

    while (true) {
      var socket = serverSocket.accept();
      var thread = new Thread(() -> {
        handleClient(socket);
      });
      thread.start();
    }
  }

  private static void handleClient(Socket socket) {
    //here we have code for handling a client
  }
}

```

In the above code, the server keeps listening from clients, and whenever a client connects, it creates a new thread and passes the job into it. That’s how threads help us.

That’s for today, cheers!!
Super Productivity v7 is out!
Tags: productivity, opensource
Published: 2021-06-28 06:55:24

---
title: Super Productivity v7 is out!
published: true
description: Free open-source ToDo-List / Time Tracker Super Productivity introduces the new timeline feature which is a simple and innovative way of planning your day.
tags: productivity, opensource
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5no0p2e0wfm5y3f9f5v8.png
---

Free open-source ToDo-List / Time Tracker Super Productivity is out in version 7. Among lots of other improvements and minor fixes, it ships with the new timeline feature which is a simple and innovative way of planning your day.

Check it out and let me know what you think!

https://super-productivity.com/
https://github.com/johannesjo/super-productivity

Special Thanks go to [stkofler](https://github.com/stkofler) for developing the search feature!
Salesforce Consulting Services ValueLabs
Tags: salesforce
Published: 2021-06-28 06:49:56

Leverage ValueLabs' silver-level partnership with Salesforce to improve your company's performance and scalability.
ValueLabs' world-class Salesforce services give your company the ability to market products better, sell them faster, and engage with customers in a whole new way - without major overhauls. Use the experience of a very experienced agile team to develop high-quality solutions and transform the customer experience.

Salesforce offers extensive analysis functions and a large number of potential applications and integrations, making it the most popular provider of cloud-based software. This flexibility and adaptability allow you to customize this powerful software to meet individual business needs. The ValueLabs team can help you with that!

Implement world-class Salesforce solutions to increase performance, improve scalability, and transform the customer experience - across the enterprise.

ValueLabs can help you benefit from fast and efficient automated deployments, achieve global rollouts and unleash innovative ideas from within. By using the expertise of a very experienced agile team and being one step ahead of the competition with a technical partnership, you will position your company for success. Let's get fit for the future together!

Link: https://www.valuelabs.com/services/salesforce/
Cheap cPanel License
Published: 2021-06-28 06:34:57

Are you thinking about starting a hosting business?
but you don't want to pay so much for official cPanel license, Then we are appropriate for you
We provide <a href="https://www.serverlicenses.com">Cheap cPanel License</a> for 6$ per month including (Softaculous, Jetbackup, Fleetssl, Sitepad) License for free.
We have a dedicated support team for supporting our customers 24/7.
Our Official Website = https://ServerLicenses.com
Our Telegram = https://t.me/serverlicenses
Web Server & Web Application Server
Tags: webdev, was, server, beginners
Published: 2021-06-28 06:34:25

## Web Server

Web server is a program that provides static contents like HTML documents by receiving HTTP request from the web browser (client).

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

Static contents mean that no matter what parameters or users will be, the response always includes the same contents.

### Web Server's Functionalities

- Receives HTTP request from the client
- For static contents, the server can provides static contents (html, jpeg, css, etc.)
- For dynamic contents, the server delivers dynamic contents request to *Web Application Server (WAS)*, and pass results from the WAS.

## Web Application Server (WAS)

Web application server is a program that is implemented for providing dynamic contents which require various logic processes or DB queries.

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

Dynamic contents can be varied from the input parameters or users

### WAS can

- directly receive HTTP request from the client
- provide static contents (html, jpeg, css, etc.)
- provide dynamic contents by processing various logics and DB query

## Why we need WS for WAS?

- We may need WS because we can separate the roles between WS (for static contents) and WAS (for dynamic contents).
- If we use multiple WAS, then WS can be a load balancer to distribute the request calls from the client.
- WS can regularly check the WAS health (check if response comes correctly)
- We can use reverse proxy from WS to secure the data from the WAS.

## Common Web Server Software

- Apache HTTP server
- Nginx
- Sun Java System Web Server
- ...
Load Balancer in AWS(ELB)
Tags: aws, cloud, devops, beginners
Published: 2021-06-28 06:33:06

We need multiple instances of a server so if one of them shuts down because of any hardware failures or load the other can handle the load and we don't experience down times but if we setup multiple instances how to manage which server will handle the requests and at what time. This is where AWS load balancers ELB(Elastic Load Balancer) comes in.

## What are load balancers?

These are basically servers that point and forward the incoming traffic to multiple different servers in a streamlined fashion.

## Why load balancers?

* It provides a way to scale your application
* It reduces downtime by maintaining health checks on different instances.
* It provides single point of access to multiple servers.
* We can provide a single configuration point for things like HTTPS, DDoS attacks etc

### Advantages of using Amazon ELB

We can always setup our own load balancers and will be cheap as compared to ELB. So, why should we use them we should just get an Ec2 instances and setup our own load balancer on it. Setting up our load balancer comes with cost saving with respect to the service but it has its problems with managing the load balancer. You have to ensure how to update configure and maintain it. Which may be a full time jib if you have 3-4 load balancers setup and setting up more will a hassle each time. With this service AWS ensures that they will upgrade, maintain with you only have to setup a few configuration knobs.

There are two type of load balancers available in AWS:-
1. Network load balancer (Layer 4)
1. Application Load balancer(Layer 7)

### Network load balancer 

Network load balancing uses information defined at the networking transport layer (Layer 4) as the basis for deciding how to distribute client requests across a group of servers. A network load balancer does load-balancing based on on the source and destination IP addresses and ports recorded in the packet header, without considering the contents of the packet.

### Application load balancer

Application load balancer deals with the actual content of each message. HTTP is the predominant Layer 7 protocol for website traffic on the Internet. Application load balancers route network traffic in a much more sophisticated way than Network load balancers, particularly applicable to TCP‑based traffic such as HTTP. An application load balancer terminates the network traffic and reads the message within. It can make a load‑balancing decision based on the content of the message (the URL or cookie, for example). It then makes a new TCP connection to the selected upstream server (or reuses an existing one, by means of HTTP keepalives) and writes the request to the server.

To know more about the layers in internet you can look up [OSI reference model](https://docs.oracle.com/cd/E19504-01/802-5886/intro-45828/index.html)

In the next article we will see how to setup a ELB with AWS.
AWS SDK with Javascript: Multi-Files Download from S3
Tags: aws, javascript, zip, download
Published: 2021-06-28 06:29:23

If you want to download multiple files as zipped from AWS S3, and you have your server to take care of the file metadata handlings, then this article may help you understand how the process works. AWS doesn't provide the default multi-files download, so in order to achieve you may want to add lambda function or to use your own implemented service. This article uses the custom service to support multi-files download function.

To know the basic setup of the code (AWS keys, the meaning of Key in the code, bucket, etc.), please refer to another article that I worte [AWS SDK with Javascript: Download File from S3](https://dev.to/ldsrogan/aws-sdk-with-javascript-download-file-from-s3-el2).

```javascript
import * as AWS from 'aws-sdk';
import archiver from 'archiver';
import path from 'path'
import { PassThrough } from 'stream';

const s3bucket = new AWS.S3({
  accessKeyId: process.env.AWS_ACCESS_KEY,
  secretAccessKey: process.env.AWS_SECRET_KEY,
  signatureVersion: 'v4',
  region: process.env.AWS_REGION, // ex) us-west-2
});
```

Here is the main function that allows to receive file infos as an input parameter and to create stream object that can be used to write or pass the data as zipped format.
```javascript
const multiFilesStream = (infos) => {
  // using archiver package to create archive object with zip setting -> level from 0(fast, low compression) to 10(slow, high compression) 
  const archive = archiver('zip', { zlib: { level: 5 } });

  for (let i = 0; i < infos.length; i += 1) {
    // using pass through stream object to wrap the stream from aws s3
    const passthrough = new PassThrough();
    s3bucket
      .getObject({
        Bucket: process.env.AWS_BUCKET_NAME,
        Key: path.join(infos[i].path, infos[i].filename);
      })
      .createReadStream()
      .pipe(passthrough);
    // name parameter is the name of the file that the file needs to be when unzipped.
    archive.append(passthrough, { name: infos[i].filename });
  }
  return archive;
};

```

```javascript
const files = [
   {path: '/drive', filename: 'file1.jpg'},
   {path: '/drive', filename: 'file2.jpg'},
   {path: '/drive', filename: 'file3.jpg'},
   {path: '/drive', filename: 'file4.jpg'},
];

const mfStream = multiFilesStream(files);

// res is the response object in the http request. You may want to create your own write stream object to write files in your local machine
mfStream.pipe(res);

// use finalize function to start the process
mfStream.finalize();
```