Hello
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
| Rails.application.routes.url_helpers |
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
| class Approval | |
| include Mongoid::Document | |
| include Mongoid::Timestamps | |
| belongs_to :user | |
| field :item_id | |
| field :key | |
| field :approved, :type=> Boolean, :default => false | |
| def pay |
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
| class PaypalController < ApplicationController | |
| def approval | |
| raise "not loggined" unless login_user | |
| @approval = Approval.find_or_create_by :user_id => login_user.id, :item_id => params[:item_id] | |
| raise "subscribed!" if @approval.key | |
| start_date = Time.now.gmtime | |
| end_date = 3.months.from_now.gmttime |
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
| unless Rails.env.production? | |
| ActiveMerchant::Billing::Base.mode = :test | |
| end | |
| config = YAML.load(ERB.new(File.read("#{Rails.root}/config/paypal.yml")).result)[Rails.env] | |
| PaypalGateway = ActiveMerchant::Billing::PaypalAdaptivePayment.new( | |
| :login => config["username"], | |
| :password => config["password"], | |
| :signature => config["signature"], | |
| :appid => config["application_id"] | |
| ) |
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
| background-color: white; | |
| background-image: url(bg.png); | |
| background-image: url(bg.png), -webkit-gradient(linear, left top, right bottom, from(#000000), to(#ffffff)); | |
| background-image: url(bg.png), -moz-linear-gradient(-45deg, #000000, #ffffff); | |
| background-attachment: fixed; |
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() { | |
| var tags = []; | |
| var _tags = {}; | |
| var words = document.documentElement.innerText.match(/[\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF]|[\uD840-\uD87F][\uDC00-\uDFFF]+|[\u12449-\u12531\u12540;]+|[a-zA-Z0-9!]+|[a-zA-Z>0-9]+/g); | |
| words.forEach(function(word) { | |
| if (word.length <= 3 || _tags[word]) { return ; } | |
| _tags[ word ] = 0; | |
| tags.push( word ); }); | |
| delete _tags; | |
| return tags; |
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
| class AccessLog | |
| class Handler | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) | |
| session = env["rack.session"] && user_id = session["user_id"] | |
| ipaddress = env["REMOTE_ADDR"] | |
| user_agent = env["HTTP_USER_AGENT"] | |
| referer = env["HTTP_REFERER"] |
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
| class Enumerator | |
| def filter(c=nil,&b) | |
| s = self | |
| e = ::Enumerator.new do |y| | |
| s.each do |x| | |
| y << (c||b).call(x) | |
| end | |
| end | |
| return e unless c | |
| e.each &b |
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
| def extract_tiny_url(url) | |
| url = URI.parse(url) if url.is_a?String | |
| TCPSocket.open(url.host, url.port) do|s| | |
| s.write("GET #{url.path} HTTP/1.1") | |
| s.write("\nHost: #{url.host}") | |
| s.write("\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0) Gecko/20100101 Firefox/11.0") | |
| s.write("\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") | |
| s.write("\nAccept-Language: ja-JP-mac,ja;q=0.8,en-US;q=0.5,en;q=0.3") | |
| s.write("\n\n") | |
| text = (s.readlines.join('').scan /URL=([a-z:\/\.\_0-9]*)/).flatten.first |