Skip to content

Instantly share code, notes, and snippets.

View dmolsen's full-sized avatar

Dave Olsen dmolsen

View GitHub Profile
@dmolsen
dmolsen / cli.php
Created April 6, 2013 15:45
A very simple example of setting up a command line tool using PHP
<?php
/*
* A ridiculously simple example of using PHP as a command line tool
*
* The following usage is supported by this script:
*
* php cli.php -a [-c]
* Do something based on the -a flag. Use the optional -c flag to modify what happens when using the -a flag.
*
@dmolsen
dmolsen / _content.scss
Last active December 14, 2015 12:19
sass-ified example of styles
// base styles for the content container div
.content {
width: 100%;
margin: 0;
padding: 0 1.25em 1.25em 1.25em;
background-color: #fff;
float: left;
}
// break at 31.25em, builds on the base
@dmolsen
dmolsen / redirect.php
Created May 21, 2012 14:47
Using ua-parser-php for a redirect script
<?php
// require the ua-parser-php library
require_once("/path/to/UAParser.php");
// parse the requesting user agent
$result = UA::parse();
// redirect phones, to redirect tablets use isMobileDevice
if ($result->isMobile) {
@dmolsen
dmolsen / cron.php
Created May 21, 2012 14:45
Cron jobs to be used with ua-parser-php
// any of the following can be used as the basis for your cron job.
// you shouldn't have to grab the regexes.yaml file more than once a day.
// the following examples will run at midnight each day
// update your regexes.yaml file with the following
0 0 * * * php /path/to/UAParser.php -get
// use the -silent flag to turn off status updates when grabbing latest regexes.yaml
0 0 * * * php /path/to/UAParser.php -get -silent
@dmolsen
dmolsen / gist:1706269
Created January 30, 2012 19:48
Example of using ua-parser-php
<?php
require("UAParser.php");
$result = UA::parse();
print $result->full;
// -> Chrome 16.0.912/Mac OS X 10.6.8
print $result->browserFull;
// -> "Chrome 16.0.912"
@dmolsen
dmolsen / gist:1696796
Created January 29, 2012 02:15
Get the latest YAML file
<?php
require("UAParser.php");
$result = UA::get();
?>
@dmolsen
dmolsen / gist:1696775
Created January 29, 2012 02:11
example of using ua-parser-php
<?php
require("UAParser.php");
$result = UA::parse();
print $result->full;
// -> Chrome 16.0.912/Mac OS X 10.6.8
print $result->browserFull;
// -> "Chrome 16.0.912"
@dmolsen
dmolsen / gist:1570854
Created January 6, 2012 14:35
MQSugr Demo Page Code Just Using Default Modernizr.load
// this code WON'T be run again with resize or orientationchange
// to start the snowflakes
var oncomplete = function() { snowflakes = new Snowflakes('container','snowflakesContainer'); snowflakes.create(40); };
// set-up breakpoints
Modernizr.load([
{ test: Modernizr.mq('only screen and (min-width: 320px)'), yep: 'css/320.css' },
{ test: Modernizr.mq('only screen and (min-width: 600px)'), yep: 'css/600.css' },
{ test: Modernizr.mq('only screen and (min-width: 600px)') && Modernizr.indexeddb, yep: 'css/600.indexeddb.css' },
@dmolsen
dmolsen / gist:1567142
Created January 5, 2012 20:32
MQSugr Demo Page Code
// to start the snowflakes
var oncomplete = function() { snowflakes = new Snowflakes('about','snowflakesContainer'); snowflakes.create(40); };
// set-up the breakpoints
var mqsugr = new MQSugr();
var breakpoints = {
breakpoint1: '320px',
breakpoint2: { mq: '600px', tests: 'indexeddb' },
breakpoint3: { mq: '801px', tests: 'cssanimations', yep: ['{cssPath}snowflakes.css', '{jsPath}snowflakes.js'], complete: oncomplete },
breakpoint4: '801px'
@dmolsen
dmolsen / gist:1495085
Created December 19, 2011 01:46
Holiday card timed events code
// don't change these variables
var p = false; // currently playing
var e = false; // ended
var j = true; // first play
var videoTimeRaw = 0;
var currentTime = 0;
var defaultInterval = 100;
// configure these variables
var vidId = 'videoEmbed'; // the ID of the div holding the video