teleren/devto huggingface dataset:
Setup and Securing RabbitMQ
Tags: rabbitmq, tutorial, homebrew
Published: 2023-12-17 23:57:45


**Changing the default username and password in RabbitMQ**

First, access the command line on the server where RabbitMQ is installed in this case we used Homebrew to install our RabbitMQ server.

We can create a new user with a custom username and password using the `rabbitmqctl command`. Replace `new_username` and `new_password` with your desired credentials.

```
rabbitmqctl add_user new_username new_password
```
 
After creating the new user, you want to set permissions for this user. You can set permissions to allow the user to access all vhosts (/ is the default vhost). The command below will give the user permissions to read, write, and configure queues on the default vhost. Adjust the permissions according to your needs. 

using `set_permissions -h`

we see that we can supply a username and its permissions under <conf> <write> <read>

`[--node <node>] [--longnames] [--quiet] set_permissions [--vhost <vhost>] <username> <conf> <write> <read>`

```
rabbitmqctl set_permissions -p / new_username ".*" ".*" ".*"
```

Optionally, If the new user needs to have administrative access, you can set the user tag to administrator.

```
rabbitmqctl set_user_tags new_username administrator
```

By default, RabbitMQ creates a `guest` user with the password with world's strongest password for simplicity `guest`, but for security reasons, we will change the default user's password or delete the user. To change the password:

```
rabbitmqctl change_password guest new_guest_password
```

If you'd rather delete the guest user you can use this command below.

```
rabbitmqctl delete_user guest
```

After making all the changes needed, you should restart the RabbitMQ service to make sure all changes are applied and avoid conflicts. You can do this using your system's service management commands.
Since we're using Homebrew we will use the `brew` command.
If you're on linux you can choose to `sudo systemctl` commands

```
brew services restart rabbitmq
```

Finally, verify that the changes have been applied correctly. You can list users to see if your new user is created:

```
rabbitmqctl list_users
```

That's it, RabbitMQ should be all setup and secured!
How to deploy NextJS app on heroku
Published: 2023-12-17 23:55:04

To deploy an existing Next.js application to Heroku, you can follow these general steps:

## 1-  Prepare Your Project:

Make sure your Next.js application is set up correctly and is working locally. You should have the necessary project files, including `package.json`,` pages` folder, and other dependencies.


## 2- Create a Git Repository:
If your project isn’t already in a Git repository, initialize one by running:

```
git init
```
Create `a .gitignore` file if you don't have one to exclude unnecessary files from being committed to the repository.


## 3- Heroku Account: 

Make sure you have a Heroku account and have the Heroku CLI installed. You can sign up for Heroku at https://www.heroku.com/ and download the Heroku CLI from https://devcenter.heroku.com/articles/heroku-cli.


## 4-  Log in to Heroku:
## Open a terminal and log in to your Heroku account by running:

```
heroku login
```

## 5- heroku login
Create a new Heroku app for your project by running:

```
heroku create your-app-name
```

Replace `your-app-name` with the desired name for your app.


## 5- Add Build Scripts:
In your `package.json` file, make sure you have the following scripts defined for building and starting your Next.js app:

```
"scripts": {
  "build": "next build",
  "start": "next start"
}
```

## 7- Configure Environment Variables (if needed):
If your app relies on environment variables, you can set them on Heroku by using the `heroku config:set` command. For example:

```
heroku config:set MY_VARIABLE=value
```
## 8- Commit and Push to Heroku:
Commit your changes and push your repository to Heroku:

```
git add .
git commit -m "Initial commit"
git push heroku master
```

## 9- Open Your App:
Once the deployment is complete, you can open your app in the browser by running:

```
heroku open
```

Your Next.js app should now be deployed to Heroku. Make sure to monitor the deployment process in your terminal for any potential errors. Additionally, remember to set up any necessary database connections or third-party services if your app relies on them, and configure environment variables accordingly on Heroku.
New Telegram contact
Tags: vpn, openvpn, softether, telegram
Published: 2023-12-17 23:37:20

