Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
#
# Joshua Sierles, 37signals, 2009
require 'rubygems'
require 'thor'
require 'chef'
require 'chef/node'
require 'chef/rest'
###
# Fragile, embedded, deeply tied
###
<% search("foo").each do |n| -%>
stuff with <%= n %>
<% end %>
###
# Less fragile, not embedded
@thommay
thommay / carbon.md
Created November 7, 2009 08:16 — forked from defunkt/carbon.md

Vim

autocmd BufWritePre * :%s/\s\+$//e

Emacs

(add-hook 'before-save-hook 'delete-trailing-whitespace)

Textmate

current_apt_keys = Dir[
File.expand_path(File.join(File.dirname(__FILE__), "..", "files", "default", "apt-keys", "*"))
]
ruby_block "cleanup apt-keys" do
block do
Dir[
File.expand_path(File.join(Chef::Config[:file_cache_path], "cache", "apt_keys", "*"))
].each do |rf|
unless current_apt_keys.include?(rf)
require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#
#!/usr/bin/ruby
# Download NASA MODIS imagery and use it as a desktop background.
# You'll need ImageMagick installed for this to work.
require 'date'
require 'net/http'
# Screen width/height
X = 2580
Y = 1024
# rsync/definition/rsync_target.rb
define :rsync_target, :path => nil, :comment => nil, :action => :set do
t = begin
resources(:template => "/etc/rsyncd.conf")
rescue
template "/etc/rsyncd.conf" do
owner "root"
group "root"
source "rsyncd.conf.erb"
cookbook "rsyncd"
# Check this out, rvm use rbx
ruby_block "rvm use rbx" do
block do
Chef::Mixin::Command.popen4('bash -l -c "rvm use 1.9.1 && env"') do |p,i,o,e|
o.each_line do |line|
env_bits = line.split("=")
ENV[env_bits[0]] = env_bits[1]
end
end
define :email_alias, :recipients => [] do
execute "newaliases" do
action :nothing
end
t = nil
begin
t = resources(:template => "/etc/aliases")
rescue ArgumentError
t = template "/etc/aliases" do
# Author:: Adam Jacob <adam@opscode.com>
# Author:: Joshua Timberman <joshua@opscode.com>
#
# Copyright 2009-2010, Opscode, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0