Skip to content

Instantly share code, notes, and snippets.

View jamiehs's full-sized avatar

Jamie Hamel‑Smith jamiehs

View GitHub Profile
@jamiehs
jamiehs / gist:3364281
Created August 15, 2012 22:25
jQuery Array Intersect One Liner
// Find the common intersection between the arrays
a1=[1,2,3]
a2=[2,3,4,5]
$.map(a1,function(a){return $.inArray(a, a2) < 0 ? null : a;})
// http://stackoverflow.com/a/9401775/24559
@jamiehs
jamiehs / copy-array.js
Created September 11, 2012 17:49
A simple way to copy an array in JavaScript
var myArray = new Array(1, 2, 3);
var copy = myArray.slice();
// now I can change myArray[0] = 5; & it wont affect copy array
@jamiehs
jamiehs / lens.js
Created October 4, 2012 14:52
Addition to a SlideDeck 2 lens.js file for adding an external title (Tool kit)
// This should be added to your custom lens based on the Tool Kit lens, right after these functions near the end of the file:
deckNavigation();
overlay();
setOptions();
deckAdjustments();
bindScrollEventForDotUpdate();
bindScrollEventForThumbUpdate();
// Add the external title to the frame
@jamiehs
jamiehs / mq.css
Created October 4, 2012 16:00 — forked from chriscoyier/mq.css
Media Query Breakpoints for Retina Displays
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
@jamiehs
jamiehs / youtube-regex.js
Created October 6, 2012 14:42
YouTube JavaScript Regex
var youTubeRegex = /(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|[a-zA-Z0-9_\-]+\?v=)([^#\&\?\n<>\'\"]*)/gi;
@jamiehs
jamiehs / gist:3845164
Created October 6, 2012 15:07
Meta tag for viewport based devices that uses native DPI Scaling
<meta name="viewport" content="width=device-width, target-densityDpi=device-dpi">
@jamiehs
jamiehs / click-timer.js
Created October 8, 2012 20:24
Click Timer for jQuery
$('#my_awesome_element').click(function(event){
var element = this;
if (this.timer) clearTimeout(element.timer);
this.timer = setTimeout(function(){
console.log("Nothing Pressed for 1000ms");
},1000);
return true;
});
@jamiehs
jamiehs / intrinsic-width.css
Created October 16, 2012 20:58
Intrinsic width on a block level element
div {
width: intrinsic; /* Safari/WebKit uses a non-standard name */
width: -moz-max-content; /* Firefox/Gecko */
}
@jamiehs
jamiehs / gist:3962024
Created October 26, 2012 22:51
Example of how to place extra custom JavaScript after the wp_footer and before the closing body tag
</div>
</div>
</div>
<!-- /Footer -->
<?php wp_footer(); ?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.slidedeck-frame').bind('mouseenter', function(){
jQuery('.slidedeck').slidedeck().pauseAutoPlay = true;
@jamiehs
jamiehs / YouTube HD Embed
Created December 14, 2012 18:51
Force YouTube to embed a player with modest branding, autoplay, and 720p
http://www.youtube.com/embed/oHg5SJYRHA0?wmode=opaque&autoplay=1&modestbranding=1&vq=hd720