teleren/devto huggingface dataset:
Migrate MSsql (SQL-Server) to PostgreSQL
Tags: sqlserver, postgres, database
Published: 2022-12-21 11:40:26

To migrate a database from Microsoft SQL Server to PostgreSQL, you can use a database migration tool such as pgLoader. This tool allows you to easily migrate your data and schema from SQL Server to PostgreSQL, without having to write complex SQL queries or scripts.

To use pgLoader to migrate a database from SQL Server to PostgreSQL, you can follow these steps:

    Install pgLoader on your computer. This can be done by downloading and installing the pgLoader package from the pgLoader website.

    Create a new database in PostgreSQL to hold the migrated data. This can be done using the createdb command, or using a GUI tool such as pgAdmin.

read full: https://thedbadmin.com/migrate-mssql-sql-server-to-postgresql/
Python Script to Monitor MongoDB
Tags: mongodb, python, monitoring
Published: 2022-12-21 11:38:33



Here is a Python script that checks the status of MongoDB and sends an email using the smtplib library:

import smtplib
from pymongo import MongoClient

# Replace these with your own email and MongoDB connection details
sender_email = "myemail@example.com"
receiver_email = "otheremail@example.com"
mongodb_uri = "mongodb://localhost:27017"

# Connect to MongoDB
client = MongoClient(mongodb_uri)

# Check the status of the server
server_status = client.server_info()

# Set the subject and body of the email based on the server status
if "ok" in server_status and server_status["ok"] == 1.0:
    subject = "MongoDB status: OK"
    body = "The MongoDB server is running and responding to requests."
else:
    subject = "MongoDB status: ERROR"
    body = "There was a problem connecting to the MongoDB server."

# Send the email using SMTP

read full: https://thedbadmin.com/python-script-to-monitor-mongodb/
Docker Compose For Elasticserach with Persistent Volume
Tags: elasticsearch, database
Published: 2022-12-21 11:36:08

To create a Docker Compose file for Elasticsearch with a persistent volume, you can use the volumes and volume_driver options in the elasticsearch service configuration. Here is an example docker-compose.yml file:​

version: '3.7'

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
    volumes:
      - data:/usr/share/elasticsearch/data
    environment:
      - node.name=elasticsearch
      - cluster.name=elasticsearch
      - discovery.seed_hosts=elasticsearch
      - cluster.initial_master_nodes=elasticsearch

read full: https://thedbadmin.com/docker-compose-for-elasticserach-with-persistent-volume/#more-6564
Is AI an existential threat to humanity?
Tags: ai, android, ios
Published: 2022-12-21 11:35:28

There is a debate about whether artificial intelligence (AI) could pose an existential threat to humanity. Some experts believe that as AI continues to advance, it could potentially pose a risk to human society if it were to surpass human intelligence and become able to outmaneuver us. 

However, others believe that AI will always be limited by its programming and that it is unlikely to pose a threat to humanity as long as we ensure that it is aligned with our values and goals.

It's important to note that AI is a tool that can be used for both good and bad purposes. Like any technology, it has the potential to be misused, and it's important for us to consider the ethical implications of AI and to take steps to ensure that it is developed and used responsibly. 

However, it's also important to recognize that AI has the potential to be a powerful force for good, enabling us to solve some of the world's most pressing problems and improve the lives of people around the globe.

To know more: http://bitly.ws/xSNh
What is MySQL Replication ?
Tags: mysql, database, replication
Published: 2022-12-21 11:35:04

MySQL replication is a process in which data from one MySQL database server (the master) is automatically copied to one or more other MySQL database servers (the slaves). This allows multiple copies of the same data to be maintained on different servers, providing a number of benefits, such as improved performance, higher availability, and better scalability.

There are several different types of MySQL replication, including:

    Master-slave replication: In this type of replication, data is copied from a single master server to one or more slave servers. The master server receives all writes and updates, and these changes are then propagated to the slave servers. This allows the slaves to be used for read-only operations, which can improve performance and reduce the load on the master server.

