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
// Tip: You can go to any result in preview by pressiong ctrl+alt+[result number] | |
CmdUtils.makeSearchCommand({ | |
name: ["rails","rails-search"], | |
homepage: "http://rafagarcia.net/", | |
author: { name: "Rafa Garcia", email: "[email protected]"}, | |
license: "GPL", | |
url: "http://apidock.com/rails/search/?query={QUERY}", | |
description: _("Searches Ruby on Rails terms in Apidock.com"), | |
icon: "http://apidock.com/images/rails_icon_16.png", | |
parser: { |
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
ab -n 100 -c 4 http://localhost:3000/searches/concept_search | |
# ESTADO ACTUAL | |
Server Software: Mongrel | |
Server Hostname: localhost | |
Server Port: 3000 | |
Document Path: /searches/concept_search | |
Document Length: 80751 bytes |
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
class ActionDuck | |
attr_accessor :errors | |
def initialize(h) | |
h ||= {} | |
h.each { |k,v| send("#{k}=", v) } | |
self.errors = ActiveRecord::Errors.new(self) | |
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
module ShouldaContextExtensions | |
def self.included(base) | |
base.class_eval do | |
alias_method_chain :build, :fast_context | |
alias_method_chain :am_subcontext?, :fast_context | |
end | |
end | |
def fast_context(name, &blk) | |
@fast_subcontexts ||= [] |
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
# 1) Point *.example.com in your DNS setup to your server. | |
# | |
# 2) Setup an Apache vhost to catch the star pointer: | |
# | |
# <VirtualHost *:80> | |
# ServerName example.com | |
# ServerAlias *.example.com | |
# </VirtualHost> | |
# | |
# 3) Set the current account from the subdomain |
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
class User < ActiveRecord::Base | |
before_create :create_profile | |
has_one :profile, :dependent => :destroy | |
protected | |
def create_profile | |
self.profile ||= Profile.new | |
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
# Dado una variable Profile profile con datos de ejemplo | |
profile.graffities.all(:include => [{:user => :profile}, {:replys => {:user => :profile}}]) | |
Comment Load (0.2ms) SELECT * FROM `comments` WHERE (`comments`.commentable_id = 3 AND `comments`.commentable_type = 'Profile' AND (parent_id IS NULL)) LIMIT 1 | |
Comment Load (0.1ms) SELECT * FROM `comments` WHERE (`comments`.parent_id = 2) ORDER BY created_at DESC | |
User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`id` = 1) | |
Profile Load (0.2ms) SELECT `profiles`.* FROM `profiles` WHERE (`profiles`.user_id = 1) | |
Comment Load (0.2ms) SELECT `comments`.* FROM `comments` WHERE (`comments`.parent_id = 4) ORDER BY created_at ASC | |
User Load (0.2ms) SELECT * FROM `users` WHERE (`users`.`id` IN (1,3)) | |
Profile Load (0.2ms) SELECT `profiles`.* FROM `profiles` WHERE (`profiles`.user_id IN (1,3)) | |
+----+----------------+------------------+-------+---------------------+---------+---------+-----------+-----+-----+-------------------------+------- |
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
class Comment < ActiveRecord::Base | |
def self.preload_graffities_associations(graffities) | |
# We want to load the following data | |
# associations = [{:user => :profile}, {:replys => {:user => :profile}}] | |
# We join graffities and replys to load its users and profile to avoid two querys | |
graffities_and_replys = (graffities + graffities.map(&:replys)).flatten | |
Comment.send(:preload_associations, graffities_and_replys, {:user => :profile}) | |
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
document.observe("dom:loaded", function() { | |
function updateElementsWithTime() { | |
$$("span[time]").invoke('updateTime') | |
} | |
// update immediately | |
updateElementsWithTime() | |
// continue updating every 2 minutes | |
new PeriodicalExecuter(updateElementsWithTime, 60 * 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
document.observe("dom:loaded", function() { | |
function updateElementsWithTime() { | |
$$("span[time]").invoke('updateTime') | |
} | |
// update immediately | |
updateElementsWithTime() | |
// continue updating every 2 minutes | |
new PeriodicalExecuter(updateElementsWithTime, 60 * 2) | |
}) |