Skip to content

Instantly share code, notes, and snippets.

View methodmissing's full-sized avatar

Lourens Naudé methodmissing

View GitHub Profile
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
>> pounds = 1.5
=> 1.5
>> ounces = (1 - "0.#{pounds.to_s.split('.').last}".to_f) * 16
=> 8.0
unless Object.const_defined? 'WillPaginate'
module ActiveRecord
class Base
class << self
def paginate( options = {} )
find( :all, options.except( :page, :per_page ) )
end
end
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)
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/
/* 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");
/* <MYSQL_ROOT>/vio/vio.c */
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
macbook-pros-computer:Ruby lourens$ sudo dtrace -n 'syscall:::entry/execname == "ruby"/{ @[execname, probefunc] = count() }'
dtrace: description 'syscall:::entry' matched 427 probes
^C
ruby execve 1
ruby exit 1
ruby fork 1
ruby getdtablesize 1
ruby kill 1
ruby mkdir 1
# modified <RAILS_ROOT/script/console overloading the irb executeable ( assumes script/irb )
#!/usr/bin/env ruby
ARGV << "--irb=#{File.dirname(__FILE__)}/irb"
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
#<RAILS_ROOT>/script/irb or elsewhere
#!/usr/bin/env ruby
module ActiveSupport
class BufferedLogger
def <<( message )
info( message )
end
end
end