Skip to content

Instantly share code, notes, and snippets.

@thotbox
thotbox / PHP: Test For Internet Connection.php
Created September 17, 2014 16:15
PHP: Test For Internet Connection
<?php
$connected = @fsockopen("www.workwiththey.com", 80);
if ($connected) {
echo "connected";
fclose($connected);
} else {
echo "not connected";
}
?>
@thotbox
thotbox / Ping Pong Compare Timestamps.js
Created September 11, 2014 13:01
Ping Pong Compare Timestamps
// Ping Pong Compare Timestamps
setInterval(function () {
fetchEditDate('/fetch/edit-date/{segment_2}');
var origEditDate = $('#original-edit-date-field').val();
var fetchedEditDate = $('#fetched-edit-date-field').val();
if (fetchedEditDate > origEditDate){
location.reload();
}
},500);
@thotbox
thotbox / JavaScript: Responsive Parallax.js
Created August 14, 2014 13:03
JavaScript: Responsive Parallax
// Parallax
$(document).ready(function(){
$window = $(window);
var width = $window.width();
$(window).bind('resize', function () {
width = $window.width();
});
$(window).scroll(function() {
// #hero
@thotbox
thotbox / CSS: Boilerplate.css
Created July 31, 2014 13:55
CSS: Boilerplate
.row {
max-width: 1920px;
}
.container {
padding: 0 15px;
}
.nopad {
padding: 0;
@thotbox
thotbox / PHP: IE8 Conditional.php
Created July 31, 2014 13:43
PHP: IE8 Conditional
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE 8')) {
// IE 8 Stuff
}
else {
// Default Stuff
}
?>
@thotbox
thotbox / JavaScript: Freeform Pagination HTTPS Fix.js
Last active August 29, 2015 14:04
JavaScript: Freeform Pagination HTTPS Fix
// Pagination Links Fix
$('#pagination a').each(function() {
var href = $(this).attr('href');
if (href.indexOf('http:') > -1) {
href = href.replace('http:', 'https:');
$(this).attr('href', href);
}
});
@thotbox
thotbox / CSS: Facebook Iframe Scroll Hack.css
Created July 28, 2014 15:12
CSS: Facebook Iframe Scroll Hack
#focus-field {
position: absolute;
height: 0!important;
width: 0!important;
margin-top: -500px;
z-index: -999;
}
#focus-field.sub-focus {
margin-top: 500px;
@thotbox
thotbox / JavaScript: Facebook Iframe Scroll Hack.js
Last active September 2, 2015 09:14
JavaScript: Facebook Iframe Scroll Hack
// Scroll Top Iframe Hack
$(document).ready(function() {
if($('#focus-field').length ) {
setTimeout(function () {
$('#focus-field').focus();
$('#focus-field').blur();
}, 300);
}
});
@thotbox
thotbox / JavaScript: Popup Confirm Close.js
Last active August 29, 2015 14:04
JavaScript: Popup Confirm Close
// Vote Submit
function voteShare (pageURL,title,w,h) {
var left = (window.screen.width/2)-(w/2);
var top = (window.screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
var pollTimer = window.setInterval(function() {
if (targetWin.closed !== false) {
window.clearInterval(pollTimer);
setTimeout(function () {
@thotbox
thotbox / JavaScript: Email Submit Disable.js
Last active August 29, 2015 14:04
JavaScript: Email Submit Disable
// Email Submit Disable
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
return pat