teleren/devto huggingface dataset:
[Series] Drupal Env using docker & nginx - 3!
Tags: php, docker, nginx, drupal
Published: 2021-01-06 14:45:41


---
title: [Series] Drupal Env using docker & nginx - 3!
published: true
description: Setting up a drupal env using docker.
tags: php,docker,nginx,drupal
---



In the [Previous article](https://dev.to/hamzahasbi/series-drupal-env-using-docker-nginx-2-24i5) we were able to create our stack based on docker containers, and we discussed how to configure each container as a seperate service.
In this last chapter we need to get our Drupal application up and running.

First thing we need to understand how we can connect the containers over the network, previously in a the spoiler alert i've mentionned the use of the network key in our docker-composer which defines a bridge network that gives the containers the ability to communicate with each other using predefined IP adress [Bridge NetWork](https://docs.docker.com/network/bridge/) (i've opted for the use of a bridge network with static IP mapping so we can easily understand how the communication is done) ...So each service will have a well defined IP adress by which we can target its container. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9fezdxn30ci78dwpurtz.png)

With that being set now let's test our Drupal app :

 **- For drupal dev we need to set our database configuration in the appropriate settings.php :**


    $databases['default']['default'] = array (
	  'database' => 'db_name',
	  'username' => 'root',
	  'password' => 'root_password_defined_in_mariadb_container',
	  'prefix' => '',
	  'host' => 'name_of_the_mariadb_service_OR_IPAdress',
	  'port' => '3306',
	  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
	  'driver' => 'mysql',
	); 

As a result let's visit the admin dashboard to check if  the configuration is working :
  
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9xyupquuhsxena4n8sru.png)

 **- Next thing we'll set the cache system to use our Memcache container :**
 

    // Memcache
	$settings['memcache']['servers'] = ['IPADRESS:11211' => 'default'];
	$settings['memcache']['bins'] = ['default' => 'default'];
	$settings['memcache']['key_prefix'] = 'choose_your_key_prefix';

	// Set default cache storage as Memcache and excludes database connection for cache
	$settings['cache']['default'] = 'cache.backend.memcache';
	$settings['cache']['bins']['render'] = 'cache.backend.memcache';
	$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.memcache';
	// Enables to display total hits and misses
	$settings['memcache_storage']['debug'] = TRUE;

Now let's check if Memcached service is working and well connected to Drupal .
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6004zrqrwygjbei9amzz.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/71yxfwszrm4zx0vcyzj6.png)


