Oct 16, 2014 - mysql remote access

1 创建mysql用户

1
$ CREATE USER myuser IDENTIFIED BY 'password';

2 分配权限

1
$ grant all privileges on mydb.* to myuser@'%' identified by 'mypasswd';

mydb:DB name myuser: mysql user name mypassword: password

eg. assign all DB privileges to all remote user

1
$ grant all PRIVILEGES on *.* to root@'%' identified by '123456';

不要忘记flush修改的内容

1
$ FLUSH PRIVILEGES;

3 ubuntu 开放 3306端口,远程访问

  • 使用nestat命令查看3306端口状态
1
$ netstat -an | grep 3306

tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN

如果是上面的结果,说明 3306端口只是在IP 127.0.0.1上监听,所以拒绝了其他IP的访问。

  • 解决方法:修改/etc/mysql/my.cnf文件。打开文件,找到下面内容:
1
2
3
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address  = 127.0.0.1

把上面这一行注释掉或者把127.0.0.1换成合适的IP,建议注释掉。

  • 重新启动
1
$ sudo /etc/init.d/mysql restart

c 重新使用netstat检测:

1
$ netstat -an | grep 3306

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN

Oct 15, 2014 - Rails upgrade to 2.3.18, fix some warning messages

1 DEPRECATION WARNING: Kernel#returning has been deprecated in favor of Object#tap

acts_as_paranoid发生的warning

fix before

1
2
3
4
5
6
7
8
9
10
def has_many_without_deleted(association_id, options = {}, &extension)
  with_deleted = options.delete :with_deleted
  returning has_many_with_deleted(association_id, options, &extension) do
    if options[:through] && !with_deleted
    reflection = reflect_on_association(association_id)
    collection_reader_method(reflection, Caboose::Acts::HasManyThroughWithoutDeletedAssociation)
    collection_accessor_methods(reflection, Caboose::Acts::HasManyThroughWithoutDeletedAssociation, false)
    end
  end
end

fix after

1
2
3
4
5
6
7
8
9
10
def has_many_without_deleted(association_id, options = {}, &extension)
  with_deleted = options.delete :with_deleted
  has_many_with_deleted(association_id, options, &extension).tap do
    if options[:through] && !with_deleted
    reflection = reflect_on_association(association_id)
    collection_reader_method(reflection, Caboose::Acts::HasManyThroughWithoutDeletedAssociation)
    collection_accessor_methods(reflection, Caboose::Acts::HasManyThroughWithoutDeletedAssociation, false)
    end
  end
end

change returning has_many_with_deleted(association_id, options, &extension) do to has_many_with_deleted(association_id, options, &extension).tap do .

2 DEPRECATION WARNING: Giving :session_key to SessionStore is deprecated, please use :key instead. (called from new at /home/mencio/.gem/ruby/1.8/gems/actionpack-2.3.8/lib/action_controller/middleware_stack.rb:72)

1
2
3
4
config.action_controller.session = {
  :secret_key => 'aaaaa' ,
  :secret => 'tajneprzezpoufne'
}

3 DEPRECATION WARNING: ActionView::SafeBuffer is deprecated! Use ActiveSupport::SafeBuffer instead. (called from local_constants at /home/mencio/.gem/ruby/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/module/introspection.rb:74)

代码发生地方是在 lib/fckeditor.rb:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
include ActionView
module ActionView::Helpers::AssetTagHelper
  alias_method :rails_javascript_include_tag, :javascript_include_tag
 
  #  <%= javascript_include_tag :defaults, :fckeditor %>
  def javascript_include_tag(*sources)
    main_sources, application_source = [], []
    if sources.include?(:fckeditor)
      sources.delete(:fckeditor)
      sources.push('fckeditor/fckeditor')
    end
    unless sources.empty?
      main_sources = rails_javascript_include_tag(*sources).split("\n")
      application_source = main_sources.pop if main_sources.last.include?('application.js')
    end
    [main_sources.join("\n"), application_source].join("\n")
  end
end

需要把上面的代码都要注释掉 然后 页面的调用 fckeditor的方法也要修改

1
javascript_include_tag "fckeditor/fckeditor"

4 DEPRECATION WARNING: Giving :session_http_only to SessionStore is deprecated, please use :httponly instead.

错误发生的地方是: config/initializers/session_store.rb 代码如下:

1
2
3
4
5
ActionController::Base.session = {
:key         => '_src_session',
:session_http_only => true,
:secret      => '0f118033ca9bae289e520c98bbb1f68ef100bec29c7caf25baa7d9e7236876448a1d5c8d7ee384114125b2ae047fefb0d33729ae7476cc3b6b59b5f795d6908a'
}

修改为如下的代码:

1
2
3
4
5
ActionController::Base.session = {
:key         => '_src_session',
:httponly => true,
:secret      => '0f118033ca9bae289e520c98bbb1f68ef100bec29c7caf25baa7d9e7236876448a1d5c8d7ee384114125b2ae047fefb0d33729ae7476cc3b6b59b5f795d6908a'
}

Aug 22, 2014 - Jekyll Clean Theme

Welcome to the sample post for the Jekyll Clean theme.

A simple and clean Jekyll theme using bootstrap (not to be confused with jekyll-bootstrap) that's easy to modify and very modular in component and element reuse.

It uses Disqus for comments and includes Google Analytics support. Both of these features are disabled by default and can be enabled via _config.yml. You can also rip this code out of the templates if you like (footer.html and post.html). The beauty of Jekyll - keep things clean... Jekyll Clean!

The theme works well on mobile phones, using a collapsable nav bar and hiding the sidebar. The links pane in the sidebar is available on mobile through the nav menu, and you can do the same thing for any other sections added to the sidebar.

Don't forget to occassionally merge against my upstream repository so you can get the latest changes. Pull requests are encouraged and accepted!

Installation

If you don't have a blog already on github, start by cloning this repository. Best to do that directly on github and then clone that down to your computer.

If you already do have a blog, You can certainly apply this theme to your existing blog in place, but then you won't be able to merge as the theme changes. If you re-apply your blog history on top of this theme's gh-pages branch, it's then easy to update to the latest version of the theme. You also don't want to have to deal with resolving old conflicts from your existing history, so you may wish to to push your existing master off to a new branch so you have the old history and start a new branch with this as the start, merging in your _posts and other assets (after git rm'ing the current _posts.

Not ideal, but you have to make a choice - either apply it manually or base your blog off this theme's branch. Either way it will work, and both have their own pros and cons.

You can setup an upstream tracking repository like so:

$ git remote add upstream git@github.com:scotte/jekyll-clean.git

And now when you wish to merge your own branch onto the latest version of the theme, simply do:

$ git fetch upstream
$ git merge upstream/gh-pages

Of course you will have to resolve conflicts for _config.yml, _includes/links-list.html, and _posts, and so on, but in practice this is pretty simple.

This is how I maintain my own blog which is based on this theme. The old history is sitting in an old-master branch that I can refer to when I need to.

License

The content of this theme is distributed and licensed under a License Badge Creative Commons Attribution 4.0 License

This license lets others distribute, remix, tweak, and build upon your work,
even commercially, as long as they credit you for the original creation. This
is the most accommodating of licenses offered. Recommended for maximum
dissemination and use of licensed materials.

In other words: you can do anything you want with this theme on any site, just please provide a link to the original theme on github so I get credit for the original design. Beyond that, have at it!

This theme includes the following files which are the properties of their respective owners:

My helpful screenshot