Skip to content

Instantly share code, notes, and snippets.

View murtaugh's full-sized avatar
👋

Tim Murtaugh murtaugh

👋
View GitHub Profile
@murtaugh
murtaugh / wait.js
Created November 20, 2013 22:56
a function that does what I always expect .delay() to do
$.wait = function( callback, seconds){
return window.setTimeout( callback, seconds * 1000 );
}
// usage
$.wait( function(){ $("#message").slideUp() }, 5);
@murtaugh
murtaugh / menu-items.md
Last active May 17, 2020 13:22
How would you mark up an item on a restaurant menu?

I was thinking about restaurant menus, and started wondering how best to mark up individual items on the menu. Assuming you're going to put the each item in an li one approach could be:

<li>
	<h2>Home-Style Burger</h2>
	<p>half-pound burger with grilled onions</p>
	<p class="price">$7.25</p>
</li>	
@murtaugh
murtaugh / codepen-sample.html
Created February 12, 2014 23:24
CodePen on ALA
<figure class="text full-width">
<p data-height="388" data-theme-id="0" data-slug-hash="BJrpg" data-default-tab="result" class='codepen'>See the demo: <a href='http://alistapart.com/d/390/ui-animation-and-ux-a-not-so-secret-friendship/demo-show-hide'>Show/hide example</a></p>
<script async src="//codepen.io/assets/embed/ei.js"></script>
<figcaption>Select items on the main nav to reveal the submenus.</figcaption>
</figure>
@murtaugh
murtaugh / parallax.js
Created March 5, 2014 16:06
Finally a simple parallax script I like
$(window).scroll(function(e){
parallax();
});
function parallax() {
var scrolled = $(window).scrollTop();
//81% is the original top position of the element,
.notched-box {
position: relative;
width: 50%;
height: 200px;
margin: 2em auto;
padding: 2em 0;
background: #eee;
overflow: hidden;
}

Keybase proof

I hereby claim:

  • I am murtaugh on github.
  • I am murtaugh (https://keybase.io/murtaugh) on keybase.
  • I have a public key whose fingerprint is D47C 9FB7 E5D4 4EC1 DD55 6D3D BE9F DFE5 D9A1 EB0F

To claim this, I am signing this object:

@murtaugh
murtaugh / handle-missing-image.js
Last active August 29, 2015 13:57
If an image fails, what do we do? In my case, maybe I've already defined a backup (usually in the case of inline SVGs), so we should look for that first. If that fails, then we'll hide the image (or do whatever the context requires).
$('img').on('error', function(){
//console.log('img load failure: ' + $(this).attr('src'));
var fallback = $(this).attr('data-fallback');
if (typeof fallback !== 'undefined' && fallback !== false) {
$(this).attr('src', fallback);
@murtaugh
murtaugh / keyboard-controls.js
Last active August 29, 2015 13:57
Keyboard Controls
document.onkeydown = checkKey;
function checkKey(e) {
e = e || window.event;
if ((e.keyCode == '39') || (e.keyCode == '40')) { // right / down arrow
console.log('right / down');
@murtaugh
murtaugh / hide menu,js
Created May 20, 2014 14:51
The right way to close a menu (without preventing event bubbling)
$(document).on('click', function(event) {
if (!$(event.target).closest('#menucontainer').length) {
// Hide the menus.
}
});
@murtaugh
murtaugh / eecms-update-for-ala
Last active August 29, 2015 14:06
A List Apart migration plan
0. Make sure local and dev files are in synch.
1. turn off comments on prod
... by hiding the comment form
2. clear caches on prod
3. turn off local
4. clear caches on local
5. make local copy of prod db