This file contains 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
/** | |
* 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; }); | |
This file contains 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
// 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(); | |
}; |
This file contains 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
require 'irb/completion' | |
require 'pp' | |
IRB.conf[:AUTO_INDENT]=true | |
if defined?(Rails) && !Rails.env.nil? | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
end |
This file contains 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
<div data-replace="item"> | |
PARTIAL 1: <span data-bind="item.name"></span> | |
</div> |
This file contains 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
User.find(1).flag Tablet.find(1) | |
# => #<MakeFlaggable::Flagging id: 1, flaggable_type: "Device", flaggable_id: 1, flagger_type: "User", flagger_id: 1, reason: nil, created_at: "2012-05-30 16:16:23", updated_at: "2012-05-30 16:16:23"> | |
User.find(1).flagged? Tablet.find(1) | |
# MakeFlaggable::Flagging Load (0.4ms) SELECT "flaggings".* FROM "flaggings" WHERE "flaggings"."flagger_id" = 1 AND "flaggings"."flagger_type" = 'User' AND "flaggings"."flaggable_type" = 'Tablet' AND "flaggings"."flaggable_id" = 1 LIMIT 1 | |
# => false | |
# :rage: | |
######### | |
# If you look at the query, it inserted the `flaggable_type` as 'Device', but is searching for 'Tablet' |
This file contains 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
<html> | |
<head> | |
<meta http-equiv="X-UA-Compatible" content="IE=8" /> | |
<title>Batman Profiler</title> | |
<script type="text/javascript" src="https://raw.github.com/Shopify/batman/master/lib/es5-shim.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/Shopify/batman/v0.9.0/lib/batman.js"></script> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.3.3/underscore-min.js"></script> | |
<script type="text/javascript" src="http://coffeescript.org/extras/coffee-script.js"></script> | |
<script src="http://code.highcharts.com/highcharts.js"></script> |
This file contains 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
# jQuery method to detect whether or not a point (x,y) is within the bounds of a jQuery element. | |
# Example usage: $("#container").containsPoint 100, 100 | |
$.fn.containsPoint = (x, y) -> | |
(@offset.left < x < @offset.left + @width()) and | |
(@offset.top < y < @offset.top + @height()) |
This file contains 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
$.fn.overlaps = (el) -> | |
el = $(el) | |
o = | |
el1: @offset() | |
el2: el.offset() | |
el1 = | |
x1: o.el1.left | |
x2: o.el1.left + @width() |
This file contains 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 parse_git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo " ("${ref#refs/heads/}")" | |
} | |
export PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\$(parse_git_branch) \$\[\033[00m\] " |
This file contains 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
# Insert this in ~/.bashrc or ~/.bash_login | |
function parse_git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo " ("${ref#refs/heads/}")" | |
} | |
export PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \w\$(parse_git_branch) \$\[\033[00m\] " |
OlderNewer