***Now we are all set with our Docker environment !*** 
All the services are up and running i've added a Bonus script to start the stack automatically you just need to have Docker and docker-compose installed and TADAAA!


 **Code can be found [here](https://github.com/hamzahasbi/docker-nginx).**
RxJs interval with condition
Tags: javascript
Published: 2021-01-06 14:17:24

We have used setInterval() to run a task multiple times after every specific interval. We need to clear interval after the task is done. Using RxJs interval function we can simulate setInterval function.


    import { interval } from "rxjs";

    // creating observable
    let numbers = interval(1000);

    // subscribe function returns reference to observable
    let numbesubs = numbers.subscribe(x => {
      console.log("Next: ", x);
      // clearing interval when x reaches 10 value
      if (x == 10) {
        unSubscribingfunction();
      }
    });

    function unSubscribingfunction() {
        // clearing interval
        numbesubs.unsubscribe();
    }

    // Logs:
    // Next: 0
    // Next: 1
    // Next: 2
    // ..
    // Next: 10
Interact with the Command Line using "process.argv" in NodeJS
Tags: node
Published: 2021-01-06 14:15:37

*[Follow Me on Twitter @AnnaJMcDougall](http://www.twitter.com/AnnaJMcDougall)*

One of the really cool things I'm discovering about NodeJS is that it allows us to interact more directly with computers, and enables the production of tools using the CLI (Command Line Interface: you may know it as the Terminal).

Just as how [yesterday I wrote about the core module `fs`](https://dev.to/annajmcdougall/reading-and-writing-files-directories-in-nodejs-using-the-fs-core-module-225c) to achieve some basic file manipulation, today we'll look at one of *the* big methods in the `process` core module: `argv`.

## What is the `process` core module?

This module tends to cover anything involving the actual running of Node scripts. It allows us to do things like terminate the program using `process.exit()`, for example. 

## What is `argv`?

The method `process.argv` basically captures what the user has typed into the command line or terminal when the programme runs. It returns us an array of each term entered which was separated by a space. If you're familiar with JavaScript string methods, it basically takes the command entered into the terminal, splits it by spaces, and then returns that array.

For example, if we run this code in the Terminal:

```bash
$ node index.js a b c
```

Our `process.argv` will return:

```javascript
[
   'C:\\Program Files\\nodejs\\node.exe',
   'C:\\exercises\\index.js',
   'a',
   'b',
   'c'
]
```

Here we see the path for node, then the path of the file we're running, and then each of the arguments we've entered into the command line.

The really cool thing about this is that it means if we run a simple slice command, we can pull out whatever the user has entered, and then use that in the program they run.

For example, we could make a quick and dirty madlibs like this:

```javascript
const [name, number, animal, verb] = process.argv.slice(2)

console.log(`${name} was taking a nice stroll 
along the river when suddenly 
${number} ${animal}s appeared and 
began to ${verb}!`)

```

Line 1 uses destructuring to assign the four words entered by the user to those variables. So now we can enter:

```bash
node index.js Bob 42 frog dig
```

We now have a fun little story pop out the other end:

```bash
Bob was taking a nice stroll
along the river when suddenly
42 frogs appeared and
began to dig!
```

This might seem a relatively silly example, but this allows us access to the command line and to using typed values in our programmes in all sorts of ways, opening up a whole new world of possibilities for creating tools for our fellow developers.
My Goal For 2021
Tags: webdev, react, javascript
Published: 2021-01-06 14:09:07

Hello everyone, I am Gaurav and why I am writing this post title itself explains it. I wanted to hold myself accountable, that's why I'm publishing, so let's write my goals, my first Goal for 2021 is to become a full-stack web developer and get a decent job. I will give weekly updates every week to let you know what I am learning, what interesting I discover, what problem I faced, and how I solved it. The second goal is to learn Ds and Algo and after writing this post I think I should work on writing skills too. if anyone has advice on how can I get the goal or best resources please comment on it. I will love to know.

Thanks for reading!!!
NEPSE Dataset on Kaggle
Tags: datascience, kaggle, analytics
Published: 2021-01-06 13:56:50

NEPSE stands for Nepal Stock Exchange and it is a historian of Nepal's Stock Market. After being interested on Data world, I first took a dive into NEPSE data on 2019 and I scrapped it on Google Colab in 2019/10/10. I am sharing it now. Please follow the link below.
[https://www.kaggle.com/qramkrishna/nepal-stock-exchange-data](https://www.kaggle.com/qramkrishna/nepal-stock-exchange-data)
I/O Stream or Shift Operators Overloading | C++
Tags: cpp, overloading, friend, operator
Published: 2021-01-06 13:55:36

### The `Data` class
```cpp
#include <iostream>
using namespace std;

class Data
{
private:
    int n, m;
public:
    Data() { n = 0; m = 0; }
    Data(int n, int m) { this->n = n; this->m = m; }

    //stuff for ostream operator << ...
    //stuff for istream operator >> ...
};
```

### Inside "Data" class...
```cpp
    friend ostream &operator<<(ostream &myout, Data &data)
    {
        myout << "n: " << data.n << " m: " << data.m << endl;
        return myout;
    }
    friend istream &operator>>(istream &myin, Data &data)
    {
        myin >> data.n;
        myin >> data.m;

        return myin;
    }
```
### Now the `main()`
```cpp
int main()
{
    Data data(5, 7);
    Data data1;

    cout << data;

    cin >> data1;

    cout << data1;

    return 0;
}
```
### Output
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/djvx7n7rqy16upjv43sn.png)

Also available on YouTube
{% youtube 4KmDjn6Zn60 %}
Github like Calendar Heatmap built from Scratch using React - JSitor
Tags: javascript, css, react, 100daysofcode
Published: 2021-01-06 13:49:01

Today, I have challenged myself to pick a random UI and built it from scratch. I picked up the Github Contribution heatmap view and built it using React and SCSS. 

![](https://i.ibb.co/n1LzvPz/Screenshot-2021-01-06-at-5-40-21-PM.png)

{% jsitor zdrqOxaWK %}

It took me ~1hour to complete this. A full video in making is available here -
{% youtube xmfcI2mjy4s %}
Immutable architecture patterns
Published: 2021-01-06 13:22:18

Immutable architecture

Immutable architecture is more reliable, consistent and predictable.
Immutable means something that is not capable of change

Immutable architecture characteristics

1.	Do not try to update, upgrade or apply security patches on Server hardware, OS or security software. Rather just create a new server and deploy application on it.
2.	Stop any SSH or manual access to servers
3.	Send same code to all the environments
 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6f2nv022utjy7shp0z79.png)

VS

 ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/78871y81hyrvlsejco2h.png)

4.	Do not download any dependency on run time, rather keep them offline in artifactory
5.	Also, if we use Canary/Blue-Green deployment possibility of downtime is almost gone
 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/khfdof0vbwcxzv2npps9.png)

6.	Rollback should be setup
7.	This will stop any malicious attack because server is completely out of external interference 

Canary Deployment

Routing strategy for Canary
 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vt50fe5uiqhs95sa9o3q.png)