read full: https://thedbadmin.com/what-is-mysql-replication/
Run Pgadmin on Docker Compose
Tags: postgres, database, tooling
Published: 2022-12-21 11:33:24

To run pgAdmin on Docker Compose, you can follow these steps:

Install Docker and Docker Compose on your system if you haven’t already.

Create a docker-compose.yml file in a new directory and add the following contents to it:

 
version: '3'
services:
  pgadmin:
    image: dpage/pgadmin4
    environment:
      - PGADMIN_DEFAULT_EMAIL=pgadmin@example.com
      - PGADMIN_DEFAULT_PASSWORD=secret
    ports:

Read full: https://thedbadmin.com/run-pgadmin-on-docker-compose
Architecture of Kubernetes on a high level
Tags: kubernetes
Published: 2022-12-21 11:30:17

As discussed in the previous post of the series, Kubernetes has one Master node and multiple Worker nodes. Master node monitors all Worker nodes. In Kubernetes, there must be at least one Cluster, one Master node and one Worker node.

*Master Node* : It has four components. They are API Manager, Scheduler, Controller Manager and ETCD.

API Server acts as a Cluster Gateway. It can be used using command line tool kubectl or through Kubernetes Dashboard.

Scheduler schedules PODs in the Worker nodes based of availability of CPU and Memory. Scheduler gets the information of Worker nodes from ETCD.

Whenever a POD or Node gets crashed, ReplicaSet creates a new one. Controller Manager manages the process of Scheduling the same as per availability working with the Scheduler.

*Worker Node* : It has three components. They are kubelet, kube-proxy and Container runtime.

Kubelet is an agent that runs on each Worker node and communicates with Master node using API Server.

Kube-Proxy is a network agent that runs on each Worker node.

Container runtime helps to run container inside PODs.
C++da sonlarni bolish
Tags: webdev, programming, devops
Published: 2022-12-21 11:29:22



```cpp
sonlarni bolganda iki hil javob chiqadi foizi yoki butun   butunini olish uchun mana shu kodlardan foydalaniladi

#include <iostream>
using namespace std;
int main (){

  int son;
  cin >> son;

 cout << son /100 ;





  return 0;
}

```

```cpp
foizini olish uchun esa



#include <iostream>
using namespace std;
int main (){

  int son;
  cin >> son;

 cout << son /100 % 10 ;





  return 0;
}


```
@davron
Refactoring. The beginning.
Tags: refactoring, typescript, programming, cleancode
Published: 2022-12-21 11:28:35

Hi everyone! 
This article will be dedicated to refactoring and clean code practices. 
Let's start with the task I kindly took from the awesome project for developers and the possibility to mentor, learn different practices and languages and polish your skills instantly - [Exercism.org](https://exercism.org/dashboard). 

