- Install VirtualBox
- Install vagrant (use the OS installer instead of gem)
vagrant box add <box_name> <box_url>
require 'sinatra' | |
CODE_PATH = '/repo/lives/here' | |
RVM_COMMAND = '[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm' | |
UPDATE_COMMAND = 'git pull' | |
BUILD_COMMAND = 'bundle && rake db:migrate && rake' | |
def log(message='') | |
File.open('build.log', 'a') {|log| log.puts "#{Time.now.utc} #{message}" } | |
end |
# Remove everything from the index | |
git rm --cached -r . | |
# Re-add all the deleted files to the index | |
# You should get lots of messages like: "warning: CRLF will be replaced by LF in <file>." | |
git diff --cached --name-only -z | xargs -0 git add | |
# Commit | |
git commit -m "Fix CRLF" |
module Concerns | |
module MessagableWithData | |
extend ActiveSupport::Concern | |
included do | |
Message.class_eval do | |
has_many :message_data, | |
class_name: MessageData, |
## This script can be used to detect simple order dependencies if one of tests is failing when some other test(or tests, independently) is being run before it. | |
## Script will not give reliable results if the dependency is complex - e.g. two specific tests must be run before for affected one to fail. | |
## Script will refine results with each rspec run: more runs will result smaller UNSAFE lists. Files from previous script runs are used too | |
## Ensure that you have config.order = 'random' in RSpec.configure block . | |
## Running rspec with different seeds to collect data | |
RSPEC_RUN_COUNT = 5 #set to 0 to analyze already existing rspec_*.txt files | |
RSPEC_RUN_COUNT.times do |
# db/migrate/20131118172653_create_transactional_items_view.rb | |
class CreateTransactionalItemsView < ActiveRecord::Migration | |
def up | |
select_sql = File.open("#{Rails.root}/db/migrate/20131118172653_create_transactional_items_view.sql", 'r') { |f| f.read } | |
# for materialized view: | |
view_sql = "CREATE MATERIALIZED VIEW transactional_items AS (#{select_sql})" | |
# for normal view: | |
view_sql = "CREATE VIEW transactional_items AS (#{select_sql})" | |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'aws-sdk' | |
class S3FolderUpload | |
attr_reader :folder_path, :total_files, :s3_bucket | |
attr_accessor :files |
class DocumentUploader < CarrierWave::Uploader::Base | |
include CarrierWave::RMagick | |
# Store on Amazon S3 using Fog | |
storage :fog | |
# Directory where uploaded files will be stored. | |
def store_dir | |
"documents/#{model.id}" | |
end |