Skip to content

Instantly share code, notes, and snippets.

;; This is in erlang_mode_config.el
(provide 'erlang_mode_config)
(add-to-list 'load-path "/opt/lib/erlang/lib/tools-2.6.1/emacs")
(require 'erlang-start)
(setq erlang-indent-level 2)
(add-to-list 'exec-path "/opt/bin")
(setq erlang-root-dir "/opt")
;;;
;;; This part is in ~/.emacs.local
;;;
;;; You can load it in your .emacs with this:
;;; (load "~/.emacs.local" t)
;; Erlang
(add-to-list 'load-path "/usr/local/lib/erlang/lib/tools-2.6.1/emacs")
(setq erlang-root-dir "/usr/local/lib/erlang")
Router.prepare do |r|
r.match("/something",
:user_agent => %r[(?:one|two|three)]
).to(:controller => "foo", :action => "bar")
r.match("/something/else",
:user_agent => %r[(?:four|five|six)]
).to(:controller => "foo", :action => "bar")
end
Router.prepare do |r|
r.match("/something", :user_agent => %r[some/complex/regexp/with/parentheses]).to(:browser => ":user_agent[1]")
end
Router.generate(:browser => "something")
# => I can't tell if something is a valid match
# from the original :user_agent regex
# since we have :browser => "something", and we know that :browser is :user_agent[1], we match "something" against the regex
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'rubygems'
require 'json'
require 'pp'
url = 'http://www.apple.com/retail/iphone/feeds/3g_us_inv.json'
json = Net::HTTP.get_response(URI.parse(url)).body