Skip to content

Instantly share code, notes, and snippets.

@thbar
thbar / private_buckets_test.rb
Last active August 29, 2015 14:17
Production sanity test to verify that S3 buckets remain private over time
def buckets
[
'myapp-production-backups',
'myapp-staging-backups',
'myapp-s3-logs'
]
end
def test_buckets_subdomain_private
buckets.each do |bucket_name|
/*
Adapt.js licensed under GPL and MIT.
Read more here: http://adapt.960.gs
*/
// Closure.
(function(w, d, config, undefined) {
// If no config, exit.
if (!config) {
@nathos
nathos / fancy-hover-mixin.sass
Last active September 25, 2015 17:47
Compass fancy-hover - snazzy-looking image replacement hovers with an animated opacity ramp. Now using Compass sprites so you don't have to do the dirty work! See the demo at http://nathos.github.com/fancy-hovers/
@mixin fancy-hover($sprite_dir, $off_state, $hover_state, $speed: 0.3s)
$sprites: sprite-map("#{$sprite_dir}/*.png")
$width: image-width(sprite_file($sprites, $off_state))
$height: image-height(sprite_file($sprites, $off_state))
@include hide-text
width: $width
height: $height
background: sprite($sprites, $off_state) no-repeat
display: block
position: relative
@lloydk
lloydk / gist:1019398
Created June 10, 2011 18:16 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@patmaddox
patmaddox / render_with_comments.rb
Created August 30, 2011 16:38
HTML comments to tell you what partial is rendering
# Throw a comment in before and after every render call on html based templates
module ActionView # :nodoc: all
class Base
alias_method :render_file_without_comments, :render
attr_accessor :render_stack
def render(options = {}, local_assigns = {}, &block)
self.render_stack ||= []
if options[:partial]
@josevalim
josevalim / 1_README.md
Created December 13, 2011 09:30
FSSM based FileWatcher for Rails

Rails 3.2 ships with a simple FileWatcher that only reloads your app if any of the files changed.

Besides, it also provides a mechanism to hook up your own file watcher mechanism, so we can use tools like FSSM that hooks into Mac OS X fsevents. This is an example on how to hook your own mechanism (you need Rails master, soon to be Rails 3.2):

  1. Copy the 2_file_watcher.rb file below to lib/file_watcher.rb

  2. Add the following inside your Application in config/application.rb

if Rails.env.development?

# This allows developers to pass an Active Model object
# to within, check and uncheck. This is very useful when
# used with `content_tag_for` since `content_tag_for`
# generates an unique dom id for each object. With this
# module, we can write:
#
# within comment do
# click_link "Destroy"
# end
#
@jeremy
jeremy / schema.xml
Created April 2, 2011 00:53
Basecamp Solr schema
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="basecamp" version="1.3">
<types>
<!-- indexed/stored verbatim -->
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true" omitTermFreqAndPositions="true"/>
<!-- "true" or "false" -->
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true" omitTermFreqAndPositions="true"/>
<!-- binary data, base64 -->
# Multiple inheritance with Modules as an alternative to injected composition
# from Sandi Metz's talk [Nothing is Something](http://confreaks.tv/videos/bathruby2015-nothing-is-something)
# Like Sandi's 'direct' DI method this has behavior outside of the base class
# that gets composed together. However in this gist I compose modules in class
# definitions instead of injecting collaborators.
# Tradeoffs between this and Sandi's version are that in this case the API consumer doesn't
# have to know how to make a RandomEchoHouse (no `house = House.new(formatter: Whatever.new)`),
# but also the API consumer can't make anything not already accounted for either.