Skip to content

Instantly share code, notes, and snippets.

@markreale
markreale / external_links.js
Created May 28, 2012 10:21
Open External Links in a New Window
@markreale
markreale / window_sizes.js
Created May 28, 2012 10:53
Function to retrieve sizes of Window and Document objects for reference in applications
/***********************************************
* *
* Declare global variables for all of the *
* elements that you are going to be using for *
* size reference. *
* *
***********************************************/
var landscape = false,
portrait = false,
ww,wh,dw,dh;
@markreale
markreale / prevent_bounce.js
Created May 28, 2012 15:56
Prevent Default Bounce in iOS web projects
/***********************************************
* *
* Function that will prevent default bounce *
* behaviour in iOS applications. *
* (Also prevents any touch-scrolling) *
* - requires jQuery *
* *
***********************************************/
function preventBounce(){
$(document).bind('touchmove',function(e) {
@markreale
markreale / display_custom_fields.php
Created May 31, 2012 05:29
Conditionally Displaying Custom Fields with WordPress
/****************************************************************
* *
* Conditional statement to retrieve content based on the *
* existence of a Custom Field. *
* If the Custom Field exists, display the content of the *
* Custom Field (can be adjusted to display alternate content). *
* *
****************************************************************/
// Check for existence of content in that custom field
@markreale
markreale / wordpress_query.php
Last active October 5, 2015 17:07
A Full WordPress Query
<?php
// Gather all of the parameters / filters to be used in your database query as an array of arguments
$args = array(
'post_type' => 'page',
'page_id' => '2064',
'posts_per_page' => '1',
'cat' => '7',
'offset' => '7',
'paged' => '7',
'orderby' => 'rand',
@markreale
markreale / ip_test.php
Created August 7, 2012 21:12
Restrict PHP code to a specific IP Address
<?php
$thisIp = $_SERVER['REMOTE_ADDR'];
if($thisIp == 'the.ip.you.test'){
// Do something
}
else{
// Show the normal state
}
?>
@markreale
markreale / Screen Window and Dimensions
Created May 27, 2013 21:56
A couple of objects to access screen and window size.
var winDim = {};
winDim.X = window.innerWidth;
winDim.Y = window.innerHeight;
var screenDim = {};
screenDim.X = screen.width;
screenDim.Y = screen.height;
@markreale
markreale / mediaSizeCheck.js
Created May 28, 2013 19:35
Check when an interface passes a media query threshold.
var checker = 0;
$(window).resize(function(){
if(window.matchMedia){
var mq = window.matchMedia( "(min-width: 940px)" );
var aMatch = mq.matches;
if(checker == 0){
if(aMatch) {
return;
@markreale
markreale / og.html
Created June 3, 2013 15:44
Meta Info for Open Graph stuff
<meta property="og:title" content="This is the title of your page" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://yoursite.com/" />
<meta property="og:image" content="http://www.theymc.com/wp-content/themes/theymc/assets/images/ymc_logo_374.png" />
<meta property="fb:admins" content="000000009" />
@markreale
markreale / basics.html
Last active December 21, 2015 15:19
The most basics of the basics. Document declaration, html, head, and body tags, and some comments about what goes where.
<!doctype html>
<html>
<head>
<!-- Inside the <head> tag will be content about your web page, or links to other resources. -->
</head>
<body>
<!-- Inside the <body> tag will be the content that appears in your browser window -->
</body>