teleren/devto huggingface dataset:
Dependency Injection in swift
Tags: swift, ios, dependency, dependencyinjection
Published: 2023-04-10 08:22:27

The approach used to provide the initial value to the property. 
The purpose of this approach is to obtain the loosely coupled code.

There are three type to obtain this - 

**By Initialisation ->** In this type we need to pass the initialisation value in the init func of the class

```Swift
class DemoVC:UIViewController{
    override func viewDidLoad() {
        super.viewDidLoad()
        //passing dependency value by init func
        let obj = Language(langName: "Swift")
        print(obj.name)
    }
}

class Language{
    var name:String
    ///1. Initialisation Dependency Injection
    init(langName:String) {
        self.name = langName
    }
}
```

**By Function ->** In this type we pass the initial value as the function param. And the class property is initialised from this param.

```Swift
class DemoVC:UIViewController{
    override func viewDidLoad() {
        super.viewDidLoad()
        //setting dependency value passing parameter in method
        let obj = Language()
        obj.getLanuageDetails(lanugage: "Swift")
    }
}

class Language{
    private var name:String!
    func getLanuageDetails(lanugage:String){
        name = lanugage
        print("Your have shown interest in \(lanugage) Language.")
    }
}
```

**By Property ->** Here we generally create / access the class property and set the value directly. 


```Swift
class DemoVC:UIViewController{
    override func viewDidLoad() {
        super.viewDidLoad()
        //setting dependency value by setting property directly
        let obj = Language()
        obj.name = "Objective C"
    }
}

class Language{
    var name:String = "Swift"
}
```
Generar datos de pruebas en un proyecto con Laravel 10
Published: 2023-04-10 07:34:00

Había leído muchas veces sobre este tema, pero no me había puesto a generar datos de pruebas con Laravel 10. Al final lo he conseguido, y quiero compartirlo.

Vamos a necesitar dos clases. Una clase de tipo **Factory** y otra clase de tipo **Seeder**. La primera nos servirá para definir cómo va a ser cada fila, y la segunda, creamos las filas que necesitemos.

En el ejemplo que voy a usar, vamos a imaginar que vamos a crear revisores para las comunicaciones de un congreso.

## Factory

Lanzamos primero el comando para crear la clase Factory:

```
php artisan make:factory RevisorFactory -m Revisor
```

Ahora creamos la definición:

```
 public function definition()
    {
        return [
            'congreso' => 'test',
            'user_id' => 1,
            'email' => $this->faker->unique()->safeEmail,
            'genero' => $this->faker->numberBetween(1, 2),   
            'nombre' => $this->faker->firstName,
            'apellido1' => $this->faker->lastName,
            'apellido2' => $this->faker->lastName,
            'pais_trabajo_id' => 'ES',
            'provincia_trabajo_id' => $this->faker->numberBetween(1, 50),

        ];
    }
```

## Seeder

Creamos la clase Seeder:

```
php artisan make:seeder RevisorSeeder
```

Y creamos su definición para en este caso, generar 20 revisores:

```
public function run()
    {
        Revisor::factory()
            ->count(20)
            ->create();
    }
```

## Creamos los datos de prueba

A continuación, lanzamos este comando, y se generarán en la base de datos 20 revisores con la definición que hayamos especificado:

```
php artisan db:seed --class=RevisorSeeder
```

## Localización en español

Si queremos localizar en español los datos, debemos especificar la clave siguiente en nuestro fichero **.env**

```
FAKER_LOCALE=es_ES
```

## Extra: Asociamos temas a los revisores

Si queremos asociar temas a los revisores recién creados, una forma de hacerlo es modificando el Seeder:

```
public function run()
    {
        Revisor::factory()
            ->count(20)
            ->create();

        //Asociamos temas a los revisores
        $revisores = Revisor::whereCongreso('test')->get();

        foreach ($revisores as $r) {
            //Selecciono un numero aleatorio de temas
            $num_temas = rand(1, 10);
            //Selecciono los temas
            $temas = Tema::inRandomOrder()->take($num_temas)->get();
            //Asocio los temas al revisor
            $r->temas()->attach($temas);
        }
    }
```