Achieve Canary in AWS by
 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/grszc4gu3ji2mlyje4sa.png)


1.	Route 53: Route through Route 53
 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/g5ok8vfy4hi6q4pzks85.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mrdgo3kvwdknxvto09jh.png)
 
Minimize TTL value for faster Route 53 updation 

2.	Rolling deployments for auto scaling groups
 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ylttz1s0q083oc8x1dgs.png)

a.	2 auto scaling group has to be there
b.	1st auto scaling group is the production environment
c.	Keep removing no of servers from the 1st
d.	And keep increasing no of servers from the 2nd 
e.	The more instances slower updation

3.	Application load balancer and weighted target groups
 
 ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2017o60gwvmncqczqcse.png)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bxjjmo2l74vvfvd1fbjn.png)

a.	Create target groups for load balancer and route traffic to it
b.	Session stickiness can be enabled so session is not lost

4.	API Gateway
 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6kpe0va85v3un75ayzhm.png)

a.	Only for REST API
b.	We can set percentage of the API requests to a new API deployment for a particular stage
c.	Use cloud watch metric to monitor the performance and errors of the API and react to them
d.	We can also gradually increase the percentage of requests handled by the new API deployment and rollback if errors are detected


5.	Lambda alias traffic shifting 
 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/nl24m4j1niuceghesu0e.png)

a.	Just update the version weighs of a particular lambda alias and traffic will be routed to a new version of that function 
b.	Use cloud watch metric to monitor the performance and errors of the API and react to them

 ![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/i7dx44cxb3k2me8cppre.png)

Automate using code deploy with canary deployment
How to access a Hash either string or symbol keys
Tags: rails, ruby
Published: 2021-01-06 13:18:01

Sometimes, You may have stumbled across these cases why you got `nil` value from accessing a hash.

For example

First case,

```rb
fruit = { name: "Grape", color: "purple" }
```

Then
```rb
fruit[:name]
=> "Grape"

fruit["name"]
=> nil
```

Second case,

```rb
fruit = { "name" => "Grape", "color" => "purple" }
```

Then
```rb
fruit[:name]
=> nil

fruit["name"]
=> "Grape"
```

These two examples show that you need to know the hash key's structure, whether it's a string or a symbol key, to access it correctly.

Or you can convert it by using `symbolize_keys()` (returns a new hash with all keys converted to be symbols) and you can access it by using the symbol key.

###Would it be better if we can access a hash either string or symbol keys?

Using `with_indifferent_access()` 

For example

```rb
fruit = { name: "Grape", color: "purple" }.with_indifferent_access

fruit[:name]
=> "Grape"

fruit["name"]
=> "Grape"
```

It's pretty convenient because it ensures you get the value of the hash.

Reference: https://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html
I made a procedural MIDI melody generator
Published: 2021-01-06 13:11:30

I've just released a [melody generator](https://dopeloop.ai/melody-generator) that I've been working on for a while. It's a small web app that you can use to procedurally generate looping MIDI melodies and then use them in your own music.

