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 TeachPgToGroupConcat < ActiveRecord::Migration | |
def self.up | |
return unless adapter_name == "PostgreSQL" | |
execute <<-EOF | |
CREATE FUNCTION _group_concat(text, text, text) | |
RETURNS text AS $$ | |
SELECT CASE | |
WHEN $2 IS NULL THEN $1 | |
WHEN $1 IS NULL THEN $2 | |
ELSE $1 operator(pg_catalog.||) $3 operator(pg_catalog.||) $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
module ActiveRecord | |
module ConnectionAdapters | |
class SQLite3Adapter | |
def initialize(*args) | |
Rails.logger.debug "Adding group_concat to SQLite database" | |
super | |
raw_connection.create_aggregate("group_concat", 2) do | |
step do |func, value, separator| | |
if String(func[:concat]).empty? then | |
func[:concat] = String(value) |
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
# В config/initializers/development.rb | |
# | |
# config.middleware.insert_before(::Rack::Lock, ::ProductionImagesDownload, "www.lookatme.ru") | |
class ProductionImagesDownload | |
# Перехватывает отсутствующие картинки и пытается слить их с lookatme.ru | |
def initialize(app, host) | |
Rails.logger.debug "Production images downloader started" | |
@app = app | |
@host = host |
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 ActiveRecord | |
module ConnectionAdapters | |
class PostgreSQLAdapter | |
def quote_table_name(name) | |
schema, name_part = extract_pg_identifier_from_name(name.to_s) | |
return quote_column_name(schema) unless name_part | |
table_name, name_part = extract_pg_identifier_from_name(name_part) | |
"#{quote_column_name(schema)}.#{quote_column_name(table_name)}" | |
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
# This is a monkey patch for MessageVerifier — I need to change Marshal.load to JSON | |
if defined?(ActionController::Flash::FlashHash) | |
class ActionController::Flash::FlashHash | |
def to_json(*args) | |
{}.merge(self).merge({:used => @used}).to_json | |
end | |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'sinatra' | |
require 'active_support' | |
require 'haml' | |
require 'thin' | |
gem 'tmm1-amqp' | |
require 'mq' |
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 7bb6d8424ad931aee5b016c5986dcb4d0e12f5d2 Mon Sep 17 00:00:00 2001 | |
From: Max Lapshin <[email protected]> | |
Date: Tue, 28 Jul 2009 11:10:38 +0400 | |
Subject: [PATCH] Added support for server redirection. | |
http://www.rabbitmq.com/clustering.html | |
--- | |
lib/amqp/client.rb | 18 ++++++++++++++++++ | |
1 files changed, 18 insertions(+), 0 deletions(-) |
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
# = Schema Information | |
# | |
# Table name: *comments* | |
# | |
# id :integer not null, primary key | |
# user_id :integer not null | |
# commentable_id :integer not null | |
# commentable_type :string(255) not null | |
# body :text | |
# parent_id :integer |
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 AsyncRequestLogger | |
def initialize(app, logger = nil) | |
@app = app | |
@logger = logger || Logger.new(STDOUT) | |
end | |
def call(env) | |
time = Time.now | |
status, header, body = @app.call(env) | |
ensure |
OlderNewer