This file contains 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 BootstrapFormBuilder < ActionView::Helpers::FormBuilder | |
delegate :capture, :content_tag, :tag, to: :@template | |
%w[text_field text_area password_field collection_select email_field].each do |method_name| | |
define_method(method_name) do |name, *args| | |
errors = object.errors[name].any?? " error" : "" | |
error_msg = object.errors[name].any?? content_tag(:span, object.errors[name].join(","), class: "help-inline") : "" | |
content_tag :div, class: "control-group#{errors}" do |
This file contains 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
gem 'devise' | |
gem 'omniauth' | |
gem 'omniauth-github' | |
gem "omniauth-twitter" | |
gem "omniauth-facebook" | |
gem "omniauth-google-oauth2" |
This file contains 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
* Go to https://code.google.com/apis/console, log in with your Google account and click on API Access. | |
* Create OAuth2 credentials by clicking the big blue OAuth2 button. | |
* Set the callback url and the name of your app (can be edited later) | |
* The Google Key (as it is referred to by OmniAuth) is the Client ID | |
* The Google Secret (as it is referred to by OmniAuth) is the Client Secret | |
* Use those credentials as per your documentation for implementing OAuth2 authentication. | |
The Google OmniAuth strategy for OAuth2 is here: https://github.com/zquestz/omniauth-google-oauth2. Look in the examples folder for details on the rest of the implementation. |
This file contains 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
<% flash.each do |name, msg| %> | |
<div class="alert alert-<%= name == :notice ? "success" : "error" %>"> | |
<a class="close" data-dismiss="alert">×</a> | |
<%= msg %> | |
</div> | |
<% end %> |
This file contains 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
导出数据库pg_dump -Fc mydb > db_name.dump | |
导入数据库 pg_restore -d mydb db_name.dump | |
导出 pg_dump mydb > db_name.sql | |
表导出 pg_dump database -t table > table.sql | |
加上' -a '可只到导出表内容,不导出表结构 |
This file contains 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
file = File.join(Rails.root, 'log/markdown.log') | |
File.new(file, 'w+') unless File.exist?(file) | |
logger = Logger.new(file) | |
logger.info("#{Time.now}: Share##{_id}'s price is from #{latest_price} to #{new_price}") | |
logger.close |
This file contains 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
<VirtualHost *:80> | |
ServerName anderweb.ca | |
RewriteEngine on | |
RewriteRule ^(.*)$ http://www.anderweb.ca$1 [R=301,L] | |
</VirtualHost> |
This file contains 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
1 服务器上: | |
2 git init --bare --shared reggin.git | |
3 本地: | |
4 git remote add origin [email protected]:/home/dev/repos/xxxx.git |
This file contains 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
begin #开始 | |
raise.. #抛出异常 | |
rescue [ExceptionType = StandardException] #捕获指定类型的异常 缺省值是StandardException | |
$! #表示异常信息 | |
$@ #表示异常出现的代码位置 | |
else #其余异常 | |
.. | |
ensure #不管有没有异常,进入该代码块 |
This file contains 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
# -*- encoding: utf-8 -*- | |
require 'digest/md5' | |
require 'nestful' | |
class Smsbao | |
def initialize(login, passwd) | |
@login = login | |
@passwd = Digest::MD5.hexdigest(passwd.to_s) | |
end |
OlderNewer