Enlaces con otros ficheros compartidos en los comentarios:
This file contains hidden or 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
unless ARGV[0].nil? | |
File.open(ARGV[0],'r').each do |line| | |
line.gsub!(/\(|\)|,/,'') | |
versions = line.split | |
gem_name = versions.shift | |
versions.each do |version| | |
puts "gem install #{gem_name} -v=#{version} --ignore-dependencies" | |
system("gem install #{gem_name} -v=#{version} --ignore-dependencies") |
This file contains hidden or 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
# This script just get the latest tracks of your friends on Last.fm and recommends those more popular. | |
# It's all based on a conversation between @mort, @rochgs, @littlemove and me (mainly by @mort) | |
# INSTRUCTIONS | |
# 1. Install lastfm gem: https://github.com/youpy/ruby-lastfm/ | |
# gem install lastfm | |
# 2. Get a Last.fm API Key on http://www.lastfm.es/api | |
require 'lastfm' |
This file contains hidden or 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(){ | |
(function($) { | |
$.fn.render_json = function (url, data_to_send) { | |
$.ajax({url: url, dataType: 'json', data: data_to_send, context: $(this), | |
success: function(data_received){ | |
if(data_received.length > 0) | |
{ | |
$(this).each(function () { | |
Tempo.prepare(this.id).render(data_received); | |
}); |
This file contains hidden or 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 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
# SOME CONFIG STUFF ########################################################### | |
survey_urls = { | |
"Aragón" => "http://www.cis.es/cis/opencms/-Archivos/Marginales/2680_2699/2687/e268700.html", | |
"Asturias" => "http://www.cis.es/cis/opencms/-Archivos/Marginales/2680_2699/2688/e268800.html", | |
"Baleares" => "http://www.cis.es/cis/opencms/-Archivos/Marginales/2680_2699/2689/e268900.html", |
This file contains hidden or 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 -> we are in master, take care! | |
# blue -> just a normal branch. Carry on | |
function __colorize_git_ps1 () { | |
local branch=$(__git_ps1 "%s") | |
if [ -n "$branch" ]; then | |
local color | |
if [[ $branch == master* ]]; then | |
color="31" #Red |
This file contains hidden or 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
/* | |
Select Linker: This extension links two selects so the options loaded depends on each select. | |
How to use it: | |
> options = {"__default" : ...} | |
> $("#select_one").link_select("#select_two", options, false); | |
Params: | |
* other_select : Selector to reach other select |
This file contains hidden or 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
# Source: http://stackoverflow.com/questions/1255176/test-rake-tasks | |
def execute_rake(file,task) | |
require 'rake' | |
rake = Rake::Application.new | |
Rake.application = rake | |
Rake::Task.define_task(:environment) | |
load "#{Rails.root}/lib/tasks/#{file}" | |
rake[task].invoke | |
end |
This file contains hidden or 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
# Yo tengo un modelo site con la información de los sites (dominios) de mi aplicación | |
# Si esa información estuviera en un fichero de configuración o algo habría que cambiar esto. | |
Dado /^que estamos en el site "(.+)"$/ do |site_name| | |
site = Site.find_by_title site_name | |
MundoPepino.world.host = site.host | |
end |
This file contains hidden or 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
# INFO extracted from : http://stackoverflow.com/questions/6331065/matching-balanced-parenthesis-in-ruby-using-recursive-regular-expressions-like-pe | |
require 'wikipedia' | |
wikipage = Wikipedia.find(title) | |
# This regular expression is not valid for infoboxes with '}' (i.e: http://en.wikipedia.org/wiki/The_Royal_Anthem_of_Jordan) | |
no_infoboxes = wikipage.content.gsub(/\{\{[^\}]*\}\}/, "") | |
# This regular expression makes use of recursive regular expressions so now handles recursive {{}} structures | |
no_infoboxes = wikipage.content.gsub(%r{(?<re>\{\{(?:(?> [^\{\}]+ )|\g<re>)*\}\})}x, "") |