Skip to content

Instantly share code, notes, and snippets.

namespace :secret do
desc "Edit an encrypted data bag item in EDITOR"
task :edit, :data_bag, :bag_item do |t, args|
unless ENV['EDITOR']
puts "No EDITOR found. Try:"
puts "export EDITOR=vim"
puts "or"
puts "export EDITOR='subl -w'"
exit 1
end
#!/bin/bash
# Actual filename: bootstrap/rvm.erb
# vim: set ft=sh
# This script automatically bootstraps the system with everything it needs to run chef-solo.
# Note: This should only do the absolute minimum necessary to get chef-solo (and your recipes)
# working. All else should be done via chef recipes.
#===================================================================================================
# Config
require 'restclient'
# RestClient logs using << which isn't supported by the Rails logger,
# so wrap it up with a little proxy object.
RestClient.log =
Object.new.tap do |proxy|
def proxy.<<(message)
Rails.logger.info message
end
end
@freiden
freiden / foo.rb
Created August 21, 2013 09:08 — forked from h3h/foo.rb
class Foo < ActiveRecord::Base
ALLOWED_HTML_ELEMENTS = %w[
a b br blockquote code em h2 h3 hr i li ol p pre s strong sub sup u ul
]
ALLOWED_EMPTY_HTML_ELEMENTS = %w[br hr]
before_validation :sanitize_html
private
#
# = Capistrano database.yml task
#
# Provides a couple of tasks for creating the database.yml
# configuration file dynamically when deploy:setup is run.
#
# Category:: Capistrano
# Package:: Database
# Author:: Simone Carletti <weppos@weppos.net>
# Copyright:: 2007-2010 The Authors
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
task :ask_production_confirmation do
set(:confirmed) do
puts <<-WARN
========================================================================
WARNING: You're about to perform actions on production server(s)
Please confirm that all your intentions are kind and friendly
========================================================================
@freiden
freiden / deploy.rb
Created October 23, 2013 08:58 — forked from thbar/deploy.rb
# cap deploy deploy:db_schema_load
namespace :deploy do
desc "Load the initial schema - it will WIPE your database, use with care"
task :db_schema_load, :roles => :db, :only => { :primary => true } do
puts <<-EOF
************************** WARNING ***************************
If you type [yes], rake db:schema:load will WIPE your database
any other input will cancel the operation.
Install ree with the following commands: CFLAGS="-O2 -fno-tree-dce -fno-optimize-sibling-calls" rbenv install ree-1.8.7-2012.02

Setting up and installing rbenv, ruby-build, rubies, rbenv-gemset, and bundler

This guide enables you to install (ruby-build) and use (rbenv) multiple versions of ruby, isolate project gems (gemsets and/or bundler), and automatically use appropriate combinations of rubies and gems.

TL;DR Demo

# Ensure system is in ship-shape.

aptitude install git zsh libssl-dev zlib1g-dev libreadline-dev libyaml-dev