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($) { | |
$.stuff = function(bitoftext) { | |
this.bitoftext = bitoftext; | |
} | |
$.extend($.stuff, { | |
report: function() { alert(this.bitoftext) } | |
}) | |
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
# largely inspired by http://blog.macromates.com/2006/keychain-access-from-shell/ | |
namespace :deploy do | |
desc "Generates database.yml from info store in Keychain" | |
task :generate_database_yml do | |
account = ENV['KEYCHAIN_ACC'] | |
security_stdout = `security find-generic-password -ga #{account} 2>&1 > /dev/null` | |
if security_stdout[/could not be found/] | |
rollback |
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
var table = $('<table />').attr('id', 'host-' + host.host). | |
.append('<thead />') | |
.find('thead') | |
.append('<tr />') | |
.find('tr') | |
.append('<th class="name">File name</th>') | |
.append('<th class="size">Size</th>') | |
.parent() | |
.parent() | |
.append('<tfoot />') |
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
var table = $([ | |
'<table>', | |
'<thead>, | |
'<tr'>, | |
'<th>Foo</th>', | |
'<th>Bar</th>', | |
'</tr>', | |
'</thead>', | |
'<tfoot />', | |
'<tbody />' |
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
# Maybe soon to be a feeds plugin. So you go like | |
# | |
# class Message < ActiveRecord::Base | |
# generates_feed do | |
# after :create, :like => ":sender has sent a message to :recipient" | |
# end | |
# end | |
# | |
# Capisce? Pure beauty. | |
# ps: Props to thinking_sphinx |
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
$.extend($.expr[':'], { | |
'and': function(a, i, m) { | |
return $(a).filter(m[3]).length | |
} | |
}) | |
// Thus allowing $('p:and(.post)') | |
// finds <p class="post"></p> |
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
# I admit this is somewhat nutty, but I needed to find a way for mini_feed | |
# (http://github.com/juliocesar/mini_feed/tree/master) to be able to access | |
# helpers, or more specifically, link_to, so feeds can have links in them. | |
# This is what I came up with | |
# for instance | |
class Book < ActiveRecord::Base | |
if defined?(Rails) |
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
$.extend($.expr[':'], { | |
matches: function(e, i, m) { | |
if (!m[3]) return false; | |
var regexp = new RegExp(m[3], 'ig'); | |
return regexp.test($(e).text()); | |
} | |
}) | |
// Usage: | |
// Say you have |
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
// Oh, by the way, it works like this: | |
// | |
// $('myform :text:first').ghost('username'); | |
// | |
// The above will make the first text element of a form display a | |
// slightly faded "username" text inside until focused. | |
$.ghost = function(element, label, options) { | |
if (typeof options == 'undefined') options = {}; | |
var originalColor = $(element).css('color'); |
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($) { | |
String.prototype.substrUntil = function(index, until, backwards) { | |
var string = []; | |
var regex = new RegExp(until, 'ig'); | |
if (backwards) index--; // reverse the caret direction, pretty much | |
while(this[index]) { | |
if (regex.test(this[index])) break; | |
if (backwards) { | |
string.unshift(this[index]); | |
index--; |
OlderNewer