Skip to content

Instantly share code, notes, and snippets.

View liwh's full-sized avatar
🎯
Focusing

robie lee liwh

🎯
Focusing
View GitHub Profile
if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
[2010-12-16 20:23:45] ERROR ArgumentError: invalid byte sequence in US-ASCII
@liwh
liwh / gist:743606
Created December 16, 2010 16:30
github rollback
git reset --hard <old-commit-id>
git push -f
可用request.query_string获取页面中传过来的所有params参数,例如:
"#{export_excel_path(:from=>'aaa')&#{request.query_string}"
// remove crappy contents from news.google.de
$("div.source, span.source").filter(function() { return /(BILD|WELT ONLINE)/.test( $(this).text() ) }).parent().fadeOut();
$("h2.title > a").filter(function() { return /.*(welt.de|bild.de).*/.test( $(this).attr('href') ) } ).parents("div.story").fadeOut();
@liwh
liwh / gist:764571
Created January 4, 2011 09:18
valid? 方法会清空errors
>> c.errors.add_on_blank('instructor','not be blank')
=> ["instructor"]
>> c.errors
=> #<ActiveRecord::Errors:0xb01f150c @errors={"instructor"=>["not be blank"]}, @base=#<Conversation id: "3e7f4481-e96b-012d-7fdc-042b2b5ce4fb", state: 10, tag: "20101214-2-00022", title: "死亡索赔", aim: 1, emergency: 1, security: 1, kind_id: 1, content: "当事人利爱琼称有29人来我厂索赔,事�...", record_id: nil, district: "440310008000", ownerdistrict: "440310008000", sub_kind_id: 199, place: "坑梓", source: 3, reportor_id: "3e7f4480-e96b-012d-7fdc-042b2b5ce4fb", reported_at: "2010-12-14 12:46:00", levels: 2, finishdate: "2011-01-27 00:00:00", advice: "请司法所处理,并将处理结果于15个工作...", remark: nil, flag: 1, creator_id: "57ec3557-c4dc-4ac8-87a6-a13ad4104686", modifier_id: "57ec3557-c4dc-4ac8-87a6-a13ad4104686", dispatched_at: "2010-12-16 18:29:35", finished_at: nil, created_at: "2010-12-14 12:47:57", updated_at: "2010-12-31 17:59:31", count: nil, grid_id: nil, building_id: nil, warndate: "2011-01-25 00:00:00", dealdistrict: "440310008000", instruct: "同意拟办意见."
@liwh
liwh / gist:764574
Created January 4, 2011 09:18
valid? 方法会清空errors
>> c.errors.add_on_blank('instructor','not be blank')
=> ["instructor"]
>> c.errors
=> #<ActiveRecord::Errors:0xb01f150c @errors={"instructor"=>["not be blank"]}, @base=#<Conversation id: "3e7f4481-e96b-012d-7fdc-042b2b5ce4fb", state: 10, tag: "20101214-2-00022", title: "死亡索赔", aim: 1, emergency: 1, security: 1, kind_id: 1, content: "当事人利爱琼称有29人来我厂索赔,事�...", record_id: nil, district: "440310008000", ownerdistrict: "440310008000", sub_kind_id: 199, place: "坑梓", source: 3, reportor_id: "3e7f4480-e96b-012d-7fdc-042b2b5ce4fb", reported_at: "2010-12-14 12:46:00", levels: 2, finishdate: "2011-01-27 00:00:00", advice: "请司法所处理,并将处理结果于15个工作...", remark: nil, flag: 1, creator_id: "57ec3557-c4dc-4ac8-87a6-a13ad4104686", modifier_id: "57ec3557-c4dc-4ac8-87a6-a13ad4104686", dispatched_at: "2010-12-16 18:29:35", finished_at: nil, created_at: "2010-12-14 12:47:57", updated_at: "2010-12-31 17:59:31", count: nil, grid_id: nil, building_id: nil, warndate: "2011-01-25 00:00:00", dealdistrict: "440310008000", instruct: "同意拟办意见."
jQuery
1.特点:
小巧
功能强
跨浏览器
插件
2.使用
实际是js文件
a) 复制js到WebRoot
当使用mysql,我们利用actasferret作全文检索的时候,会发现有时候,我们重建索引会失效,查看日志会发现
using mysql specific batched find :all. Turn off with :mysql_fast_batches => false if you encounter problems (i.e. because of non-integer UUIDs in the id column) 的时候,这时候,我们需要将:mysql_fast_batches => false加到模型的acts_as_ferret中去。
@liwh
liwh / gist:779026
Created January 14, 2011 02:02
going crazy wit proc
http://iain.nl/2010/02/going-crazy-with-to_proc/
>> c.errors.add_on_blank('instructor','not be blank')
=> ["instructor"]
>> c.errors
=> #<ActiveRecord::Errors:0xb01f150c @errors={"instructor"=>["not be blank"]}, @base=#<Conversation id: "3e7f4481-e96b-012d-7fdc-042b2b5ce4fb", state: 10, tag: "20101214-2-00022", title: "死亡索赔", aim: 1, emergency: 1, security: 1, kind_id: 1, content: "当事人利爱琼称有29人来我厂索赔,事�...", record_id: nil, district: "440310008000", ownerdistrict: "440310008000", sub_kind_id: 199, place: "坑梓", source: 3, reportor_id: "3e7f4480-e96b-012d-7fdc-042b2b5ce4fb", reported_at: "2010-12-14 12:46:00", levels: 2, finishdate: "2011-01-27 00:00:00", advice: "请司法所处理,并将处理结果于15个工作...", remark: nil, flag: 1, creator_id: "57ec3557-c4dc-4ac8-87a6-a13ad4104686", modifier_id: "57ec3557-c4dc-4ac8-87a6-a13ad4104686", dispatched_at: "2010-12-16 18:29:35", finished_at: nil, created_at: "2010-12-14 12:47:57", updated_at: "2010-12-31 17:59:31", count: nil, grid_id: nil, building_id: nil, warndate: "2011-01-25 00:00:00", dealdistrict: "440310008000", instruct: "同意拟办意见."