Skip to content

Instantly share code, notes, and snippets.

@ucnv
Created November 6, 2010 19:39
Show Gist options
  • Save ucnv/665654 to your computer and use it in GitHub Desktop.
Save ucnv/665654 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Based on https://gist.github.com/165171
require 'ubygems'
require 'rmagick'
require 'webrick'
require 'webrick/httpproxy'
handler = Proc.new do |req, res|
if req.host =~ /^cbk\d+\.google/ and res['content-type'] =~ /jpeg/
res.body = Magick::Image.from_blob(res.body).shift.blur_image(50, 30).to_blob
res['cache-control'] = 'no-cache'
end
end
s = WEBrick::HTTPProxyServer.new(
:BindAddress => '0.0.0.0',
:Port => 8080,
:ProxyContentHandler => handler
)
Signal.trap('INT') do
s.shutdown
end
s.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment