Skip to content

Instantly share code, notes, and snippets.

View gavinblair's full-sized avatar

Gavin Blair gavinblair

View GitHub Profile
@gavinblair
gavinblair / style.css
Created January 10, 2012 15:56
hidden
/* from HTML5 Boilerplate http://html5boilerplate.com/ */
/* For image replacement */
.ir { display: block; text-indent: -999em; overflow: hidden; background-repeat: no-repeat; text-align: left; direction: ltr; }
.ir br { display: none; }
/* Hide for both screenreaders and browsers:
css-discuss.incutio.com/wiki/Screenreader_Visibility */
.hidden { display: none; visibility: hidden; }
@gavinblair
gavinblair / mymodule.module
Created December 1, 2011 21:34
using hook_theme
<?php
/* hook_menu */
function mymodule_menu(){
$items = array();
$items['my/awesome/path'] = array(
'title' => t('My Cool Listing Page'),
'page callback' => 'mymodule_listingpage',
'type' => MENU_NORMAL_ITEM
);
@gavinblair
gavinblair / gist:1394439
Created November 25, 2011 21:21
Blue Beanie Day
Some people think that Blue Beanie Day is about supporting the most recent browsers.
Wear your blue beanie to stick it to the backwards people who use outdated browsers.
Put a message on your site that says "Upgrade to Chrome or Firefox, or even IE9,
just for the love of all that is good STOP using IE7/6/Netscape..."
Turns out it's not that at all. In fact, Blue Beanie Day is quite the opposite.
Your site should be useful to anyone who views it. Browser hate was justified before
there were a bazillion different devices, each with a unique rendering engine.
Now it's time for the web developers and designers to adapt. Our sites are outdated,
@gavinblair
gavinblair / animation.js
Created November 24, 2011 20:14
jQuery Looping Animation
setInterval(function(){
$("#c1").animate({ left: "500px" }, 4000, function(){
$(this).show();
$(this).animate({ left: "-500px" }, 6000);
});
}, 10000);
@gavinblair
gavinblair / preload.js
Created November 24, 2011 14:49
Preload Images without DOM Manipulation
//preloading images
function preload(source) {
var i = new Image();
i.src = source;
}
preload("img/hover.jpg");
preload("img/active.jpg");
@gavinblair
gavinblair / helloworld.info
Created November 21, 2011 01:26
Simple Module Development
name = Hello World!
description = A simple module example
core = 7.x
version = "7.x-1.0"
@gavinblair
gavinblair / first.php
Created October 31, 2011 17:42
Get first element of an array
<?php
//Get value of first element in array, without modifying the array
$first_value = array_shift(array_values($array));
//Get key of first element
$first_key = array_shift(array_keys($array));
@gavinblair
gavinblair / page.tpl.php
Created September 9, 2011 15:44
print a block generated by a view from a tpl.php file
<?php
//third param: my_view_name-block_id
$block = module_invoke('views', 'block_view', 'magazine_issues-block_1');
print render($block);
?>
@gavinblair
gavinblair / shortcuts.xml
Created August 18, 2011 14:06
echo "<pre>".print_r($selectedvariable,true)."</pre>"; die;
<Macro name="Die Print_r" Ctrl="yes" Alt="yes" Shift="no" Key="68">
<Action type="0" message="2304" wParam="0" lParam="0" sParam="" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="d" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="i" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="e" />
<Action type="0" message="2326" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2326" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2326" wParam="0" lParam="0" sParam="" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="e" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="c" />
@gavinblair
gavinblair / afterload.js
Created June 16, 2011 15:06
Trigger an event after specific background images have been loaded
​$('<img>')​.attr('src',function(){
return $('#mydiv1').css('background-image');
})​​​.load(function(){
​$('<img>')​.attr('src',function(){
return $('#mydiv2').css('background-image');
})​​​.load(function(){
$('<img>')​.attr('src',function(){
return $('#mydiv3').css('background-image');
})​​​.load(function(){
//done loading background images of all 3 divs