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
# In boot.rb | |
require File.join RAILS_ROOT, 'config/autogit_libs.rb' | |
require "railties/lib/initializer" | |
Rails::Initializer.run(:set_load_path) | |
# Rails.boot! | |
class AutogitPluginLocator < Rails::Plugin::Locator | |
def plugins |
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
From http://www.scribd.com/doc/23548865/Debugging-Ruby | |
lsof | |
list open files | |
lsof -nPp <pid> | |
-n | |
Inhibits the conversion of network numbers to host names for | |
network files. | |
-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
class FixedStack < Array | |
attr_accessor :max_size | |
def initialize(max_size, *args) | |
self.max_size = max_size | |
super(*args) | |
end | |
def push(*args) | |
super | |
self.replace self.last(max_size) if size > max_size |
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
# MogileFS client backend on EventMachine | |
# req = mogilefs_client.backend.get_hosts | |
# req.callback { |data| puts data } | |
module EMogileFS | |
@@connections = {} | |
class << self | |
def <<(request) |
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
# VKRequest.get :method => 'secure.getAppBalance' | |
require 'digest/md5' | |
require 'open-uri' | |
class VKRequest | |
SECURE_SECRET = 'ololo' | |
API_ID = 1807324 | |
API_SERVER = 'http://api.vkontakte.ru/api.php' | |
DEFAULT_FORMAT = 'json' | |
VERSION = '2.0' |
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
# Support of amqp redirect method. It uses in amqp-clusters. | |
# For use: AMQP.client = AmqpClient | |
module AmqpClient | |
def process_frame frame | |
if mq = channels[frame.channel] | |
mq.process_frame(frame) | |
return | |
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
class CircleQueue | |
include Enumerable | |
class Head | |
attr_accessor :first, :last | |
def initialize | |
self.first = self | |
self.last = 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
# Usage: | |
respond_to :rss, :only => [:index] | |
def index | |
@deals = Deal.by_city(@city).limit(15) | |
respond_with(@deals) do |format| | |
format.rss { render :rss => @deals, :title => "KupiKon", :item => { :title => :title, :description => :description }} | |
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
class EMChain | |
attr_accessor :queue, :complete_clb, :item_block | |
attr_accessor :in_progress_queue | |
attr_accessor :max | |
def initialize(&config_blk) | |
self.queue = [] | |
self.in_progress_queue = {} | |
config_blk.call self if config_blk | |
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
require 'pathname' | |
require 'open-uri' | |
def require_gist(number, file, options = {}) | |
AutoGist::Gist.new(number, file, options).setup | |
end | |
# TODO Add logs | |
# TODO Reload gists (especially without ref) |
OlderNewer