Skip to content

Instantly share code, notes, and snippets.

View softcraft-development's full-sized avatar

Craig Walker softcraft-development

View GitHub Profile
module InlineMailPartUrls
def url
# I'm toggling this behaviour based on an environment variable.
# As far as I can see, there is no (better) way to decide whether or not
# the url is being called from a Rails Mailer Preview vs the actual Mailer call.
if ENV["INLINE_MAIL_PART_URLS"] == "true"
# Encode the part body in a data URI
# http://en.wikipedia.org/wiki/Data_URI_scheme
"data:#{mime_type};base64,#{Base64.encode64(body.decoded)}"
else
@softcraft-development
softcraft-development / application_mailer.rb
Created February 15, 2015 22:41
Set custom Content-Transfer-Encoding header on mailer responses.
def insert_part(container, response, charset)
part_list = super
part = part_list.last
part.header[:content_transfer_encoding] = "quoted-printable"
part_list
end
@softcraft-development
softcraft-development / output.txt
Created September 2, 2016 23:06
output of npm test for favicons-webpack-plugin
$ npm test
> favicons-webpack-plugin@0.0.7 test D:\projects\favicons-webpack-plugin
> ava
loudRejection/api is deprecated. Use the currently-unhandled module instead.
4 passed
3 failed
begin
begin
raise Exception.new("An Exception")
rescue => e
puts "Rescued an unspecified error: #{e.message}"
end
rescue Exception => e
puts "Rescued an exception: #{e.message}"
end
class Foo
CONST_ON_FOO = "the constant on Foo"
class << self
puts "When we're defining CONST_ON_FOOS_CLASS, we're actually in: #{self}, a #{self.class}"
CONST_ON_FOOS_CLASS = "the constant on Foo's class"
end
end
instance = Foo.new