teleren/devto huggingface dataset:
Book summary: The Lonely Century
Tags: books, book, society
Published: 2023-01-21 16:10:47

---
title: Book summary: The Lonely Century
published: true
date: 2023-01-21 16:06:00 UTC
tags: books, book, society
canonical_url: https://blog.dornea.nu/2023/01/21/book-summary-the-lonely-century/
---

Do you feel invisible when you’re in the city and everybody just walks by without any eye contact, completely ignoring your existence? Are you already suffering from Zoom fatigue and sick of meeting your colleagues in a virtual environment? Or maybe you’re lucky enough and do have an office but everybody headphones while moving from A to B, signaling (fake) busyness and some sort of “I don’t want to talk to you now. So please respect my right to isolate myself from the rest of the world.”

If you already have these symptoms, it’s tempting to think it’s only related to one life area (e.g. job, friends). But no, it’s more than that: Do you feel disconnected from your relatives and friends despite all the modern and endless communication options? Did you also notice how public space (parks, playgrounds, cafes, libraries) seems to change in the favour of malls, housing complexes, co-working spaces, industry areas? In the worst-case scenario you have completely lost trust in politics, faith in humanity and feel how society has become “exclusive”.

If you’ve answered most of these questions with YES, most likely you feel alone. But you’re not the only one - at least in this aspect you’re not alone. In her book “[The lonely century](https://www.goodreads.com/book/show/50695158-the-lonely-century)” **Noreena Hertz** systematically analyzes why people all over the world suffer from loneliness and how tech and politics play a vital role in amplifying feelings of frustration, misbeliefs, rage, angst, anger among people. And while COVID-19 has brought the biggest “social distancing” experiment ever, the foundations of today’s loneliness at a society level have been layed long before the pandemic.

Although some of the reading is quite depressing (especially the chapter about robots, automatization and how more and more people will lose their jobs), this books serves as a reminder and manual of ideas meant to restore human connnections where “social” media and neoliberal policies have been pulling us apart. So, put your smartphone down, start being aware of your surroundings, reconnect with nature, talk to people around you, engage in communities, support local stores, take initiatives, do not isolate yourself.

BTW: You can measure your subjective feeling of loneliness using the “[UCLA Loneliness scale](https://psytests.org/ipl/uclaen.html)”.
Can't use redis with nodejs 18.13. Invalid or unexpected token?
Published: 2023-01-21 18:17:02



Nodejs Application Crashes by only importing redis. I am not even using it any where else.

Just `import redis from "redis"` is throwing me this error.

Node & Redis Version:

1. `❯ node -v v18.13.0`
2.  `"redis": "^4.5.1"`

This is my server index.js file:
[index.js](https://github.com/DebanjanT/debug/blob/main/redis_error.js)

Error:

```
/Users/debanjantewary/Desktop/YSG/server/node_modules/@redis/client/dist/lib/cluster/cluster-slots.js:65
            if (node.client.options?.readonly)
                                    ^

SyntaxError: Invalid or unexpected token
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)

Node.js v18.13.0
```


Tried solution But didn't work:

    Clear cache node
    Re-install Node stable version

Please help If anyone knows. Thank you ❤️
An overview of Loss function and Gradient descent in Machines Learning
Published: 2023-01-21 18:10:54


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

Loss Function and Gradient Descent are two of the most important concepts in Machine Learning. They are used to optimize the performance of a model by minimizing the error between the predicted output and the actual output. In this article, we will discuss what Loss Function and Gradient Descent are, how they work, and provide examples of each.

A Loss Function is a mathematical equation used to measure the difference between a predicted output and an actual output. It is used to evaluate how well a model is performing on a given task. The goal of any machine learning algorithm is to minimize this loss function so that it can accurately predict outputs for unseen data points. Common loss functions include mean squared error (MSE), cross-entropy loss, hinge loss, and logistic regression loss. To Optimize the loss function various Gradient Descent algorithms are used.

**Gradient Descent** is an optimization algorithm used to minimize a given Loss Function. It works by iteratively updating the parameters of a model in order to reduce the value of the Loss Function at each step. This process continues until either the Loss Function reaches its minimum value or until no further improvement can be made. Gradient Descent can be implemented using various algorithms such as Stochastic Gradient Descent (SGD), Mini-Batch Gradient Descent (MBGD), or Batch Gradient Descent (BGD).

To illustrate these concepts with an example, let’s consider a simple linear regression problem where we want to predict housing prices based on square footage. We can use MSE as our Loss Function which measures how far off our predictions are from the actual values: 

MSE = 1/n * Σ(y_i - y_hat)^2 

where,
n :-  the number of data points. 
y_i :-  our predicted value for each data point i. 


We can then use Gradient Descent to find optimal parameters for our model which will minimize this MSE value. 

It’s also important to remember that minimizing a cost function does not guarantee good performance on unseen data; it only indicates that your model is performing well on seen data. Therefore, it’s important to evaluate your model on unseen data as well in order to get an accurate measure of its performance.

In conclusion, Loss Functions and Gradient Descent are two essential concepts in Machine Learning that allow us to optimize models so that they can accurately predict outputs for unseen data points. By understanding these concepts and how they work together, we can create more powerful machine learning models that produce better results than ever before!
Ubuntu doesn't show git branch name in command line prompt? Simple fix
Tags: tutorial, linux, ubuntu, git
Published: 2023-01-21 18:00:20

After one of the recent updates I noticed that Ubuntu stopped showing active git branch in Command line prompt.

It's annoying but, luckily, very easy to fix.

Find following in your `.bashrc` file:
```
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac
```

And replace it with:
```
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]'
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w'
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# get current git branch
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

PS1="$PS1\[\033[0;32m\]\$(parse_git_branch)\[\033[00m\]\$ "
```

And it will work again!
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psmf26yu96t8m6cdz8v8.png)
JWT & Passport.js authentication
Tags: passportjs, node, jsonwebtoken
Published: 2023-01-21 18:00:00

To use JSON Web Token (JWT) authentication with Passport.js and Node.js, you can follow these general steps:

- Install the necessary packages:
```
npm install passport passport-jwt jsonwebtoken
```

- Create a user model with fields such as `username`, `password`, and `email`. You can use a library like Mongoose to define the schema and interact with a MongoDB database.

- Create a new strategy for Passport.js that uses JWT. This strategy will check for a valid JWT in the `Authorization` header of incoming requests, and decode it to get the user's ID.

- In the route handling function, use `passport.authenticate('jwt', { session: false })` to authenticate the user.

- In the route handling function, use req.user to access the user's ID and other information.

- In the login function, use the jsonwebtoken package to create a JWT with the user's ID as the payload.

Here is some sample code to demonstrate the above steps:
```javascript
const passport = require('passport');
const JwtStrategy = require('passport-jwt').Strategy;
const ExtractJwt = require('passport-jwt').ExtractJwt;
const jwt = require('jsonwebtoken');
const mongoose = require('mongoose');

const User = mongoose.model('users', new mongoose.Schema({
  username: String,
  password: String,
  email: String
}));

const jwtOptions = {
  jwtFromRequest: ExtractJwt.fromHeader('authorization'),
  secretOrKey: 'secret'
};

const jwtAuth = new JwtStrategy(jwtOptions, (payload, done) => {
  User.findById(payload.sub)
    .then(user => {
      if (user) {
        done(null, user);
      } else {
        done(null, false);
      }
    })
    .catch(err => {
      done(err, false);
    });
});

passport.use(jwtAuth);

app.post('/login', (req, res, next) => {
  passport.authenticate('local', { session: false }, (err, user, info) => {
    if (err || !user) {
      return res.status(400).json({
        message: 'Something is not right',
        user: user
      });
    }
    req.login(user, { session: false }, (err) => {
      if (err) {
        res.send(err);
      }
      // generate a signed json web token with the contents of user object and return it in the response
      const token = jwt.sign(user.toJSON(), 'secret');
      return res.json({ user, token });
    });
  })(req, res);
});

app.get('/profile', passport.authenticate('jwt', { session: false }), (req, res) => {
  res.send(req.user);
});
```
Please note that the above example is just a sample and should not be used in production without additional security checks.

You can also checkout the github [repo](https://github.com/muhammadabir64/passport.js-jwt)
JavaScript more efficient and readable code for make a calculator with only 20 lines with
Tags: webdev, javascript, codequality, motivation
Published: 2023-01-21 17:46:02



## **Eval Function for a Calculator**

[Click Here for visit the calculator and its code](https://saucalc.netlify.app/)
This is very very best way to improve and make efficient for our code. The eval() function is very helpful to make efficient, readable and maintainable. As we know about eval() function the eval() is a function property of the global object. The argument of the eval() function is a string. It will evaluate the source string as a script body, which means both statements and expressions are allowed. It returns the completion value of the code. For expressions, it's the value the expression evaluates to.

## **Comment me if you have impressive by this calculator.**

## **[Click Here for visit the calculator and its code](https://saucalc.netlify.app/)**
Installing Apache JMeter using Homebrew
Tags: jmeter, loadtesting, performancemeasurement, tutorial
Published: 2023-01-21 17:39:04

Apache JMeter is a popular open-source tool for load testing and performance measurement of web applications. One of the ways to install JMeter on a Mac or Linux is by using the package manager Homebrew.

Before you can install JMeter, you need to have Homebrew installed on your system. If you do not have Homebrew installed, you can install it by following the instructions on the Homebrew website (<https://brew.sh/>).

Once you have Homebrew installed, you can use the following command to install the latest version of JMeter:

```bash
brew install jmeter
```

This command will install JMeter and all its dependencies on your system.

Once the installation is complete, you can run JMeter by using the command:

```bash
jmeter
```

You can also check the version of JMeter that is installed on your system by using the command:

```bash
jmeter -v
```

It should display the version of JMeter that is installed on your system.

```bash
   / \  |  _ \ / \  / ___| | | | ____|     | |  \/  | ____|_   _| ____|  _ \
  / _ \ | |_) / _ \| |   | |_| |  _|    _  | | |\/| |  _|   | | |  _| | |_) |
 / ___ \|  __/ ___ \ |___|  _  | |___  | |_| | |  | | |___  | | | |___|  _ <
/_/   \_\_| /_/   \_\____|_| |_|_____|  \___/|_|  |_|_____| |_| |_____|_| \_\ 5.5

Copyright (c) 1999-2022 The Apache Software Foundation
```


That's all you need to do to install Apache JMeter using Homebrew. You can now start using JMeter to load test and measure the performance of your web applications.
Task about python
Published: 2023-01-21 17:36:56



Create a base class of a geometric figure (Figure). Implement classes of geometric shapes Triangle, Rectangle, Square, Circle.

 Each class should be placed in a separate file with an appropriate name (eg class Triangle => Triangle.py).
 All class files must be in the src/ folder at the root of the repository.
 The triangle must be given by three sides, if the triangle cannot be created, then throw the raise ValueError error.
 1 part.
 Each shape must have the following attributes:
 name - shape name,
 area (calculated!) - area,
 perimeter (calculated!) - perimeter (sum of side lengths or circumference)
 All computed properties must be calculated using formulas for the corresponding geometric shapes (no hardcoded values).
 Each figure must implement the add_area(figure) method which must accept another geometric figure and return the sum of the areas of those figures.
 If the method is not a geometric figure, then you need to throw an error (raise ValueError).
 An example of working with one of the figure classes:

             square = Square(10) # This creates a square with side 10
             square area
             one hundred
             triangle = Triangle(13, 14, 15) # This creates a triangle with sides 13, 14, 15
             triangle.area
             84
             triangle.add_area(square)
             184

How to complete a task? What to add in the Figure class?

https://github.com/AsiaS55/Figure/pull/1/files
Teknoloji Haberleri, Dünya Gündemi, Güncel Gelişmeler
Published: 2023-01-21 17:33:40

[hemenduy.com](https://hemenduy.com), [teknoloji](https://hemenduy.com/teknoloji/) ve oyun sektörlerinde son dakika gelişmelerini, en ilginç haberleri ve inovasyonları okuyucularına sunmak amacıyla kurulmuş bir web sitesidir. Site, teknoloji dünyasındaki en yeni cihazların inceleme ve özelliklerini, oyunların özellikleri, oyun videoları, oyun inceleme ve [oyun haberleri](https://hemenduy.com/oyun-haberleri/) gibi içerikleri okuyuculara sunar. Bu sayede okuyucular, teknoloji ve oyun sektöründe son dakika gelişmelerini ve haberleri takip edebilir, cihaz ve oyunlar hakkında bilgi sahibi olabilirler.

Güncel gündemdeki önemli olayları da takip eden Hemenduy.com, okuyuculara geniş bir yelpazede haberleri sunar. Bu haberler arasında siyasi, ekonomi, sosyal, kültürel, sağlık gibi konular yer almaktadır. [Astroloji](https://hemenduy.com/astroloji/) bölümünde ise okuyucular, burçlarının günlük, haftalık ve aylık yorumlarını okuyabilirler. Dünya haberleri bölümünde ise okuyucular, dünya genelinde meydana gelen önemli olayları ve haberleri takip edebilirler.

[hemenduy.com](https://hemenduy.com), okuyucuların ihtiyaçlarına yönelik birçok içeriği sunarak, onların bilgiye erişebilecekleri, güncel konular hakkında bilgilendirilebilecekleri ve eğlenerek zaman geçirebilecekleri bir platform olarak tasarlanmıştır. Site, okuyucuların zamanlarını verimli ve eğlenceli bir şekilde geçirmelerine olanak tanırken, aynı zamanda onların bilgi ve haberleşme ihtiyaçlarını karşılamaktadır. Hemenduy.com, okuyucuların hayatın her alanındaki önemli olayları ve haberleri takip etmelerine olanak tanır ve onların bilgiye erişimini kolaylaştırır
How to Deploy a set of Microservices with a specified version using Docker?
Tags: docker, microservices, tutorial, bash
Published: 2023-01-21 17:19:03

You can create a script (bash or python) to deploy a set of microservices with specified versions and parameters using the docker command.

Here's an example of a bash script that takes the version_service1 and version_service2 as arguments and deploys the corresponding microservices:

```
#!/bin/bash

# Get the version of service1
version_service1=$1

# Get the version of service2
version_service2=$2

# Get any additional parameters
additional_param_1=$3

# Start service1 with the specified version
docker run -d --name service1 myregistry/service1:$version_service1 --additional_param_1=$additional_param_1

# Start service2 with the specified version
docker run -d --name service2 myregistry/service2:$version_service2
```

You can execute the script with the command:

```
./deploy.sh v1.0 v1.0 5
```

This script will run the two microservices with specified versions and pass the additional parameter to the service1.

You can also create a similar script using python, for example, using the subprocess module to run the docker command and passing the arguments to the script.

It's important to note that this script runs the microservices on detached mode and name them service1 and service2. You can also use a more advanced approach like using docker-compose to deploy multiple services and manage them together, and use a .yml file to define the services, their versions, and their parameters.
Server in Node JS
Tags: webdev, tutorial, programming, javascript
Published: 2023-01-03 11:51:55

A server listens to the incoming requests from a browser. Then it decides what will be its response to the client, in most cases, it is an HTML page, but it could be an image or CSS as well. How does a server identify what response should be sent?

## IP Address

IP addresses are uniquely identified addresses to the computers which are connected to the internet. Some special computers known as Host means they host websites on the internet and publish a website. It will be hosted on the computer somewhere and all IP addresses to identify it and connect to it. They are a series of numbers, they could be hard to remember so we have a domain name to mask these IP addresses. When we type the domain in the browser and it will find the IP address associated with it and it will use that to find the computer that hosts the website, this way it can send requests and get back responses to and from it.

browser → Look-up IP address associated with the domain → Host 

when we type something into the browser and hit enter that is a GET request. It s made every time we go to a different web page either by link or directly typing into the address bar.

Now this communication between the client and server happens via HTTPS (Hyper Text Transfer Protocol). 

## Local host

Localhost is like a domain name on the web but it takes us to a very specific IP address known as loopback IP address. That is 127.0.0.1 and it points to our own computer. We consider our computer as a host when we are developing the website.

## Port Number

Port numbers are like a ‘door’ into a computer. It represents a gateway on our computer where a certain bit of software and server should communicate. There is software that interacts with the internet to receive and send data, but all of them has a different port number.

## Creating a server

In Node , server are manually created which lives on the backend of our website. 

Let s  create  a server that listens to the request and response to it.

```jsx
const http = require('http')
const server = http.createServer((req,res)=>{
  console.log('request made');
})

server.listen(3000, 'localhost' , () =>{
    console.log(`listening for request at 3000`)
})
```

  we use the http module to create a server. createServer method takes a callback with two arguments i.e. req(request) and res(response). Once we create a server, it listens to the requests, listen() method takes three arguments (port number, localhost, callback).

here it is! 🙂
Turn ChatGPT into a Docker Playground in 5 Minutes
Tags: docker, chatgpt, chatbo, ai
Published: 2023-01-21 17:12:19

ChatGPT is a highly advanced language model that can perform a wide range of natural language processing tasks with remarkable accuracy. It can act as a playground for you to experiment with language and test out different prompts or questions. You can use it to generate creative writing, have a conversation, or receive answers to your questions. Just keep in mind that the responses provided by ChatGPT are based on patterns it has learned from the data it was trained on, and may not always be accurate or appropriate.

To check its accuracy and capabilities, I spent considerable time with ChatGPT to see if it can act as a Linux terminal and run Docker-specific commands. Sounds interesting?

Keep Reading...

Here are a series of exciting questions that I asked ChatGPT to turn into a Docker Playground. I have used [Docker Awesome-Compose Repository](https://github.com/docker/awesome-compose). These samples provide a starting point for integrating different services using a Compose file and managing their deployment with Docker Compose.


_**Me: Hello GPT. Good Morning. I want you to act as a Mac terminal. Docker Desktop is already installed. I will type some commands and you'll reply with what the terminal should show. Show me the results using Mac terminal. When I tell you something, I will do so by putting text inside curly brackets {like this}. My first command is the docker version.**_



![Image1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90364cj5vvvzsmgsu7py.png)



_**Me: {docker run -d -p 81:80 ajeetraina/webpage}**_


![Image2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30a6qwwk0fgu1bg07vps.png)

**_Me: {docker ps}_**



![Image3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6mg42u8vvec4lhtfumm5.png)



_**Me: {docker stats}**_


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




_**Me: {wget https://github.com/docker/awesome-compose && cd awesome-compose/flask-redis && docker compose up}}**_


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


_**Me: {docker compose ps}**_



![Image31](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uk9qowv79cgb9ao2dzi3.png)
Back up Fly Postgres with GitHub Actions
Tags: fly, postgres, github, s3
Published: 2023-01-21 17:09:16

[Fly Postgres](https://fly.io/docs/postgres/) stores its data on volumes, and the fine folks at Fly.io set up automatic snapshots for us. However, I sleep better at night knowing that my databases are backed up with `pg_dump`. 

I found surprisingly few results when I searched for a quick solution to this problem. [One of the solutions](https://www.advantch.com/blog/automate-postgres-database-backups-on-fly-dot-io/) was a python script, which seemed overkill for such a simple task, but it was a useful starting point. In the end, I came up with a relatively short backup.yml that does the job:

{% embed https://gist.github.com/mfilej/af354f315508f114259773cc17c8d964 %}

The task will run every day at 4AM. `workflow_dispatch` is there so that the task can be run manually as well.

Don't forget to set the correct `region`, update `PGUSER`and `PGDATABASE`, as well as replace `your-fly-db-app-name`, `your-s3-bucket`, and `your-path`.

You will also need to visit your repository settings and set the following secrets: 

- `FLY_API_TOKEN` — A Fly personal access token ([generate one here](https://fly.io/user/personal_access_tokens))
- `PGPASSWORD` — the password for the database being backed up

And finally, don't forget: a backup is not a backup if you've never tried restoring it!