Skip to content

Instantly share code, notes, and snippets.

View loginx's full-sized avatar

Xavier Spriet loginx

View GitHub Profile
@loginx
loginx / .irbrc
Created March 10, 2011 16:36
~/.irbrc config file to enable ActiveRecord logging to the rails console (if in rails console) and enable IRB autocompletion and autoindent.
require 'irb/completion'
require 'pp'
IRB.conf[:AUTO_INDENT]=true
if defined?(Rails) && !Rails.env.nil?
ActiveRecord::Base.logger = Logger.new(STDOUT)
end
@loginx
loginx / jquery_isotope_reset.js
Created February 15, 2011 17:35
Extends Isotope, providing a reset() method to empty the grid and reLayout.
// Adds a .isotope( 'flush' ) method to your Isotope widget.
// This method will remove all items from the widget and from the DOM,
// then trigger a reLayout.
$.Isotope.prototype.flush = function() {
this.$allAtoms = $();
this.$filteredAtoms = $();
this.element.children().remove();
this.reLayout();
};
@loginx
loginx / gist:810311
Created February 3, 2011 22:04
Underscore.js mixin to emulate ruby's Array#each_slice method.
/**
* Underscore.js mixin to emulate Ruby's Enumerable#each_slice method.
* http://www.ruby-doc.org/core/classes/Enumerable.html#M001514
*
*/
_.mixin({
each_slice: function(obj, slice_size, iterator, context) {
var collection = obj.map(function(item) { return item; });