teleren/devto huggingface dataset:
Why Am I Getting a 502 Bad Gateway After Turning on Plausible?
Tags: analytics, 502
Published: 2024-01-28 04:22:54

---
title: Why Am I Getting a 502 Bad Gateway After Turning on Plausible?
published: true
date: 2024-01-28 04:11:47 UTC
tags: analytics, 502
canonical_url: https://plausiblebootstrapper.com/posts/bad-gateway
---

If you’re using Docker to self-host Plausible on DigitalOcean or any other virtual machine, you might’ve run into a “502 Bad Gateway” error when attempting to navigate to the administrator dashboard.

![](https://cms.macarthur.me/content/images/2024/01/image-7.png)

It’s a more common problem than you might think, but there are fortunately a few says to figure it out:

## **1. Give it a minute or two after start-up.**

If you set up Plausible using the [Plausible Bootstrapper](https://plausiblebootstrapper.com/?ref=alex-macarthur) or their recommended `docker-compose.yml`, you started everything up by running `docker compose up -d`. That `-d` flag is helpful, but can also hide feedback from your containers about what’s goin on under the good.

If you ran `docker compose up` _without_ that flag, you’d see logs from every container running under the good, and you’d be more aware of the fact that _a lot is going on under the hood,_ and it might take a bit to get to the point of it being ready to receive requests.

![](https://cms.macarthur.me/content/images/2024/01/image-8.png)
_container activity_

On my own virtual machine, it takes several seconds to become fully functional after turning on every container. And in the meantime, incoming requests may be met with a 502 error.

So, if you’re seeing this issue just seconds after turning on everything, it might just required waiting a couple minutes for the containers to boot up properly until they’re ready to received requests.

## **2. Allocate more RAM.**

By default, the Docker engine running on your machine [doesn’t have specific memory constraints](https://docs.docker.com/config/containers/resource_constraints/?ref=alex-macarthur) when running your containers — it’ll just assume the resources available on the machine itself.

But that can mean the specifications of your machine can impact Plausible’s ability to function effectively. Using `docker compose logs` in the directory of your Plausible instance can reveal odd errors being through by various components, and they’re often tied to limited RAM available at the time.

On DigitalOcean, an easy way to test this is to resize your machine to one with more RAM:

![](https://cms.macarthur.me/content/images/2024/01/image-9.png)
_droplet sizing_

If you’re on the 512MB size, switching to 1BG can make a big impact. Restart your containers, and it’s possible your issues will go away.

## **Other Causes?**

These are the two most common causes of a 502 Gateway when running my own instances of self-hosted Plausible, but I’m sure it’s not an exhaustive list. If you’ve identified any other culprits, I’d love to hear them. Send me a message or find me on X.
The Best Hacker In The World is TREK Tech Corp
Published: 2024-01-28 03:32:37


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kdqxznllvx2oe83z239l.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvobcrs5r11va31pmedi.jpg)I encountered an unexpected issue with my Cryptonator account, leaving me unable to access my Bitcoin wallet. Despite numerous attempts, I was continuously blocked and denied access. With $80,000 at stake, I felt overwhelmed by the thought of losing everything. Thankfully, a ray of hope emerged when I stumbled upon a review about TREK Tech Corp, a trusted funds recovery service that had successfully assisted countless individuals in similar situations. Without hesitation, I reached out to them, and to my amazement, TREK Tech Corp was able to retrieve my Bitcoin wallet and restore my funds. I am immensely grateful to TREK Tech Corp for their incredible work. For those in need, you can contact TREK Tech Corp through the following channels:

E-Mail:trektechcorp1@gmail.com 
E-Mail:trektechcorp@consultant.com
Demystifying JavaScript's typeof Operator: A Guide to Type Checking
Published: 2024-01-28 02:47:56

In the vast world of JavaScript, understanding data types is crucial for writing robust and reliable code. Enter the `typeof` operator, a fundamental tool for type checking in JavaScript. Let's unravel the mysteries of `typeof` and learn how to wield its power effectively.

**Understanding the typeof Operator**
The `typeof` operator is a unary operator that returns a string indicating the data type of its operand. It's commonly used to determine the type of a variable or value at runtime.
```js
console.log(typeof 42);          // 'number'
console.log(typeof 'hello');      // 'string'
console.log(typeof true);         // 'boolean'
console.log(typeof undefined);    // 'undefined'
console.log(typeof null);         // 'object' (an infamous quirk of JavaScript)
console.log(typeof {});           // 'object'
console.log(typeof []);           // 'object'
console.log(typeof function(){}); // 'function'
```

**Handling Primitives and Objects**
While `typeof` can reliably determine the primitive types (number, string, boolean, undefined), it's important to note its limitations when dealing with objects and arrays. In JavaScript, arrays and objects are considered 'objects' by `typeof`, which can lead to confusion.

**Dealing with Objects and Functions**
When it comes to objects and functions, `typeof` provides valuable insights. Objects, including arrays and null, are all categorized as 'objects' by `typeof`. Functions are classified separately as 'function'.
```js
console.log(typeof {});           // 'object'
console.log(typeof []);           // 'object'
console.log(typeof null);         // 'object' (a JavaScript quirk)
console.log(typeof function(){}); // 'function'
```

**The Pitfalls of typeof**
While `typeof` is useful for basic type checking, it's not foolproof. It's essential to be aware of its limitations, especially when dealing with objects and arrays. For more precise type checking, consider using other methods such as instanceof or custom validation functions.


**Conclusion: A Tool in Your Toolbox**
The `typeof` operator is a fundamental aspect of JavaScript's type system. While it has its limitations, it serves as a valuable tool for type checking and conditional logic. By understanding its behavior and nuances, you can wield `typeof` effectively in your JavaScript projects.

**Console You Later!**
Code Smell 239 - Big Pull Request
Tags: webdev, javascript, beginners, programming
Published: 2024-01-28 02:26:03

*You make too many different changes in a single pull request*

> TL;DR: Always stick to baby steps

# Problems

- Readability

- Code Review time and complexity

- Merge Conflicts

- Testing Challenges

# Solutions

1. Break the change in atomic parts

# Context

When pull requests become very large, they can pose several challenges and problems for development teams.

You must avoid merge requests making different unrelated changes.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/8324fa9cdd7a18f1f66f33ad874244c8)
```javascript
function generateFibonacci(ordinal) {
  const fibonacciSequence = [0, 1];

  for (let index = index; index < ordinal; index++) {
    const nextFibonacci = fibonacciSequence[index - 1]
          + fibonacciSequence[index - 2];
    fibonacciSequence.push(nextFibonacci);
  }

  return fibonacciSequence;
}

// This function solves a very different problem
// You should not mix them in a single pull request

function voyagerDistanceFromEarth(currentDistanceInKms, yearsTravelled) {
  const speedOfVoyagerInKmS = 17; 

  return currentDistanceInKms + 
        speedOfVoyagerInKmS * yearsTravelled * 60 * 60 * 24 * 365.25;
}
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/9d8adddf01f4ba19917b6307cdcd66f3)
```javascript
function generateFibonacci(ordinal) {
  const fibonacciSequence = [0, 1];

  for (let index = index; index < ordinal; index++) {
    const nextFibonacci = fibonacciSequence[index - 1]
          + fibonacciSequence[index - 2];
    fibonacciSequence.push(nextFibonacci);
  }

  return fibonacciSequence;
}

// You break it into two different pull requests
```

# Detection

[X] Automatic 

You can put a threshold and a warning on big merge requests.

# Exceptions

- Big refactors that cannot be made with baby steps

# Tags

- Complexity

# Level

[ X] Beginner

# AI Assistants

AI assistants do not create pull requests. 

They generate the code you need.

# Conclusion

Software engineers must be experts at managing (and avoiding) [accidental complexity](https://dev.to/mcsee/coupling-the-one-and-only-software-design-problem-2pd7).

# Relations

{% post https://dev.to/mcsee/code-smell-170-refactor-with-functional-changes-4e13 %}

# Disclaimer

Code Smells are my [opinion](https://dev.to/mcsee/i-wrote-more-than-90-articles-on-2021-here-is-what-i-learned-1n3a).

# Credits

Photo by [Håkon Grimstad](https://unsplash.com/@grimstad) on [Unsplash](https://unsplash.com/photos/blue-and-black-butterfly-on-brown-stick-hteXWSF9jA4)
    
* * *

> First make the change easy (warning: this might be hard), then make the easy change.

_Kent Beck_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
جلب الحبيب ☎️ 00𝟐0𝟏0𝟐𝟳0𝟑𝟗𝟐𝟱𝟒 - السعودية - الامارات - الكويت
Tags: ios, devops, github, learning
Published: 2024-01-28 02:22:15

جلب الحبيب السعودية ، شيخ روحاني فى السعودية ، جلب الحبيب الامارات ، شيخ روحاني فى الامارات ، جلب الحبيب الكويت ، شيخ روحاني فى الكويت
iPhone 15 Pro Max giveaway
Tags: javascript, webdev, react, beginners
Published: 2024-01-28 01:44:28

)key=8ffe55f8f3c80075e5b2946fd24c7642Be cautious 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/clzw5yl9n94siaiccxk1.jpeg)of online giveaways, as [many[ can be scams. Legitimate companies typically promote giveaways on their official websites or social media channels. Verify the legitimacy of any giveaway and avoid providing personal information to unknown sources.](https://www.toprevenuegate.com/p0qz330hc?key=8ffe55f8f3c80075e5b2946fd24c7642)
[iPhone 15 Pro Max giveaway](https://www.toprevenuegate.com/p0qz330hc?key=8ffe55f8f3c80075e5b2946fd24c7642)
Avoid Infinite Loop When Using UseMemo with UseEffect
Tags: javascript, react, tutorial, learning
Published: 2024-01-28 01:04:53

In my previous blog post, I discussed useMemo. I received valuable insights in the comments, pointing out the importance of caution when combining useMemo with useEffect since it could lead to an infinite loop. So, in today's post, I aim to delve deeper into this topic, focusing specifically on when this issue may arise.

**useEffect(setup, dependencies?)**
The `setup` is a function and runs every time some values in the `dependencies` array are changed.

**const cachedValue = useMemo(calculateValue, dependencies)**
The `calculateValue` is a function and runs every time some values in the `dependencies` array are changed, and then the new value is cached.

Let's take a look at when an infinite loop occurs.
Here's an example:

```
import { useEffect, useMemo, useState } from "react"

export const InfiniteCountUp = () => {
  const [count, setCount] = useState(0)

  const cachedMemo = useMemo(() => count * 2, [count])

  useEffect(() => {
    console.log("Triggered")
  }, [cachedMemo])

  return (
    <div>
      <p>{cachedMemo}</p>
      <button onClick={() => setCount(count + 1)}>Increment</button>
    </div>
  )
}
```
Every time the Increment button is clicked, the `count` is updated, which triggers the recalculation of the `cachedMemo` value due to the dependency on `count` in the useMemo dependency array. Subsequently, the useEffect is triggered as it depends on the updated `cachedMemo` value. 
This sequence of events could potentially lead to an infinite loop.

Another example is when fetching data.

```
import { useEffect, useMemo, useState } from "react"

export const InfiniteDataFetching = ({ postId }) => {
  const [post, setPost] = useState("")

  const cachedMemo = useMemo(() => {
    const { postId } = post
    return postId
  }, [post])

  useEffect(() => {
    const fetchData = async () => {
      try {
        const res = await fetch(`https://example.blog/${postId}`)
        const data = await res.json()
        setPost(data)
      } catch (error) {
        console.error(error)
      }
    }

    fetchData()
  }, [postId, cachedMemo])

  return <div>{post && <p>{post.article}</p>}</div>
}
```
In this example, each time the `postId` changes, new data is fetched, setting the new post. This setup creates a potential infinite loop: changes in `postId` trigger useEffect, and the memoized `cachedMemo` value is recalculated during each render, potentially leading to repeated calls of the effect. 

To avoid an infinite loop, it would be better to carefully consider the overall flow. As the code gets larger, it's easy to fix a smaller part without seeing the whole picture. So, taking a step back and understanding the interactions between different parts of the code can help us avoid an infinite loop and decide which dependencies truly need to be included.
Introduction to Graph Algorithms in Python
Tags: python, beginners, graphql, programming
Published: 2024-01-28 00:31:42

## Introduction

Graph algorithms are an essential tool for solving complex problems in computer science, data analysis, and network optimization. These algorithms are used to traverse, analyze, and manipulate data represented in the form of graphs. Python, being a popular and versatile programming language, offers a robust collection of libraries and modules for implementing graph algorithms efficiently. In this article, we will discuss the advantages, disadvantages, and features of graph algorithms in Python.

## Advantages

- **Ease of Implementation**: Python's simple and readable syntax makes it easier to write and understand complex algorithms.
- **Rich Library Support**: With libraries such as NetworkX, igraph, and pygraphviz, Python provides powerful tools for various types of graph operations.

## Disadvantages

- **Slower Execution**: Python's execution speed may lag behind lower-level languages like C or Java.
- **Handling Large Datasets**: As an interpreted language, Python may face efficiency issues when dealing with large datasets.

## Features

- **Versatility**: Python supports both directed and undirected graphs, making it suitable for a wide range of applications.
- **Shortest Path Algorithms**: It includes implementations of various shortest path algorithms, catering to both weighted and unweighted graphs.
- **Rich Data Structures**: Python's data structures and built-in methods are well-suited for working with graph data.

### Example Code Snippet Using NetworkX

```python
import networkx as nx

# Create a graph
G = nx.Graph()

# Add nodes
G.add_node(1)
G.add_nodes_from([2, 3])

# Add edges
G.add_edge(1, 2)
G.add_edges_from([(2, 3), (1, 3)])

# Draw the graph
nx.draw(G, with_labels=True)
```

This code snippet demonstrates how to create a simple graph, add nodes and edges, and draw the graph using the NetworkX library.
## Conclusion

In conclusion, Python’s extensive collection of libraries and its user-friendly design make it a popular choice for implementing graph algorithms. While it may have some limitations in terms of speed, the ease of use and numerous features make it a powerful tool for solving problems related to graphs. By utilizing the right libraries and understanding the underlying concepts, one can effectively apply graph algorithms in Python to tackle a wide range of real-world problems.
Animated emojis for React apps
Tags: react, nextjs, emoji, lottie
Published: 2024-01-28 00:15:42

Hey Dev community! 👋
{% youtube wyiVbxj4G0M %}

Ever wished your React projects could be as expressive as you are? Well, now they can! I'm thrilled to introduce [ReactEmojis](https://reactemojis.com?source=dev), a game-changer for React developers seeking to add a touch of fun and creativity to their UI.

## The Backstory:

As a solo indie hacker, I've spent the past two years navigating the intricate world of app development. My journey was filled with half-finished projects and a quest for that 'perfect' product. It was time for a shift in approach.

Instead of diving into another massive app, I started small – and thus, ReactEmojis was born. This ReactJS package is designed to effortlessly integrate animated SVG emojis into your landing page or React app, bringing your UI to life in a playful and engaging way.

## Why ReactEmojis?

Spice Up Your UI: ReactEmojis offers a dynamic way to animate your user interface, making it more visually appealing.

Start Small, Dream Big: Begin with something simple. ReactEmojis is your ticket to testing the waters and gaining that much-needed motivation.

Seamless Integration: The package is designed to be user-friendly. Just a few lines of code, and you're all set to elevate your UI experience.

Choose from 100 Emojis, 300 Styles: With a diverse collection of 100 emojis, each offering three animated variations, the possibilities are practically endless.

Feedback Welcome: I'm eager to hear your thoughts! Your feedback is invaluable in shaping the future of ReactEmojis.

## How to Get Started:

Install ReactEmojis in your React project.
Choose your favorite emoji.
Watch your UI come to life!
Ready to inject some fun into your React coding journey? Check out ReactEmojis here and let the emoji magic begin! 🚀

Feel free to drop your thoughts and feedback below. Happy coding!


[https://reactemojis.com](https://reactemojis.com)
CSS Stacked Cards: Simple and Easy way
Tags: css, html, webdev, tailwindcss
Published: 2024-01-27 23:45:09

Probably you've seen this cool effect on some websites where images stack on top of each other, you liked this animation and were wondering how it can be done.

![Stacked Cards using CSS demonstration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1w77rni2njv82qnwuaaw.gif)

Do I need to use the animation library for that? GSAP? Or maybe Framer Motion.

And the actual answer is no. It can be done with just plain CSS!

![What if I told you CSS could do that meme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ftvd84w74w0cewe3cjl.jpg)

Here is the code sample:

```
<div>
	<div id="layer1" class="bg-red-400  h-screen w-screen flex justify-center items-center top-0 sticky">
		<p>CSS</p>
	</div>
	<div id="layer2" class="bg-orange-400 h-screen w-screen flex justify-center items-center top-0 sticky">
		<p>is</p>
	</div>
	<div id="layer3" class="bg-blue-400 h-screen w-screen flex justify-center items-center top-0 sticky">
		<p>not</p>
	</div>
	<div id="layer4" class="bg-green-400 h-screen w-screen flex justify-center items-center top-0 sticky">
		<p>awesome!</p>
	</div>
</div>
```

In this example I used TailwindCSS, but you can use whatever you want - plain CSS or any other library. 
So, the most important properties here are these two:

- _**top-0**_ that sets top to 0

- _**sticky**_ that sets the position of the card to sticky

And not to forget, all cards are contained within the div - the containing block-level ancestor.

---

And that's it, guys.

I hope that you have learned something new today!
I would appreciate it if you could like this post or leave a comment below!

Also, feel free to follow me on [GitHub](https://github.com/Kai4ik) and [Medium](https://medium.com/@kai4ik)!

Adios, mi amigos)

![Bye bye dear friend](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02fmxavj6v951cpykmig.gif)
Enhance Viewer Experience with our Spanish Subtitle Generator
Tags: spanishsubtitle, spanishsubtitles
Published: 2024-01-27 23:13:16

Make your content accessible to all by utilizing  Spanish Subtitle Generator. By adding Spanish subtitles, you cater to the needs of Spanish-speaking viewers, making your videos inclusive and engaging for a diverse audience. spanish subtitle Spanish Subtitle Generator is a revolutionary tool that empowers content creators to effortlessly generate accurate and professional **[Spanish subtitles](https://simplified.com/subtitle-generator/spanish)** for their videos. With its advanced algorithms and user-friendly interface, this innovative software ensures that your content reaches a wider audience and breaks language barriers. Say goodbye to the tedious and time-consuming process of manually translating your videos into Spanish.  Spanish Subtitle Generator automates the entire process, saving you countless hours of work and delivering precise subtitles that enhance the viewer experience. With  **[Spanish Subtitle](https://simplified.com/subtitle-generator/spanish)** Generator, you can tap into the enormous potential of the Spanish-speaking market. By matically adding Spanish subtitles to your videos, you can expand your reach, increase engagement, and ultimately boost your brand's visibility and growth. Spanish Subtitle Generator is designed to be intuitive and efficient, even for users with no prior subtitle creation experience. Its seamless integration with popular video editing software allows you to easily import and export subtitles, ensuring a hassle-free workflow.