This file contains hidden or 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
SECTION1 - Rails | |
1.Enumerable inject用法:User.limit(2).inject({}) {|h, u| h[u.id]=u.email;h} #return {1=>"[email protected]", 2=>"[email protected]"}; | |
2.查看所有precompile的assets文件 y Rails.application.config.assets.paths | |
3..gitignore没有作用的解决方法 | |
git rm . -r --cached | |
git add . | |
git commit -m "fixed untracked files" | |
4.install fish shell on ubuntu | |
#install fish shell | |
sudo apt-add-repository ppa:fish-shell/release-2 |
This file contains hidden or 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
// get chart object in javascript | |
var chart = $("#chart_container_id").highcharts(); | |
// fire click event of first point | |
chart.series[0].data[0].firePointEvent('click'); |
This file contains hidden or 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.cap staging deploy -s branch=1626d55d3da9 | |
2.cap staging deploy:rollback #rollback to the previous version | |
3.添加新的任务-显示服务器当前的代码版本号。在config/deploy.rb文件添加如下代码 | |
namespace :deploy do | |
desc 'Show deployed version' | |
task :revision do | |
on roles(:app) do | |
execute "echo current version is------------------" | |
execute "cat #{current_path}/REVISION" | |
execute "echo end----------------" |
This file contains hidden or 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
def run_in_browser(js, html) | |
jsfile = Tempfile.new(['js', '.js']) | |
jsfile.write(js) | |
jsfile.close | |
htmlfile = Tempfile.new(['test', '.html']) | |
htmlfile.write(html) | |
htmlfile.close | |
Phantomjs.run(jsfile.path, htmlfile.path) |
This file contains hidden or 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
TODO List | |
2014-10-12 13:04:37 ---------------------------------------- | |
[_] 50% About vimoutliner | |
[X] Learn vimoutliner | |
[_] Content code issue of vimoutliner when use otl2html.py | |
NEXT ACTIONS | |
[_] 16%Lenrn rails | |
[X] Try swaggerui gem | |
[_] Learn docker-http://blog.gemnasium.com/post/65599561888/rails-meets-docker | |
[_] Learn chef http://learn.getchef.com/ |
This file contains hidden or 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
# return boolean but not MatchData | |
!!website.match(Regexp.new(sites)) |
This file contains hidden or 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
params.require(:article).permit(:title, :content, :description, :images_attributes => [:title, :image]) |
This file contains hidden or 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
Image.where("image is not ?", nil).each do |image| image.image.recreate_versions! if image.image? end |
This file contains hidden or 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
#create capistrano task to run rake task of rails | |
# add below code to deploy.rb | |
desc "recreate version of all images." | |
task :recreate_version_of_images do | |
on roles(:app) do | |
within "#{current_path}" do | |
with rails_env: :production do | |
execute :rake, "images:recreate_version" | |
end | |
end |
This file contains hidden or 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
a.sort # sort by asc | |
a.sort { |x,y| y <=> x } # sort by desc |