This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( function ( win, doc ) { | |
// Google Analytics global variable | |
win._gaq = [ ['_setAccount','UA-XXXXX-X'], ['_trackPageview'], ['_trackPageLoadTime'] ]; | |
// Array of cross-domain script urls | |
var urls = [ | |
'//connect.facebook.net/en_US/all.js', // Facebook SDK | |
'//platform.twitter.com/widgets.js', // Twitter Widgets | |
'https://apis.google.com/js/plusone.js', // Google +1 Button |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$("img").load(function() { | |
$(this).wrap(function(){ | |
return '<span class="image-wrap ' + $(this).attr('class') + '" style="position:relative; display:inline-block; background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" />'; | |
}); | |
$(this).css("opacity","0"); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Call this function after body load | |
function manageDebug(){ | |
var debug = false; | |
if(window.console){ | |
var consoleBackUp = window.console.log; | |
window.console.log = function(str){ | |
if(debug){ | |
consoleBackUp.call(this,str); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
include Rails.application.routes.url_helpers | |
def cancel_link | |
return link_to 'Cancel', request.env["HTTP_REFERER"], | |
:class => 'cancel', | |
:confirm => 'Are you sure? Any changes will be lost.' | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def in_columns(count) | |
in_groups_of(count).transpose.collect(&:compact) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('a[href^="#"][data-animate]').live('click', function() { | |
var hash = $(this).attr('href'); | |
var offset = $(hash).offset(); | |
if (offset) { | |
$('html, body').animate({ scrollTop: offset.top }, 'slow'); | |
location.hash = hash; | |
return false; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Often used regular expressions - Cheatsheet | |
EMAIL = /\A[a-z0-9\+\-_\.]+@[a-z0-9]+[a-z0-9\-\.]*[a-z0-9]+\z/i | |
HOST = /\A[a-z0-9]+[a-z0-9\-\.]*[a-z0-9]+\z/i | |
URL = /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)*([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/ | |
HEX_COLOR = /\A([a-fA-F0-9]{3}){1,2}\z/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Configuration | |
SERVER='myserver' | |
DEPLOY_TO='/path/to/app' | |
EXCLUDE='*.swp .git/ db/sphinx/ tmp/ log/' | |
DRY_RUN=false | |
DEPLOY_GEM_PATH='/opt/ec/ruby/1.8.7/lib/ruby/gems/1.8' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def in_columns(count) | |
in_groups_of(count).transpose.collect(&:compact) | |
end | |
end |