drupal - update an alias programmatically

When you use the "pathauto" module and want to make the node's URL depends on your custom field you can create a pattern using a token, however, what can you do if the field is boolean and you want to make a human path or you needed in the more complex pattern? You can implement it programmatically. I going to show how to fix it very quickly.