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 / 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";
@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 / 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 / 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 / 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 / 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 / open4_threaded.rb
Created September 3, 2015 15:59
open4 threaded io handlers
require 'open4'
CASE = 'ruby -e "STDERR.puts \'a\'*70000; STDOUT.puts \'Hi\'"'
puts CASE
puts "---"
status = Open4.open4(CASE) do |pid, stdin, stdout, stderr|
stdin.close
threads = [
Thread.new { stdout.each_line { |l| puts "STDOUT: #{l}" } },
Thread.new { stderr.each_line { |l| puts "STDERR: #{l}" } }
@Fryguy
Fryguy / 01 influxdb_metrics.diff
Last active November 6, 2015 21:15
InfluxDB Cap and U metrics
diff --git a/Gemfile b/Gemfile
index 90b36f7..75077b4 100644
--- a/Gemfile
+++ b/Gemfile
@@ -4,6 +4,8 @@ eval_gemfile(File.expand_path("gems/pending/Gemfile", __dir__))
# VMDB specific gems
#
+gem 'influxdb'
+
@Fryguy
Fryguy / slick.grid.css.diff
Last active October 9, 2015 19:01
SlickGrid changes
diff --git a/generated_slick.grid.css b/app/assets/stylesheets/slick.grid.css
index fb2bede..6cc53a4 100644
--- a/generated_slick.grid.css
+++ b/app/assets/stylesheets/slick.grid.css
@@ -4,14 +4,21 @@ In order to preserve the uniform grid appearance, all cell styles need to have p
No built-in (selected, editable, highlight, flashing, invalid, loading, :focus) or user-specified CSS
classes should alter those!
*/
-/* line 10, /Users/jfrey/.gem/ruby/2.2.3/gems/rails-assets-slickgrid-2.1.0/app/assets/stylesheets/slickgrid/slick.grid.scss */
+
@Fryguy
Fryguy / irb_log.rb
Created October 13, 2015 00:54
simple irb allocations
irb(main):001:0> require 'objspace'
=> true
irb(main):002:0> GC.start
=> nil
irb(main):003:0> GC.start
=> nil
irb(main):004:0> ObjectSpace.dump_all
=> #<File:/var/folders/y3/p3qvt8mj7v36kg5m6_mfdfgm0000gn/T/rubyheap20151012-93687-1kakmc5.json>
irb(main):005:0> ObjectSpace.trace_object_allocations_start
=> nil