Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamie Hamel‑Smith jamiehs

View GitHub Profile
@jamiehs
jamiehs / gist:3364281
Created Aug 15, 2012
jQuery Array Intersect One Liner
View gist:3364281
// 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 Sep 11, 2012
A simple way to copy an array in JavaScript
View copy-array.js
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 Oct 4, 2012
Addition to a SlideDeck 2 lens.js file for adding an external title (Tool kit)
View lens.js
// 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 Oct 4, 2012 — forked from chriscoyier/mq.css
Media Query Breakpoints for Retina Displays
View mq.css
@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 Oct 6, 2012
YouTube JavaScript Regex
View youtube-regex.js
var youTubeRegex = /(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|[a-zA-Z0-9_\-]+\?v=)([^#\&\?\n<>\'\"]*)/gi;
@jamiehs
jamiehs / gist:3845164
Created Oct 6, 2012
Meta tag for viewport based devices that uses native DPI Scaling
View gist:3845164
<meta name="viewport" content="width=device-width, target-densityDpi=device-dpi">
@jamiehs
jamiehs / click-timer.js
Created Oct 8, 2012
Click Timer for jQuery
View click-timer.js
$('#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 Oct 16, 2012
Intrinsic width on a block level element
View intrinsic-width.css
div {
width: intrinsic; /* Safari/WebKit uses a non-standard name */
width: -moz-max-content; /* Firefox/Gecko */
}
@jamiehs
jamiehs / gist:3962024
Created Oct 26, 2012
Example of how to place extra custom JavaScript after the wp_footer and before the closing body tag
View gist:3962024
</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 Dec 14, 2012
Force YouTube to embed a player with modest branding, autoplay, and 720p
View YouTube HD Embed
http://www.youtube.com/embed/oHg5SJYRHA0?wmode=opaque&autoplay=1&modestbranding=1&vq=hd720