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 'java' | |
module UrlFetch | |
module UF | |
import java.net.URL; | |
import java.net.URLEncoder; | |
import com.google.appengine.api.urlfetch.HTTPHeader | |
import com.google.appengine.api.urlfetch.HTTPMethod | |
import com.google.appengine.api.urlfetch.HTTPRequest |
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 Components | |
components_path = File.expand_path(File.dirname(__FILE__) + '/components') | |
files = Dir.new(components_path).select{|f| f =~ /.*\.rb/ } || [] | |
files.each do |f| | |
body = File.new(File.join([components_path, f])).read | |
name = File.basename(f, '.rb').capitalize + "Helper" | |
module_eval <<-"end;" | |
module #{name} |
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 'rubygems' | |
require 'sinatra' | |
helpers do | |
def request_headers | |
env.inject({}){|acc, (k,v)| acc[$1.downcase] = v if k =~ /^http_(.*)/i; acc} | |
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
(function( $ ){ | |
$.fn.collectFields = function(fieldSelector) { | |
var convert = function(type, value) { | |
switch (type) { | |
case "int" : return value ? parseInt(value) : 0; | |
case "float" : return value ? parseFloat(value): 0.0; | |
case "boolean" : return Boolean(value); | |
default : return value; | |
} | |
}; |
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 Sinatra | |
module BuilderHelper | |
def helper_modules | |
@helper_mods ||= Sinatra::Application.ancestors.select{|m| m.name =~ /Helper/} | |
end | |
def builder_partial(template, xml, locals = {}, helper_mods = nil) | |
template = "#{template}.builder" unless "#{template}" =~ /[.]builder$/ | |
helper_mods ||= self.helper_modules | |
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
defmodule MyModule.Router do | |
@moduledoc """ | |
Http Entry Point | |
""" | |
use Plug.Router | |
use Plug.ErrorHandler | |
plug Plug.Logger | |
plug :match |