Skip to content

Instantly share code, notes, and snippets.

View SeanJA's full-sized avatar
🦑
🦖

SeanJA SeanJA

🦑
🦖
View GitHub Profile
@SeanJA
SeanJA / jquery.referrer.js
Created October 5, 2012 19:23 — forked from gavinblair/jquery.referrer.js
Get the referrer with jQuery: A useless bookmarklet
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"1.7.2",function($,L){$.fn.referrer%20=%20function()%20{%20%20%20%20return%20$(document).prop("referrer").toString();};alert($().referrer());});
<?php
function daterange_range($starttime, $endtime = null) {
$return = "";
//set the endtime to the start time if there isn't an endtime provided
$endtime = empty($endtime) ? $starttime : $endtime;
//turn them into timestamps if they are not timestamps already
$endtime = ((int)$endtime == $endtime && is_int($endtime))? $endtime:strtotime($endtime);
$starttime = ((int)$starttime == $starttime && is_int($starttime))? $starttime:strtotime($starttime);
//boolean values to prevent test duplication,
/**
* Try and split a selector into its parts (. # are really the only ones supported)
*/
function splitSelector(selector){
var selectors = [];
selector = selector.split(/(\W)/);
while(selector.length){
if(selector[0].match(/(\.|#)/)){
selectors.push(selector.shift() +''+ selector.shift());
} else if(selector[0].match(/\w/)) {
@SeanJA
SeanJA / index.php
Created June 10, 2010 16:53 — forked from gavinblair/index.php
mobile browser detection
<?php
$mobiles = array(
'iphone','ipod','android','blackberry',//and so on
);
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
if($match = preg_match('/('.implode('|',$mobiles).')/', $agent)){
echo 'mobile';
//include mobile stuff here
} else {
<?php
//this would come from a database count function
$totalPages = 200;
//presumably this comes from the get variable
$currentPage = 20;
//if the current page > total pages, just set it to the number of pages,
//someone is messing with the url
if ($currentPage > $totalPages) {
$currentPage = $totalPages;
<?php
/**
* Create a select box
* @param string $name the name of the select box
* @param array $options the options, associative array array('val_1'=>'opt_1' ... )
* @param string $selected the option that is selected
* @param array $attributes associative array of attributes for the select box array('attr_1'=>'val_1', 'attr_2'=>'val_2')
*/
function html_select($name, array $options, $selected=null, array $attributes = array()) {