Espero que os sirva de ayuda. Un saludo!
Exporting Global Objects
Tags: opengauss
Published: 2023-04-10 07:30:27

You can use **gs_dumpall** to export global objects, including database users, user groups, tablespaces, and attributes (for example, global access permissions), from openGauss.

**Procedure**
1. Log in as the OS user **omm** to the primary node of the database.

2. Run **gs_dumpall** to export global tablespaces.

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

Table 1 Common parameters

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

For details about other parameters, see “Server Tools > gs_dumpall” in the Tool Reference.

**Examples**
Example 1: Run **gs_dumpall** as the administrator **omm** to export global tablespaces and users of all databases. The exported files are in text format.

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

Example 2: Run **gs_dumpall** as the administrator **omm** to export global tablespaces of all databases, encrypt the exported files, and store them in text format.

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

Example 3: Run **gs_dumpall** as the administrator **omm** to export global users of all databases. The exported files are in text format.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ye0lj0523rnr5fxdrv25.png)
「同學」對學習的幫助
Published: 2023-04-10 07:29:18

近來有個感覺是,
關於學習，其實學伴﹑同學對學習也是有莫大益處。

老師的教學能力﹑學生自身的學習能力，是最直接影響知識傳遞效益。
但其實「同學」之間的互動，對學習也是有不少益處。

同學互動，能提升學習氛圍(講白話就是「大家一齊去經歷學一樣野會開心D」)。
學生之間一知半解，但彼此一知半解也是一種共同理解，對談討論﹑無知發問，有時會激發到一些思考，更易消化。

這就令我發覺,
作為成年人去學一樣野，不一定就是自己上網google﹑youtube，孤狼作戰地學習。
其實認真去學一件事的話，最好是加入相關社群，在相關領域中去找同路人一齊學習。
System Design : Vertical And Horizontal Scaling
Tags: backend, security, cloud, node
Published: 2023-04-10 07:28:25

**To expose our code**, we cannot simply give our computer to anyone. Therefore, we need to find a way to share our code securely. To run our code, we first need to create a database on our computer and also plan for contingencies in case of power loss. It's crucial to ensure that our service remains uninterrupted since many people depend on it, and we don't want to disappoint them.<br> <br>To achieve this, we should consider hosting our services on the cloud. <br><br>But what distinguishes cloud computing from desktop computing? There's actually no significant difference between the two. With cloud computing, we can access a set of computers that provide computational power, just like a desktop that's located somewhere else. We can upload our code to a cloud computer via remote login, making cloud computing a viable option for running our services.

<br>
**Let's focus on the business requirements.** <br>
If many people will be using your service and your code can't handle that many requests, what will be the solution? There are two approaches:<br>
1. Vertical Scaling: You can upgrade your existing machine to a larger one to process requests faster.<br>
2. Horizontal Scaling: You can add more machines and distribute requests among them.<br>
Both of these approaches are known as **scalability**, which is the ability to handle an increasing number of requests. By implementing these mechanisms, you can increase the scalability of your system.

<br>
**Horizontal Scaling**
- [1], [2], [3], [4], [5]. (Many Different Machines)
- Load Balancing Required
- Resilient : Request can be redirected if system is busy.
- Communication between servers occurs over the network, which means that it involves network calls. However, network calls are generally slower than other types of calls since they involve input/output (I/O) operations. This is because data needs to be transmitted over the network, which takes time. Such calls are also known as **Remote Procedure Calls (RPC)**.
- Data inconsistency can occur when multiple requests are simultaneously using the database.
- Scales well as users increase.

<br>
**Vertical Scaling**
- [ Huge Machine ]
- No Load Balancing Required
- Single point of failure. Because of only one machine.
- Here we have Inter Process Communication. So faster than Horizontal Scaling.
- Data consistent because one system where all data resides.
- Hardware Limit.

