Skip to content

Instantly share code, notes, and snippets.

View aaronjensen's full-sized avatar

Aaron Jensen aaronjensen

View GitHub Profile
[08:34:54 reactant (master $% u=)]$ rvm autolibs status
---
value: enable
number: 4
runner: osx
description: Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X).
[08:35:03 reactant (master $% u=)]$ rvm get head
######################################################################## 100.0%
Downloading RVM from wayneeseguin branch master
% Total % Received % Xferd Average Speed Time Time Time Current
[2013-05-20 08:35:51] make
current path: /Users/aaronjensen/.rvm/src/ruby-2.0.0-p195
command(2): make -j8
CC = /usr/bin/clang
LD = ld
LDSHARED = /usr/bin/clang -dynamiclib
CFLAGS = -O3 -march=core2 -mfpmath=sse -msse4.2 -msse4.1 -O2 -fno-common -pipe
XCFLAGS = -include ruby/config.h -include ruby/missing.h -DRUBY_EXPORT
CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libxml2/include -I/usr/local/opt/libxslt/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -I. -I.ext/include/x86_64-darwin12.3.0 -I./include -I.
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libxml2/lib -L/usr/local/opt/libxslt/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -install_name /Users/aaronjensen/.rvm/rubies/ruby-2.0.0-p195/lib/libruby.2.0.0.dylib -current_version 2
module AllCacheKey
extend ActiveSupport::Concern
module ClassMethods
def cache_key
pluck("COUNT(*)", "MAX(updated_at)").flatten.map(&:to_i).join("-")
end
end
end
@aaronjensen
aaronjensen / spec_helper.rb
Created August 15, 2013 06:27
check for leaking transactions in rspec tests
def check_for_leftovers
tables = ActiveRecord::Base.connection.select_values("show tables")
leftovers = {}
tables.each do |table|
next if %w(schema_migrations vanity_experiments).include? table
count = ActiveRecord::Base.connection.select_value("select count(*) from #{table}")
leftovers[table] = count if count > 0
end
if leftovers.any?
<!-- Bad -->
<div id="externalhtmlobject"><a name="externalhtmlobjectanc">
<script src='https://www.teachingchannel.org/videos/teaching-declaration-of-independence/embed?format=js' type='text/javascript'></script>
</a></div>
<!-- Good -->
<div id="externalhtmlobject">
<script src='https://www.teachingchannel.org/videos/teaching-declaration-of-independence/embed?format=js' type='text/javascript'></script>
</div>
:javascript
Bugsnag.releaseStage = "#{Rails.env}";
Bugsnag.notifyReleaseStages = ["#{Rails.env}"];
Bugsnag.metaData = #{bugsnag_metadata.to_json};
Bugsnag.metaData['log'] = { log: "" };
Bugsnag.log = function(message) {
Bugsnag.metaData['log']['log'] += message + "\n";
}
var _onerror = window.onerror;
require 'thread'
class RackDrain
@@queue = Queue.new
def self.start_request
self.queue << :request
end
def self.end_request
self.queue.pop
@aaronjensen
aaronjensen / gist:efa824496470b74f0fd7
Last active August 29, 2015 14:06
active_interaction default instance eval procs
require 'spec_helper'
describe Interaction do
TestInteraction = Class.new(Interaction) do
model :user
string :first_name
model_fields user: [:first_name]
end
describe ".model_fields" do
@aaronjensen
aaronjensen / delete_retry_fix.rb
Last active August 29, 2015 14:06
delayed_job_active_record retry fix monkey patch see: https://github.com/collectiveidea/delayed_job_active_record/pull/91
require 'delayed/backend/active_record'
module Delayed
module Backend
module ActiveRecord
class Job < ::ActiveRecord::Base
def destroy
retries = 0
begin
super
# https://github.com/garybernhardt/selecta/issues/30
def compute_match_length(choice, query)
# Check for exact match
return query.length if choice.index(query)
query_chars = query.chars
# Extract longest possible substring
first_index = choice.index(query_chars.first)