We had to change the Telegram contacts. The account was not hacked, Telegram had just logged out it from all our devices and doesn't allow to log in back. We have a small chance to take back the access if Telegram's support responds to the complaint from us. But we don't hope very much for it.

We have lost access both our former support contact and our channel in Telegram, however there is not any suspicious activity in the channel till this moment (last our news from 4th of July 2023 about IN2 and PK1 servers).

All other contacts of DeepWebVPN (ticket form on the site, XMPPs, Tox, Email) have not changed. Look for alternative contact addresses and the new Telegram contacts on the page [Contacts](https://docs.dwv.one/en/about/contacts), please.

**Alternative contact addresses**
- [Ticket form](https://dash.dwv.one/en/tickets) (login is required)
- Jabber/XMPP #1: dwv@securetalks.biz
- Jabber/XMPP #2: dwv@jidhad.biz
- Tox: 1DF8EDFE937EBF69F355E6D6288D722700B2445C1EFCAB91FEB7EA852B50566A4937B54EF7CA
- E-mail: support@deepwebvpn.net

We apologize for the inconvenience caused.

Origin of the news: https://en.blog.deepwebvpn.net/2023/09/18/telegram

![DeepWebVPN. Just hold one's breathe](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2e1fpgbkd1f9bmaqsaz.png)
CONTACT WIZARD WEB RECOVERY TO RECOVER STOLEN OR LOST BITCOIN
Published: 2023-12-17 23:15:27

Recovery for Bitcoin is similar to working as a detective online. Regaining access to misplaced or unreachable Bitcoin wallets or funds is what it entails. The goal of Bitcoin recovery services is to help customers recover their valuable virtual assets from crypto-related problems, such as misplaced private keys, forgotten passwords, or technical difficulties. The possibility of losing access to your digital assets is growing along with Bitcoin's growth. People are increasingly turning to expert Bitcoin recovery services for aid as there is no central authority to turn to. The need for skilled Bitcoin recovery specialists has never been higher, from the early enthusiasts who lost their hard drives to the unlucky targets of hacking or fraud. Then come the internet magicians, such as WIZARD WEB RECOVERY, who have the know-how to recover misplaced Bitcoin and give hope to people who had given up on their chance at digital wealth. WIZARD WEB RECOVERY operates with ethics and legality as its top priorities. By adhering to legal and regulatory standards, they make sure that all recovery activities are carried out ethically and legally. They are distinguished from others in the sector by their dedication to maintaining professional standards, Just like you wouldn't trust an amateur to perform brain surgery, you shouldn't leave your Bitcoin recovery in the hands of inexperienced individuals, Expertise in Bitcoin recovery means having a deep understanding of the intricacies of the technology, staying up-to-date with the latest developments, and possessing the problem-solving skills necessary to tackle even the most complex cases. It's not just about following a step-by-step manual; it's about using technical knowledge and out-of-the-box thinking to recover what was once thought to be lost forever. With their vast knowledge and expertise, WIZARD WEB RECOVERY is at the forefront of this industry and provides efficient solutions for the recovery of lost or stolen Bitcoin assets. WIZARD WEB RECOVERY (AT) PROGRAMMER. NET has a history of successful recoveries and is dedicated to excellence, which puts them in a strong position to handle future issues. Their proficiency guarantees a safe and effective recovery procedure, whether it is handling intricate transactions, getting over security obstacles, or safeguarding customer privacy.
Advent of Code #14 (in Crystal)
Tags: crystal, adventofcode
Published: 2023-12-17 21:42:49

My brother and I worked on this puzzle together. That is partly why the solution is more imperative than functional. Admittedly, though, I have found many of these Advent of Code puzzles easier to reason about with an imperative approach.

My brother suggested finding each stone and moving it up if the space above it was empty for each row. I was planning on over complicating it my looking how far the stone could move. In the end, I really like how the code turned out, and extending it to part 2 wasn't terrible.

Speaking of part 2, it was my brother's idea again that the stones would probably stabilize well before a billion cycles, and that we wouldn't have to get that far. We tested out the theory, and then after identifying a cycle in the outputs, reduced the potential answers down to eight candidates. We got the right answer after 5 guesses.

I tried to code up a solution to return the correct answer instead of just spitting out the weights for each cycle and having to guess. Admittedly, I'm not sure if the final code is correct, but it works for my input. It doesn't work for the example because the cycle for the example contains duplicate numbers, which I wasn't sure how to account for.

Here's my code, which may or may not work on your input:
```crystal
input = File.read("input").strip

rows = input.split("\n").map(&.chars)

def tilt(rows)
  (1...rows.size).each do |row_num|
    (0...row_num).each do |prev|
      current_row = row_num - prev
      row_above = current_row - 1
      stones = rows[current_row].join.scan(/O/).map(&.begin)
      stones.each do |stone|
        if rows[row_above][stone] == '.'
          rows[row_above][stone] = 'O'
          rows[current_row][stone] = '.'
        end
      end
    end
  end
end

def weigh(rows)
  (0...rows.size).reduce(0) do |sum, row_num|
    sum + rows[row_num].join.scan("O").size * (rows.size - row_num)
  end
end

part1 = begin
  tilt(rows) 
  weigh(rows)
end

puts part1

cache = Set(String).new

part2 = begin
  last = -1
  current = 0
  i = 1
  cycle_start = nil
  cycle = Array(Int32).new
  while !cycle_start || !cycle.group_by { |x| x }.values.map { |x| x.size > 4 }.all?
    if i % 4 == 1
      cycle_start = i if last == current
      weight = weigh(rows)
      cycle.push(weight) if cycle_start
      cache.add(rows.map(&.join).join("\n"))
      last = current
      current = cache.size
    end
    tilt(rows)
    rows = rows.reverse.transpose
    i += 1
  end
  cycle = cycle[...cycle.size // 5]
  cycle[(4_000_000_000 - i + 4) % cycle.size]
end

puts part2
```
Janitorial Services
Published: 2023-12-17 22:44:48

Our [professional cleaning company](https://www.smhdiamondclean.com.au/) specialize on commercial, post-construction and move-in/move-out cleaning. We implement the best practices and do COVID-19 deep clean to ensure your facility is disinfected and well sanitized.

Our sustainable cleaning is available for businesses looking to attract and retain customers and employees.

We are passionate about our work and keep up with technology and progress. After all and now we are proud to say: Sustainable cleaning innovate your world.

SMH Diamond Clean offers reliable, affordable and professional commercial cleaning & janitorial services to hundreds of local businesses, government offices, educational campuses, and medical facilities throughout Gold Coast.
Cell iterator - Part 1 (Brain dump)
Tags: braindump, gamedev, napl
Published: 2023-12-17 22:28:29

For my game engine, one of the ideas I'm exploring is the idea of organizing the world into a grid of cells, containing sprites.

Each cell will have a fixed width, height, depth. In a 3d world, it can be visualized as a cube.

![Cell cube](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/50lwiylvqtjilx2u1hmf.png)

The main goal here is that I need to iterate through elements contained in a massive world. I'm not gonna bother with sprites several kilometers away, only the ones in the surroundings of a player.

Or perhaps I still need to render mountains... but let's keep that issue for later.

At close proximity, we can just poll a sprite providers and ask:
- At cell (x,y,z), what sprites do we find?

Then poll that for all sprites at proximity.

I could just do some kinda of loop for all the cell positions to poll:

```typescript
for (let x = -100; x < 100; x++) {
  for (let y = -100; y < 100; y++) {
    for (let z = -100; z < 100; z++) {
       pollCell(player.x + x, player.y + y, player.z + z);
    }
  }
}
```

But here's the thing. Cells that are closer, if fully opaque, should make the cells behind disappear, and therefore we can skip them.

So it's best to iterate outwards, starting from the closest cells to the ones further away. Once we figure out that a cell is opaque, we know we can skip iterating the ones behind.

![Cell order](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/79l3ecefnax6elbinion.png)

There must be some way to iterate in such a way.

More on this later...
Setting up RabbitMQ for Automated Celery Tasks via Homebrew
Tags: celery, rabbitmq, homebrew
Published: 2023-12-17 21:35:24

The easiest way to install RabbitMQ on macOS is using Homebrew the new and shiny package management system for macOS.

Here's a general step by step guide:

If you don't already have it install Homebrew, you can install it by running the following command in the Terminal:

```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

Once Homebrew is installed, you can install RabbitMQ by running this command will download and install RabbitMQ with its dependencies.

```
brew install rabbitmq
```

After installation, you might need to add RabbitMQ to your PATH. You can do this by adding the following line to your .bash_profile, .zshrc. This step ensures that you can run RabbitMQ commands from the Terminal.

```
export PATH=$PATH:/usr/local/sbin
```

**Starting/Stopping the RabbitMQ server**

Next, we can start up RabbitMQ using Homebrew, the command below ensures that RabbitMQ will run automatically at login.

```
brew services start rabbitmq
```

Optionally, If you would like to verify the installation of RabbitMQ and ensure it's up and running correctly, you can check its status by running the status command, it will provide you information on the RabbitMQ service status.

```
rabbitmqctl status
```

Also, if you would like to stop RabbitMQ services for any reason you can use the brew command stop the rabbitmq service.

```
brew services stop rabbitmq
```

**Running management plugin with RabbitMQ**

RabbitMQ also comes with a management plugin that provides a browser-based UI for managing and monitoring your RabbitMQ server. If you would like to monitor the stats of your RabbitMQ server.

```
rabbitmq-plugins enable rabbitmq_management
```

After enabling it, you can access the management console through `http://localhost:15672/`. By default the username and password are both “guest”.


Finally to keep RabbitMQ updated you can use Homebrew commands for `update` and `upgrade`

```
brew update
brew upgrade rabbitmq
```
If you encounter any issues during setup it might also be worth checking the official RabbitMQ [documentation](https://docs.celeryq.dev/en/stable/getting-started/backends-and-brokers/rabbitmq.html#broker-rabbitmq).
Advent of Code #13 (in Crystal)
Tags: crystal, adventofcode
Published: 2023-12-17 21:30:44

Similar to yesterday's puzzle, this one was fairly easy to visually inspect, but requires a bit more work to describe algorithmically. Not quite a bad as yesterday, though.

For part 1, I originally took the two halves on either side of each row, reversed one of them and then compared the two using the equality comparison (`==`). It was easy enough to swap out that equality comparison for a Levenshtein distance, which Crystal conveniently provides in the standard library.

There is still a fair amount of code duplication between parts 1 and 2, but I didn't feel like refactoring it much today.

Here's the code:
```crystal
require "levenshtein"

input = File.read("input").strip

patterns = input.split("\n\n")

def find_mirror(rows, distance = 0)
  mirror = 0
  (1...rows.size).each do |i|
    edge = Math.min(i, rows.size - i)
    image = rows[i - edge...i].join
    reflection = rows[i...i + edge].reverse.join
    mirror = i if Levenshtein.distance(image, reflection) == distance
  end
  mirror
end

part1 = patterns.reduce(0) do |sum, pattern|
  rows = pattern.split("\n")
  cols = Array.new(rows[0].size, "")
  rows.each do |row|
    row.each_char.with_index do |char, col|
      cols[col] += char
    end
  end
  sum + find_mirror(rows) * 100 + find_mirror(cols)
end

puts part1

part2 = patterns.reduce(0) do |sum, pattern|
  rows = pattern.split("\n")
  cols = Array.new(rows[0].size, "")
  rows.each do |row|
    row.each_char.with_index do |char, col|
      cols[col] += char
    end
  end
  sum + find_mirror(rows, 1) * 100 + find_mirror(cols, 1)
end

puts part2
```
SourceMaps with React
Published: 2023-12-17 20:56:41

https://javascript.plainenglish.io/debug-your-react-app-like-a-ninja-with-source-maps-c63010b3a6e7

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

Note that if we are using babel this will be translated to _this2 
https://medium.com/@tommarren/the-mystery-of-this2-2af4ed10dd28

why this sometimes shows as undefined in devtools:
https://stackoverflow.com/questions/47530878/why-chrome-dev-tools-cant-reflect-this-correctly-in-a-promise?rq=4
Filter on the Back End to Improve UI Performance
Tags: webdev, programming, learning, frontend
Published: 2023-12-17 20:05:29

Users want a fast and responsive experience and may leave if the webpage is slow. There are many ways to improve the user experience, but an easy win is to filter data on the business logic layer or data layer rather than the front end.

## Why?
Typically, we want the front end to do the least amount of work necessary. Each action the front end takes adds latency and detracts from the user experience. Some things like API calls are unavoidable, but the API should return data in a ready-to-display format so the front end only has to display the information. The front end should not filter the data when the business logic layer or data layer can. Ideally, the data layer should have a SQL view or function that the business logic layer can query. The business logic layer can also filter the data, but this is less performant than having the database do the filtering. 

### Separation of Concerns
A big part of good software development is the separation of concerns or partitioning an application into sections with logical responsibilities. This type of architecture is called an "N-tier" architecture, with N representing the application's number of layers. A typical 3-tier application is split into the front end, business logic, and data layers.

The front end should be responsible for fetching and displaying data. The business logic layer should be responsible for data processing, such as creating accounts, confirming purchases, etc. The data layer should be responsible for storing and filtering data. Each layer should be independent of the others' responsibilities, but the realities of development usually prevent this ideal from being achieved.

## Takeaway
Enforce separation of concerns to improve your front end performance. Have the data layer or business logic layer handle data processing (including filtering) and let the front end handle displaying data. This will improve front end performance and make users happier.
Brain dump
Tags: braindump, gamedev
Published: 2023-12-17 19:58:33

I've decided to start a new blogs series called "Brain dump".

One thing I realized, is that I need to keep some notes regarding my game development process, such as designs, feature ideas, etc...

I thought I was already doing that with my [NAPL series](https://dev.to/jacklehamster/series/24703), but it's not exactly the same. Before posting on NAPL, I more or less collect my thoughts, and try to put out coherent ideas that can be easily ingested by readers. So those posts are more polished, but most importantly, I only posts there once I'm convinced an idea will work and is worth sharing.

But there are many other ideas I need to jot down and I'm still unsure about. I need to work those out in an unpolished way until I'm sure they are worth posting on my main dev log.

But those ideas are still worth noting down:
- I could just write those for myself in a physical notebook, but I don't have the discipline to carry such thing around.
- I guess I could just save things locally, but if those are good ideas, why not just share it.
- Initially, I was thinking I'll just dump them into a GitHub repo. That said, I don't have a nice way to format them. Also, I don't want to think about an extra tool to use just for ideas.

So I decided I'll just post them here on dev.to, and just keep that as a new series so it doesn't clobber my main dev log with too much random stuff.

Those will not be super polished posts, I will try my best to make them coherent for readers (also for myself, since I'll need to revisit my own notes later).
Adventofcode 🎄: Day 17 - Fun fact about React!
Tags: beginners, react, codenewbie
Published: 2023-12-17 19:44:45

Did you know that React, the JavaScript library for building user interfaces, was developed by Jordan Walke, a coder over at Facebook?

Back in 2011, React made its debut on Facebook's newsfeed, and by 2012, it also made its debut on instagram too! React's primary goal was to improve the performance and efficiency of user interfaces, particularly in the context of dynamic and frequently updating content, which is common in social media applications. 

Since then, React has gained widespread popularity in the web development community and is widely used for building user interfaces for various applications.
What is ANR in Android & its types
Tags: aosp, android, anr
Published: 2023-12-17 19:43:52

## What is ANR?
ANR stands for Application not responding!! It means the User is operating the Android device and there is no response of touch and click, It looks like a hang or stuck which will end with either an ANR Dialogue or Application crash.

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

As per the user experience, ANR is one of the worst problems which an application can offer to the user for getting frustrated while doing something important.

In general, It is most important while programming the applications that, everything that we implement should not block the UI or create a bad user experience is the primary focus.

Everything that the user does on their device is more important than anything else. So there is zero space for compromising if anything interrupts the user. Asking to close the application or wait for some time for recovery, is what ANR does in between user interactions and this is how ANR can impact the User.

https://narendra147h.medium.com/anr-in-android-its-types-cc1f6631ca1e