Skip to content

Instantly share code, notes, and snippets.

@dalethedeveloper
dalethedeveloper / gist:1503252
Created December 20, 2011 21:00
Mobile Device Detection via User Agent RegEx

#Mobile Device Detection via User Agent RegEx

Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.

I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.

The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".

Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(

@gabesumner
gabesumner / fiddle.css
Last active November 19, 2023 06:01
Address Validation using the Google Maps API
body {
font: 12px verdana;
background-color: #5C87B2;
}
form {
max-width: 400px;
padding: 15px;
background-color: white;
}
@robnyman
robnyman / arraybuffer-blob-filereader-localStorage.js
Last active January 30, 2024 09:22
Get file as an arraybuffer, create blob, read through FileReader and save in localStorage
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob
var rhinoStorage = localStorage.getItem("rhino"),
rhino = document.getElementById("rhino");
if (rhinoStorage) {
// Reuse existing Data URL from localStorage
rhino.setAttribute("src", rhinoStorage);
}
else {
// Create XHR, Blob and FileReader objects
var xhr = new XMLHttpRequest(),
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active June 5, 2024 22:16 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@kogakure
kogakure / gist:4769904
Created February 12, 2013 13:31
SASS: Circle Mixin
@mixin circle($width, $color) {
width: $width;
height: $width;
background: $color;
-webkit-border-radius: $width/2;
-moz-border-radius: $width/2;
border-radius: $width/2;
}
.circle {
@rcotrina94
rcotrina94 / How to use Images as Radio buttons.md
Last active July 20, 2024 11:31
How to use images for radio buttons (input-radio).
anonymous
anonymous / night-before-opsmas.txt
Created December 24, 2013 07:19
Twas the night before Opsmas..
'Twas the night before Christmas, when all through the racks
Not a server was alerting, not even Compaqs.
The backups were written to tapes with care
In hopes that later the data would be there.
The machines were nestled all snug in their sleds
Whilst visions of vengeance danced in their heads;
And oncall in his three-wolf and I in my rack.
Had just settled down for some syn and some ack.
@molotovbliss
molotovbliss / gist:8866859
Last active November 16, 2016 02:32
MySQL Dump for Magento without locking the DB
mysqldump -u<USERNAME> -p<PASSWORD> --skip-opt --triggers --single-transaction --max_allowed_packet=512M db > db.sql
@molotovbliss
molotovbliss / example.php
Last active November 10, 2018 00:12
Running multiple processes in PHP
<?php
set_time_limit(0);
include "threads.php";
$commands = array('ffmpeg -i '.$inputFile[0].' '.$outputFile[0].' 2>&1','ffmpeg -i '.$inputFile[0].' '.$outputFile[0].' 2>&1');
$threads = new Multithread($commands);
$threads->run();
foreach ($threads->commands as $key=>$command){
echo "Command ".$command.":<br>";
echo "Output ".$threads->output[$key]."<br>";
echo "Error ".$threads->error[$key]."<br><br>";
@philwinkle
philwinkle / reproduce.md
Last active February 24, 2016 08:42
product->load as an antipattern?
<?php

require('app/Mage.php');
Mage::app();


$product = Mage::getModel('catalog/product')->getCollection()->getFirstItem();

var_dump($product-&gt;getData('media_gallery'));