Snippet of the Week
#67 - Simple A/B variation class for experiments - 2019-06-29 - PHP
Class to do variation testing based on experiments and number of variations in PHP.
<?php
class Experiment {
public static function getVariation($experiment, $numVariations = 2) {
return hexdec(substr(sha1($experiment . '.' . ($_SERVER['REMOTE_ADDR'] ?? '') . '.' . ($_SERVER['HTTP_USER_AGENT'] ?? '')), 0, 4)) % $numVariations;
}
}
Projects
Animated Backgrounds for Flutter. Easily extended to paint whatever you want on the canvas.
Link
![](/images/stellar.png)
Simple Federation server that responds to requests of the Stellar federation protocol.
Link
Blog posts from andrebaltazar.com
In this post I will show you how to create a simple animated background from scratch using the Animated Backgrounds package available at pub.dartlang.org, created by me.
Read more
This week I had to implement a pagination system for the blog. Because, as I write more posts, the blog needs these kind of features. I started looking around at the blogs I read frequently, and ended up more confused on how to implement these pages than when I started.
Read more
A few days ago I was going through the a PHP RFC page when I found a vote for deprecation of a cast I had never used before, a cast to NULL. The keyword unset is used for this cast, for example, $b = (unset) $a, which results in $b being assigned with the value NULL, and nothing else.
Read more