This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'capybara/rspec' | |
RSpec.configure do |config| | |
config.use_transactional_fixtures = false | |
config.treat_symbols_as_metadata_keys_with_true_values = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BulkUpdatable | |
def bulk_update(objects, attribute) | |
return unless objects.any? | |
query = build_query_for(objects, attribute) | |
connection.execute(query) | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/all' | |
class JsFile | |
attr_accessor :path, :file_contents | |
def initialize(path) | |
@path = path | |
@file_contents = File.read(@path) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
ENV['RAILS_ENV'] = 'test' | |
require_relative '../config/environment' | |
class Speccer | |
def configuration | |
@configuration ||= RSpec::Core::Configuration.new | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Trashable | |
module ClassMethods | |
def dependent_associations | |
reflect_on_all_associations.select do |association| | |
[:destroy, :delete_all].include?(association.options[:dependent]) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/inflector' | |
inflectors_path = File.expand_path('./config/initializers/inflections.rb') | |
load inflectors_path if File.exist?(inflectors_path) | |
class Mutagen | |
def initialize(path) | |
file_match_expression = File.join(File.expand_path(path), '**/*.rb') | |
@source_files = Dir.glob(file_match_expression).map do |file_path| | |
SourceFile.new(file_path, path) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# Eager load application and dependencies | |
require File.expand_path('../../../config/environment', __FILE__) | |
Rails.application.eager_load! | |
# All classes to mutate | |
classes = ActiveSupport::Dependencies.autoloaded_constants. | |
map(&:constantize).grep(Class).map(&:name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
# capture root dir | |
root=$(pwd) | |
echo "cache url: $CACHE_URL" | |
mv lp_solve_5.5 /tmp/ | |
cd /tmp/lp_solve_5.5/lp_solve/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Benchmark.bm do|b| | |
b.report("exclusion join ") do | |
a = "" | |
10_000.times do | |
Element.find_by_sql( | |
<<-SQL | |
select e.* from elements e | |
left outer join elements leafs | |
on e.id = leafs.parent_id | |
where leafs.parent_id is null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install some dependencies | |
sudo apt-get install -y vim eclipse git \ | |
curl mysql-server zlib1g-dev coreutils libtool bison libxt-dev \ | |
sqlite3 libsqlite3-dev libxml2-dev libreadline-dev \ | |
libmagickwand-dev libmysqlclient-dev libmemcached-dbg \ | |
postgresql postgresql-client libpq-dev libxslt1-dev nodejs \ | |
libqt4-dev libqtwebkit-dev | |
# install rvm and ruby | |
curl -L get.rvm.io | bash -s stable |
NewerOlder