Skip to content

Instantly share code, notes, and snippets.

View samdark's full-sized avatar
🛠️
Improving everything

Alexander Makarov samdark

🛠️
Improving everything
View GitHub Profile
@dzuelke
dzuelke / bcrypt.php
Last active March 28, 2023 13:15
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
$salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)), '+', '.'), 0, 22);
// 2y is the bcrypt algorithm selector, see http://php.net/crypt
// 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt
@mindplay-dk
mindplay-dk / weighted_average.php
Created February 14, 2014 15:20
Computing weighted average from a set of values
function weighted_average($values) {
$sum = 0;
foreach ($values as $i => $value) {
$sum += $value;
}
$avg = $sum / count($values);
$error = array();
@tom--
tom-- / Random bytes, ints, UUIDs in PHP.md
Last active November 4, 2024 19:12
PHP random bytes, integers and UUIDs

Random bytes, ints, UUIDs in PHP

Simple and safe random getters to copy-paste

string randomBytes( int $length )

int randomInt ( int $min , int $max )

string randomUuid ( void )
@vjik
vjik / yii3-roadmap.md
Created December 24, 2024 06:47
Yii3 Roadmap

Yii3 Roadmap

Last updated: 24.12.2024

The Yii3 release is approaching, and the team is working hard to complete the final steps 💪.

At the heart of Yii3 are its packages, which form the foundation of the framework. So far, 105 packages have been released, and the remaining ones are already 80-90% complete. But Yii3 is more than just its set of packages. It also includes great documentation and ready-to-use application templates. Completing these elements is a key part of preparing for the final release.

You can support the Yii3 team and help accelerate the release by making a donation. Every contribution, no matter the size, helps us move closer to delivering Yii3: