
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
This gem acts as a proxy for avatars on Twitter & Facebook.
Add this line to your application's Gemfile:
gem "social-avatar-proxy"
And then execute:
$ bundle
Or install it yourself as:
$ gem install social-avatar-proxy
In your config/routes.rb
file:
mount SocialAvatarProxy::Engine, at: "/avatars"
The engine is basically a proxy for the Rack app, it also adds the path helpers below:
In your views:
# for a Twitter user, by username:
image_tag(twitter_avatar_path("username"))
# by ID:
image_tag(twitter_avatar_path(12345))
# for a Facebook user, by username:
image_tag(facebook_avatar_path("username"))
# by ID:
image_tag(facebook_avatar_path(12345))
You might wish to configure a default image which will be rendered if an avatar could not be found, or if the remote service has an error (e.g. times out or has a redirect loop), this is simple with an initializer:
# choose our image
image_path = Rails.root.join(*%W(app assets images default_avatar.jpg))
# set the config
SocialAvatarProxy.configure do
default_image(image_path)
end
HTTP caching can be configured as below:
SocialAvatarProxy.configure do
http_cache do
expires 10.minutes
cache_control({
max_age: 5.days,
max_stale: 1.day,
public: true
})
end
end
Files can be cached in either or both of Memcached and the file system, here is the configuration options:
SocialAvatarProxy.configure do
file_cache do
directory "/path/to/folder"
end
memcache do
enable # only required if you don't set either of the following options
host "192.168.1.2:11211" # defaults to "localhost:11211"
namespace "something:" # defaults to "sap/"
end
end
The Rack app is available at: SocialAvatarProxy::App.
Both the class and an instance respond to call
so either can be mounted.
use SocialAvatarProxy::App
# or
use SocialAvatarProxy::App.new
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.