So, here is [the task](https://exercism.org/tracks/typescript/exercises/leap/solutions/dnim) related to clarifying whether the provided year is a leap or not: 
Given a year, report if it is a leap year.
The tricky thing here is that a leap year in the Gregorian calendar occurs:

> on every year that is evenly divisible by 4
>  except every year that is evenly divisible by 100
>   unless the year is also evenly divisible by 400

> For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap year, but 2000 is.

## My first solution was the next: 
```typescript
function isLeap(year: number) {
  return year % 400 === 0 ? true : year % 100 === 0 ? false : year % 4 === 0 ? true : false
}
```
### Pros:
**O**ne liner? 
Not actually, but quite concise I would say. The true one-liner can look like this (_Close your eyes!_):
```typescript
const isLeap = (y: number) => !(y % 400) || (!!(y % 100) && !(y % 4));
```
### Cons:
**H**ard to understand.
As you can probably agree - it's long and barely readable and easily understandable. 
**R**edundant code in the end (did it mainly to the love to ternary operators)

### Possible improvements: 
We can provide a bit of formatting and grouping, though it will not be a liner anymore. And it's ok. Also, it can be helpful for future refactoring when more logic or improvements need to be done
```typescript
const isLeap = (year: number) => 
  year % 400 === 0 ? true : 
    year % 100 === 0 ? false : 
      year % 4 === 0;
```

Not that it's still concise but more readable and logically split (pov). If evenly divisible by 400 then it's a leap. If by 100 - not and so on.

## The Second solution (Clean Code): 
After [the Clean Code](http://cleancoder.com/products) (the site is a bit outdated, but the practices are still valuable as never before) approach applying it would look like this: 
```typescript
const isLeap = (year: number): boolean => {
  const isDividedBy = (divider: number): boolean => year % divider === 0;

  return isDividedBy(400) || (!isDividedBy(100) && isDividedBy(4));
} 
```

As you can see - there is not so much more code added, but readability is much higher. Now I can simply read: "Year has leapt if it's divided evenly by 400 OR NOT divided by 100 WHILE divided by 4".  


Hope it was a bit of fun for you!
How to use Symfony messenger to consume RabbitMQ messages (with example)
Tags: php, symfony, eventdrivenarchitecture, eventdrivenpattenr
Published: 2022-12-21 11:04:00

---
title: How to use Symfony messenger to consume RabbitMQ messages (with example)

published: true
description: A practice approach to Event-Driven Architecture in PHP
tags: php,symfony,eventDrivenArchitecture, eventDrivenPattenr
cover_image: https://anastasionico.uk/img/blog/consume-rabbitmq-messages-with-symfony-messenger.jpeg
# Use a ratio of 100:42 for best results.
published_at: 2022-12-21 11:04 +0000
---
**What is Event-Driven Architecture?**
 
The traditional architecture of a system is a classic request/response one.

A service performs an action that involves some other service.

While the second one does its stuff the first need to wait.

That works well but it is not the best way to structure a system.

In an Event-Driven architecture, the flow follows the pattern of events.

When something happens, for instance, an event that requires an action, we store it rather than process it.

In this way, the service we are interacting with does need to stop and wait.

And the second can retrieve the event and perform the action whenever it is ready.

To be able to use this architecture we need to store this event somewhere.

There are several event brokers out there. 

The most famous are Apache Kafka, Google Cloud Pub/Sub, and RabbitMQ.

I have already explained in more detail what Event-Driven architecture is.

If you already know enough and want to put your hand in some Symfony code this is the post for you.

In this article, you will learn how to consume messages stored in RabbitMQ using PHP.

 
We will consume it via Symfony Messenger.

[Learn How to use Symfony messenger to consume RabbitMQ messages (with example)
](https://anastasionico.uk/blog/consume-rabbitmq-messages-with-symfony-messenger)
Kubernetes and its main components
Tags: kubernetes
Published: 2022-12-21 10:58:00

*Kubernetes(K8S)* is a Container Orchestration Engine. It automates the process of deploying, scaling and managing containerized applications. 


There are many components of Kubernetes. Following are the key components - 

- *POD* : Containers are wrapped into a functional unit known as PODs. Each POD has single IP address.


- *Node* : PODs(one or multiple) are clubbed into a virtual machine known as Node.


- *Cluster* : Multiple nodes are clubbed into Cluster. Kubernetes cluster comprises of one Master node and many Worker nodes.


- *ReplicaSet* : Creates replicas of PODs to ensure no downtime of the application.


- *Service* : One or more PODs can associate with a single Service. Service provides static IP and DNS name. Service also plays the role of Load Balancer by forwarding the traffic to the appropriate POD. There are three types of Services -
           Cluster IP
           NodePort
           LoadBalancer


- *Deployment* : Kubernetes objects for managing PODs. Deployments can be created using commands or YML files.


- *ConfigMap and Secrets* : Configurable properties of the application are stored in ConfigMap. Sensitive Configurable properties of the application are stored in Secrets.


- *ETCD* : It is a key-vale datastore. Kubernetes cluster configuration is stored in ETCD.


- *Volumes* : Volumes are used for persistent datastore like database.
UI UX Design Company — Which One To Focus Between Usability And Visual Design
Tags: webdev, ux, ui, uiuxdesign
Published: 2022-12-21 10:48:45


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/29qrszhs8s1tnainakvz.png)
Searching the world of the internet will let you come across multiple experts in the field of ui ux design company. Each one of them has its specific needs and requirements, and they differ in their works too. It is always vital to check out the major attributes of the top-notch UX agencies before finalizing the best name in the market.

**The usability vs. the visual design:**

Each agency is noted to have a different design philosophy. Some will focus more on branding and visual design, and then you have others who are obsessed with usability and making it all easy for everyone to understand.

Right now, the UX experts are looking for good looking digital interface, but that’s not all. Usability has been one major success factor to consider. That’s why most of the big brands are 
 using friendly apps to follow the principle of simplicity and clarity when it comes to design. On the other hand, the designers will not give up on the visual design. They are here to acknowledge the product’s aesthetics, which will contribute to the final success story.

There is no single answer which will help you to choose between usability and aesthetic value. Everyone needs to evaluate their own services and decide on the next focal point. For some industries, usability is the prime point, and others will love to spend more money on the aesthetic value.

Look for the [UI and UX design companies](https://www.nickelfox.com/services/ui-ux-design/), which can both work on looks and usability well. It helps you to determine the right choice to make, and the chosen firm will be able to work on that as well.

**Which one to choose between implementation and concept:**

Most of the [ui ux design agencies](https://www.nickelfox.com/services/ui-ux-design/) will have terms like strategic design company on their websites. Understanding its real meaning is very important. Previously, the term design meant the visual appearance of the product. But, later, usability took the front seat. Right now, the designers are spending quite some bucks on creating items, which make lives a lot easier than before.

On the other hand, the design professionals have been trained in some useful skills. They are focusing on prototyping, researching people’s needs, ideation sessions, workshop facilitation, and strategy creation.

That’s when the idea of data analytics came into action. Later, it was realized that such skills will not be useful in designing projects but can help define the business strategy of the firm too.

Most [UX designers](https://www.nickelfox.com/services/hire-ui-designer/) will not work on designing products that much. They are here to define strategies. You can find some exploring the new concepts for the firms. The larger firms would love to run the innovation projects, where they can experiment with the new ideas!
Disable bash script output, but save to file log
Tags: linux, bash
Published: 2022-12-21 10:31:21

---
title: Disable bash script output, but save to file log
published: true
description: 
tags: linux, bash
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-21 10:03 +0000
---

### Option 1
```
#!/bin/bash
sudo apt install -y package_name | tee -a /tmp/app.log >/dev/null
sudo apt install -y package_name1 | tee -a /tmp/app.log >/dev/null
sudo apt install -y package_name2 | tee -a /tmp/app.log >/dev/null

```
### Option 2
disable all output to tty but save to file
```
#!/bin/bash
exec 1> >(tee -a /tmp/app.log >/dev/null)
sudo apt install -y package_name
sudo apt install -y package_name1
sudo apt install -y package_name2
```
### Option 3
enable all output to tty and save to file
```
#!/bin/bash
exec 2> >(tee -a /tmp/app.log >&2) > >(tee -a /tmp/app.log")
sudo apt install -y package_name
sudo apt install -y package_name1
sudo apt install -y package_name2
```
As function
```
function __application_log(){
    if [ "${__verbose_mode}" == "no"  ]; then
        exec 1> >(tee -a /tmp/app.log >/dev/null)
    else
        exec 2> >(tee -a /tmp/app.log >&2) > >(tee -a /tmp/app.log")
    fi
}
```
When to use LinkedList over ArrayList in Java ?
Tags: java, collections, linkedlist, arraylist
Published: 2022-12-21 10:30:00

In Java, the LinkedList and ArrayList classes are both used to store and manage a collection of objects. However, there are some differences between the two classes that you should be aware of when choosing which one to use in your code.

Here are some situations where you should use a LinkedList over an ArrayList in Java:

-  If you need to frequently add and remove elements from the middle of the list. LinkedList is implemented as a doubly-linked list, which allows for efficient insertion and removal of elements at arbitrary positions in the list. In contrast, ArrayList is implemented as an array, so inserting or removing an element in the middle of the list requires shifting all of the subsequent elements to make room, which can be slow.

-  If you need to iterate over the elements of the list in both forward and backward directions. Because LinkedList is a doubly-linked list, you can easily move backwards and forwards through the list, which is not possible with an ArrayList, which is a linear structure.

-  If you have a large number of elements and you need to minimize memory usage. LinkedList uses less memory than ArrayList because it only stores the elements and references to the next and previous elements in the list, while ArrayList stores the elements and an array to hold the elements, which requires more memory.

{% embed https://youtu.be/qvGzzKoJN1E %}

 In general, LinkedList is a good choice when you need a more flexible and efficient list data structure, while ArrayList is a better choice when you need a simple and efficient way to store
Finding the LCM of an array of numbers in Ruby
Tags: ruby, lcm, array
Published: 2022-12-21 10:18:03

---
title: Finding the LCM of an array of numbers in Ruby
published: true
description: 
tags: ruby,LCM , array
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2022-12-21 10:13 +0000
---

This code demonstrates some common techniques in Ruby, such as defining methods, using recursion, and using the `reduce` method to iterate over an array and perform a computation on its elements. Many Ruby developers appreciate concise and efficient code like this, especially when it solves a common problem like finding the LCM of an array of numbers.


```ruby
# A method that returns the greatest common divisor (GCD) of two numbers using the Euclidean algorithm
def gcd(a, b)
  return a if b == 0
  gcd(b, a % b)
end

# A method that returns the least common multiple (LCM) of two numbers using the GCD method above
def lcm(a, b)
  (a * b) / gcd(a, b)
end

# A method that uses the LCM method above to find the LCM of an array of numbers
# and adds a heartfelt message to the output
def lcm_of_array(array)
  lcm = array.reduce(1) { |lcm, n| lcm(lcm, n) }
  puts "The least common multiple of the numbers #{array} is #{lcm}. May it bring you joy and happiness."
  return lcm
end

# Example usage
lcm_of_array([2, 3, 4, 5]) # Output: "The least common multiple of the numbers [2, 3, 4, 5] is 60. May it bring you joy and happiness."

```

This version of the code includes a heartfelt message in the output, wishing the user joy and happiness when they use the `lcm_of_array` method.
How to make HTTP GET and POST requests in JavaScript using Axios
Published: 2022-12-21 08:46:37

Axios is a popular, promise-based HTTP client that enables you to send HTTP requests using JavaScript. It has a simple API and can be easily integrated into your project.

In this article, we will look at how to make HTTP requests using Axios in JavaScript.

**Installation**
To use Axios in your project, you first need to install it using npm or yarn.


```
npm install axios
```

```
yarn add axios
```

**Making a GET request**
To make a GET request using Axios, you can use the get() method. The get() method takes in the URL of the endpoint as the first argument and an optional config object as the second argument.

Here is an example of making a GET request to the https://api.example.com/users endpoint:


```
const axios = require('axios');

axios.get('https://api.example.com/users')
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.log(error);
  });
```
In this example, we are sending a GET request to the https://api.example.com/users endpoint and logging the response data to the console. The then() method is called when the request is successful, and the catch() method is called when there is an error.

**Making a POST request**
To make a POST request using Axios, you can use the post() method. The post() method takes in the URL of the endpoint as the first argument and the data to be sent as the second argument. It also takes an optional config object as the third argument.

Here is an example of making a POST request to the https://api.example.com/users endpoint:

```
const axios = require('axios');

axios.post('https://api.example.com/users', {
    name: 'John Doe',
    email: 'john@example.com'
  })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.log(error);
  });
```
In this example, we are sending a POST request to the https://api.example.com/users endpoint with a payload containing the name and email of a user. The then() method is called when the request is successful, and the catch() method is called when there is an error.

**Configuring request headers**
You can configure the request headers by passing a config object as the second or third argument to the get() or post() method.

Here is an example of setting the Content-Type and Authorization headers in a POST request:

```
const axios = require('axios');

axios.post('https://api.example.com/users', {
    name: 'John Doe',
    email: 'john@example.com'
  }, {
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer abcdefghijklmnopqrstuvwxyz'
    }
  })
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.log(error);
  });
```