Skip to content

Instantly share code, notes, and snippets.

View Rafailong's full-sized avatar
🤠

ravila Rafailong

🤠
  • Mexico
View GitHub Profile
@Rafailong
Rafailong / jquery.plugin.template.js
Created December 6, 2012 05:37
jQuery plugin template.
(function ($) {
$.fn.pluginName = function (options) {
if (this.length > 1) {
this.each(function () { $(this).pluginName(options); });
return this;
}
/*
private variables
var x = ...
@Rafailong
Rafailong / Pods
Created July 4, 2013 21:42
iOS Pods file Bolierplate
platform :ios, "6.0"
pod 'JSONKit'
pod 'AFAbstractRESTClient'
pod 'SDWebImage'
pod 'SWRevealViewController'
@Rafailong
Rafailong / gist:7698565
Created November 28, 2013 21:48
Nginx Config: Front-End Reverse Proxy to Another Port
# NGINX configuration
# System configuration ##################
worker_processes 3;
events {
worker_connections 1024;
}
user nobody;
# Web configuration #####################
@Rafailong
Rafailong / gist:7812836
Created December 5, 2013 20:00
uninstall rvm in Mac OS X
rm -rf .rvm*
#Next you’ll want to remove the following line from your .bash_profile
[text]
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
[/text]
#You’ll then want to remove the /etc/rvmrc file as this has some information about the RVM install in your /home folder
[bash]
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:21
Smooth scrolling to top of page
$("a[href='#top']").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
});
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:22
Clone table header to the bottom of table
var $tfoot = $('<tfoot></tfoot>');
$($('thead').clone(true, true).children().get().reverse()).each(function(){
$tfoot.append($(this));
});
$tfoot.insertAfter('table thead');
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:23
Equal height columns
var maxheight = 0;
$("div.col").each(function(){
if($(this).height() > maxheight) { maxheight = $(this).height(); }
});
$("div.col").height(maxheight);
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:24
Partial page refresh
setInterval(function() {
$("#refresh").load(location.href+" #refresh>*","");
}, 10000); // milliseconds to wait
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:26
Preload images
$.preloadImages = function() {
for(var i = 0; i<arguments.length; i++) {
$("<img />").attr("src", arguments[i]);
}
};
$(document).ready(function() {
$.preloadImages("hoverimage1.jpg","hoverimage2.jpg");
});
@Rafailong
Rafailong / script.js
Created January 29, 2014 18:26
Open external links in a new tab/window
$('a').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href)) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
}
});