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($) { | |
$.fn.plugin = function() { | |
return this.each(function() { | |
var $this = $( this ); | |
if ( !$this.data('plugin') ) { | |
$this.data( 'plugin', new Plugin(this) ); | |
} | |
}); | |
} |
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
# spec/features/random_spec.rb | |
require 'spec_helper' | |
describe "Random feature" do | |
it "Does't have debugging" do | |
# ... | |
# page.driver.debug | |
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
/** | |
* ValidateSpanishID. Returns the type of document and checks its validity. | |
* | |
* Usage: | |
* ValidateSpanishID( str ); | |
* | |
* > ValidateSpanishID( '12345678Z' ); | |
* // { type: 'dni', valid: true } | |
* | |
* > ValidateSpanishID( 'B83375575' ); |
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
inputs.each(function(){ | |
var address = $(this), | |
form = address.closest('form'), | |
hiddenCoords = form.find('#coordinates'); | |
// Namespaceamos el evento para quitarlo más adelante | |
form.on('submit.getAddress', function(e){ | |
// Paramos el evento por defecto | |
e.preventDefault(); |
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.lastTweet | |
* ---------------- | |
* | |
* Fetch the last tweet from the specified user | |
* | |
* Usage: | |
* | |
* $('#container').lastTweet('username'); | |
* |
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
#!/bin/bash | |
# Downloads and install a .dmg from a URL | |
# | |
# Usage | |
# $ dmginstall [url] | |
# | |
# For example, for installing alfred.app | |
# $ dmginstall http://cachefly.alfredapp.com/alfred_1.3.1_261.dmg | |
# |
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
# gives a valid key=value SQL string for using in "INSERT INTO `table` SET" sentences | |
# >> "INSERT INTO `table_name` SET #{sqlize(Model.find(id).attributes)};" | |
# returns | |
# => "INSERT INTO `table_name` SET `attr1`=value1,`attr2`=value2..." | |
# Handles different datatypes | |
def sqlize hash | |
hash.map do |k,v| | |
v = case v | |
when Time |
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 filterator | |
* | |
* Filter collections of elements using javascript. | |
* Uses HTML5 data attributes to get the filter values. | |
* | |
* Usage: | |
* | |
* $('element_containing_filters').filterator( { target: filter_criteria, items: selector_or_jquery_collection_to_filter } ); | |
* |
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
# WikiStance. A Wikipedia distance meter. | |
# Based on the alt text of http://xkcd.org/903/ | |
# Gets a Wikipedia URL and measure the distance of this page to the Philosophy article, clicking on links not in parens | |
# neither italics | |
# | |
# Author:: Alejandro Fernández (mailto:[email protected]) | |
# Copyright:: Copyright (c) 2011 Alejandro Fernández | |
# License:: GPL | |
# | |
# =Usage= |
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
# Color the current git branch in prompt | |
# red -> master branch, take care! | |
# blue -> just a normal branch | |
# green -> dev branch | |
# cyan -> feature branch | |
# magenta -> fix branch | |
function __colorize_git_ps1 () { | |
local branch=$(__git_ps1 "%s") | |
if [ -n "$branch" ]; then |