# Main reference was lascarides' post at http://stackoverflow.com/questions/14743447/getting-pdf-from-wickedpdf-for-attachment-via-carrierwave | |
# estimate.rb | |
# ... | |
has_attached_file :pdf, | |
storage: :s3, | |
s3_credentials: { | |
access_key_id: ENV['AWS_ACCESS_KEY_ID'], | |
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'], | |
bucket: ENV['AWS_BUCKET'] |
(I guarantee nothing. No warranty I am not responsible blah blah blah. Seems to work great for me so far. Thanks to Tyler Bird who I forked this from.)
This installs a patched ruby 1.9.3-p448 with the railsexpress patchsets: https://github.com/skaes/rvm-patchsets
require 'spec_helper' | |
describe Image do | |
it_behaves_like 'it references creators and places' | |
it_behaves_like 'it supports tagging' | |
it_behaves_like 'it has a hash bag' | |
end |
# First blacklist checks for /etc/password, and counts hits in cache | |
blacklist 'etc/password' do | |
if req.query_string =~ %r{/etc/passwd} | |
Fail2Ban.fail('etc_password', req.ip, limit: 3, period: 24.hours, ban_for: 24.hours) | |
end | |
end | |
# 2nd blacklist checks for banned IPs in cache | |
blacklist 'banned_ips' do | |
Fail2Ban.banned?(req.ip) |
#in app/roles/ | |
module CollectorRole | |
def paintings | |
["Van Gogh"] | |
end | |
end |
#!/usr/bin/env ruby | |
#------------------------------------------------------------------------------ | |
# Aggregate Print useful information from /proc/[pid]/smaps | |
# | |
# pss - Roughly the amount of memory that is "really" being used by the pid | |
# swap - Amount of swap this process is currently using | |
# | |
# Reference: | |
# http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt#361 |
web: bundle exec rails server puma -p $PORT -e $RACK_ENV | |
critical: env HEROKU_PROCESS=critical bundle exec sidekiq -c 2 -q critical,4 | |
default: env HEROKU_PROCESS=default bundle exec sidekiq -c 4 -q default,2 | |
low: env HEROKU_PROCESS=low bundle exec sidekiq -c 1 -q low,1 |
When access to an object's internals is truly necessary, it isn't practical to use composition based techniques. For example, consider the following mixin-based code which implements a memoization routine for caching method return values:
module Cached
def cache(*method_names)
method_names.each do |m|
original = instance_method(m)
One of the problems with advancing the discussion on DCI is that we lack a comparable alternative pattern that has the same goals, but favors a low ceremony approach. The closest thing we have to that is Rails concerns, but they are more like distant relatives of the DCI concepts rather than first cousins, and that makes comparisions between the two approaches not especially fruitful.
I am considering the idea of experimenting with my own paradigm that captures the intent and purity of DCI, but with the convenience of concerns. Please note that this is just the starting point of a conversation, it is NOT a promise of comercially available cold fusion or a cure for cancer. It's just a gist with an idea on it I'd like to hear your thoughts on.
What if we had a top-level topology that was split into Models, **Rol