Skip to content

Instantly share code, notes, and snippets.

Kirk Ouimet kirkouimet

Block or report user

Report or block kirkouimet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View aspect-ratio-rounded.php
public static function aspectRatioRounded($a, $b) {
$total = $a + $b;
for($i = 1; $i <= 40; $i++) {
$arx = $i * 1.0 * $a / $total;
$brx = $i * 1.0 * $b / $total;
if($i == 40 || (
abs($arx - round($arx)) <= 0.02 &&
abs($brx - round($brx)) <= 0.02)) {
# Accept aspect ratios within a given tolerance
return round($arx).'x'.round($brx);
@kirkouimet
kirkouimet / php-analytics.php
Created Nov 14, 2011
PHP analytics function
View php-analytics.php
function getAnalytics() {
$user = $_SERVER['HTTP_USER_AGENT'];
$browser = 'Unknown';
$platform = 'Unknown';
$version= '';
// First get the platform?
if(preg_match('/linux/i', $user)) {
$platform = 'Linux';
}
You can’t perform that action at this time.