How to win friends and influence people in 10 steps

We can say the best books are the ones which pass the test of time. How to win friends and influence people was published in 1936 but it’s more actual than ever.

1. DO NOT CRITICIZE

Try to understand the people, instead of stop them to talk. It is much more useful than to criticize.

Try to imagine why they are doing what they are doing and ask them questions. It is better than judge them.

2. SHOWS HONEST APPRECIATION

Anyone can be better than me in some fields. In this sense, I can learn from them. Try to think to the best qualities of the other person, without going to extreme adulation. Be generous in praise.

3. BE SINCERELY INTERESTED IN OTHERS

To have real friends, help others and appreciate them. You must be interested in the other’s life: ask how they are doing, what they like, and anything else that might be important to them.

To be interesting, you have to be interested.

4. BE A GOOD LISTENER

If you aspire to have a good conversation, you first have to know how to listen.

Encourages the other to talk about him/her.

5. SPEAK ABOUT WHAT THE OTHERS ARE INTERESTED

Speak about what the other person is interested is beneficial for both parts. Make sure you know what concerns and interests they have and focus on bringing them up often in the conversation.

6. MAKE THEM FEEL IMPORTANT

Speak to the people about them and they will listen you for hours, but… you must talk in a sincere manner.

7. RESPECT THE OPINIONS OF OTHERS

NEVER tell to a person he/she is wrong. You will put them in a defensive position. You have to act with tact. Before argue with someone, you can say “maybe I am wrong” or “I am many times wrong”.

8. ADMIT YOUR MISTAKES

If you are wrong, admit quickly and clearly. To criticize yourself when you are wrong is more funny and gives better results than defending yourself.

9. TALK ABOUT YOUR MISTAKES FIRST

Before correcting someone, a true lider speaks first about their own errors. This can help the other one to improve their behaviour.

10. PRAISE PROGRESS

The qualities of a person dries under criticism but they develop under stimulation. Praise others and inspire them to develop their full potential.

Backup database in S3

A simple cron backup script of the databse in aws s3. Our script is called mysqlbackup.sh and it looks like this:

#!/bin/bash
DB="razvantudorica"
NOW=$(date +"%m_%d_%Y")
BACKUPFILE="${DB}_${NOW}.sql.gz"
mysqldump --login-path=s3gallery --databases $DB | gzip > $BACKUPFILE
aws s3 cp $BACKUPFILE s3://backup.razvantudorica.net/$BACKUPFILE --profile backuper
rm $BACKUPFILE

And now a few explanations about the script.

First of all we need to have installed the awscli command.

Afterwords, as you can see, the database password is not hardcoded into the script. We can setup the password with mysql_config_editor. This will store authentication credentials in an encrypted login file named .mylogin.cnf.

For our example database, razvantudorica, and database user myuser, we can run

mysql_config_editor set --login-path=razvantudorica --host=localhost --user=myuser --password

The next step is to configure aws s3 bucket and credentials.

  • Create a bucket in s3, in our example is called backup.razvantudorica.net.
  • Create the IAM credentials and save them in ~/.aws/credentials as
[backuper]
aws_access_key_id=AK... 
aws_secret_access_key=...
  • And in ~/.aws/config add
[profile backuper]
region=eu-west-1
output=json
  • The last step is to test our script. If no error occurs at running and the backup file is uploaded successfully in S3, then everything is correct and we can add it the crontab list.
  • Run crontab -e and add this line
0  1 * * * /root/mysqlbackup.sh >> /var/log/mysqlbackup.log

Unknown database type enum requested

Using symfony (5) console command to create new migration based on my entities, I encountered this error.

php bin/console doctrine:migrations:diff

Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.

The simplest solution is to add mapping_types in config\packages\doctrine.yml

doctrine:
    dbal:
        # ...
        mapping_types:
            enum: string

Upload asynchronously to Amazon S3 using Tornado

TornadoWeb is a great non-blocking web server written in Python and Boto3 is the Amazon Web Services (AWS) SDK for Python, which allows developers to write in a very easy manner software that makes use of Amazon services like S3. Unfortunately boto3 S3 wrapper is blocking and if you would just use it out of the box in a Tornado application it will block the main thread because it uses a synchronous HTTP client.
Continue reading Upload asynchronously to Amazon S3 using Tornado