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
#!/bin/ruby | |
Gem::Specification.new do |s| | |
s.author = "John Doe" | |
s.email = "[email protected]" | |
s.description = "helps out with writing your project." | |
s.summary = "A library helps your project!" | |
s.require_paths = ["lib"] |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'open-uri' | |
require 'hpricot' | |
dependencies = [:wget, :curl] | |
dependencies.each { |program| !`which #{program.to_s}`.empty? || STDERR.puts( "Requires #{program}") } | |
index_doc = Hpricot(open("http://confreaks.net/events/scotlandruby2011")) |
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
#!/usr/bin/env ruby | |
# | |
# A quick script to dump an overview of all the open issues in all my github projects | |
# | |
require 'octokit' | |
require 'awesome_print' | |
require 'rainbow' |
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
#!/usr/bin/env ruby | |
# | |
# A quick script to dump an overview of all the open issues in all my github projects | |
# | |
require 'octokit' | |
require 'awesome_print' | |
require 'rainbow' |
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
def tip(msg); puts; puts msg; puts "-"*100; end | |
# | |
# 30 Ruby 1.9 Tips, Tricks & Features: | |
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
# | |
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
tip "Ruby 1.9 supports named captures in regular expressions!" |
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
module RuleBook | |
def RuleBook.add_rules(object, instance_or_class, rules) | |
instance_or_class = instance_or_class.to_s.downcase.strip.to_sym | |
raise(ArgumentError, "'instance_or_class' must equal :instance or :class") unless [:instance, :class].include?(instance_or_class) | |
raise(ArgumentError, "'rules' must be a Hash") unless rules.is_a?(Hash) | |
unless object.instance_variable_get(:@_rulebook_initiated) # Class instance variable. Not class variable. Not instance variable. Is confusing. | |
object.instance_variable_set(:@_rulebook_initiated, true) | |
object.instance_variable_set(:@_rulebook, {:instance=>{}, :class=>{}}) # @_rulebook is actually two rulebooks, instance and class | |
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
class A | |
end | |
puts "--" + A.instance_methods(false).join(', ') | |
class A | |
def otro | |
end | |
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
def dsh(un, va) | |
(va.size - 1).downto(1) {|j| va[j] = va[0 .. j].inject(1) { |pr, it| pr * it } } | |
ar = un.zip va | |
hs = {} | |
ar.each {|i| hs[i[0]] = i[1] } | |
hs | |
end |
NewerOlder