Skip to content

Instantly share code, notes, and snippets.

View methodmissing's full-sized avatar

Lourens Naudé methodmissing

View GitHub Profile
static VALUE
pgconn_async_exec(obj, str)
VALUE obj, str;
{
PGconn *conn = get_pgconn(obj);
PGresult *result;
char *msg;
int cs;
int ret;
require 'mysqlplus'
ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
def execute(sql, name = nil) #:nodoc:
if @connection.respond_to?(:send_query)
log(sql, "Async result #{name || ''}") { @connection.async_query(sql) }
else
log(sql, name) { @connection.query(sql) }
end
diff --git a/ext/extconf.rb b/ext/extconf.rb
index d14738e..73bef6d 100644
--- a/ext/extconf.rb
+++ b/ext/extconf.rb
@@ -71,4 +71,4 @@ File.open('error_const.h', 'w') do |f|
end
end
-create_makefile("mysql")
+create_makefile("mysql")
static VALUE mysqlres2obj(MYSQL_RES* res)
{
VALUE obj;
struct mysql_res* resp;
obj = Data_Make_Struct(cMysqlRes, struct mysql_res, 0, free_mysqlres, resp);
rb_iv_set(obj, "colname", Qnil);
rb_iv_set(obj, "tblcolname", Qnil);
resp->res = res;
resp->freed = Qfalse;
rb_obj_call_init(obj, 0, NULL);
static void schedule_query(VALUE obj, VALUE timeout)
{
MYSQL* m = GetHandler(obj);
fd_set read;
timeout = ( NIL_P(timeout) ? m->net.read_timeout : INT2NUM(timeout) );
struct timeval tv = { tv_sec: timeout, tv_usec: 0 };
FD_ZERO(&read);
#!/usr/sbin/dtrace -Zs
/*
* rb_syscalls.d - count Ruby calls and syscalls using DTrace.
* Written for the Ruby DTrace provider.
*
* $Id: rb_syscalls.d 20 2007-09-12 09:28:22Z brendan $
*
* USAGE: rb_syscalls.d { -p PID | -c cmd } # hit Ctrl-C to end
*
* FIELDS:
#abstract/database_statements.rb
# Returns the last auto-generated ID from the affected table.
def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
execute(sql, name)
id_value
end
#mysql_adapter.rb
require 'rubygems'
require 'activesupport'
z = returning( "" ) do |html|
html += "stuff"
html += "more stuff" if true
end
z = returning( [] ) do |html|
html << "stuff"
class Class
def publicize_methods!
hidden_methods = self.private_instance_methods + self.protected_instance_methods
self.class_eval { public *hidden_methods }
end
end
module ActiveResource
class Base
protected
alias :original_create :create
def create( attributes = {} )
self.attributes = attributes
original_create