Skip to content

Instantly share code, notes, and snippets.

View metaskills's full-sized avatar
🧠
Adding Digital Intelligence

Ken Collins metaskills

🧠
Adding Digital Intelligence
View GitHub Profile
module Webrat
class Session
def formatted_error
doc = Nokogiri::HTML(response_body)
exception_name = doc.css('head title').inner_html.squish
exception_msg = doc.css('body h1').inner_html.squish
exception_detail1 = "".tap do |detail|
d = doc.css('body p')[0]
detail << d.content.strip
detail << d.next_sibling.content.squish
if Rails.version == '2.3.8' && Gem.available?('mongrel', Gem::Requirement.new('~>1.1.5')) && self.class.const_defined?(:Mongrel)
# Pulled right from latest rack. Old looked like this in 1.1.0 version.
#
# def [](k)
# super(@names[k] ||= @names[k.downcase])
# end
#
module Rack
if false
local_var = "..."
end
local_var # => nil
Last login: Thu Jul 22 10:16:16 on ttys000
You have mail.
(kencollins@mc1) - (~)
∴ echo $PATH
/opt/ruby-enterprise-1.8.7-2010.01/bin:/opt/local/bin:/opt/local/sbin:/opt/local/apache2/bin:/opt/local/lib/mysql5/bin:/opt/local/lib/postgresql84/bin:/Users/kencollins/.zshkit/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
(kencollins@mc1) - (~)
∴ rvm use system
info: Now using system ruby.
(kencollins@mc1) - (~)
# Here is a neat little named scope module that let's me easily abstract out making finders based on
# class column names. The nice thing is that it does quite a few chores. First it makes sure that passed
# in column names exist in the schema. Second, it escapes values while building the string.
module NamedScopes
module AttributeScopes
def self.included(base)
base.class_eval do
class Dlr < ActiveRecord::Base
set_table_name(:dealers)
set_primary_key(:dealer_id)
end
Dlr.columns_hash['dealer_name'].sql_type
=> "nvarchar(150)"
d = Dlr.first ; puts d.id
require 'tasks/alias_task_chain'
namespace :db do
alias_task_chain :charset => :environment do
config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
case config['adapter']
when 'sqlserver'
ActiveRecord::Base.establish_connection(config)
# encoding: utf-8
require 'odbc'
require 'odbc_utf8'
GC.disable
module ODBC
class Statement
def finished?
--- a/lib/active_record/connection_adapters/sqlserver/database_statements.rb
+++ b/lib/active_record/connection_adapters/sqlserver/database_statements.rb
@@ -219,7 +219,7 @@ module ActiveRecord
when :adonet
handle_to_fields_and_rows_adonet(handle)
end
- fields_and_row_sets << fields_and_rows
+ fields_and_row_sets << fields_and_rows if (fields_and_row_sets.blank? || fields_and_rows[0].present? && fields_and_rows[1].present?)
break unless handle_more_results?(handle)
end
module Foo
def foo
'foo'
end
end
module FooWithBar
def foo
"bar #{super}"
end