问:
Issue deploying rails app on heroku
I am new to rails and I was to work on a code. The website works perfect on my local but when deploying remotely on heroku, the css files seem not found.

I am running the app with ruby 2.4, Rails 5.0 and gemfile

```<code>source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
gem 'autoprefixer-rails'
gem 'font-awesome-rails', '~> 4.6', '>= 4.6.3.1'
gem 'animate-rails', '~> 1.0', '>= 1.0.10'
gem 'owlcarousel-rails', '~> 1.1', '>= 1.1.3.3'
gem 'wow-rails', '~> 0.0.1'
gem 'magnific-popup-rails', '~> 1.1'
gem 'google-api-client', '~> 0.12.0'
gem 'figaro'
# cron task
gem 'whenever', require: false
# Authentication
gem 'devise'
gem 'cancancan', '~> 1.15'
# serach and autocompletion
gem 'pg_search'
# mailer dev
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.3'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails', '~> 5.0'
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
#gem 'capistrano3-puma', github: "seuros/capistrano-puma"

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  # Use Capistrano for deployment
  gem 'capistrano'
  gem 'capistrano-rails'
  gem 'capistrano-rvm'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

ruby "2.4.1"
</code>```

Here's the log via the command heroku log --tail

```<code>2017-11-16T16:07:52.898937+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 6818 -e production`
2017-11-16T16:07:58.371812+00:00 app[web.1]: => Booting Puma
2017-11-16T16:07:58.371821+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:6818
2017-11-16T16:07:58.371822+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:07:58.371822+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:07:58.371827+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:07:58.371828+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:07:58.371828+00:00 app[web.1]: * Environment: production
2017-11-16T16:07:58.371978+00:00 app[web.1]: * Listening on tcp://0.0.0.0:6818
2017-11-16T16:07:58.372379+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:07:58.939021+00:00 heroku[web.1]: State changed from starting to up
2017-11-16T16:07:59.757157+00:00 app[web.1]: I, [2017-11-16T16:07:59.757044 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Started GET "/" for 80.12.27.252 at 2017-11-16 16:07:59 +0000
2017-11-16T16:07:59.766621+00:00 app[web.1]: I, [2017-11-16T16:07:59.766547 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendering pages/index.html.erb within layouts/application
2017-11-16T16:07:59.763739+00:00 app[web.1]: I, [2017-11-16T16:07:59.763642 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Processing by PagesController#index as HTML
2017-11-16T16:07:59.767481+00:00 app[web.1]: I, [2017-11-16T16:07:59.767416 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered pages/index.html.erb within layouts/application (0.7ms)
2017-11-16T16:07:59.936841+00:00 app[web.1]: I, [2017-11-16T16:07:59.936713 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered layouts/_nav.html.erb (0.4ms)
2017-11-16T16:07:59.941558+00:00 app[web.1]: I, [2017-11-16T16:07:59.941458 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered layouts/_footer.html.erb (4.1ms)
2017-11-16T16:07:59.941919+00:00 app[web.1]: I, [2017-11-16T16:07:59.941858 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Completed 200 OK in 178ms (Views: 177.2ms)
2017-11-16T16:07:59.942814+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-crag-68857.herokuapp.com request_id=b03307de-5170-474a-9f27-50cd05bf07a3 fwd="80.12.27.252" dyno=web.1 connect=0ms service=190ms status=200 bytes=14894 protocol=https
2017-11-16T16:08:00.224613+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=d2c6dfd6-4660-4844-9d44-143e3d21b917 fwd="80.12.27.252" dyno=web.1 connect=5ms service=10ms status=200 bytes=290 protocol=https
2017-11-16T16:08:00.469689+00:00 heroku[router]: at=info method=GET path="/assets/fondation_pierre_fabre.png" host=mysterious-crag-68857.herokuapp.com request_id=c7adcbdd-8478-4916-9aff-0a90a52058bc fwd="80.12.27.252" dyno=web.1 connect=0ms service=8ms status=200 bytes=3889 protocol=https
2017-11-16T16:08:00.354457+00:00 heroku[router]: at=info method=GET path="/assets/logo2.png" host=mysterious-crag-68857.herokuapp.com request_id=720bf865-6dc4-401f-aac2-bf8eb96c5e90 fwd="80.12.27.252" dyno=web.1 connect=0ms service=5ms status=200 bytes=15746 protocol=https
2017-11-16T16:08:00.331984+00:00 heroku[router]: at=info method=GET path="/assets/application-7a19b05aebcc1264ba7bc75e8a9ab79af4669370f312952095c90b8160480841.js" host=mysterious-crag-68857.herokuapp.com request_id=c58820a6-ce78-43d8-b9da-f188ab36a9d4 fwd="80.12.27.252" dyno=web.1 connect=0ms service=3ms status=200 bytes=303 protocol=https
2017-11-16T16:08:00.351225+00:00 app[web.1]: I, [2017-11-16T16:08:00.351111 #4]  INFO -- : [720bf865-6dc4-401f-aac2-bf8eb96c5e90] Started GET "/assets/logo2.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.464437+00:00 app[web.1]: I, [2017-11-16T16:08:00.464337 #4]  INFO -- : [62f2a2a3-392b-446d-be9b-a32e38f68397] Started GET "/assets/single_folio/featured1.jpg" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.465587+00:00 app[web.1]: I, [2017-11-16T16:08:00.464658 #4]  INFO -- : [c7adcbdd-8478-4916-9aff-0a90a52058bc] Started GET "/assets/fondation_pierre_fabre.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.582164+00:00 app[web.1]: I, [2017-11-16T16:08:00.582059 #4]  INFO -- : [2c5ed467-5129-4e52-9794-c22a611efaec] Started GET "/assets/logo_altran.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.480539+00:00 heroku[router]: at=info method=GET path="/assets/single_folio/featured1.jpg" host=mysterious-crag-68857.herokuapp.com request_id=62f2a2a3-392b-446d-be9b-a32e38f68397 fwd="80.12.27.252" dyno=web.1 connect=1ms service=19ms status=200 bytes=230727 protocol=https
2017-11-16T16:08:00.628238+00:00 heroku[router]: at=info method=GET path="/assets/home/build.jpg" host=mysterious-crag-68857.herokuapp.com request_id=f9d88aa4-d176-4190-8ad7-08f15cffc6fd fwd="80.12.27.252" dyno=web.1 connect=0ms service=7ms status=200 bytes=19242 protocol=https
2017-11-16T16:08:00.584670+00:00 heroku[router]: at=info method=GET path="/assets/logo_altran.png" host=mysterious-crag-68857.herokuapp.com request_id=2c5ed467-5129-4e52-9794-c22a611efaec fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=8918 protocol=https
2017-11-16T16:08:00.623571+00:00 app[web.1]: I, [2017-11-16T16:08:00.623424 #4]  INFO -- : [f9d88aa4-d176-4190-8ad7-08f15cffc6fd] Started GET "/assets/home/build.jpg" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:01.911423+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-crag-68857.herokuapp.com request_id=69791277-1eb3-4067-a23a-51987305595b fwd="80.12.27.252" dyno=web.1 connect=1ms service=1ms status=200 bytes=180 protocol=https
2017-11-16T16:08:04.306986+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=9d090e84-2bfe-49d8-afe1-7a5769d84497 fwd="80.12.27.252" dyno=web.1 connect=1ms service=5ms status=304 bytes=48 protocol=https
2017-11-16T16:12:50.000000+00:00 app[api]: Build started by user benchoufi.mehdi@gmail.com
2017-11-16T16:13:08.103929+00:00 heroku[web.1]: Restarting
2017-11-16T16:13:08.116568+00:00 heroku[web.1]: State changed from up to starting
2017-11-16T16:13:07.390096+00:00 app[api]: Release v7 created by user benchoufi.mehdi@gmail.com
2017-11-16T16:13:07.390096+00:00 app[api]: Deploy 99038abe by user benchoufi.mehdi@gmail.com
2017-11-16T16:12:50.000000+00:00 app[api]: Build succeeded
2017-11-16T16:13:08.751218+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-11-16T16:13:08.761369+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-11-16T16:13:08.788899+00:00 app[web.1]: Exiting
2017-11-16T16:13:08.789433+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:395:in `close': stream closed (IOError)
2017-11-16T16:13:08.789487+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:398:in `handle_servers'
2017-11-16T16:13:08.789453+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:395:in `ensure in handle_servers'
2017-11-16T16:13:08.789489+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:327:in `block in run'
2017-11-16T16:13:08.907475+00:00 heroku[web.1]: Process exited with status 1
2017-11-16T16:13:13.745852+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 5997 -e production`
2017-11-16T16:13:22.652430+00:00 heroku[web.1]: State changed from starting to up
2017-11-16T16:13:22.424108+00:00 app[web.1]: => Booting Puma
2017-11-16T16:13:22.424142+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:5997
2017-11-16T16:13:22.424145+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:13:22.424195+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:13:22.424286+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:13:22.424247+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:13:22.424352+00:00 app[web.1]: * Environment: production
2017-11-16T16:13:22.424528+00:00 app[web.1]: * Listening on tcp://0.0.0.0:5997
2017-11-16T16:13:22.425055+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:13:57.966340+00:00 app[web.1]: I, [2017-11-16T16:13:57.966187 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Started GET "/" for 80.12.27.252 at 2017-11-16 16:13:57 +0000
2017-11-16T16:13:58.001708+00:00 app[web.1]: I, [2017-11-16T16:13:58.001639 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered pages/index.html.erb within layouts/application (0.9ms)
2017-11-16T16:13:57.996269+00:00 app[web.1]: I, [2017-11-16T16:13:57.996152 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Processing by PagesController#index as HTML
2017-11-16T16:13:58.000897+00:00 app[web.1]: I, [2017-11-16T16:13:58.000568 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendering pages/index.html.erb within layouts/application
2017-11-16T16:13:58.296994+00:00 app[web.1]: I, [2017-11-16T16:13:58.296906 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Completed 200 OK in 301ms (Views: 299.3ms)
2017-11-16T16:13:58.286219+00:00 app[web.1]: I, [2017-11-16T16:13:58.286073 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered layouts/_nav.html.erb (0.7ms)
2017-11-16T16:13:58.296500+00:00 app[web.1]: I, [2017-11-16T16:13:58.296376 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered layouts/_footer.html.erb (9.3ms)
2017-11-16T16:13:58.290239+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-crag-68857.herokuapp.com request_id=e8dd584a-d608-4421-ac81-44cd455ed936 fwd="80.12.27.252" dyno=web.1 connect=0ms service=348ms status=200 bytes=14894 protocol=https
2017-11-16T16:13:58.571091+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=92a4edc0-7f6f-4317-b7b8-7ea7e202aff4 fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=290 protocol=https
2017-11-16T16:13:58.704480+00:00 heroku[router]: at=info method=GET path="/assets/application-7a19b05aebcc1264ba7bc75e8a9ab79af4669370f312952095c90b8160480841.js" host=mysterious-crag-68857.herokuapp.com request_id=db83d660-cedf-4642-972c-1d2b4e08d156 fwd="80.12.27.252" dyno=web.1 connect=0ms service=3ms status=200 bytes=303 protocol=https
2017-11-16T16:13:58.832979+00:00 heroku[router]: at=info method=GET path="/assets/logo2.png" host=mysterious-crag-68857.herokuapp.com request_id=16ea7daf-d704-43f0-a8ce-91243a15b8f3 fwd="80.12.27.252" dyno=web.1 connect=0ms service=26ms status=200 bytes=15746 protocol=https
2017-11-16T16:13:58.817763+00:00 app[web.1]: I, [2017-11-16T16:13:58.817635 #4]  INFO -- : [16ea7daf-d704-43f0-a8ce-91243a15b8f3] Started GET "/assets/logo2.png" for 80.12.27.252 at 2017-11-16 16:13:58 +0000
2017-11-16T16:13:59.035120+00:00 app[web.1]: I, [2017-11-16T16:13:59.035020 #4]  INFO -- : [7191af72-e7a6-4c9f-b34d-f866349e19fe] Started GET "/assets/single_folio/featured1.jpg" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.038959+00:00 heroku[router]: at=info method=GET path="/assets/single_folio/featured1.jpg" host=mysterious-crag-68857.herokuapp.com request_id=7191af72-e7a6-4c9f-b34d-f866349e19fe fwd="80.12.27.252" dyno=web.1 connect=0ms service=18ms status=200 bytes=230727 protocol=https
2017-11-16T16:13:59.146207+00:00 heroku[router]: at=info method=GET path="/assets/fondation_pierre_fabre.png" host=mysterious-crag-68857.herokuapp.com request_id=f54b3701-44ae-4d9c-b76a-200a5be5f4f7 fwd="80.12.27.252" dyno=web.1 connect=0ms service=18ms status=200 bytes=3889 protocol=https
2017-11-16T16:13:59.137862+00:00 app[web.1]: I, [2017-11-16T16:13:59.137756 #4]  INFO -- : [b5620bf1-cd26-430e-bdc4-4b18d283d602] Started GET "/assets/logo_altran.png" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.152893+00:00 app[web.1]: I, [2017-11-16T16:13:59.152788 #4]  INFO -- : [f54b3701-44ae-4d9c-b76a-200a5be5f4f7] Started GET "/assets/fondation_pierre_fabre.png" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.158096+00:00 app[web.1]: I, [2017-11-16T16:13:59.158011 #4]  INFO -- : [19624a74-80a0-4796-b349-47e1a359291a] Started GET "/assets/home/build.jpg" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.161169+00:00 heroku[router]: at=info method=GET path="/assets/logo_altran.png" host=mysterious-crag-68857.herokuapp.com request_id=b5620bf1-cd26-430e-bdc4-4b18d283d602 fwd="80.12.27.252" dyno=web.1 connect=0ms service=34ms status=200 bytes=8918 protocol=https
2017-11-16T16:13:59.176271+00:00 heroku[router]: at=info method=GET path="/assets/home/build.jpg" host=mysterious-crag-68857.herokuapp.com request_id=19624a74-80a0-4796-b349-47e1a359291a fwd="80.12.27.252" dyno=web.1 connect=0ms service=43ms status=200 bytes=19242 protocol=https
2017-11-16T16:14:00.250138+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-crag-68857.herokuapp.com request_id=8f82cf74-f19c-4fd8-af88-aaa76fba7f60 fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=180 protocol=https
2017-11-16T16:38:30.000000+00:00 app[api]: Build started by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:47.990291+00:00 app[api]: Deploy 504623ba by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:47.990291+00:00 app[api]: Release v8 created by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:30.000000+00:00 app[api]: Build succeeded
2017-11-16T16:38:49.057909+00:00 heroku[web.1]: State changed from up to starting
2017-11-16T16:38:49.057351+00:00 heroku[web.1]: Restarting
2017-11-16T16:38:50.018531+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-11-16T16:38:50.030701+00:00 app[web.1]: === puma shutdown: 2017-11-16 16:38:50 +0000 ===
2017-11-16T16:38:50.030736+00:00 app[web.1]: - Goodbye!
2017-11-16T16:38:50.030914+00:00 app[web.1]: Exiting
2017-11-16T16:38:50.172254+00:00 heroku[web.1]: Process exited with status 143
2017-11-16T16:38:50.003821+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-11-16T16:38:52.617190+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 3626 -e production`
2017-11-16T16:38:56.842223+00:00 app[web.1]: => Booting Puma
2017-11-16T16:38:56.842258+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:3626
2017-11-16T16:38:56.842260+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:38:56.842261+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:38:56.842261+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:38:56.842267+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:38:56.842268+00:00 app[web.1]: * Environment: production
2017-11-16T16:38:56.842314+00:00 app[web.1]: * Listening on tcp://0.0.0.0:3626
2017-11-16T16:38:56.842706+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:38:56.991984+00:00 heroku[web.1]: State changed from starting to up
</code>```

besides, here's the content of the application.css.scss

```<code>*= require animate
*= require jquery-ui
*= require owl.carousel
*= require owl.theme
*= require magnific-popup
*= require_self
*= require_tree .
*/
@import "bootstrap";
@import "bootstrap-sprockets";
@import "font-awesome";
</code>```

答:
When you're running app on heroku you need to precompile your assets

Do the following:
In development.rb file put the below line:

config.assets.debug = false

and then run

RAILS_ENV=production bundle exec rake assets:precompile

Title: Issue deploying rails app on heroku

Body:
I am new to rails and I was to work on a code. The website works perfect on my local but when deploying remotely on heroku, the css files seem not found.

I am running the app with ruby 2.4, Rails 5.0 and gemfile

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
gem 'autoprefixer-rails'
gem 'font-awesome-rails', '~> 4.6', '>= 4.6.3.1'
gem 'animate-rails', '~> 1.0', '>= 1.0.10'
gem 'owlcarousel-rails', '~> 1.1', '>= 1.1.3.3'
gem 'wow-rails', '~> 0.0.1'
gem 'magnific-popup-rails', '~> 1.1'
gem 'google-api-client', '~> 0.12.0'
gem 'figaro'
# cron task
gem 'whenever', require: false
# Authentication
gem 'devise'
gem 'cancancan', '~> 1.15'
# serach and autocompletion
gem 'pg_search'
# mailer dev
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.3'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails', '~> 5.0'
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
#gem 'capistrano3-puma', github: "seuros/capistrano-puma"

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  # Use Capistrano for deployment
  gem 'capistrano'
  gem 'capistrano-rails'
  gem 'capistrano-rvm'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

ruby "2.4.1"

Here's the log via the command heroku log --tail

2017-11-16T16:07:52.898937+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 6818 -e production`
2017-11-16T16:07:58.371812+00:00 app[web.1]: => Booting Puma
2017-11-16T16:07:58.371821+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:6818
2017-11-16T16:07:58.371822+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:07:58.371822+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:07:58.371827+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:07:58.371828+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:07:58.371828+00:00 app[web.1]: * Environment: production
2017-11-16T16:07:58.371978+00:00 app[web.1]: * Listening on tcp://0.0.0.0:6818
2017-11-16T16:07:58.372379+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:07:58.939021+00:00 heroku[web.1]: State changed from starting to up
2017-11-16T16:07:59.757157+00:00 app[web.1]: I, [2017-11-16T16:07:59.757044 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Started GET "/" for 80.12.27.252 at 2017-11-16 16:07:59 +0000
2017-11-16T16:07:59.766621+00:00 app[web.1]: I, [2017-11-16T16:07:59.766547 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendering pages/index.html.erb within layouts/application
2017-11-16T16:07:59.763739+00:00 app[web.1]: I, [2017-11-16T16:07:59.763642 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Processing by PagesController#index as HTML
2017-11-16T16:07:59.767481+00:00 app[web.1]: I, [2017-11-16T16:07:59.767416 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered pages/index.html.erb within layouts/application (0.7ms)
2017-11-16T16:07:59.936841+00:00 app[web.1]: I, [2017-11-16T16:07:59.936713 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered layouts/_nav.html.erb (0.4ms)
2017-11-16T16:07:59.941558+00:00 app[web.1]: I, [2017-11-16T16:07:59.941458 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3]   Rendered layouts/_footer.html.erb (4.1ms)
2017-11-16T16:07:59.941919+00:00 app[web.1]: I, [2017-11-16T16:07:59.941858 #4]  INFO -- : [b03307de-5170-474a-9f27-50cd05bf07a3] Completed 200 OK in 178ms (Views: 177.2ms)
2017-11-16T16:07:59.942814+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-crag-68857.herokuapp.com request_id=b03307de-5170-474a-9f27-50cd05bf07a3 fwd="80.12.27.252" dyno=web.1 connect=0ms service=190ms status=200 bytes=14894 protocol=https
2017-11-16T16:08:00.224613+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=d2c6dfd6-4660-4844-9d44-143e3d21b917 fwd="80.12.27.252" dyno=web.1 connect=5ms service=10ms status=200 bytes=290 protocol=https
2017-11-16T16:08:00.469689+00:00 heroku[router]: at=info method=GET path="/assets/fondation_pierre_fabre.png" host=mysterious-crag-68857.herokuapp.com request_id=c7adcbdd-8478-4916-9aff-0a90a52058bc fwd="80.12.27.252" dyno=web.1 connect=0ms service=8ms status=200 bytes=3889 protocol=https
2017-11-16T16:08:00.354457+00:00 heroku[router]: at=info method=GET path="/assets/logo2.png" host=mysterious-crag-68857.herokuapp.com request_id=720bf865-6dc4-401f-aac2-bf8eb96c5e90 fwd="80.12.27.252" dyno=web.1 connect=0ms service=5ms status=200 bytes=15746 protocol=https
2017-11-16T16:08:00.331984+00:00 heroku[router]: at=info method=GET path="/assets/application-7a19b05aebcc1264ba7bc75e8a9ab79af4669370f312952095c90b8160480841.js" host=mysterious-crag-68857.herokuapp.com request_id=c58820a6-ce78-43d8-b9da-f188ab36a9d4 fwd="80.12.27.252" dyno=web.1 connect=0ms service=3ms status=200 bytes=303 protocol=https
2017-11-16T16:08:00.351225+00:00 app[web.1]: I, [2017-11-16T16:08:00.351111 #4]  INFO -- : [720bf865-6dc4-401f-aac2-bf8eb96c5e90] Started GET "/assets/logo2.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.464437+00:00 app[web.1]: I, [2017-11-16T16:08:00.464337 #4]  INFO -- : [62f2a2a3-392b-446d-be9b-a32e38f68397] Started GET "/assets/single_folio/featured1.jpg" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.465587+00:00 app[web.1]: I, [2017-11-16T16:08:00.464658 #4]  INFO -- : [c7adcbdd-8478-4916-9aff-0a90a52058bc] Started GET "/assets/fondation_pierre_fabre.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.582164+00:00 app[web.1]: I, [2017-11-16T16:08:00.582059 #4]  INFO -- : [2c5ed467-5129-4e52-9794-c22a611efaec] Started GET "/assets/logo_altran.png" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:00.480539+00:00 heroku[router]: at=info method=GET path="/assets/single_folio/featured1.jpg" host=mysterious-crag-68857.herokuapp.com request_id=62f2a2a3-392b-446d-be9b-a32e38f68397 fwd="80.12.27.252" dyno=web.1 connect=1ms service=19ms status=200 bytes=230727 protocol=https
2017-11-16T16:08:00.628238+00:00 heroku[router]: at=info method=GET path="/assets/home/build.jpg" host=mysterious-crag-68857.herokuapp.com request_id=f9d88aa4-d176-4190-8ad7-08f15cffc6fd fwd="80.12.27.252" dyno=web.1 connect=0ms service=7ms status=200 bytes=19242 protocol=https
2017-11-16T16:08:00.584670+00:00 heroku[router]: at=info method=GET path="/assets/logo_altran.png" host=mysterious-crag-68857.herokuapp.com request_id=2c5ed467-5129-4e52-9794-c22a611efaec fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=8918 protocol=https
2017-11-16T16:08:00.623571+00:00 app[web.1]: I, [2017-11-16T16:08:00.623424 #4]  INFO -- : [f9d88aa4-d176-4190-8ad7-08f15cffc6fd] Started GET "/assets/home/build.jpg" for 80.12.27.252 at 2017-11-16 16:08:00 +0000
2017-11-16T16:08:01.911423+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-crag-68857.herokuapp.com request_id=69791277-1eb3-4067-a23a-51987305595b fwd="80.12.27.252" dyno=web.1 connect=1ms service=1ms status=200 bytes=180 protocol=https
2017-11-16T16:08:04.306986+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=9d090e84-2bfe-49d8-afe1-7a5769d84497 fwd="80.12.27.252" dyno=web.1 connect=1ms service=5ms status=304 bytes=48 protocol=https
2017-11-16T16:12:50.000000+00:00 app[api]: Build started by user benchoufi.mehdi@gmail.com
2017-11-16T16:13:08.103929+00:00 heroku[web.1]: Restarting
2017-11-16T16:13:08.116568+00:00 heroku[web.1]: State changed from up to starting
2017-11-16T16:13:07.390096+00:00 app[api]: Release v7 created by user benchoufi.mehdi@gmail.com
2017-11-16T16:13:07.390096+00:00 app[api]: Deploy 99038abe by user benchoufi.mehdi@gmail.com
2017-11-16T16:12:50.000000+00:00 app[api]: Build succeeded
2017-11-16T16:13:08.751218+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-11-16T16:13:08.761369+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-11-16T16:13:08.788899+00:00 app[web.1]: Exiting
2017-11-16T16:13:08.789433+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:395:in `close': stream closed (IOError)
2017-11-16T16:13:08.789487+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:398:in `handle_servers'
2017-11-16T16:13:08.789453+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:395:in `ensure in handle_servers'
2017-11-16T16:13:08.789489+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.4.0/gems/puma-3.10.0/lib/puma/server.rb:327:in `block in run'
2017-11-16T16:13:08.907475+00:00 heroku[web.1]: Process exited with status 1
2017-11-16T16:13:13.745852+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 5997 -e production`
2017-11-16T16:13:22.652430+00:00 heroku[web.1]: State changed from starting to up
2017-11-16T16:13:22.424108+00:00 app[web.1]: => Booting Puma
2017-11-16T16:13:22.424142+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:5997
2017-11-16T16:13:22.424145+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:13:22.424195+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:13:22.424286+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:13:22.424247+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:13:22.424352+00:00 app[web.1]: * Environment: production
2017-11-16T16:13:22.424528+00:00 app[web.1]: * Listening on tcp://0.0.0.0:5997
2017-11-16T16:13:22.425055+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:13:57.966340+00:00 app[web.1]: I, [2017-11-16T16:13:57.966187 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Started GET "/" for 80.12.27.252 at 2017-11-16 16:13:57 +0000
2017-11-16T16:13:58.001708+00:00 app[web.1]: I, [2017-11-16T16:13:58.001639 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered pages/index.html.erb within layouts/application (0.9ms)
2017-11-16T16:13:57.996269+00:00 app[web.1]: I, [2017-11-16T16:13:57.996152 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Processing by PagesController#index as HTML
2017-11-16T16:13:58.000897+00:00 app[web.1]: I, [2017-11-16T16:13:58.000568 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendering pages/index.html.erb within layouts/application
2017-11-16T16:13:58.296994+00:00 app[web.1]: I, [2017-11-16T16:13:58.296906 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936] Completed 200 OK in 301ms (Views: 299.3ms)
2017-11-16T16:13:58.286219+00:00 app[web.1]: I, [2017-11-16T16:13:58.286073 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered layouts/_nav.html.erb (0.7ms)
2017-11-16T16:13:58.296500+00:00 app[web.1]: I, [2017-11-16T16:13:58.296376 #4]  INFO -- : [e8dd584a-d608-4421-ac81-44cd455ed936]   Rendered layouts/_footer.html.erb (9.3ms)
2017-11-16T16:13:58.290239+00:00 heroku[router]: at=info method=GET path="/" host=mysterious-crag-68857.herokuapp.com request_id=e8dd584a-d608-4421-ac81-44cd455ed936 fwd="80.12.27.252" dyno=web.1 connect=0ms service=348ms status=200 bytes=14894 protocol=https
2017-11-16T16:13:58.571091+00:00 heroku[router]: at=info method=GET path="/assets/application-cbd352f84234371962220aac536e7439e570099d31857c088b4e6d82141e9206.css" host=mysterious-crag-68857.herokuapp.com request_id=92a4edc0-7f6f-4317-b7b8-7ea7e202aff4 fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=290 protocol=https
2017-11-16T16:13:58.704480+00:00 heroku[router]: at=info method=GET path="/assets/application-7a19b05aebcc1264ba7bc75e8a9ab79af4669370f312952095c90b8160480841.js" host=mysterious-crag-68857.herokuapp.com request_id=db83d660-cedf-4642-972c-1d2b4e08d156 fwd="80.12.27.252" dyno=web.1 connect=0ms service=3ms status=200 bytes=303 protocol=https
2017-11-16T16:13:58.832979+00:00 heroku[router]: at=info method=GET path="/assets/logo2.png" host=mysterious-crag-68857.herokuapp.com request_id=16ea7daf-d704-43f0-a8ce-91243a15b8f3 fwd="80.12.27.252" dyno=web.1 connect=0ms service=26ms status=200 bytes=15746 protocol=https
2017-11-16T16:13:58.817763+00:00 app[web.1]: I, [2017-11-16T16:13:58.817635 #4]  INFO -- : [16ea7daf-d704-43f0-a8ce-91243a15b8f3] Started GET "/assets/logo2.png" for 80.12.27.252 at 2017-11-16 16:13:58 +0000
2017-11-16T16:13:59.035120+00:00 app[web.1]: I, [2017-11-16T16:13:59.035020 #4]  INFO -- : [7191af72-e7a6-4c9f-b34d-f866349e19fe] Started GET "/assets/single_folio/featured1.jpg" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.038959+00:00 heroku[router]: at=info method=GET path="/assets/single_folio/featured1.jpg" host=mysterious-crag-68857.herokuapp.com request_id=7191af72-e7a6-4c9f-b34d-f866349e19fe fwd="80.12.27.252" dyno=web.1 connect=0ms service=18ms status=200 bytes=230727 protocol=https
2017-11-16T16:13:59.146207+00:00 heroku[router]: at=info method=GET path="/assets/fondation_pierre_fabre.png" host=mysterious-crag-68857.herokuapp.com request_id=f54b3701-44ae-4d9c-b76a-200a5be5f4f7 fwd="80.12.27.252" dyno=web.1 connect=0ms service=18ms status=200 bytes=3889 protocol=https
2017-11-16T16:13:59.137862+00:00 app[web.1]: I, [2017-11-16T16:13:59.137756 #4]  INFO -- : [b5620bf1-cd26-430e-bdc4-4b18d283d602] Started GET "/assets/logo_altran.png" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.152893+00:00 app[web.1]: I, [2017-11-16T16:13:59.152788 #4]  INFO -- : [f54b3701-44ae-4d9c-b76a-200a5be5f4f7] Started GET "/assets/fondation_pierre_fabre.png" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.158096+00:00 app[web.1]: I, [2017-11-16T16:13:59.158011 #4]  INFO -- : [19624a74-80a0-4796-b349-47e1a359291a] Started GET "/assets/home/build.jpg" for 80.12.27.252 at 2017-11-16 16:13:59 +0000
2017-11-16T16:13:59.161169+00:00 heroku[router]: at=info method=GET path="/assets/logo_altran.png" host=mysterious-crag-68857.herokuapp.com request_id=b5620bf1-cd26-430e-bdc4-4b18d283d602 fwd="80.12.27.252" dyno=web.1 connect=0ms service=34ms status=200 bytes=8918 protocol=https
2017-11-16T16:13:59.176271+00:00 heroku[router]: at=info method=GET path="/assets/home/build.jpg" host=mysterious-crag-68857.herokuapp.com request_id=19624a74-80a0-4796-b349-47e1a359291a fwd="80.12.27.252" dyno=web.1 connect=0ms service=43ms status=200 bytes=19242 protocol=https
2017-11-16T16:14:00.250138+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=mysterious-crag-68857.herokuapp.com request_id=8f82cf74-f19c-4fd8-af88-aaa76fba7f60 fwd="80.12.27.252" dyno=web.1 connect=0ms service=4ms status=200 bytes=180 protocol=https
2017-11-16T16:38:30.000000+00:00 app[api]: Build started by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:47.990291+00:00 app[api]: Deploy 504623ba by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:47.990291+00:00 app[api]: Release v8 created by user benchoufi.mehdi@gmail.com
2017-11-16T16:38:30.000000+00:00 app[api]: Build succeeded
2017-11-16T16:38:49.057909+00:00 heroku[web.1]: State changed from up to starting
2017-11-16T16:38:49.057351+00:00 heroku[web.1]: Restarting
2017-11-16T16:38:50.018531+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2017-11-16T16:38:50.030701+00:00 app[web.1]: === puma shutdown: 2017-11-16 16:38:50 +0000 ===
2017-11-16T16:38:50.030736+00:00 app[web.1]: - Goodbye!
2017-11-16T16:38:50.030914+00:00 app[web.1]: Exiting
2017-11-16T16:38:50.172254+00:00 heroku[web.1]: Process exited with status 143
2017-11-16T16:38:50.003821+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-11-16T16:38:52.617190+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 3626 -e production`
2017-11-16T16:38:56.842223+00:00 app[web.1]: => Booting Puma
2017-11-16T16:38:56.842258+00:00 app[web.1]: => Rails 5.0.6 application starting in production on http://0.0.0.0:3626
2017-11-16T16:38:56.842260+00:00 app[web.1]: => Run `rails server -h` for more startup options
2017-11-16T16:38:56.842261+00:00 app[web.1]: Puma starting in single mode...
2017-11-16T16:38:56.842261+00:00 app[web.1]: * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
2017-11-16T16:38:56.842267+00:00 app[web.1]: * Min threads: 5, max threads: 5
2017-11-16T16:38:56.842268+00:00 app[web.1]: * Environment: production
2017-11-16T16:38:56.842314+00:00 app[web.1]: * Listening on tcp://0.0.0.0:3626
2017-11-16T16:38:56.842706+00:00 app[web.1]: Use Ctrl-C to stop
2017-11-16T16:38:56.991984+00:00 heroku[web.1]: State changed from starting to up

besides, here's the content of the application.css.scss

*= require animate
*= require jquery-ui
*= require owl.carousel
*= require owl.theme
*= require magnific-popup
*= require_self
*= require_tree .
*/
@import "bootstrap";
@import "bootstrap-sprockets";
@import "font-awesome";


来源: stackexchange

问:
How to convert a 2D Int array to a string
Trying to create a basic battleships game

```<code>   import java.util.*;
   import java.util.Scanner;
   public class BattleShip
   {
      Scanner input = new Scanner(System.in);
      //public static final boolean DEBUG = false;
      public static void breakln()
      {

   }

      public static void main(String[] arg)
      {
          int size = 0;
          int[][] board = new int[5][5];
         createBoard(board);
         createShip(board, 4);
         BattleShip.createBoard(board);
         BattleShip.Display_Baord(board);
         BattleShip.createShip(board, size );

      }

      public static void createBoard(int[][] board){
          for(int row=0 ; row < 5 ; row++ )
              for(int column=0 ; column < 5 ; column++ )
                  board[row][column]=-1;
      }

      public static void Display_Baord(int[][] board){
          System.out.println("\t1 \t2 \t3 \t4 \t5");
          System.out.println
</code>```

();

```<code>          for(int row=0 ; row < 5 ; row++ ){
              System.out.print((row+1)+"");
              for(int column=0 ; column < 5 ; column++ ){
                  if(board[row][column]==-1){
                      System.out.print("\t"+"~");
                  }else if(board[row][column]==0){
                      System.out.print("\t"+"*");
                  }else if(board[row][column]==1){
                      System.out.print("\t"+"X");
                  }

              }
              System.out.println();
          }

      }

      This is the method where the error is

      public static void createShip(int[][] board,int size)
      {
         if(Math.random() < 0.5)
         {
            int col = (int)(Math.random()*5);
            int row = (int)(Math.random()*7);
            for(int i = 0; i<size; i++)
            {
               board[row][col+i] = "S"; Hear is my error, i cannot have 's' as my 2d array ' board is an int
            }
         }
         else
         {
            int col = (int)(Math.random()*7);
            int row = (int)(Math.random()*5);
            for(int i = 0; i<size; i++)
            {
               board[row+i][col] = "S";    Hear is my error, it cannot be a string as 'board' is an int
            }
         }
      }
   }
</code>```

I'm just looking to find out how I can store 's' in my int 2D array Board.

答:
Instead of using "S" inside of your int array, use an int that you can extract later as a flag almost.

For example, it doesn't appear you are using negative numbers.

Instead of using "S", what about -1?

Then in your code instead of checking for "S" later on, you can check for -1 and not have to worry about converting your entire array.

ContentLicense: CC BY-SA 3.0

Body:
Trying to create a basic battleships game

   import java.util.*;
   import java.util.Scanner;
   public class BattleShip
   {
      Scanner input = new Scanner(System.in);
      //public static final boolean DEBUG = false;
      public static void breakln()
      {

   }

      public static void main(String[] arg)
      {
          int size = 0;
          int[][] board = new int[5][5];
         createBoard(board);
         createShip(board, 4);
         BattleShip.createBoard(board);
         BattleShip.Display_Baord(board);
         BattleShip.createShip(board, size );

      }

      public static void createBoard(int[][] board){
          for(int row=0 ; row < 5 ; row++ )
              for(int column=0 ; column < 5 ; column++ )
                  board[row][column]=-1;
      }

      public static void Display_Baord(int[][] board){
          System.out.println("\t1 \t2 \t3 \t4 \t5");
          System.out.println

();

          for(int row=0 ; row < 5 ; row++ ){
              System.out.print((row+1)+"");
              for(int column=0 ; column < 5 ; column++ ){
                  if(board[row][column]==-1){
                      System.out.print("\t"+"~");
                  }else if(board[row][column]==0){
                      System.out.print("\t"+"*");
                  }else if(board[row][column]==1){
                      System.out.print("\t"+"X");
                  }

              }
              System.out.println();
          }

      }

      This is the method where the error is

      public static void createShip(int[][] board,int size)
      {
         if(Math.random() < 0.5)
         {
            int col = (int)(Math.random()*5);
            int row = (int)(Math.random()*7);
            for(int i = 0; i<size; i++)
            {
               board[row][col+i] = "S"; Hear is my error, i cannot have 's' as my 2d array ' board is an int
            }
         }
         else
         {
            int col = (int)(Math.random()*7);
            int row = (int)(Math.random()*5);
            for(int i = 0; i<size; i++)
            {
               board[row+i][col] = "S";    Hear is my error, it cannot be a string as 'board' is an int
            }
         }
      }
   }

I'm just looking to find out how I can store 's' in my int 2D array Board.


问:
Makefile compiles all files even if file is not changed when .o files are placed in other floder
I am new to Makefile(Actually to programming). I had following makefile:-

```<code>$ cat Makefile
VER = Debug

main: main.o Time.o
    g++ Object\ Code/main.o Object\ Code/Time.o -o ../$(VER)/main

main.o: main.cpp
    g++ -c main.cpp -o Object\ Code/main.o

Time.o: Time.cpp Time_.h
    g++ -c Time.cpp -o Object\ Code/Time.o

clean:
    rm Object\ Code/*.o
    rm ../$(VER)/main
</code>```

makefile is in src folder

```<code>$ ls && pwd
main.cpp  Makefile  Object Code  Time.cpp  Time_.h
/home/Rahul/Devlopment/WorkSpace/Test C++/src
</code>```

Object code is a Directory in src.

```<code>$ ls ..
Debug  Release  src
</code>```

But whenver I change just one single file and try to use make it compiles all files:-

```<code>$ make
g++ -c main.cpp -o Object\ Code/main.o
g++ -c Time.cpp -o Object\ Code/Time.o
g++ Object\ Code/main.o Object\ Code/Time.o -o ../Debug/main
$ touch Time
Time.cpp     Time_.h
$ touch Time_.h
$ make
g++ -c main.cpp -o Object\ Code/main.o
g++ -c Time.cpp -o Object\ Code/Time.o
g++ Object\ Code/main.o Object\ Code/Time.o -o ../Debug/main
$ make
g++ -c main.cpp -o Object\ Code/main.o
g++ -c Time.cpp -o Object\ Code/Time.o
g++ Object\ Code/main.o Object\ Code/Time.o -o ../Debug/main
</code>```

As a complete noob I have no Idea. Please help me.

答: The file main.o is not the same file as Object\ Code/main.o, and similarly for other files, and I would strongly advise you to avoid spaces in filenames and directories when developing programs. Setting up make to use separate directories is not entirely straightforward, and you should get your makefile working off a single directory before implementing multiple directories.

Body:
I am new to Makefile(Actually to programming). I had following makefile:-

$ cat Makefile
VER = Debug

main: main.o Time.o
    g++ Object\ Code/main.o Object\ Code/Time.o -o ../$(VER)/main

main.o: main.cpp
    g++ -c main.cpp -o Object\ Code/main.o

Time.o: Time.cpp Time_.h
    g++ -c Time.cpp -o Object\ Code/Time.o

clean:
    rm Object\ Code/*.o
    rm ../$(VER)/main

makefile is in src folder

$ ls && pwd
main.cpp  Makefile  Object Code  Time.cpp  Time_.h
/home/Rahul/Devlopment/WorkSpace/Test C++/src

Object code is a Directory in src.

$ ls ..
Debug  Release  src

But whenver I change just one single file and try to use make it compiles all files:-

$ make
g++ -c main.cpp -o Object\ Code/main.o
g++ -c Time.cpp -o Object\ Code/Time.o
g++ Object\ Code/main.o Object\ Code/Time.o -o ../Debug/main
$ touch Time
Time.cpp     Time_.h
$ touch Time_.h
$ make
g++ -c main.cpp -o Object\ Code/main.o
g++ -c Time.cpp -o Object\ Code/Time.o
g++ Object\ Code/main.o Object\ Code/Time.o -o ../Debug/main
$ make
g++ -c main.cpp -o Object\ Code/main.o
g++ -c Time.cpp -o Object\ Code/Time.o
g++ Object\ Code/main.o Object\ Code/Time.o -o ../Debug/main

As a complete noob I have no Idea. Please help me.


问:
TFS build cannot publish test results if TFS server is in domain different from drop location
I have the problem with failing TFS build if my drop location is in domain different from TFS server. The error I get is

```<code>     Results file: C:\TestResults\CPU_Release.trx
     Test Settings: Default Test Settings
     Waiting to publish...
     Publishing results of test run buildAgent@computername 2011-01-03 15:31:38_Any CPU_Release to http://tfsserver:8080/...
     .....................The drop share directory "\\computername\Builds\projectName\CI_1.0.193.0" could not be accessed.
     The drop share directory "\\computername\Builds\projectName\CI_1.0.193.0" could not be accessed.
     1:6>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(1403,5): error MSB6006: "MSTest.exe" exited with code 1. [C:\Users\BuildType\TFSBuild.proj]
</code>```

How can at least I skip publishing test results? I tried to set up property

```<code><PublishTestResults>false</PublishTestResults>
</code>```

but it does not help. I use TFS server 2008.

答: This workaround finally helped me.</p>

ContentLicense: CC BY-SA 2.5

Body:
I have the problem with failing TFS build if my drop location is in domain different from TFS server. The error I get is

     Results file: C:\TestResults\CPU_Release.trx
     Test Settings: Default Test Settings
     Waiting to publish...
     Publishing results of test run buildAgent@computername 2011-01-03 15:31:38_Any CPU_Release to http://tfsserver:8080/...
     .....................The drop share directory "\\computername\Builds\projectName\CI_1.0.193.0" could not be accessed.
     The drop share directory "\\computername\Builds\projectName\CI_1.0.193.0" could not be accessed.
     1:6>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets(1403,5): error MSB6006: "MSTest.exe" exited with code 1. [C:\Users\BuildType\TFSBuild.proj]

How can at least I skip publishing test results? I tried to set up property

<PublishTestResults>false</PublishTestResults>

but it does not help. I use TFS server 2008.

Body: This workaround finally helped me.


问:
Separation of the name by the surname and initials
There is a list of names and initials, which are separated by a comma and stored in a variable called $author

Shevchuk T.I., Piskun R.P., Vasenko T.B.

It is necessary to separate the initials and surnames separately into variables.

Example of Names:

Belemets N.I. / N.I. Belemets / N. I. Belemets / Belemets N. I. / Belemets N. / N. Belemets / Nu. Belemets / Belemets Nu.

Now I try to do this as follows:

```<code>$str_arr1= explode(", ", $author);
$initials= preg_split('([A-Z]\.[A-Z]\.|[A-Z]\.\s+[A-Z]\.|[A-Z][a-z]\.)', $str_arr1);
$surnames= preg_split('\w{3,15}', $str_arr1);
</code>```

Example of print_r ($str_arr1):

```<code>Array
(
    [0] => Gunas I. V.
    [1] => Babych L. V.
    [2] => Cherkasov E. V.
)
</code>```

But $initials and $surnames do not output anything. What could be the problem? CMS MODX.

Thanks in advance!

UPD:

Now code looks like this:

```<code>$str_arr= explode(", ", $author);
foreach($str_arr as $value){
    $preinitial= preg_split('/([A-Z]\.[A-Z]\.|[A-Z]\.\s+[A-Z]\.|[A-Z][a-z]\.\s+[A-Z]\.|[A-Z][a-z]\.)/', $value, -1, PREG_SPLIT_NO_EMPTY);
    $presurname= preg_split('/\w{3,15}/', $value, -1, PREG_SPLIT_NO_EMPTY);
    $initial = implode("", $preinitial);
    $surname = implode("", $presurname);
    echo '<given_name>'.$surname.'</given_name>';
    echo '<surname>'.$initial.'</surname>';
    echo "\r\n";
}
</code>```

答:
You have a few issues with your implementation. preg_split doesn't take arrays, and requires delimiters. You also should use the PREG_SPLIT_NO_EMPTY so you don't get back empty values. Your variable names also are inverted, the split removes what is matched so $initials is really the surname, and $surnames are really the initials.

```<code>$author = 'Shevchuk T.I., Piskun R.P., Vasenko T.B.';
$str_arr1= explode(", ", $author);
foreach($str_arr1 as $str_arr) {
    $initials= preg_split('/([A-Z]\.[A-Z]\.|[A-Z]\.\s+[A-Z]\.|[A-Z][a-z]\.)/', $str_arr, -1, PREG_SPLIT_NO_EMPTY);
    $surnames= preg_split('/\w{3,15}/', $str_arr, -1, PREG_SPLIT_NO_EMPTY);
    print_r($initials);
    print_r($surnames);
}
</code>```

Demo: https://3v4l.org/1sgmX

I'd recommend this library which I've used successfully to parse full references, https://github.com/knmnyn/ParsCit. You can probably pull out the logic to just parse the authors.

The surname check with 3,15 also won't work in all cases. For example https://www.ncbi.nlm.nih.gov/pubmed/29052443, Hong Yu won't be matched because the surname is only 2 characters.

Body:
There is a list of names and initials, which are separated by a comma and stored in a variable called $author

Shevchuk T.I., Piskun R.P., Vasenko T.B.

It is necessary to separate the initials and surnames separately into variables.

Example of Names:

Belemets N.I. / N.I. Belemets / N. I. Belemets / Belemets N. I. / Belemets N. / N. Belemets / Nu. Belemets / Belemets Nu.

Now I try to do this as follows:

$str_arr1= explode(", ", $author);
$initials= preg_split('([A-Z]\.[A-Z]\.|[A-Z]\.\s+[A-Z]\.|[A-Z][a-z]\.)', $str_arr1);
$surnames= preg_split('\w{3,15}', $str_arr1);

Example of print_r ($str_arr1):

Array
(
    [0] => Gunas I. V.
    [1] => Babych L. V.
    [2] => Cherkasov E. V.
)

But $initials and $surnames do not output anything. What could be the problem? CMS MODX.

Thanks in advance!

UPD:

Now code looks like this:

$str_arr= explode(", ", $author);
foreach($str_arr as $value){
    $preinitial= preg_split('/([A-Z]\.[A-Z]\.|[A-Z]\.\s+[A-Z]\.|[A-Z][a-z]\.\s+[A-Z]\.|[A-Z][a-z]\.)/', $value, -1, PREG_SPLIT_NO_EMPTY);
    $presurname= preg_split('/\w{3,15}/', $value, -1, PREG_SPLIT_NO_EMPTY);
    $initial = implode("", $preinitial);
    $surname = implode("", $presurname);
    echo '<given_name>'.$surname.'</given_name>';
    echo '<surname>'.$initial.'</surname>';
    echo "\r\n";
}

Body:
You have a few issues with your implementation. preg_split doesn't take arrays, and requires delimiters. You also should use the PREG_SPLIT_NO_EMPTY so you don't get back empty values. Your variable names also are inverted, the split removes what is matched so $initials is really the surname, and $surnames are really the initials.

$author = 'Shevchuk T.I., Piskun R.P., Vasenko T.B.';
$str_arr1= explode(", ", $author);
foreach($str_arr1 as $str_arr) {
    $initials= preg_split('/([A-Z]\.[A-Z]\.|[A-Z]\.\s+[A-Z]\.|[A-Z][a-z]\.)/', $str_arr, -1, PREG_SPLIT_NO_EMPTY);
    $surnames= preg_split('/\w{3,15}/', $str_arr, -1, PREG_SPLIT_NO_EMPTY);
    print_r($initials);
    print_r($surnames);
}

Demo: https://3v4l.org/1sgmX

I'd recommend this library which I've used successfully to parse full references, https://github.com/knmnyn/ParsCit. You can probably pull out the logic to just parse the authors.

The surname check with 3,15 also won't work in all cases. For example https://www.ncbi.nlm.nih.gov/pubmed/29052443, Hong Yu won't be matched because the surname is only 2 characters.


问:
Multiple docker containers vs multiple ec2 instances
I have multiple microservices that I have to run independently. I am thinking of deploying them in docker containers in one ec2 instances. But then there is the question of scaling. I knowledge is ecs gives me the ability to scale. I haven't used ecs though. So my question is can I scale all my containers by creating one ec2 networks ? Or is there anything I haven't thought or know about ? Also, what is the performance issues with this deployment ?

Thanks
Amit

答:
For the microservices deployment, one ec2 instance will never suffice for production workload considering HA, scaling, performance etc.

You should think of cluster. A compute cluster is a multi-tenant computing environment consisting of servers (called “nodes”) whose resources have been pooled together and are used to execute processes. To enable this behavior, the nodes in a cluster must be managed by some sort of cluster management framework.

So you have to choose between multiple options from Kubernets, Mesos & Marathon and AWS ECS.

The EC2 Container Service is: A cluster management framework that uses optimistic, shared state scheduling to execute processes on EC2 instances using Docker containers.

The above option provides all the functionality you looking for. So you need to analyze more of them and select the most suitable option as per your need.


问:
Ansible multi hop design
I would like to run an ansible playbook on a target host passing through multiple hosts. The scenario looks similar to the one depicted in the picture:

I partially solved  issue creating the ssh_config file in the Ansible project directory:

```<code>Host IP_HostN
        HostName IP_HOST_N
        ProxyJump Username1@IP_HOST_2:22,Username2@IP_HOST_2:22
        User UsernameN
</code>```

and defining in the ansible.cfg in the Ansible project directory:

```<code>[ssh_connection]
ssh_args= -F "ssh_config"
</code>```

The problem is that I need to insert automatically for each transient hosts and target host ssh username and password and I don't know how to automate this task. Moreover, python may not be installed on every transient node.

答:
I found a reasonably good workaround. According to the scenario below:

we create an ssh tunnel until the transient host that can directly reach the target host. We also create a local port binding with -L flag:

```<code>ssh  -J user_1@transient_host1:port_1 -p port_2 user_2@transient_host2  -L LOCAL_PORT:TARGET_HOST_IP:TARGET_HOST_PORT
</code>```

Then we can directly enter into Target Host using the local binding:

```<code>ssh user_target_host@localhost -p LOCAL_PORT
</code>```

In this way, we can run ansible playbooks on the local host configuring ansible variables accordingly:

```<code>ansible_host: localhost
ansible_user: user_target_host
ansible_port: LOCAL_PORT
ansible_password: password_target_host
</code>```

Title: Ansible multi hop design

Body:
I would like to run an ansible playbook on a target host passing through multiple hosts. The scenario looks similar to the one depicted in the picture:

I partially solved  issue creating the ssh_config file in the Ansible project directory:

Host IP_HostN
        HostName IP_HOST_N
        ProxyJump Username1@IP_HOST_2:22,Username2@IP_HOST_2:22
        User UsernameN

and defining in the ansible.cfg in the Ansible project directory:

[ssh_connection]
ssh_args= -F "ssh_config"

The problem is that I need to insert automatically for each transient hosts and target host ssh username and password and I don't know how to automate this task. Moreover, python may not be installed on every transient node.

Body:
I found a reasonably good workaround. According to the scenario below:

we create an ssh tunnel until the transient host that can directly reach the target host. We also create a local port binding with -L flag:

ssh  -J user_1@transient_host1:port_1 -p port_2 user_2@transient_host2  -L LOCAL_PORT:TARGET_HOST_IP:TARGET_HOST_PORT

Then we can directly enter into Target Host using the local binding:

ssh user_target_host@localhost -p LOCAL_PORT

In this way, we can run ansible playbooks on the local host configuring ansible variables accordingly:

ansible_host: localhost
ansible_user: user_target_host
ansible_port: LOCAL_PORT
ansible_password: password_target_host


问:
Express req.body is empty when using the http.post
I do not know why the req.body is EMPTY...
app.js use the body-parser middleware(http://www.expressjs.com.cn/4x/api.html#req.body)

```<code>var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var index = require('./routes/index');
var users = require('./routes/users');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

// add baseurl
app.use('/api', index);
app.use('/api', users);
</code>```

user.js

```<code>router.route('/user')
.post(function (req, res, next) {
    console.log(req.body);
    console.log(req.headers);
    //console.log(JSON.parse(Object.keys(req.body)[0]));
    res.json({title: 'RESTful: POST...'});
});
</code>```

I have printed the headers: But the req.body is empty and I used the JSON.parse(Object.keys(req.body)[0]) to parse the result from the other similar question, but it did not work to me.
I use the postman to request the POST,

```<code>{ 'cache-control': 'no-cache',
'postman-token': 'db7766d7-767c-4d33-be3a-acfa18ac1d9c',
'content-type': 'application/x-www-form-urlencoded',
'user-agent': 'PostmanRuntime/6.4.1',
accept: '*/*',
host: 'localhost:3000',
'accept-encoding': 'gzip, deflate',
'content-length': '0',
connection: 'keep-alive' }
</code>```

postman screenshot

答:
Try this package. It is useful when you are passing form data and not in json format.

https://www.npmjs.com/package/formidable

Body:
I do not know why the req.body is EMPTY...
app.js use the body-parser middleware(http://www.expressjs.com.cn/4x/api.html#req.body)

var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var index = require('./routes/index');
var users = require('./routes/users');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

// add baseurl
app.use('/api', index);
app.use('/api', users);

user.js

router.route('/user')
.post(function (req, res, next) {
    console.log(req.body);
    console.log(req.headers);
    //console.log(JSON.parse(Object.keys(req.body)[0]));
    res.json({title: 'RESTful: POST...'});
});

I have printed the headers: But the req.body is empty and I used the JSON.parse(Object.keys(req.body)[0]) to parse the result from the other similar question, but it did not work to me.
I use the postman to request the POST,

{ 'cache-control': 'no-cache',
'postman-token': 'db7766d7-767c-4d33-be3a-acfa18ac1d9c',
'content-type': 'application/x-www-form-urlencoded',
'user-agent': 'PostmanRuntime/6.4.1',
accept: '*/*',
host: 'localhost:3000',
'accept-encoding': 'gzip, deflate',
'content-length': '0',
connection: 'keep-alive' }

postman screenshot


问:
Update Firebase local data with observeSingleEvent
so I have a function to retrieve the user information from a given user id:

```<code>func getUserDataFrom(_ userID: String, completion: @escaping (_ userData: DBUser) -> Void) {

    ref.child(usersTable).child(userID).observeSingleEvent(of: .value) { (snapshot) in

        if let userDic = snapshot.value as? NSDictionary {

            let userData = DBUser(with: userDic)

            completion(userData)

        }

    }

}
</code>```

The problem is that this returns the local data instead of reading from Firebase. I'd like to retrieve the data from the server (as long as there's internet connection) and only read from disk if it's not available.

I know that the easiest way to accomplish this would be using a listener, but I'm making a Today Extension and they use way too much memory increasing the chances of a crash.

I've also researched about keepSynced feature but since the database reference to the users table will have a lot of children I don't know if this will affect the memory of my extension.

Long story short: I'd like to read data from Firebase once, and only read from disk if there isn't internet connection with the minimum memory usage possible.

Thank you in advance.

答:
In the fresh project I created and added your code, it retrieves data from Firebase when there's a connection and when not, from local storage. Because of that, we conclude the above code is correctly fetching Firebase data from their server.

However, in my experience observeSingleEvent and offline persistence has been a tad intermittent (perhaps a 'feature'?). To fix it, force the data at the reference to stay sync'd

```<code>let usersTableRef = Database.database().reference(withPath: usersTable)
let thisUsersTableRef = usersTableRef.child(userId)
thisUsersTableRef.keepSynced(true)
//optional:  thisUsersTableRef.child("temp").setValue(true)
thisUsersTableRef.observeSingleEvent(of: .value)
</code>```

See Offline Capabilities for a bit more info and further examples.

Also see this post from 2015 for some insight on observers/listeners.

Body:
so I have a function to retrieve the user information from a given user id:

func getUserDataFrom(_ userID: String, completion: @escaping (_ userData: DBUser) -> Void) {

    ref.child(usersTable).child(userID).observeSingleEvent(of: .value) { (snapshot) in

        if let userDic = snapshot.value as? NSDictionary {

            let userData = DBUser(with: userDic)

            completion(userData)

        }

    }

}

The problem is that this returns the local data instead of reading from Firebase. I'd like to retrieve the data from the server (as long as there's internet connection) and only read from disk if it's not available.

I know that the easiest way to accomplish this would be using a listener, but I'm making a Today Extension and they use way too much memory increasing the chances of a crash.

I've also researched about keepSynced feature but since the database reference to the users table will have a lot of children I don't know if this will affect the memory of my extension.

Long story short: I'd like to read data from Firebase once, and only read from disk if there isn't internet connection with the minimum memory usage possible.

Thank you in advance.

Body:
In the fresh project I created and added your code, it retrieves data from Firebase when there's a connection and when not, from local storage. Because of that, we conclude the above code is correctly fetching Firebase data from their server.

However, in my experience observeSingleEvent and offline persistence has been a tad intermittent (perhaps a 'feature'?). To fix it, force the data at the reference to stay sync'd

let usersTableRef = Database.database().reference(withPath: usersTable)
let thisUsersTableRef = usersTableRef.child(userId)
thisUsersTableRef.keepSynced(true)
//optional:  thisUsersTableRef.child("temp").setValue(true)
thisUsersTableRef.observeSingleEvent(of: .value)

See Offline Capabilities for a bit more info and further examples.

Also see this post from 2015 for some insight on observers/listeners.


问:
Jquery UI Sortable not working in Dynamic container
I have a container where I dynamically add sections, I create items inside the section , that should be sortable, But Jquery sortable does not work inside dynamically created containers, while if I give the containers static it works,
Can anyone please share a solution.Thanks

https://jsfiddle.net/anubala/7ut5wk3j/1/

HTML:

```<code><div class='row page-layout'>
        <div class='col-md-10 col-md-offset-1' >
        <div class="add_section_div">
            <p>Add section</p>
        </div>
        <div id="contents">
        </div>
        </div>
    </div>
</code>```

JavaScript:

```<code>$(".wrap_body").sortable();
$(".add_section_div").on("click", function() {
    var $section = "<div class='section_div'><div class='div_header clearfix'><p class='pull-left'>Add Wrap</p></div><div class='section_body div_body'></div></div>";
    $("#contents").append($section);

})
$("body").on("click", ".section_div>.div_header", function() {
    var $wrap = "<div class='wrap_div'><div class='div_header clearfix'><p class='pull-left'>Add Item</p></div><div class='wrap_body div_body clearfix'></div></div>";
    $(this).parent().find('.section_body').append($wrap);
})
const regex = /^.*-\s*(.*)$/;
$("body").on("click", ".wrap_div>.div_header", function() {
    var $item1 = "<div class='drag col-sm-";
    var $item2 = "'><div class='item_div'><div class='div_header clearfix'><p class='pull-left'><span class='minus'><i class='fa fa-minus'></i></span><span class='plus'><i class='fa fa-plus'></i></span></p><p class='pull-left header_text'>";
    var $item3 = "</p></div><div class='div_body'></div></div></div>";
    var length_item = $(this).parent().find(".wrap_body .item_div").length;
    var count = 0;
    for (i = 0; i < length_item; i++) {
        if ($(this).parent().find(".wrap_body>div:eq('" + i + "')")) {
            console.log($(this).parent().find(".wrap_body>div:eq('" + i + "')"))
            var col_count_text = $(this).parent().find(".wrap_body>div:eq('" + i + "')").attr('class');
            count += parseInt(find_col_count(col_count_text));

        }
    }
    var current_col_count = 12 - (count % 12);
    if (count < 12) {
        $(this).parent().find('.wrap_body').append($item1 + current_col_count + $item2 + "col-sm-" + current_col_count + $item3);
    }
})

function find_col_count(col_text) {
    var col_count = regex.exec(col_text);
    col_count.forEach((match, groupIndex) => {
        count1 = match;
    });
    return count1;
}
$("body").on("click", ".plus", function() {
    var $parent = $(this).parent().parent().parent().parent();
    var col_count_text = $parent.attr('class');
    var length_item = $parent.parent().find(".item_div").length;
    var count = 0;
    for (i = 0; i < length_item; i++) {
        if ($parent.parent().find(".item_div:eq('" + i + "')").parent()) {
            var col_count_text = $parent.parent().find(".item_div:eq('" + i + "')").parent().attr('class');
            count += parseInt(find_col_count(col_count_text));
        }
    }
    var col_count_text = $parent.attr('class');
    var col_count = find_col_count(col_count_text);
    if (count < 12) {
        var col_count_new = "col-sm-" + (++col_count);
        var col_count_drag = "drag " + col_count_new;
        $parent.attr("class", col_count_drag);
        $parent.find(".header_text").html(col_count_new);
    }
});
$("body").on("click", ".minus", function() {
    var $parent = $(this).parent().parent().parent().parent();
    var col_count_text = $parent.attr('class');
    var col_count = find_col_count(col_count_text);
    if (col_count > 1) {
        var col_count_new = "col-sm-" + (--col_count);
        var col_count_drag = "drag " + col_count_new;
        $parent.attr("class", col_count_drag);
        $parent.find(".header_text").html(col_count_new);
    }
});
</code>```

答:
You probably may have found the solution already but to solve this issue you only need to move this line

```<code>$(".wrap_body").sortable();
</code>```

To where you actually append the .wrapper_body to the body as following:

```<code>$("body").on("click", ".section_div>.div_header", function() {
        var $wrap = "<div class='wrap_div'><div class='div_header clearfix'><p class='pull-left'>Add Item</p></div><div class='wrap_body div_body clearfix'></div></div>";
        $(this).parent().find('.section_body').append($wrap);
        $(".wrap_body").sortable();
    });
</code>```

This should solve your problem. See JsFiddle

Body:
I have a container where I dynamically add sections, I create items inside the section , that should be sortable, But Jquery sortable does not work inside dynamically created containers, while if I give the containers static it works,
Can anyone please share a solution.Thanks

https://jsfiddle.net/anubala/7ut5wk3j/1/

HTML:

Add section

JavaScript:

$(".wrap_body").sortable();
$(".add_section_div").on("click", function() {
    var $section = "

Add Wrap

";
    $("#contents").append($section);

})
$("body").on("click", ".section_div>.div_header", function() {
    var $wrap = "

Add Item

";
    $(this).parent().find('.section_body').append($wrap);
})
const regex = /^.*-\s*(.*)$/;
$("body").on("click", ".wrap_div>.div_header", function() {
    var $item1 = "

";
    var $item3 = "

";
    var length_item = $(this).parent().find(".wrap_body .item_div").length;
    var count = 0;
    for (i = 0; i < length_item; i++) {
        if ($(this).parent().find(".wrap_body>div:eq('" + i + "')")) {
            console.log($(this).parent().find(".wrap_body>div:eq('" + i + "')"))
            var col_count_text = $(this).parent().find(".wrap_body>div:eq('" + i + "')").attr('class');
            count += parseInt(find_col_count(col_count_text));

        }
    }
    var current_col_count = 12 - (count % 12);
    if (count < 12) {
        $(this).parent().find('.wrap_body').append($item1 + current_col_count + $item2 + "col-sm-" + current_col_count + $item3);
    }
})

function find_col_count(col_text) {
    var col_count = regex.exec(col_text);
    col_count.forEach((match, groupIndex) => {
        count1 = match;
    });
    return count1;
}
$("body").on("click", ".plus", function() {
    var $parent = $(this).parent().parent().parent().parent();
    var col_count_text = $parent.attr('class');
    var length_item = $parent.parent().find(".item_div").length;
    var count = 0;
    for (i = 0; i < length_item; i++) {
        if ($parent.parent().find(".item_div:eq('" + i + "')").parent()) {
            var col_count_text = $parent.parent().find(".item_div:eq('" + i + "')").parent().attr('class');
            count += parseInt(find_col_count(col_count_text));
        }
    }
    var col_count_text = $parent.attr('class');
    var col_count = find_col_count(col_count_text);
    if (count < 12) {
        var col_count_new = "col-sm-" + (++col_count);
        var col_count_drag = "drag " + col_count_new;
        $parent.attr("class", col_count_drag);
        $parent.find(".header_text").html(col_count_new);
    }
});
$("body").on("click", ".minus", function() {
    var $parent = $(this).parent().parent().parent().parent();
    var col_count_text = $parent.attr('class');
    var col_count = find_col_count(col_count_text);
    if (col_count > 1) {
        var col_count_new = "col-sm-" + (--col_count);
        var col_count_drag = "drag " + col_count_new;
        $parent.attr("class", col_count_drag);
        $parent.find(".header_text").html(col_count_new);
    }
});

Body:
You probably may have found the solution already but to solve this issue you only need to move this line

$(".wrap_body").sortable();

To where you actually append the .wrapper_body to the body as following:

$("body").on("click", ".section_div>.div_header", function() {
        var $wrap = "<div class='wrap_div'><div class='div_header clearfix'><p class='pull-left'>Add Item</p></div><div class='wrap_body div_body clearfix'></div></div>";
        $(this).parent().find('.section_body').append($wrap);
        $(".wrap_body").sortable();
    });

This should solve your problem. See JsFiddle


问:
How many levels of inheritance
Are there any best practices regarding the maximum depth of the inheritance hierarchy for a framework and guidelines when to use multiple levels of inheritance or join them in a single class?

Some references to established practices/examples that worked well in the Java world would be nice in the answers as this is from the perspective of the community and frameworks surrounding Java.

答:
The best is that each class takes care of a bunch of similar things.

Each method inside this class takes care of one action/behaviour.

Look at this refcard from DZone:
http://refcardz.dzone.com/assets/download/refcard/54c22c8b0a53591ea9e0504fdfd4bada/rc130-010d-designing-quality_0.pdf

Title: How many levels of inheritance


问:
Highstock title setting via options
I have used the same chart base to show different measurement quantities in same chart based to quantity selection. I have used Highcharts setOptions function to set the quantity specific setup, for example chart title.

Now I have faced the situation that I needs to change to the Highstock chart the title setting via setOptions function doesn't work.

Is this bug or wanted feature?

答:
Why do you need to use setOptions to change chart title? You can set all other options with setOptions function and update specific title with chart.update or chart.setTitle.

API Reference:

https://api.highcharts.com/class-reference/Highcharts.Chart.html#setTitle
https://api.highcharts.com/class-reference/Highcharts.Chart.html#update

Example:

http://jsfiddle.net/Ltjq9bbm/.

Title: Highstock title setting via options


问:
Does Field Grouping ensure strict order?
I am a beginner with Apache Storm and wondering when the order of tuples is guaranteed in a stream.
When I get this post right Processing records in order in Storm then the order between a Bolt/Spout and a other Bolt is guaranteed.

So if I have KaffkaSpout which emits Tuples which are ordered according to a timestamp and have some Bolts with field grouping according to some id.

```<code>builder.setBolt("Bolt1", bolt1).fieldsGrouping("Bolt1", new Fields("id"));
</code>```

Is it guaranteed that tuples with an id x are always processed in order for a Bolt. So Tuple1 must be processed in Bolt1 (strictly) before Tuple2 is processed in Bolt1 if they have the same id? With strictly I mean not parallel.

Is this true even when a worker node fails?

答:
That depends on your topology and where does "Bolt1" lie in the topology relative to the KafkaSpout. For e.g. consider the following 2 topology cases -

Case 1 -

builder.setSpout("KafkaSpout", Kafkaspout);

builder.setBolt("Bolt1", bolt1).fieldsGrouping("KafkaSpout", new Fields("id"));

In this case, since bolt1 is next in topology to kafkaSpout and with field grouping, all tuples with same "id" will go to the same bolt instance, it will be strict in order.
However consider the following topology

Case 2 -

builder.setSpout("KafkaSpout", Kafkaspout);

builder.setBolt("Bolt2", bolt2).shuffleGrouping("KafkaSpout");

builder.setBolt("Bolt1", bolt1).fieldsGrouping("Bolt2", new Fields("id")); //id field emitted by Bolt2

In this case, since the order is lost in Bolt2, there is no guarantee that the tuples would come to bolt 1 in the order they were pushed into Kafka partition.

In general, if you are looking for a strict ordering of processing in Storm system, it is your responsibility to keep all the components work and emit in order. But in general this would restrict you in many ways to use the full capabilities of Storm by restricting parallelism in your code and topology.

Body:
I am a beginner with Apache Storm and wondering when the order of tuples is guaranteed in a stream.
When I get this post right Processing records in order in Storm then the order between a Bolt/Spout and a other Bolt is guaranteed.

So if I have KaffkaSpout which emits Tuples which are ordered according to a timestamp and have some Bolts with field grouping according to some id.

builder.setBolt("Bolt1", bolt1).fieldsGrouping("Bolt1", new Fields("id"));

Is it guaranteed that tuples with an id x are always processed in order for a Bolt. So Tuple1 must be processed in Bolt1 (strictly) before Tuple2 is processed in Bolt1 if they have the same id? With strictly I mean not parallel.

Is this true even when a worker node fails?


问:
Passing a Variable to a system stored procedure
I am sure I am missing something simple. I am looking to map some of my data objects. I wanted to create a procedure would insert the results of sp_depends and insert data name.

Here is what I have created:

```<code>create table DatasetMapping
(
    Name nvarchar(257),
    Type nvarchar(16),
    updated nvarchar(7),
    Selected nvarchar(8),
    Column sysname
);

Insert into DatasetMapping
    exec sp_depends 'dbo.PositionReport_Quote_V3_2016'
</code>```

This works great manually.

I then created

```<code>SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Repotingdatasets]
AS
    DECLARE @object NVARCHAR(257)

    INSERT INTO DatasetMapping
        EXEC sp_epends  @objname = @object

    EXEC [dbo].[Repotingdatasets] @object =' dbo.PositionReport_Quote_V3_2016';
</code>```

but I only get an error:

Msg 8146, Level 16, State 2, Procedure Repotingdatasets, Line 0 [Batch Start Line 48]

  Procedure Repotingdatasets has no parameters and arguments were supplied

答:
You just need to change some syntax:</p>

```<code>SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create PROCEDURE [dbo].[Repotingdatasets](
@object     nvarchar(257)
)
as

Insert into DatasetMapping
exec sp_depends  @objname=@object

exec [dbo].[Repotingdatasets]  @object =' dbo.PositionReport_Quote_V3_2016';
</code>```

Body:
I am sure I am missing something simple. I am looking to map some of my data objects. I wanted to create a procedure would insert the results of sp_depends and insert data name.

Here is what I have created:

create table DatasetMapping
(
    Name nvarchar(257),
    Type nvarchar(16),
    updated nvarchar(7),
    Selected nvarchar(8),
    Column sysname
);

Insert into DatasetMapping
    exec sp_depends 'dbo.PositionReport_Quote_V3_2016'

This works great manually.

I then created

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Repotingdatasets]
AS
    DECLARE @object NVARCHAR(257)

    INSERT INTO DatasetMapping
        EXEC sp_epends  @objname = @object

    EXEC [dbo].[Repotingdatasets] @object =' dbo.PositionReport_Quote_V3_2016';

but I only get an error:

Msg 8146, Level 16, State 2, Procedure Repotingdatasets, Line 0 [Batch Start Line 48]

  Procedure Repotingdatasets has no parameters and arguments were supplied

Body:
You just need to change some syntax:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create PROCEDURE [dbo].[Repotingdatasets](
@object     nvarchar(257)
)
as

Insert into DatasetMapping
exec sp_depends  @objname=@object

exec [dbo].[Repotingdatasets]  @object =' dbo.PositionReport_Quote_V3_2016';


问:
kafka.admin.TopicCommand Failing
I am using a single node Kafka V 0.10.2 (16 GB RAM, 8 cores) and a single node zookeeper V  3.4.9 (4 GB RAM, 1 core ). I am having 64 consumer groups and 500 topics each having 250 partitions. I am able to execute the commands which require only Kafka broker and its running fine
ex.

./kafka-consumer-groups.sh --bootstrap-server localhost:9092
  --describe --group

But when I execute the admin command like create topic, alter topic For example

./kafka-topics.sh --create --zookeeper :2181
  --replication-factor 1 --partitions 1 --topic

Following exception is being displayed:

Error while executing topic command : replication factor: 1 larger
  than available brokers: 0 [2017-11-16 11:22:13,592] ERROR
  org.apache.kafka.common.errors.InvalidReplicationFactorException:
  replication factor: 1 larger than available brokers: 0
  (kafka.admin.TopicCommand$)

I checked my broker is up. In server.log following warnings are there

```<code>[2017-11-16 11:14:26,959] WARN Client session timed out, have not heard from server in 15843ms for sessionid 0x15aa7f586e1c061 (org.apache.zookeeper.ClientCnxn)
[2017-11-16 11:14:28,795] WARN Unable to reconnect to ZooKeeper service, session 0x15aa7f586e1c061 has expired (org.apache.zookeeper.ClientCnxn)
[2017-11-16 11:21:46,055] WARN Unable to reconnect to ZooKeeper service, session 0x15aa7f586e1c067 has expired (org.apache.zookeeper.ClientCnxn)
</code>```

Below mentioned is my Kafka server configuration :

```<code>broker.id=1
delete.topic.enable=true
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/kafka/data/logs
num.partitions=1
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=<zookeeperIP>:2181
zookeeper.connection.timeout.ms=6000
</code>```

Zookeeper Configuration is :

```<code># The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/zookeeper/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
autopurge.snapRetainCount=20
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=48
</code>```

I am not able to figure out which configuration to tune. What I am missing .Any help will be appreciated.

答:
When you are running consumer with zookeeper argument like

./kafka-topics.sh --create --zookeeper :2181 --replication-factor 1
  --partitions 1 --topic

it means that consumer will go and ask zookeeper to about broker details. if broker details available in zookeeper it can able to connect to the broker.

in your scenario, I think zookeeper lost broker details. zookeeper usually store all your configuration in tree path.

to check whether zookeeper has broker path or not you need log into zookeeper shell using  /bin/zkCli.sh -server localhost:2181

after successful connection do ls / you will see output like this

```<code>[controller, controller_epoch, brokers, zookeeper, admin, isr_change_notification, consumers, config]
</code>```

and then do ls /brokers output will be [ids, topics, seqid]

and then do ls /brokers/ids output will be [0] - it is an array of broker id's. if your array is empty [] that means that no broker details are present in your zookeeper

in that case, you need to restart your broker and zookeeper.

Updated :

This problem won't happen usually. because your zookeeper server is closing(killing) or losing broker path automatically.

To overcome this it is better to maintain two more zookeepers means complete 3 zookeepers nodes.

if it is local use localhost:2181, localhost:2182, localhost:2183.

if it is cluster use three instances zookeeper1:2181, zookeeper2:2181, zookeeper3:2181

you can tolerate up to two failures.

for creating topic and use following command :

./kafka-topics.sh --create --zookeeper
  localhost:2181,localhost:2182,localhost:2183 --replication-factor 1
  --partitions 1 --topic

Title: kafka.admin.TopicCommand Failing

Body:
I am using a single node Kafka V 0.10.2 (16 GB RAM, 8 cores) and a single node zookeeper V  3.4.9 (4 GB RAM, 1 core ). I am having 64 consumer groups and 500 topics each having 250 partitions. I am able to execute the commands which require only Kafka broker and its running fine
ex.

./kafka-consumer-groups.sh --bootstrap-server localhost:9092
  --describe --group

But when I execute the admin command like create topic, alter topic For example

./kafka-topics.sh --create --zookeeper :2181
  --replication-factor 1 --partitions 1 --topic

Following exception is being displayed:

Error while executing topic command : replication factor: 1 larger
  than available brokers: 0 [2017-11-16 11:22:13,592] ERROR
  org.apache.kafka.common.errors.InvalidReplicationFactorException:
  replication factor: 1 larger than available brokers: 0
  (kafka.admin.TopicCommand$)

I checked my broker is up. In server.log following warnings are there

[2017-11-16 11:14:26,959] WARN Client session timed out, have not heard from server in 15843ms for sessionid 0x15aa7f586e1c061 (org.apache.zookeeper.ClientCnxn)
[2017-11-16 11:14:28,795] WARN Unable to reconnect to ZooKeeper service, session 0x15aa7f586e1c061 has expired (org.apache.zookeeper.ClientCnxn)
[2017-11-16 11:21:46,055] WARN Unable to reconnect to ZooKeeper service, session 0x15aa7f586e1c067 has expired (org.apache.zookeeper.ClientCnxn)

Below mentioned is my Kafka server configuration :

broker.id=1
delete.topic.enable=true
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/kafka/data/logs
num.partitions=1
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=<zookeeperIP>:2181
zookeeper.connection.timeout.ms=6000

Zookeeper Configuration is :

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/zookeeper/data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
autopurge.snapRetainCount=20
# Purge task interval in hours
# Set to "0" to disable auto purge feature
autopurge.purgeInterval=48

I am not able to figure out which configuration to tune. What I am missing .Any help will be appreciated.

Body:
When you are running consumer with zookeeper argument like

./kafka-topics.sh --create --zookeeper :2181 --replication-factor 1
  --partitions 1 --topic

it means that consumer will go and ask zookeeper to about broker details. if broker details available in zookeeper it can able to connect to the broker.

in your scenario, I think zookeeper lost broker details. zookeeper usually store all your configuration in tree path.

to check whether zookeeper has broker path or not you need log into zookeeper shell using  /bin/zkCli.sh -server localhost:2181

after successful connection do ls / you will see output like this

[controller, controller_epoch, brokers, zookeeper, admin, isr_change_notification, consumers, config]

and then do ls /brokers output will be [ids, topics, seqid]

and then do ls /brokers/ids output will be [0] - it is an array of broker id's. if your array is empty [] that means that no broker details are present in your zookeeper

in that case, you need to restart your broker and zookeeper.

Updated :

This problem won't happen usually. because your zookeeper server is closing(killing) or losing broker path automatically.

To overcome this it is better to maintain two more zookeepers means complete 3 zookeepers nodes.

if it is local use localhost:2181, localhost:2182, localhost:2183.

if it is cluster use three instances zookeeper1:2181, zookeeper2:2181, zookeeper3:2181

you can tolerate up to two failures.

for creating topic and use following command :

./kafka-topics.sh --create --zookeeper
  localhost:2181,localhost:2182,localhost:2183 --replication-factor 1
  --partitions 1 --topic


问:
PHP: Class containing array of sponsors and method for echoing them
I want to have my Datasource_Sponsor class contain sponsor information, an array called sponsorList and a method which echoes each sponsor.

At the moment I have this

```<code>class Datasource_Sponsor
 {

protected $sponsor = 'New and Upcoming Startup';
protected $sponsor2 = 'Average Company Ltd.';
protected $sponsor3 = 'Super Duper Cool Best Company Ever';

protected $sponsorList = array($sponsor, $sponsor2, $sponsor3);

public function returnSponsors()
{
    foreach ($sponsorList as $sponsor) {
        $sponsor = new Sponsor();
        echo 'Sponsor: ' . $sponsor->getSponsor() . '<br/>';
        echo '<hr>';
        }

    }
}
</code>```

And I get this error "Fatal error: Constant expression contains invalid operations" for this line

```<code>protected $sponsorList = array($sponsor, $sponsor2, $sponsor3);
</code>```

答:
You can't use properties in that way, i suggest you to do this:</p>

```<code><?php
class Datasource_Sponsor
 {

    protected $sponsor = 'New and Upcoming Startup';
    protected $sponsor2 = 'Average Company Ltd.';
    protected $sponsor3 = 'Super Duper Cool Best Company Ever';

    protected $sponsorList;

    public function __construct(){
        $this->sponsorList = [$this->sponsor, $this->sponsor2, $this->sponsor3];
    }

    public function returnSponsors()
    {
        foreach ($this->sponsorList as $sponsor) {
            $myOthersponsor = new Sponsor();
            echo 'Sponsor: ' . $myOthersponsor->getSponsor() . '<br/>';
            echo '<hr>';
        }

    }

}
</code>```

Body:
I want to have my Datasource_Sponsor class contain sponsor information, an array called sponsorList and a method which echoes each sponsor.

At the moment I have this

class Datasource_Sponsor
 {

protected $sponsor = 'New and Upcoming Startup';
protected $sponsor2 = 'Average Company Ltd.';
protected $sponsor3 = 'Super Duper Cool Best Company Ever';

protected $sponsorList = array($sponsor, $sponsor2, $sponsor3);

public function returnSponsors()
{
    foreach ($sponsorList as $sponsor) {
        $sponsor = new Sponsor();
        echo 'Sponsor: ' . $sponsor->getSponsor() . '
';
        echo '
';
        }

    }
}

And I get this error "Fatal error: Constant expression contains invalid operations" for this line

protected $sponsorList = array($sponsor, $sponsor2, $sponsor3);

Body:
You can't use properties in that way, i suggest you to do this:

<?php
class Datasource_Sponsor
 {

    protected $sponsor = 'New and Upcoming Startup';
    protected $sponsor2 = 'Average Company Ltd.';
    protected $sponsor3 = 'Super Duper Cool Best Company Ever';

    protected $sponsorList;

    public function __construct(){
        $this->sponsorList = [$this->sponsor, $this->sponsor2, $this->sponsor3];
    }

    public function returnSponsors()
    {
        foreach ($this->sponsorList as $sponsor) {
            $myOthersponsor = new Sponsor();
            echo 'Sponsor: ' . $myOthersponsor->getSponsor() . '<br/>';
            echo '<hr>';
        }

    }

}


问:
How to move locked files with an file outbound adapter
So currently I am reading files with an file inbound adapter (nio locker on) and just log them.

I've tried to attach a file outbound adapter at the tail of the flow, in order to move the files to a new location (/done), but every time I encounter an error because the file is locked.

If I remove the nio-locker flag, everything is OK. Problem here is that I would like to have multiple JVM working on those files, and there is a risk that a file will picked up by two JVMs.

Thanks,
Cristi

答:
Try to expose NioFileLocker as a bean and use its name in the <locker ref=""> instead of internal <nio-locker>.

When you are ready to move the file, call that NioFileLocker bean and its unlock(File).

Let us know how it works and I guess we can revise the NioFileLocker bean registration based on the name of the <int-file:inbound-channel-adapter>.