Code Library

Practical snippets you can use freely, each with a short description and a real-world example.

3 results

Token Bucket
PHP

Token Bucket

Allow a short burst, then refill tokens at a steady rate. The burst cannot exceed the bucket size.

View code
Connection Pool
PHP

Connection Pool

Reuse an idle connection inside the same process, instead of opening a new one for every query.

View code
Password Hashing
PHP

Password Hashing

Store a password as a salted hash, with a pepper from app config. This is not reversible encryption.

View code

Need a snippet that is not here?

Describe the problem or idea, and I will see if it belongs in the library.