Skip to content

Instantly share code, notes, and snippets.

View craigmdennis's full-sized avatar
🚀

Craig Dennis craigmdennis

🚀
View GitHub Profile
@craigmdennis
craigmdennis / stickToTop.js
Created March 8, 2012 18:02
A simple sticky header jQuery plugin
(function($){
$.fn.stickToTop = function (offset) {
// Return this to maintain chainability
return this.each(function () {
// Set some variables
var $this = $(this),
elemTop = $this.offset().top,
@craigmdennis
craigmdennis / README.md
Created August 27, 2012 19:12 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@craigmdennis
craigmdennis / gist:3952052
Created October 25, 2012 11:17
Track mouse movements in an iframe
var $iframe = $("iframe#file-display");
$iframe.contents().mousemove( function(e){
console.log(e.pageX, e.pageY, e.clientX, e.clientY);
});
@craigmdennis
craigmdennis / gist:5988499
Created July 12, 2013 23:02
Sublime Text 2 User Preferences
{
"auto_indent": true,
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"default_line_ending": "system",
"dictionary": "Packages/Language - English/en_GB.dic",
"draw_minimap_border": false,
"draw_white_space": "all",
"find_selected_text": true,
"font_face": "Ubuntu Mono",
"font_options":
@craigmdennis
craigmdennis / multi-page.js
Created August 15, 2013 16:58
From one page of markup, break it down into multiple pages on small screens and revert to normal on large screens.
var multiPage = {
debug: true,
// Global Params
wrapClass: ".js-multi-page",
triggerClass: ".js-multi-page-trigger",
pageClass: ".js-multi-page-item",
loadedString: "js-multi-page-loaded",
@craigmdennis
craigmdennis / new_gist_file
Created August 22, 2013 13:22
Notice I'm using getBoundingClientRect() and accessing three of its properties: left, top, and width. The returned object has six read-only properties: the ones already mentioned, along with height, right, and bottom. The values returned would be numbers representing those properties in pixels. Notice the code also has an if/else branch. Because…
var wrapper = document.getElementById('wrapper'),
x, y, w;
x = wrapper.getBoundingClientRect().left;
y = wrapper.getBoundingClientRect().top;
if (wrapper.getBoundingClientRect().width) {
w = wrapper.getBoundingClientRect().width; // for modern browsers
} else {
w = wrapper.offsetWidth; // for oldIE
}
@craigmdennis
craigmdennis / triangle
Created August 23, 2013 16:19
CSS Triangle Mixin
.triangle-base() {
content: '';
display: block;
width: 0;
height: 0;
}
.triangle(@direction, @size, @color) when (@direction = up) {
.triangle-base();
border-left: @size solid transparent;
border-right: @size solid transparent;
function on_resize(c,t){onresize=function(){clearTimeout(t);t=setTimeout(c,100)};return c};
function remove_admin_menu_items() {
$remove_menu_items = array(__('Comments'),__('Links'),__('Posts'),__('Contact'));
global $menu;
end ($menu);
while (prev($menu)){
$item = explode(' ',$menu[key($menu)][0]);
if(in_array($item[0] != NULL?$item[0]:"" , $remove_menu_items)){
unset($menu[key($menu)]);}
}
}
@craigmdennis
craigmdennis / index.html
Last active February 1, 2022 03:08
When not including Modernizr, use this to remove the no-js class from the html.From: http://www.paulirish.com/2009/avoiding-the-fouc-v3/
<html class="no-js">
<head>
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
</head>
<body>
</body>
</html>