<br>
**What do you think is used in the real world?**
- The answer is that both vertical and horizontal scaling have different benefits, so we use them according to our requirements.
- However, **a hybrid solution is essentially horizontal scaling**, where each machine has a larger processing capacity. 
- Initially, it's recommended to use vertical scaling, but once users trust your service, you can consider moving to horizontal scaling.
What is interface
Tags: java, interface, programming, tutorial
Published: 2023-04-10 07:24:59

**Interface**
Inteface is basically a contract with the class that if you want to use this interface you have to do this stuff(the methods defined in the class) and if you don't then you won't be able to proceed and the best part it that it totally depends on you how you are going to achinve the funtionality.

E.G. The banking system
Every bank performs some common tasks like Withdraw, deposite, check Balance etc. but every bank has its own way of doing it.
The code that run behinds or the procedure the follow may differ but ultimate goal is to do deposite, withdraw or check balance.
So, the bank governing authority give them an interface that have three abstract methods e.g.
deposite(int howmuch), withdraw(int howmuch), checkBalance(int actno);

Checkout full video on Interface in java here
{% embed https://youtu.be/kNNGZlJd7Gs %}
thedevlog 1 - Shinobi Tactics
Tags: gamedev, reactnative, javascript, programming
Published: 2023-04-10 07:23:48

Created a simple naruto-based game for mobile devices. 
It is a turned based game that players will be choosing 3 characters and battle against each other.

Game is built with:
React Native & NodeJS (Socket IO)

The project is already discontinued. Just sharing this for future references.

Here is the youtube link gameplay.

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


https://youtu.be/skz74SgxBJs
Exporting All Databases
Tags: opengauss
Published: 2023-04-10 07:22:05

You can use **gs_dumpall** to export full information of all databases in openGauss, including information about each database and global objects. You can specify the information to export as follows:

**·** Export full information of all databases, including information about each database and global objects (such as roles and tablespaces).

You can use the exported information to create a host environment containing the same databases, global objects, and data as the current one.

**·** Export data of all databases, excluding all object definitions and global objects.

**·** Export all object definitions of all databases, including the definitions of tablespaces, databases, functions, schemas, tables, indexes, and stored procedures.

You can use the exported object definitions to quickly create a host environment that is the same as the current one, containing the same databases and tablespaces but no data.

**Procedure**
1. Log in as the OS user **omm** to the primary node of the database.

2. Run **gs_dumpall** to export full information of all databases.

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

The following table describes common parameters. For details about other parameters, see “Server Tools > gs_dumpall” in Tool Reference.

Table 1 Common parameters

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

**Examples**
Example 1: Run **gs_dumpall** as a cluster administrator **omm** to export full information of all databases in a cluster. After the command is executed, a large amount of output information will be displayed. **total time** will be displayed at the end of the information, indicating that the backup is successful. In this example, only relative output information is included.

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

Example 2: Run **gs_dumpall** as a cluster administrator **omm** to export object definitions of all databases in a cluster. The exported files are in text format. After the command is executed, a large amount of output information will be displayed. **total time** will be displayed at the end of the information, indicating that the backup is successful. In this example, only relative output information is included.

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

Example 3: Run **gs_dumpall** to export data of all databases in a cluster, encrypt the exported files, and store them in text format. After the command is executed, a large amount of output information will be displayed. **total time** will be displayed at the end of the information, indicating that the backup is successful. In this example, only relative output information is included.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8m4jdqimvbcpye7d2fpi.png)
Работа с внешними библиотеками
Published: 2023-04-10 07:01:00

Как разработчикам, нам важно иметь контроль над внешними библиотеками, которые мы используем в своих проектах. Один из способов достижения этого - обернуть эти библиотеки в самостоятельно созданные фасады.

