Skip to content

Instantly share code, notes, and snippets.

View littlemove's full-sized avatar

Diego Fernández Fernández littlemove

  • BeBanjo
  • Asturias - Spain
View GitHub Profile
class ApplicationController < ActionController::Base
helper :all
before_filter :set_global
before_filter :wadus, :except => [:index]
def wadus
@foo = "Oh my gosh!"
end
require 'rubygems'
require 'smusher'
out = `smusher ./`
out.lines.each do |line|
line.gsub!("\n",'')
if line.include?("smushing")
system("git add #{line.gsub("smushing ",'')}")
end
end
~$ irb
>> require 'open-uri'
=> true
>> foo = open("http://feeds.feedburner.com/walkaways")
=> #<StringIO:0xb7891c0c>
>> foo.each_line{ |l| puts l }
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss version="2.0"><channel>
[...]
def what_changed(new)
attributes = Array.new
for attr in self.attribute_names
attributes.push(attr) unless (self.send(attr) == new.send(attr))
end
attributes
end
“You can take a group of idiots that maybe even didn’t go to school, don’t understand computer science, don’t understand software development engineering techniques, hate each other, don’t understand the business domains, have lousy engineering tools and uniformly, they will produce CRAP every increment.“
Ken Schwaber - “Scrum et al.“@ Google Tech Talks
Talking about Waterfall Vs SCRUM Software Development Process
¿Qué es "Agil"?
Individuals and interactions over processes and tools
Working software over comprehensive documentation
class Event
has_many :attendings
has_many :attendees, :through => :attendings, :source => :user do |id|
# Esto es un poco oscuro pero se explica rápido: redefinimos el operador << para que
# al insertar un usuario en un evento, si previamente ya se encontraba apuntado al mismo
# se borre.
def <<(user)
attending = Attending.find_by_user_id_and_event_id(user.id, self.proxy_owner.id)
attending.blank? ? Attending.create(:user_id => user.id, :event_id => self.proxy_owner.id) : attending.destroy
module Categorizable
def self.included(base)
base.has_many :audience_scopes, :as => :audienciable
base.has_many :audience_categories, :through => :audience_scopes
base.has_many :areas, :through => :audience_scopes
...
class NewsItem < ActiveRecord::Base
...
acts_as_categorizable
end
class NewsItem < ActiveRecord::Base
include Categorizable
...
acts_as_categorizable
end
module Categorizable
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
def acts_as_categorizable
has_many :audience_scopes, :as => :audienciable