This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'nokogiri' | |
| require 'socksify' | |
| # Configure SOCKSify to use local Tor proxy | |
| TCPSocket::socks_server = "127.0.0.1" | |
| TCPSocket::socks_port = 9050 | |
| # Make sure that we use the Tor network | |
| begin | |
| doc = Nokogiri::HTML(open("https://check.torproject.org")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'mini_magick' | |
| module CarrierWave | |
| module ClassMethods | |
| # Custom processor to apply a white background to a picture | |
| def apply_white_background | |
| process :apply_white_background | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'httparty' | |
| # ApiModel could be inherited by all models on the top of a RESTfull API | |
| # | |
| # Note: Inheriting models should at least define the "api_collection_name" | |
| # | |
| # == Example | |
| # | |
| # class Product < RestApiModel | |
| # api_collection_name "products" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module HTTPCacheable | |
| def self.included(base) | |
| base.extend ClassMethods | |
| default_options = { | |
| :http_cache_directive => 'public', | |
| :http_cache_expiration => 300 | |
| } | |
| base.instance_variable_set("@default_options", default_options) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module MyHelper | |
| def image_tag_without_exception image_name, opts = {} | |
| begin | |
| return image_tag(image_name, opts) | |
| rescue | |
| # DO NOTHING | |
| end | |
| return "" | |
| end | |
| end |
NewerOlder