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 'guard' | |
require 'guard/guard' | |
module ::Guard | |
class Reload < Guard | |
def initialize(*args, &block) | |
super | |
@script = <<-APPLESCRIPT | |
tell window 1 of application "Google Chrome" |
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
#! /usr/bin/env ruby | |
#usage: imsg daniel "hello world" | |
buddyids = { | |
daniel: "dcadenas@gmail.com", | |
elcuervo: "yo@brunoaguirre.com" | |
} | |
nickname = ARGV[0].to_sym |
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
#!/usr/bin/env ruby | |
test_dirs = %w[configurations | |
lib | |
modules | |
services | |
uploaders | |
controllers | |
helpers | |
mailers | |
presenters |
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
#!/usr/bin/env ruby | |
#Script to explore chess opening lines based on most popular of google's top 100 results | |
#Usage: | |
#▸ ./goopening "1. e4 e5 2." | |
#1: nf3 (35) | |
#2: qh5 (7) | |
#3: bc4 (4) | |
#4: nc6 (2) |
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
#!/usr/bin/env ruby | |
require 'net/https' | |
require 'open-uri' | |
require 'tempfile' | |
# This script tries to detect a bug in which macosx doesn't raise an exception | |
# and executes the request despite knowing the host failed its ssl verification | |
# | |
# Run with ruby < <(curl -s https://raw.github.com/gist/3049397/checkbug.rb) | |
# Try it in linux and macosx. Linux behaves correctly. |
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
#!/usr/bin/env ruby | |
require 'net/https' | |
require 'open-uri' | |
require 'tmpdir' | |
unless ARGV[0] | |
puts "Usage: #{File.basename(__FILE__)} hostname [pemfile]" | |
puts "It will use http://curl.haxx.se/ca/cacert.pem if no pemfile is specified" | |
exit false |
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
#Which is the best alternative? A is clearer but is it slower? is there a better way? | |
#A: The block will be run in all examples, do_something_with will only be run when my_metadata defined | |
RSpec.configure do |config| | |
config.before(:each) do |example| | |
do_something_with(example.metadata[:my_metadata]) if example.metadata.has_key?(:my_metadata) | |
example.run | |
end | |
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
(function(){ | |
var putRatings = function($){ | |
$('.peli_izq .cinesala').each(function(_,link){ | |
var escapedTitle = escape(link.text.trim()); | |
if(escapedTitle !== ""){ | |
$.getJSON("http://www.imdbapi.com/?t=" + escapedTitle + "&tomatoes=true&y=" + (new Date().getFullYear()) + "&callback=?", function(d){ | |
if(d.imdbRating) { | |
$(link).after('<div style="float:right; background:yellow; line-height:8px; border:solid; padding:3px">\ | |
<p>Búsqueda en IMDB<\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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'json' | |
require 'rankable_graph' | |
require 'net/http' | |
require 'mechanize' | |
require 'nokogiri' | |
def follower_usernames_of(user) |
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 have this AR model that has two scopes that should return complementary sets | |
# of rows: one returns all the rows that match certain conditions, the other | |
# returns all rows that DON'T match the same conditions. | |
# | |
# I would like to build the second scope using the first one. Something like: | |
# | |
# class Article | |
# def self.problematic | |
# not(complete) | |
# end |