Skip to content

Instantly share code, notes, and snippets.

@jhjguxin
jhjguxin / _detail.html.erb
Created July 24, 2012 06:28
tag_cloud base on BBTCMS use gem 'acts-as-taggable-on', '~> 2.3.1' and bootstrap
<div id = "hot_tags_dail">
<% if @model_class.present?%>
<div id = "hot_tags_dail">
<%- model_class = @model_class.new.class -%>
<!--div class="page-header">
<h1><%=t '.title', :default => model_class.model_name.human.pluralize %></h1>
</div-->
<%- identity_model_class = Identity.new.class -%>
<%- timeline_model_class = Timeline.new.class -%>
@jhjguxin
jhjguxin / application.html.erb
Created July 27, 2012 02:49
Rails mete info on template (seo setting) base on BBTangCMS
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--%= yield(:title)%-->
<!--%= yield(:description)%--><!--%= yield(:keywords)%-->
<%= render_page_title %>
<%= raw("<meta name='keywords' content='#{@meta_keywords}' />") if @meta_keywords.present? %>
@jhjguxin
jhjguxin / AddFieldToUser.rb
Created July 30, 2012 09:14 — forked from wesgarrison/AddFieldToUser.rb
Using Rails Migration on different database than standard “production” or “development”
class AddFieldToUser < ActiveRecord::Migration
ActiveRecord::Base.establish_connection "user_#{Rails.env}"
def self.up
add_column :users, :field, :type
end
...
end
<!--comment words>
You may find that your application requires a layout that differs slightly from your regular application layout to support one particular controller. Rather than repeating the main layout and editing it, you can accomplish this by using nested layouts (sometimes called sub-templates). Here’s an example:
Suppose you have the following ApplicationController layout:
app/views/layouts/application.html.erb
<-->
<html>
<head>
<title><%= @page_title or 'Page Title' %></title>
<%= stylesheet_link_tag 'layout' %>
@jhjguxin
jhjguxin / Gemfile
Created August 3, 2012 08:02
breadcrumbs base on BBTangCms
#麵包屑
gem "breadcrumbs", "~> 0.1.6"
@jhjguxin
jhjguxin / notifier.coffee
Created August 3, 2012 15:16 — forked from sishen/notifier.coffee
Web Notifications integration in Pragmatic.ly
class Notifier
constructor: ->
@enableNotification = false
@checkOrRequirePermission()
hasSupport: ->
window.webkitNotifications?
requestPermission: (cb) ->
window.webkitNotifications.requestPermission (cb)
@jhjguxin
jhjguxin / git_diff.md
Created August 6, 2012 07:40
Git diff 比较不同版本的差异

Git 比较不同版本文件差异的常用命令格式:

git diff                                       查看尚未暂存的文件更新了哪些部分

git diff filename 查看尚未暂存的某个文件更新了哪些

git diff –cached                    查看已经暂存起来的文件和上次提交的版本之间的差异

git diff –cached filename 查看已经暂存起来的某个文件和上次提交的版本之间的差异
@jhjguxin
jhjguxin / extras_version.rb
Created August 9, 2012 06:10
how extras third models class(如何扩展譬如三方gem的model class) base on BBTangCMS
#lib/paper_trail/extras_version.rb
#because one **require statement** can only require one times, you cannot just create one file named 'version.rb' and place in 'app/models/ ' folder.
class Version
#class << self
def object_hash
YAML.load self.object if self.object.present?
end
def whodoit
@jhjguxin
jhjguxin / 404.html.erb
Created August 13, 2012 05:13
exception catch on rails 3(eg, 400, 403, 500), base on BBTangCMS
<div id="error_page" class="box">
<h1>Ops, 404</h1>
<p>
似乎没有这个页面哦!大哥,去看看别的吧。
</p>
</div>
<!--因为不排除连rails 都无法运行的情况 所以添加 'public/STATUS.htm' 还是很有必要的-->
<!--more>
Finally, the default exceptions application used by Rails that simply renders a page in `public/STATUS.html` is available here: [action_dispatch/middleware/public_exceptions.rb](https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/public_exceptions.rb)
Remember that whatever you do in the errors controller, it should not be anything “fancy”. Keep it simple because something already went wrong with your application!
@jhjguxin
jhjguxin / deploy.rb
Created August 14, 2012 05:46
rails on ruby whenever demo
require "bundler/capistrano"
require "whenever/capistrano"
# RVM bootstrap
#$:.unshift(File .expand_path( "~/.rvm/lib" ))
set :rvm_ruby_string , 'ruby-1.9.3-p194@askjane' #这个值是你要用rvm的gemset。名字要和系统里有的要一样。
#set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") # Read from local system
set :rvm_type , :user # Don't use system-wide RVM
require 'rvm/capistrano'