Skip to content

Instantly share code, notes, and snippets.

View derekclee's full-sized avatar

Derek Lee derekclee

View GitHub Profile
@derekclee
derekclee / compressed_svg.rb
Last active March 22, 2018 14:53
Compressing static svg files for the rails asset pipeline
# I used https://github.com/eliotsykes/rack-zippy to serve gzipped static assets.
# By default the rails asset pipeline was not compressing any static svg files,
# so I did the following to achive that.
#
# First create a rake task that will fine and compress svg files.
# File: lib/tasks/assets_svg_compress.rake
namespace :assets do
task :svg_compress => :environment do
svg_files = Dir["./public/**/*.svg"]
svg_files.each do |file|
@derekclee
derekclee / default.vcl
Last active June 11, 2024 19:51
Varnish Cache Set CORS headers
sub vcl_deliver {
if (req.url ~ "/fonts/") {
set resp.http.Access-Control-Allow-Origin = "*";
set resp.http.Access-Control-Allow-Methods = "GET, OPTIONS";
set resp.http.Access-Control-Allow-Headers = "Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token";
}
}