Python: check if item or value exists in list or array

Introduction Sometimes we need to know if an element or value is within a list or array in Python. There may be a need to simply know if it exists, but it is also possible that we need to obtain the position of an element, that is, its index. Today we will see how to do it in Python, to check if an element exists in array, as well as to obtain the index of a certain value. ...

April 2, 2019 · 2 min · 296 words · Parzibyte

Switch in Python

There is no switch statement in Python, but there are equivalents depending on what you want to achieve. The best-known use of switch is to evaluate a value and avoid nesting multiple if statements. Today I will explain it: how to make an equivalent switch in Python. ...

April 2, 2019 · 3 min · 437 words · Parzibyte

PHP: Generate cryptographically secure token

Intro Sometimes we need to create a random string or token using PHP. For example, it’s quite common that when we want to reset our password on some website a message is sent to the mail we registered. Probably the message have a link like this: site.com/reset-pass?token=123 Where 123 is the token. Today we will see how to create a token cryptographically secure using PHP. We can use this token as a password or as random string to reset something. This works for PHP 5 and for PHP 7. ...

April 1, 2019 · 2 min · 379 words · Parzibyte