Skip to content

Instantly share code, notes, and snippets.

View Fryguy's full-sized avatar
💻
Codin'

Jason Frey Fryguy

💻
Codin'
View GitHub Profile
@Fryguy
Fryguy / irb session
Created December 5, 2014 21:33
Unnecessary BEGIN/COMMIT happens when model save is a no-op
Loading development environment (Rails 4.1.8)
irb(main):001:0> u = User.first
User Load (0.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
=> #<User id: 1, name: "Fryguy", created_at: "2014-12-05 21:18:18", updated_at: "2014-12-05 21:18:18">
irb(main):002:0> u.save!
(0.2ms) begin transaction
(0.1ms) commit transaction
=> true
irb(main):003:0> u.name = "Fryguy"
=> "Fryguy"
@Fryguy
Fryguy / delayed_begin_on_rails_2.2.2.patch
Created December 5, 2014 21:31
Unnecessary BEGIN/COMMIT happens when model save is a no-op
diff --git a/vmdb/vendor/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb b/vmdb/vendor/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb
index 97c6cd4..28f1318 100644
--- a/vmdb/vendor/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb
+++ b/vmdb/vendor/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -36,9 +36,15 @@ module ActiveRecord
# Executes the SQL statement in the context of this connection.
def execute(sql, name = nil)
- raise NotImplementedError, "execute is an abstract method"
+ check_delayed_open_transaction
@Fryguy
Fryguy / gist:4149410
Created November 26, 2012 17:10
VCR against multithreaded code
require "vcr"
require "net/http"
VCR.configure do |c|
c.cassette_library_dir = '/tmp'
c.hook_into :webmock
c.default_cassette_options = {
record: :once
}
@Fryguy
Fryguy / test_string.patch
Created December 15, 2011 19:22
psych doesn't handle subclasses of String nor Array
diff --git a/test/psych/test_array.rb b/test/psych/test_array.rb
index ec6a1aa..57b9428 100644
--- a/test/psych/test_array.rb
+++ b/test/psych/test_array.rb
@@ -2,11 +2,30 @@ require 'psych/helper'
module Psych
class TestArray < TestCase
+ class X < Array
+ end
@Fryguy
Fryguy / test_hash.patch
Created December 15, 2011 19:08
psych doesn't handle instance variables in subclasses of Hash
diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb
index 4bd4edf..b000226 100644
--- a/test/psych/test_hash.rb
+++ b/test/psych/test_hash.rb
@@ -5,6 +5,10 @@ module Psych
class X < Hash
end
+ class Y < Hash
+ attr_accessor :val
@Fryguy
Fryguy / gist:805479
Created February 1, 2011 05:45
shlwapi.h methods
#include <windows.h>
#include <stdio.h>
#include <shlwapi.h>
void main()
{
CHAR *path;
BOOL ret;
path = "C:/projects/rubyinstaller/sandbox";