[![Melody Generator](https://dev-to-uploads.s3.amazonaws.com/i/ngvsywptmmih69t2mc75.png)](https://dopeloop.ai/melody-generator/)

The fractalesque algorithm it uses to generate melodies is one I came up with when I was writing a lot of [algorave](https://en.wikipedia.org/wiki/Algorave) music a decade ago. The MIDI melodies are rendered to sound using the wasm port of [Timidity](https://github.com/feross/timidity) by Feross.

Enjoy!
Daily Developer Jokes - Wednesday, Jan 6, 2021
Tags: jokes, dailydeveloperjokes
Published: 2021-01-06 13:00:02

---
title: "Daily Developer Jokes - Wednesday, Jan 6, 2021"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Wednesday%2C%20Jan%206%2C%202021"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1259369613c.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit.*

<!-- 
Joke text:
___Q:___ How does a sysadmin keep a fire going?

___A:___ They rotate the logs.
 -->
Vue or React?
Tags: discuss, webdev, vue, react
Published: 2021-01-06 12:55:05

A couple of months ago, I chose Vue to be my point of entry to the frameworks realm in web development. I also decided to go in depth-first. So, I practiced barebones Vue, then used Vuetify, then - after getting sick of all the props and emits - I learned Vuex, and now I am playing around with Nuxt. In all this, I have not even glanced at the documentation of React.

What I know about React, I know from occasional blog posts. A common claim I came upon was that Vue is simpler to learn than React. And that does not seem to come with a penalty in terms of performance or robustness. As I understand, from reading and not from experience, both frameworks are equally useful for projects of different scales.

At least from my experience, as I work on my first meaningful web project, I find myself constantly impressed by how simple the development process is. Especially, when component libraries like Vuetify are utilized.

Assuming my understanding is correct (and feel free to enlighten me if it isn't) I have two questions:
1. With Vue.js readily available, is there any reason to learn React—other than the fact that React came first and therefore has the bigger market share?
2. If no such reason exists, do you expect Vue to take over in the future? In other words, any reason for a startup project today not to be developed in Vue instead of React?
Browse Instagram with no Account
Published: 2021-01-06 12:52:07

Want to Browse Instagram with no Account. See the below 2 minute use of a very nice Chrome extension that allows you to do this.

Well to be honest you can do much more with the Extension. It is basically an add blocker and privacy script blocker in one.

Enjoy and let me know in the comments what you think about it.

https://www.youtube.com/watch?v=7X8Ix0gwwQc&feature=youtu.be
Agrega la opción de verificación de emails con Laravel Jetstream.
Tags: laravel, php, jetstream
Published: 2021-01-06 12:49:04

### Modificar el archivo "config/fortify.php":

Debemos quitar el comentario sobre este feature.

```php
'features' => [
    Features::registration(),
    Features::resetPasswords(),
    Features::emailVerification(),
    Features::updateProfileInformation(),
    Features::updatePasswords(),
    Features::twoFactorAuthentication([
        'confirmPassword' => true,
]),
```

### En el modelo User implementar la interface "MustVerifyEmail":


```php
class User extends Authenticatable implements MustVerifyEmail
```

### Agregar un servicio proveedor de correos de prueba.

Puedes usar mailhog, pero el mas conocido y utilizado para pruebas en mailtrap.io, te logueas gratis y el servicio para una sola cuenta no tiene costo.

#### Agregas las llaves del servicio de mail

En tu archivo ".env" agrega las credenciales del servicio seleccionado, aquí un ejemplo con mailtrap.io

```env
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=273b5ab0b82231
MAIL_PASSWORD=b5612d6ea6iir3
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="admin@tuapp.com"
MAIL_FROM_NAME="${APP_NAME}"
```

###### Nota

Si deseas trabajar en producción, uno de los servicios mas beneficiosos y fáciles de implementar es Sendgrid.

Espero el post sea de utilidad.
Envía email de verificación de forma manual en Laravel.
Tags: laravel, php, spanish
Published: 2021-01-06 12:39:24

# Escenario

Estoy creando un Seeder de usuarios, ya tengo implementada la verificación por correo, pero quiero que todos los usuarios que se generan por medio de mi seeder, reciban el correo de verificación.

### Crear el seeder de usuarios.

```php
php artisan make:seeder UserSeeder
```

### Codigo para crear un usuario y enviar la notificacion por correo

```php
<?php

class UserSeeder 
{
    public function run()
    {
        $user = User::create([
            'name' => $name,
            'email' => $email,
            'password' => bcrypt($password),
        ]);

        $user->sendEmailVerificationNotification();
    }
}
```

### Registrar el UserSeeder en la clase DatabaseSeeder

```php
public function run()
{
    $this->call([
        UserSeeder::class,
    ]);
}
```

### Ejecutar el seeder en la terminal

```php
php artisan db:seed
```

Con esto puedes revisar tu servicio de depuración de correos como mailhog o mailtrap.io y tendras el correo en tu bandeja de entrada.


### Creando multiples usuarios

Puede darse el caso donde necesitemos crear una gran cantidad de usuarios de prueba, para ello podemos usar el metodo times() para crear una gran cantidad de usuarios e iterar para enviarle a cada uno el correo de confirmacion.

```php
$users = User::factory()->times(10)->create();

$users->each(function($user) {
    $user->sendEmailVerificationNotification();
});
```

Espero el post sea de utilidad, saludos!
PeppyOcean | On Demand App Development Company
Tags: mobile, android
Published: 2021-01-06 12:36:17

Are you looking for an on-demand app development company? If yes, then your search ends here. As a leading on-demand app development company in India, PeppyOcean provides the best mobile app development services using the latest technologies. Our talented developers are highly experienced in developing such applications. Let's have a cup of tea or coffee and discuss your project: https://www.peppyocean.com/
Is Node.js good to learn in 2021?
Tags: node, javascript, webdev
Published: 2021-01-06 12:32:32

Yes. Node.js is good to learn as well as best for web app development. So, let’s first of all know here What exactly is Node.js?

Node.js cannot be considered to be a library or framework; however, it is a runtime environment that depends on chrome’s V8 JavaScript engine that helps to apply JavaScript code. Node.js is selected by lots of companies and developers at present since it can support JavaScript and comes with innovative features.

Node.js can provide 2-way real-time interaction between the server-side and the client. In this way, the customer and the service provider get an equal share of the workload. Making use of Node.js for web app development service
will be the proper choice in case you require a personalized solution having innovative and useful features.

Let's learn more here:https://qr.ae/pNVxbJ
Base Node.js project
Tags: node, javascript, beginners, architecture
Published: 2021-01-06 12:31:33

---
title: Base Node.js project
published: true
description: Node.js start project.
tags: node,javascript,beginners,architecture
cover_image: https://images.unsplash.com/photo-1562516155-e0c1ee44059b?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=889&q=80
---
Hi guys, I'd like to share my minimalistic boostrap Node.js project, **node-essential**. The propose of **node-essential** is a base structure to start a development with Node.js.

Sometimes we needed do create a new Node.js project with a base structure and base libraries to start a Web API's, swagger documentation and so fourfh.

In this project, I am create a base structure using clean architecture principles.

Please, check out on my github: [https://github.com/leandroandrade/node-essential](https://github.com/leandroandrade/node-essential)

I hope it helps you, just as it is helping me. Thank you and have fun!!!
Store spring sessions in Separate Database
Published: 2021-01-06 12:28:25

Storing session details in Redis or database is usually a good idea. However,
the [default implementation](https://springhow.com/spring-boot-security/session-jdbc/) of `spring-session-jdbc` uses the primary data source to store and
retrieve data from the session related tables. This can be a problem when there is a large amount of session related
operations to the database.

The solution here is to define a custom datasource bean and mark it with `@SpringSessionDataSource` as shown below. 

```java
@Bean
@SpringSessionDataSource
public DataSource sessionDataSource() {
    return sessionDataSource();
}
```

However, when you define multiple data sources, you end up breaking the default auto-configurations involving the primary data source. 

To avoid all that, you need to mark one datasource as primary and somehow create and feed the second datasource to the session auto-configuration.

Follow this post about [Store spring sessions in Separate Database](https://springhow.com/session-jdbc-different-database/) to learn how and why you should do it this way.