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
@littlemove
littlemove / gist:751d86849b6f71a74cb8
Last active August 29, 2015 14:27
Escenario calendario tipo 2
Dos escenarios con una propiedad con un calendario tipo 2, con dos períodos de disponibilidad (de s1 a e1 y de s2 a e2), para unas fechas dadas (de fi a ff):
s1 fi ff e1 s2 e2
--------|----|-----|-----|--------|------|--------
s1 fi e1 s2 ff e2
--------|----|----------|--------|----|---|--------
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
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
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
...