Фасад - это архитектурный паттерн, который предоставляет упрощенный интерфейс к сложной системе. В контексте внешних библиотек фасад действует как обертка вокруг API библиотеки, предоставляя более простой и последовательный интерфейс к библиотеке. Создавая фасад для внешней библиотеки, мы можем получить следующие преимущества:

1. **Независимость от API библиотеки:** Используя фасад, мы можем защитить свой код от изменений API внешней библиотеки. Это означает, что если библиотека изменит свой API в будущей версии, вам нужно будет обновить только свой фасад для адаптации к изменениям, а не обновлять весь код, который использует библиотеку напрямую.
2. **Контроль над изменениями:** Обернув внешнюю библиотеку в фасад, мы получаем полный контроль над тем, как мы используем библиотеку. Это означает, что мы можем выбрать, какие части библиотеки мы хотим выставлять наружу, и как мы хотим, чтобы код взаимодействовал с этими частями. Мы также можем добавлять дополнительную функциональность к фасаду, такую как кэширование или обработку ошибок, не влияя на остальной код.
3. **Поддержка кода:** Используя фасад, мы можем упростить свой код и снизить его сложность. Это упрощает его поддержку в долгосрочной перспективе, а также делает его более понятным и удобным для работы другим разработчикам.

В дополнение к этим преимуществам, есть несколько других причин, по которым может захотеться создать фасад для внешней библиотеки. Например:

- **Тестирование:** Используя фасад, мы можем мокать API внешней библиотеки в своих тестах, что делает процесс написания и поддержки тестов проще.
- **Безопасность:** Контролируя, как наш код взаимодействует с внешней библиотекой, мы можем снизить риск уязвимостей безопасности, вызванных неожиданными взаимодействиями с библиотекой.
- **Производительность:** Создавая фасад, мы можем оптимизировать использование библиотеки для улучшения производительности вашего кода.

Поэтому рекомендуется обернуть все внешние библиотеки в фасады, чтобы достичь этих преимуществ.
S'Monday 😪 Is Code the Next Universal Language?
Tags: discuss, beginners, codenewbie, motivation
Published: 2023-04-10 07:00:00

Finnish computer programmer, children's book author, and founder of Rails Girls, Linda Liukas, writes:

> Code is the next universal language. In the future, all barriers to communication will crumble as we become fluent in programming.

With technology playing an increasingly important role in our lives, it's not hard to see why code is becoming more and more important. But will code eventually replace traditional languages as the global standard? What do you think?

---

Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more engaging, thought-provoking, and sometimes silly discussions just like this.
What are Prerequisites for learning AngularJS?
Published: 2023-04-10 06:58:07

AngularJS is a powerful and popular JavaScript framework that is used for building dynamic, single-page web applications. If you're interested in learning AngularJS, there are a few prerequisites that you should have to make the process easier and more effective. Here are some of the prerequisites for learning AngularJS:

**Knowledge of JavaScript:** Before learning AngularJS, you should have a strong foundation in JavaScript. This includes understanding JavaScript syntax, data types, functions, and objects. Without a solid understanding of JavaScript, it can be difficult to grasp the concepts and techniques used in AngularJS.

**HTML and CSS:** You should also have a good understanding of HTML and CSS. This is because AngularJS is used to build web applications, and HTML and CSS are the building blocks of the web. You should be comfortable with creating HTML pages and styling them using CSS.

**Familiarity with MVC architecture:** AngularJS uses the Model-View-Controller (MVC) architecture, which is a software design pattern used for building scalable and maintainable applications. Before learning AngularJS, it's helpful to have a basic understanding of MVC architecture and how it works. More can be learned from this [Angular Course](https://www.edureka.co/angular-training).

**Knowledge of Git and command-line interface:** Git is a popular version control system used for managing code, while the command-line interface is used for interacting with the operating system. Understanding Git and the command-line interface is important for working with AngularJS, as it makes it easier to manage and deploy your code.

