Skip to content

Instantly share code, notes, and snippets.

View methodmissing's full-sized avatar

Lourens Naudé methodmissing

View GitHub Profile
/* Return 0 if there is data to be read */
my_bool vio_poll_read(Vio *vio,uint timeout)
{
#ifndef HAVE_POLL
return 0;
#else
struct pollfd fds;
int res;
DBUG_ENTER("vio_poll");
ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
def execute(sql, name = nil) #:nodoc:
if @connection.respond_to?(:async_query)
log(sql, "Async #{name || ''}") { @connection.async_query(sql) }
else
log(sql, name) { @connection.query(sql) }
end
rescue ActiveRecord::StatementInvalid => exception
if exception.message.split(":").first =~ /Packets out of order/
class ApplicationController < AC::Base
def with_etags( *etag, &block )
etag = supplement_etag!( etag ).compact
logger.info "** Etag source: #{etag.inspect}"
response.last_modified = last_modified_for_etag( etag ).sort.last || now
logger.info "** Response Last Modified: #{response.last_modified}"
response.etag = etag
logger.info "** Response Etag: #{response.etag.inspect}"
if request.fresh?(response)
unless Object.const_defined? 'WillPaginate'
module ActiveRecord
class Base
class << self
def paginate( options = {} )
find( :all, options.except( :page, :per_page ) )
end
end
>> pounds = 1.5
=> 1.5
>> ounces = (1 - "0.#{pounds.to_s.split('.').last}".to_f) * 16
=> 8.0
module Accountable
class Transaction < ::ActiveRecord::Base # to ensure not clashing with Accountable::ActiveRecord::Macro
has_many :credits
has_many :debits
end
end
module Accountable
module Accounts
class Base < ::ActiveRecord::Base #see above