Skip to content

Instantly share code, notes, and snippets.

@gbissett
gbissett / minibuild.rb
Created March 18, 2012 08:13
a build server that is smaller and less capable than cijoe
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

Using vagrant

Install

  • Install VirtualBox
  • Install vagrant (use the OS installer instead of gem)

Setup

  • vagrant box add <box_name> <box_url>
@jrafanie
jrafanie / gist:5424bc23a5c5fcbe5047
Last active August 7, 2016 04:57
bundler: no place like gem home
$ bundler -v
Bundler version 1.9.7

Add git based rake to Gemfile:

$ cat Gemfile
source 'https://rubygems.org'
@amalagaura
amalagaura / runme.sh
Created December 15, 2011 04:29
Commands to fix damn CRLF with rubymine saving in windows
# 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"
@denilsonsa
denilsonsa / Python Virtual Environments on Debian and Ubuntu.md
Last active December 1, 2016 06:25
Python Virtual Environments on Debian and Ubuntu

pyvenv-3.3 (Ubuntu 13.10, also Debian)

Symptoms

pyvenv-3.3 venvdir
venvdir/bin/python -c 'import sys; print(sys.path)'
# This should print the venvdir in sys.path.

But in buggy Ubuntu/Debian, it doesn't.

@damien
damien / concerns-messagable_with_data.rb
Created July 12, 2012 23:06
Extending Mailboxer through Concerns
module Concerns
module MessagableWithData
extend ActiveSupport::Concern
included do
Message.class_eval do
has_many :message_data,
class_name: MessageData,
@biomancer
biomancer / dep_detect.rb
Last active March 20, 2017 16:04
Dirty simple order dependencies detector
## 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
@romansklenar
romansklenar / 20131118172653_create_transactional_items_view.rb
Last active July 3, 2017 09:15
Using PostgreSQL's materialized views as background for ActiveRecord models for flexible statistics
# 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})"
@milesmatthias
milesmatthias / directory_upload.rb
Created September 1, 2014 00:57
S3 directory upload in ruby. Switched http://avi.io/blog/2013/12/03/upload-folder-to-s3-recursively to use the official aws ruby sdk.
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
class S3FolderUpload
attr_reader :folder_path, :total_files, :s3_bucket
attr_accessor :files
@willkoehler
willkoehler / document_uploader.rb
Created February 11, 2014 15:14
Carrier uploader for documents that creates thumbnails from images and PDFs
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