gem 'omniauth'
#config/intitializers/omniauth.rb
#userful gem [rack-p3p](https://github.com/hoopla/rack-p3p) | |
# [ie_iframe_cookies](https://github.com/grosser/ie_iframe_cookies) | |
# encoding: utf-8 | |
class ApplicationController < ActionController::Base | |
protect_from_forgery | |
before_filter :set_p3p | |
def set_p3p | |
headers['P3P'] = "policyref=\"/w3c/p3p.xml\", CP=\"ALL DSP COR CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT\"" | |
end |
=begin | |
notify = {} | |
notify[:item_id][email protected] | |
notify[:item_type]='Note' | |
notify[:create_user_id] = message_box[sender_id] | |
notify[:event]='新站内信' | |
notify[:relate_user_id]=message_box[recipient_id] | |
notify[:read]= true || false | |
notify[:content][email protected]_s | |
notify[:content_path] = Time.now |
<%= simple_form_for(@recommend_recommend_other, :html => {id: "recommend_recommend_other"}) do |f| %> | |
<%= f.error_notification %> | |
<div class="form-inputs"> | |
<%= f.input :_id, as: :hidden %> | |
<%= f.input :recommend_other_type, as: :select, collection: Recommend::OtherColumn.all.map(&:recommend_type) %> | |
<%# f.input :created_at %> | |
<%# f.input :updated_at %> | |
<% dynamic_feilds = @recommend_recommend_other.dynamic_attribute_names %> | |
<% if dynamic_feilds.present? %> |
after "deploy:create_symlink", "deploy:restart_workers" | |
## | |
# Rake helper task. | |
# http://pastie.org/255489 | |
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/ | |
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/ | |
def run_remote_rake(rake_cmd) | |
rake_args = ENV['RAKE_ARGS'].to_s.split(',') | |
cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}" |
Weibo2::Strategy::AuthCode.class_eval do | |
# place inside initializers | |
# The Authorization Code Strategy | |
# setting on yml | |
# with_offical_account: "1" | |
# @see http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-4.1 | |
def authorize_url(params={}) | |
params = {:redirect_uri => @client.redirect_uri}.merge(params) | |
params = params.merge({"with_offical_account" => with_offical_account}) if with_offical_account? |
gem 'omniauth'
#config/intitializers/omniauth.rb
#http://www.germane-software.com/software/rexml/docs/tutorial.html | |
#this convter | |
require 'rexml/document' | |
require "date" | |
## -- Misc Configs -- ## | |
public_dir = "../public" # compiled site directory | |
source_dir = "../source" # source file directory | |
blog_index_dir = '../source' # directory for your blog's index page (if you put your index in source/blog/index.html, set this to 'source/blog') |
# Deploy with Capistrano | |
gem 'capistrano' | |
gem 'rvm-capistrano' | |
gem "resque", "~> 1.20.0" | |
gem "resque_mailer", "~> 2.1.0" | |
#Clean ruby syntax for writing and deploying cron jobs. | |
gem "whenever", "~> 0.7.3" |
require 'csv' | |
#sources http://rake.rubyforge.org/doc/rakefile_rdoc.html | |
def load_data(param={}) | |
file = param.delete(:file) | |
#file = "#{Rails.root}/tmp/goods/test.csv" unless file.present? | |
#csv = CSV.open(file) | |
#JSON.parse csv.to_json | |
file = "#{Rails.root}/#{file}" unless file.to_s.start_with? '/' | |
if File.exists? file |
#!/usr/bin/ruby | |
##ruby获得自己的外网IP地址 | |
require "logger" | |
require 'open-uri' | |
require "mongo" | |
#require "net/smtp" | |
require "mail" | |
logger = Logger.new("ip.log", "monthly") | |
logger.level = Logger::DEBUG |