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 ActionDispatch::Routing | |
class Mapper | |
def authenticate(scope = Devise.default_scope) | |
constraint = lambda do |request| | |
request.env["warden"].authenticate!(:scope => scope) | |
end | |
constraints(constraint) do | |
yield | |
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 CouchDBAttachments | |
def attachment(*args) | |
lambda do |env| | |
request = ActionDispatch::Request.new(env) | |
doc = DocWithAttachments.get(request.params[:doc]) | |
serve_attachment(doc, request.params[:path]) | |
end | |
end | |
private |
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
if defined?(Rails) | |
class ActionController::Base | |
include RailsWarden::Mixins::HelperMethods | |
include RailsWarden::Mixins::ControllerOnlyMethods | |
end | |
module ApplicationHelper | |
include RailsWarden::Mixins::HelperMethods | |
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
%% This is http://code.google.com/p/ip2country-erlang on steroids. | |
%% Database: http://software77.net/cgi-bin/ip-country/geo-ip.pl?action=download | |
%% Speed: over 200000 lookups in a second. | |
-module(ip2country). | |
-compile(export_all). | |
for_each_line_in_file(Name, Proc, Acc) -> | |
{ok, Device} = file:open(Name, [read]), | |
for_each_line(Device, Proc, Acc). |
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
radius.erl | |
has_attribute(A) when is_list(A) -> | |
X = radius:lookup_attribute(A), | |
Code = ... | |
has_attribute(Code); | |
has_attribute(A) when is_integer(A) -> | |
... | |
has_attribute({Vendor, Specific}) -> |