**Familiarity with other JavaScript libraries:** AngularJS is just one of many JavaScript libraries and frameworks available. Familiarity with other libraries such as jQuery and Underscore can help you better understand AngularJS and its features.

**Problem-solving skills:** Finally, it's important to have good problem-solving skills. As with any programming language or framework, you will encounter bugs and issues that need to be resolved. Having good problem-solving skills will help you troubleshoot and debug your code effectively.

**Conclusion:** Learning AngularJS requires a strong foundation in JavaScript, HTML, and CSS, as well as familiarity with MVC architecture, Git, the command-line interface, and other JavaScript libraries. Additionally, having good problem-solving skills is essential for working with AngularJS effectively. By having these prerequisites, you'll be better equipped to learn AngularJS and build dynamic, single-page web applications.
Orator Discord Bot
Tags: tts, voice
Published: 2023-04-10 06:54:29

**Orator Discord Bot**

Orator is a Text to Speech generator Discord Bot using which you can generate your own text to speech in 50+ languages or AI generated custom voices. You can also get the TTS file and have the full right to use them.

**Main Features:**

1. Text to Speech in more than 50+ languages.
2. Text to Speech file generation.
3. Automatic TTS Panel.
4. Special / Famous personality's Text to Speech voice.
5. And many more TTS related utility commands with full customisation.

[Visit Orator's Website](https://oratorbot.xyz)
Best Mulesoft Service Providers
Tags: mulesoft, api, rpa
Published: 2023-04-10 06:51:40

**Description
**
Phidimensions provides [Mulesoft services](https://www.phidimensions.com/) to businesses. As Mulesoft service providers, we are one of the top Data integration service providers. Phidimensions has worked with Top rated companies from many industries to provide innovative solutions that simplify their data integration process. Phidimensions provides Mulesoft RPA and[ Mulesoft API Development services](https://www.phidimensions.com/api-development-automation/) as well as Mulesoft data integration services. If you are looking for a trusted, strategic, and cost-effective business model that offers the best range of MuleSoft services, here we are.

**Why Choose us
**·
MuleSoft consultants, architects, and developers are certified. They have the skills and abilities to help you.
•	MuleSoft solutions that are result-oriented, ensuring the desired outcome and quick ROI.
•	High-quality, end-to-end Mulesoft services at an affordable price.
•	MuleSoft has a proven track record of delivering successful, efficient projects.

**Contact us
**Feel free to reach out. Our team will be glad to help you out.
Email ID: info@phidimensions.com
Website:  https://www.phidimensions.com/
Exporting a Schema
Tags: opengauss
Published: 2023-04-10 06:35:27

You can use **gs_dump** to export data and all object definitions of a schema from openGauss. You can export one or more specified schemas as needed. You can specify the information to export as follows:

**·** Export full information of a schema, including its data and object definitions.
**·** Export data of a schema, excluding its object definitions.
**·** Export the object definitions of a schema, including the definitions of tables, stored procedures, and indexes.

**Procedure**
1. Log in as the OS user **omm** to the primary node of the database.

2. Run **gs_dump** to export the **hr** and **public** schemas.

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

Table 1 Common parameters

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

For details about other parameters, see “Server Tools > gs_dump” in the Tool Reference.

**Examples**
Example 1: Run **gs_dump** to export full information of the **hr** schema. The exported files are compressed and stored in text format.

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

Example 2: Run **gs_dump** to export data of the **hr** schema. The exported files are in .tar format.

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

Example 3: Run **gs_dump** to export the object definitions of the **hr** schema. The exported files are stored in a directory.

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

Example 4: Run **gs_dump** to export the **human_resource** database excluding the **hr** schema. The exported files are in a custom format.

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

Example 5: Run **gs_dump** to export the **human_resource** database excluding the **hr** and public schemas. The exported files are in a custom format.

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

Example 6: Run gs_dump to export all tables (views, sequences, and foreign tables are also included) in the public schema and the staffs table in the hr schema, including data and table definition. The exported files are in a custom format.

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