text:
Q: Heroku build error: Specified 'sqlite3' for database adapter, but the gem is not loaded What I'm trying to do
I'm building an app with rails and deploying a non master branch to heroku master test the app in production. I didn't want to mess with master until I know what I'm doing on Heroku, therefore I deployed a feature branch.
The repository of the app can be found here if the refernce is needed.
After any change to the gemfile I ran:
bundle update
bundle install
git add .
git commit
git push heroku 0007/heroku:master

The last command is documented here and used to push a non-master branch to herokus master. Usually this is done because you don't want to mess with master. I also asked about this a while back.The question how to set non-master up for heroku can be found here.
I adjusted database.yml to fit Heroku requirements with postgresql and sqlite3.
default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

My gemfile is also pretty straight foreward:
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

ruby '2.4.1'

# Use sqlite3 as the database for Active Record
gem 'sqlite3', group: :development # Added development group.
gem 'pg', group: :production # Added postgres and made it production only.
gem 'rails_12factor'

# Specifying an exact Ruby version
ruby '2.4.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Step-by-step debugging and stack navigation in Pry
  gem 'pry-byebug', platform: :ruby
  # Pry is a powerful alternative to the standard IRB shell for Ruby
  gem 'pry-rails'
  # Pretty print your Ruby objects with style -- in full color and with proper indentation
  gem 'awesome_print'
  # Add a comment summarizing the current schema to the top or bottom of each of your ActiveRecord models, Specs, factory_girl factories...
  gem 'annotate'
  # Annotate guard runs the annotate gem when needed
  gem 'guard-annotate', '~> 2.3'
  # Use for fighting the N+1 problem in Ruby
  gem 'bullet'
  # Speedup RSpec + Cucumber by running parallel on multiple CPU cores
  gem 'parallel_tests'
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'
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', '< 3.2'
  # 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'
  # bundler-audit provides patch-level verification for Bundled apps
  gem 'bundler-audit', '~> 0.6.0', require: false
  # Bundler guard allows to automatically & intelligently install/update bundle when needed.
  gem 'guard-bundler', '~> 2.1', require: false
  # compare licenses against a user-defined whitelist, and give you an actionable exception report
  gem 'license_finder', '~> 3.0', '>= 3.0.1', require: false
  # Brakeman is an open source static analysis tool which checks Rails applications for security vulnerabilities.
  gem 'brakeman', require: false
  # Better Errors replaces the standard Rails error page with a much better and more useful error page
  gem 'better_errors'
  # necessary to use Better Errors' advanced features
  gem 'binding_of_caller', platforms: :ruby
  # RuboCop configuration which has the same code style checking as official Ruby on Rails
  gem 'rubocop', '~> 0.51.0', require: false
  gem 'guard-rubocop', require: false
  # i18n-tasks helps you find and manage missing and unused translations
  gem 'i18n-tasks', require: false
  # IYE makes it easy to translate your Rails I18N files and keeps them up to date
  gem 'iye', require: false
  # Image Uploader Carrierwave for all kinds of Picture related jobs
  gem 'carrierwave', '~> 1.0'

end

group :test do
  # Guard is a command line tool to easily handle events on file system modifications
  gem 'guard'
  gem 'guard-minitest'
  # This gem brings back assigns to your controller tests as well as assert_template
  gem 'rails-controller-testing'
  # To get the default Rails tests to show red and green at the appropriate times
  gem 'minitest-reporters'
  # Strategies for cleaning databases in Ruby. Can be used to ensure a clean state for testing.
  gem 'database_cleaner'
  # Code coverage for Ruby
  gem 'simplecov', require: false
  # Collection of testing matchers extracted from Shoulda
  gem 'shoulda-matchers'
end

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

The problem
After testing my app locally I decided to push it to Heroku, however I'm not able to resolve a dependancy conflict.
The suspected error:

Specified 'sqlite3' for database adapter, but the gem is not loaded.
  Add gem 'sqlite3' to your Gemfile

I know this issue has been documented on many posts. I combed through them to find what I had missed but to no avail.
These are the posts I found on this issue:

*

*source 1

*source 2

*source 3
They all basically say, look out that you set up postgresql as production and sqlite3 as development database or set your project up with postgres from the get go.
As far as I can tell I have this covered.
I set my gemfile to use pg as production database, and sqlite3 as development database, as mentioned here, and here.
My gemfile does not seem to have any production deps for sqlite.
 [57] → gem dependency -R sqlite
Gem sqlite3-1.3.13
  hoe (~> 3.15, development)
  hoe-bundler (~> 1.0, development)
  mini_portile (~> 0.6.2, development)
  minitest (~> 5.9, development)
  rake-compiler (~> 0.9.3, development)
  rake-compiler-dock (~> 0.5.2, development)
  rdoc (~> 4.0, development)
  Used by
    awesome_print-1.8.0 (sqlite3 (>= 0, development))
    database_cleaner-1.7.0 (sqlite3 (>= 0, development))
    rails-controller-testing-1.0.2 (sqlite3 (>= 0, development))
    sass-rails-5.0.7 (sqlite3 (>= 0, development))

The problems started to show when trying to run $ heroku run rake db:migrate.
This is the produced trail from heroku:
 [159] → heroku logs --tail
2018-09-03T03:00:29.276401+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `tap'
2018-09-03T03:00:29.276425+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `perform'
2018-09-03T03:00:29.276472+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
2018-09-03T03:00:29.276495+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
2018-09-03T03:00:29.276518+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform'
2018-09-03T03:00:29.276542+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke'
2018-09-03T03:00:29.276567+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>'
2018-09-03T03:00:29.276591+00:00 app[web.1]: from bin/rails:9:in `require'
2018-09-03T03:00:29.276615+00:00 app[web.1]: from bin/rails:9:in `<main>'
2018-09-03T08:35:36.524552+00:00 heroku[web.1]: State changed from crashed to starting
2018-09-03T08:35:39.232773+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 52942 -e production`
2018-09-03T08:35:42.729326+00:00 heroku[web.1]: State changed from starting to crashed
2018-09-03T08:35:42.656882+00:00 app[web.1]: => Booting Puma
2018-09-03T08:35:42.656898+00:00 app[web.1]: => Rails 5.1.6 application starting in production
2018-09-03T08:35:42.656899+00:00 app[web.1]: => Run `rails server -h` for more startup options
2018-09-03T08:35:42.656900+00:00 app[web.1]: Exiting
2018-09-03T08:35:42.656943+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec': Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
2018-09-03T08:35:42.656967+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/connection_specification.rb:185:in `spec'
2018-09-03T08:35:42.656977+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:880:in `establish_connection'
2018-09-03T08:35:42.656980+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/connection_handling.rb:58:in `establish_connection'
2018-09-03T08:35:42.656982+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/railtie.rb:124:in `block (2 levels) in <class:Railtie>'
2018-09-03T08:35:42.656983+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:69:in `instance_eval'
2018-09-03T08:35:42.657020+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:69:in `block in execute_hook'
2018-09-03T08:35:42.657023+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
2018-09-03T08:35:42.657024+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
2018-09-03T08:35:42.657027+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
2018-09-03T08:35:42.657038+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:49:in `each'
2018-09-03T08:35:42.657065+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
2018-09-03T08:35:42.657068+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/base.rb:326:in `<module:ActiveRecord>'
2018-09-03T08:35:42.657070+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.6/lib/active_record/base.rb:25:in `<top (required)>'
2018-09-03T08:35:42.657073+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
2018-09-03T08:35:42.657083+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
2018-09-03T08:35:42.657086+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
2018-09-03T08:35:42.657110+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
2018-09-03T08:35:42.657113+00:00 app[web.1]: from /app/app/models/application_record.rb:1:in `<top (required)>'
2018-09-03T08:35:42.657123+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
2018-09-03T08:35:42.657128+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require'
2018-09-03T08:35:42.657152+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency'
2018-09-03T08:35:42.657153+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require'
2018-09-03T08:35:42.657154+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:379:in `block in require_or_load'
2018-09-03T08:35:42.657178+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:36:in `block in load_interlock'
2018-09-03T08:35:42.657181+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
2018-09-03T08:35:42.657184+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/concurrency/share_lock.rb:149:in `exclusive'
2018-09-03T08:35:42.657186+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies/interlock.rb:11:in `loading'
2018-09-03T08:35:42.657212+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:36:in `load_interlock'
2018-09-03T08:35:42.657213+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:357:in `require_or_load'
2018-09-03T08:35:42.657216+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:335:in `depend_on'
2018-09-03T08:35:42.657220+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:251:in `require_dependency'
2018-09-03T08:35:42.657224+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
2018-09-03T08:35:42.657226+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/engine.rb:475:in `each'
2018-09-03T08:35:42.657230+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/engine.rb:475:in `block in eager_load!'
2018-09-03T08:35:42.657232+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/engine.rb:473:in `each'
2018-09-03T08:35:42.657234+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/engine.rb:473:in `eager_load!'
2018-09-03T08:35:42.657238+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/engine.rb:354:in `eager_load!'
2018-09-03T08:35:42.657240+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application/finisher.rb:67:in `each'
2018-09-03T08:35:42.657241+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application/finisher.rb:67:in `block in <module:Finisher>'
2018-09-03T08:35:42.657243+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `instance_exec'
2018-09-03T08:35:42.657247+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/initializable.rb:30:in `run'
2018-09-03T08:35:42.657249+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/initializable.rb:59:in `block in run_initializers'
2018-09-03T08:35:42.657250+00:00 app[web.1]: from /app/vendor/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
2018-09-03T08:35:42.657252+00:00 app[web.1]: from /app/vendor/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
2018-09-03T08:35:42.657254+00:00 app[web.1]: from /app/vendor/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
2018-09-03T08:35:42.657257+00:00 app[web.1]: from /app/vendor/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
2018-09-03T08:35:42.657259+00:00 app[web.1]: from /app/vendor/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each'
2018-09-03T08:35:42.657260+00:00 app[web.1]: from /app/vendor/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `call'
2018-09-03T08:35:42.657261+00:00 app[web.1]: from /app/vendor/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
2018-09-03T08:35:42.657262+00:00 app[web.1]: from /app/vendor/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
2018-09-03T08:35:42.657264+00:00 app[web.1]: from /app/vendor/ruby-2.4.1/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
2018-09-03T08:35:42.657266+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/initializable.rb:58:in `run_initializers'
2018-09-03T08:35:42.657267+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/application.rb:353:in `initialize!'
2018-09-03T08:35:42.657268+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>'
2018-09-03T08:35:42.657270+00:00 app[web.1]: from config.ru:3:in `require_relative'
2018-09-03T08:35:42.657273+00:00 app[web.1]: from config.ru:3:in `block in <main>'
2018-09-03T08:35:42.657274+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:55:in `instance_eval'
2018-09-03T08:35:42.657275+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:55:in `initialize'
2018-09-03T08:35:42.657278+00:00 app[web.1]: from config.ru:in `new'
2018-09-03T08:35:42.657279+00:00 app[web.1]: from config.ru:in `<main>'
2018-09-03T08:35:42.657280+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:49:in `eval'
2018-09-03T08:35:42.657283+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:49:in `new_from_string'
2018-09-03T08:35:42.657284+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/builder.rb:40:in `parse_file'
2018-09-03T08:35:42.657287+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2018-09-03T08:35:42.657288+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/server.rb:219:in `app'
2018-09-03T08:35:42.657290+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:24:in `app'
2018-09-03T08:35:42.657291+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/server.rb:354:in `wrapped_app'
2018-09-03T08:35:42.657294+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.5/lib/rack/server.rb:283:in `start'
2018-09-03T08:35:42.657295+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:44:in `start'
2018-09-03T08:35:42.657301+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:135:in `block in perform'
2018-09-03T08:35:42.657302+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `tap'
2018-09-03T08:35:42.657305+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `perform'
2018-09-03T08:35:42.657306+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
2018-09-03T08:35:42.657307+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
2018-09-03T08:35:42.657308+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
2018-09-03T08:35:42.657311+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform'
2018-09-03T08:35:42.657312+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke'
2018-09-03T08:35:42.657313+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>'
2018-09-03T08:35:42.657316+00:00 app[web.1]: from bin/rails:9:in `require'
2018-09-03T08:35:42.657318+00:00 app[web.1]: from bin/rails:9:in `<main>'
2018-09-03T08:35:42.704940+00:00 heroku[web.1]: Process exited with status 1
2018-09-03T09:52:58.423149+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=attendion.herokuapp.com request_id=fc40234e-28c4-4007-a780-1731f87512d4 fwd="87.144.250.234" dyno= connect= service= status=503 bytes= protocol=https
2018-09-03T09:52:59.224100+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=attendion.herokuapp.com request_id=786316ef-6db5-48b9-9590-5467827cf791 fwd="87.144.250.234" dyno= connect= service= status=503 bytes= protocol=https

A: SQLite does not work with Heroku as its disk based and Heroku uses an ephemeral file system.

SQLite runs in memory, and backs up its data store in files on disk.
While this strategy works well for development, Heroku's Cedar stack
has an ephemeral filesystem. You can write to it, and you can read
from it, but the contents will be cleared periodically. If you were to
use SQLite on Heroku, you would lose your entire database at least
once every 24 hours.
Even if Heroku's disks were persistent running SQLite would still not
be a good fit. Since SQLite does not run as a service, each dyno would
run a separate running copy. Each of these copies need their own disk
backed store. This would mean that each dyno powering your app would
have a different set of data since the disks are not synchronized.
-Heroku Devcenter: SQLite on Heroku

Heroku provides Postgres as the free default database for rails which is as close to a recommendation as you can get.
If you are deploying to Postgres you should also be developing/testing on Postgres.

Differences between backing services mean that tiny incompatibilities
crop up, causing code that worked and passed tests in development or
staging to fail in production. These types of errors create friction
that disincentivizes continuous deployment. The cost of this friction
and the subsequent dampening of continuous deployment is extremely
high when considered in aggregate over the lifetime of an application.

*

*https://12factor.net/dev-prod-parity

If you really want to stick with SQLite you need to configure the adapters properly:
default: &default
  adapter: sqlite3
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  adapter: postgresql
  # nothing else is needed

I do not recommend this.


text:
Q: trying to use DiscreteUniform as an numpy index I am trying to use pymc3.DiscreteUniform as an index for a numpy 1D array
This worked with pymc (v2) but I am transitioning to pymc3 and code that worked under pymc don't work under pymc3.
import pymc3 as pm
d0 = pm.DiscreteUniform('d0', lower=0, upper=nDens - 1, testval = nDens//2)
pred = np.zeros(len(box.match), np.float64)
for iwvl, amatch in enumerate(box.match):
    pred[iwvl] += amatch['intensitySum'][d0]

I get the following error message:
IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

A: I have found something that works but in involves going into theano and theano.tensor.
`
    import pymc3 as pm
    with pm.Model() as model:
        em0 = pm.Normal('em0', mu=emLog, sigma=0.2)
        d0 = pm.DiscreteUniform('d0', lower = 0, upper = nDens - 1, testval = Dindex)
        boundNormal = pm.Bound(pm.Normal, lower=0.0)
        wght = boundNormal('wght', mu=0.2, sigma=0.1)
    pred = np.zeros((nDens, len(box.match)), np.float64)
    for iwvl, amatch in enumerate(box.match):
        pred[0:,iwvl] += amatch['intensitySum']
    xpred = theano.shared(pred, name='p0')
    idx = tensor.as_tensor_variable(d0)
    predicted = xpred[idx]*10.**em0
    nObs = len(box.match)
    intensity = np.zeros(nObs, np.float64)
    for iwvl in range(nObs):
        intensity[iwvl] = box.match[iwvl]['obsIntensity']
    sigma = 0.2
    Y_obs = pm.Normal('Y_obs', mu=predicted, sigma=wght*intensity,    observed=intensity)
    trace = pm.sample(tune=20000, draws=100000, target_accept=0.85)`

and then you can work with the trace
it is even possible to make sigma as pm variable

redpajama_set_name: RedPajamaStackExchange


text: Q: VLC playlist names change to 'playlist' when expanding them I have created a few playlists in VLC media player. Changed the playlist names by changing the meta data.After quiting and reopening when I take the playlists and expand them,the assigned names change to just 'playlist'.


text:
Q: IconButton onPressed function throws out an error code I am currently working on an app using Flutter. I built an AppBar and a Bottomnavigationbar with IconButtons that should all route to different pages. When I execute though it displays an error message.
Here is the code:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Top navigation Bar',
      home: Scaffold(
          appBar: AppBar(
              backgroundColor: Color.fromARGB(250, 250, 250, 250),
              elevation: 0,
              actions: <Widget>[
                IconButton(
                  icon: Icon(
                    Icons.account_circle,
                    size: 40.0,
                    color: Colors.black,
                  ),
                  onPressed: () {
                    Navigator.push(
                      context,
                      MaterialPageRoute(builder: (context) => MyLoginPage()),
                    );
                  },
                )
              ]),
          body: Center(
            child: Text('NewsPage'),
          ),
          bottomNavigationBar: SizedBox(
            height: 60,
            child: new Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                IconButton(
                  icon: Icon(Icons.info_outline),
                  onPressed: () {
                    Navigator.push(
                      context,
                      MaterialPageRoute(builder: (context) => MyApp()),
                    );
                  },
                ),
                IconButton(
                  icon: Icon(Icons.calendar_today),
                  onPressed: () {
                    Navigator.push(
                      context,
                      MaterialPageRoute(builder: (context) => MyShedulePage()),
                    );
                  },
                ),
                IconButton(
                  icon: Icon(Icons.assignment_ind),
                  onPressed: () {
                    Navigator.push(
                      context,
                      MaterialPageRoute(
                          builder: (context) => MyAttendancePage()),
                    );
                  },
                ),
              ],
            ),
          )),
    );
  }
}

When I click on any of the IconButtons, it displays this error message:

Navigator operation requested with a context that does not include a Navigator.

A: There are two things you can do to remove your bug/error.
1. Build your BottomNavigationBar in another Stateless Widget:
class MyBottomNavigationBar extends StatelessWidget{
   Widget build(BuildContext context) {
    return SizedBox(
      height: 60,
      child: new Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          IconButton(
            icon: Icon(Icons.info_outline),
            onPressed: () {
              Navigator.push(
                context,
                // MYHomePage is another page for showcase
                // replace it with your page name
                MaterialPageRoute(builder: (context) => MyHomePage()),
              );
            },
          ),
          IconButton(
            icon: Icon(Icons.calendar_today),
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(builder: (context) => MyHomePage()),
              );
            },
          ),
          IconButton(
            icon: Icon(Icons.assignment_ind),
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => MyHomePage()),
              );
            },
          ),
        ],
      ),
    );
   }
}

And use it for the bottomNavigationBar in the MaterialApp
bottomNavigationBar: MyBottomNavigationBar()

2. Use Builder class Wrap your bottomNavigationBar items inside your Builder()
 bottomNavigationBar: Builder(
   builder: (context) => SizedBox(
        height: 60,
        child: new Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            IconButton(
              icon: Icon(Icons.info_outline),
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => MyApp()),
                );
              },
            ),
            IconButton(
              icon: Icon(Icons.calendar_today),
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(builder: (context) => MyShedulePage()),
                );
              },
            ),
            IconButton(
              icon: Icon(Icons.assignment_ind),
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                      builder: (context) => MyAttendancePage()),
                );
              },
            ),
          ],
        ),
       )
      )

Here is the Demo for you using Point number 1 from my answer, having MyHomePage() as another widget to be pushed to from the MyApp

PLEASE NOTE: You cannot use Navigator.push to go from same page to same page. In your code here, you are pushing to MyApp(). So please take care of that
               // please see here, not a good practise. Make sure
               // page is different, not same
               IconButton(
                  icon: Icon(Icons.info_outline),
                  onPressed: () {
                    Navigator.push(
                      context,
                      MaterialPageRoute(builder: (context) => MyApp()),
                    );
                  },
                )

A: You can't do this (use context for purposes) under Material App widget Try this
MaterialApp(
      title: 'Top navigation Bar',
      home:HomePage()
);

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
      return Scaffold( //Your code inside Scaffold..);
}
}


text:
Q: What should be the format in SimpleDateFormat to print date like this - 01-JUN-20 08.55.27.577984000 AM UTC? I want to print the current date in this format -
01-JUN-20 08.55.27.577984000 AM UTC. Tried lot of formats in SimpleDateformat but none is working. What is the right way to print like this?

A: SimpleDateFormat
You can use the following pattern:
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class TimeFormatting {
    public static void main(String[] args) {
        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy hh.mm.ss.SSS a Z");
        formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
        String formatted = formatter.format(new Date(2015, 4, 4, 13, 7, 19)); //One example date
        System.out.println(formatted);
    }
}

This will give the output 04-05-15 11.07.19.000 AM +0000 where +0000 equals to UTC.
Explanation of the pattern dd-MM-yy hh.mm.ss.SSS a Z:

*

*dd = the day

*MM = the month

*yy = the year

*hh = the hour

*mm = the minute

*ss = the second

*SSS = the millisecond. There does not exist a reference to nanoseconds in SimpleDateFormat (see this answer).

*a = to show AM/PM

*Z = to show the timezone

Additional information
Please note: SimpleDateFormat is deprecated. You should use DateTimeFormatter. One big advantage is that you can also have the nanoseconds (n).
One example:
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.ZoneOffset;

public class TimeFormatting {
  public static void main(String[] args) {
   ZonedDateTime time = ZonedDateTime.now(ZoneOffset.UTC);

   DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yy hh.mm.ss.n a 'UTC'").withZone(ZoneOffset.UTC);
   String timeDate = time.format(formatter);
   System.out.println(timeDate);
  }
}

Edit:
If you want to have UTC instead of +0000 with SimpleDateFormat you can use dd-MM-yy hh.mm.ss.SSS a zzz instead.


text:
Q: CakePHP create URL from request params Is there a function to generate the corresponding URL given the request object?
For example, if the request params values are:
params => array(
        'plugin' => 'plugin',
        'controller' => 'foo',
        'action' => 'bar',
        'named' => array(),
        'pass' => array()
    )
    data => array()
    query => array(
                'key' => 'val'
        )
)

Then, generate the URL:
http://domain.com/plugin/foo/bar?key=val

A: Whether this fits your needs depends of course, but generally Router::reverse() is able to build a URL from a request object:
Router::reverse($cakeRequestObject, true)

It's much like Router::url(), but it will do all the dirty work for you like including the query values and removing unnecessary parameters.

A: Just Use Router::reverse() like that way :
$url = Router::reverse($this->params);
echo $url;


text:
Q: How to add users and passwords to a local cloudify deployment I am following the Cloudify user guide - its pretty easy to follow, and have installed a local deployment successfully.
Now I want to add users and passwords to the web management interface, how to do this? By default, the web interface supports anonymous login.

A: Assuming your aim is to obtain full control over deployments, use the Cloudify shell (or "Cloudify CLI").
As the Cloudify shell currently exposes read-only operations, it does not require login details. Configuring secured access for the REST API, however, can be done using spring security (which will be documented soon).


text:
Q: Find the conjugate function My problem: Suppose $f(x)=-\ln x + e^{x}$. Find the conjugate function of $f(x)$
My attempt: First, i have: $domf =(0;+\infty)$.
We have
$f^*(y)=\displaystyle \sup_{x \in (0;+\infty)} (xy+\ln x -e^{x})$. I set $g(x)=xy+lnx -e^{x}$. After that, I have $g'(x)=y+1/x+e^{-x}$. Now, I can't solve this equation to find root.
Thank you for reading my post. Any help is appreciated.

A: You made a minor mistake finding the derivative:
$$g'(x)=y+\frac{1}{x}-e^x.$$
The roots of $g'$ cannot be obtained in a nice closed form. The best you can do is proving that $g'$ has only one root, so $g$ has a unique maximum there. To prove this, consider
$$g''(x)=-\left(\frac{1}{x^2}+e^x\right).$$


text:
Q: In my CSS the grid propery isn't functioning properly In all of my HTML, the grid is displaying perfectly, except for in the gallery I'm trying to make. I've tried several things to resolve it, but the grid is not displaying. I'm at a loss now for what's wrong. Please review the code below:
<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/grid.css">
    <title>...</title>

...

...

...

...

...

...

...

...

...

...

..

..

..

..

..

..

...

...

...

...

...

...

12

6

6

4

4

4

3

3

3

3

2

2

2

2

2

2

1

1

1

1

1

1

1

1

1

1

1

1

...

...

...

Exotic Birds

...

Great Tit

Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempora commodi aliquam at, quidem
                        dolorum ipsum nemo sed molestiae et in ratione sit reprehenderit ex est culpa corporis, quod
                        libero ullam.

Great Tit

Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempora commodi aliquam at, quidem
                        dolorum ipsum nemo sed molestiae et in ratione sit reprehenderit ex est culpa corporis, quod
                        libero ullam.

...

CSS (style.css):
* {
    box-sizing: border-box;
    margin: 0;
}

body {
    font-size: 16px;
    font-family: Arial, Helvetica, sans-serif;
}

.wrapper p {
    margin: 1rem;
    margin-left: 2rem;
}

.wrapper h1, h2, h3, h4, h5, h6 {
    margin-left: 1rem;
}

.wrapper ol {
    margin-bottom: 1rem;
}

footer {
    background-color: hsla(17, 100%, 50%, 1);
    color: white;
    text-align: center;
    padding: 2rem;
}

nav {
    background-color: hsla(17, 100%, 50%, 1);
    color: white;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

nav h1 {
    font-size: 2rem;
}

nav ul {
    display: flex;
    justify-content: space-between;
    list-style: none;
}

nav ul li a {
    text-decoration: none;
    color: white;
}

nav ul li {
    padding: 2rem;
    text-decoration: none;
    transition: background-color 0.5s ease;
}

nav ul li:hover {
    background-color: hsla(17, 100%, 65%, 1);
}

.main-head {
    margin-top: 6rem;
}

/* Col Display */

.col-display {
    display: grid;
    width: 50%;
    margin-left: 5rem;
    padding: 0.5rem 0;
    background-color: hsla(17, 100%, 50%, 0.5);
}

.col-display p {
    color: white;
    text-align: center;
    font-weight: bold;
    margin: 0;
}

.col-display-box {
    height: 2.5rem;
    background-color: hsla(17, 100%, 25%, 0.5);
    border: 1px solid hsla(17, 100%, 15%, 0.5);
    color: white;
    font-weight: bold;
    margin: 0.5rem;
    padding-top: 0.625rem;
    border-radius: 0.5rem;
    text-align: center;
}

/* Bird Gallery */

.bird-gallery {
    display: grid;
    width: 80%;
    margin: 0 auto;
}

.bird-card {
    background-color: hsla(17, 46%, 75%, 1);
}

.bird-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

Grid system CSS (grid.css):
/* Grid Display */

.wrapper {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
}

.col-12 {
    grid-column: span 12;
}

.col-11 {
    grid-column: span 11;
}

.col-10 {
    grid-column: span 10;
}

.col-9 {
    grid-column: span 9;
}

.col-8 {
    grid-column: span 8;
}

.col-7 {
    grid-column: span 7;
}

.col-6 {
    grid-column: span 6;
}

.col-5 {
    grid-column: span 5;
}

.col-4 {
    grid-column: span 4;
}

.col-3 {
    grid-column: span 3;
}

.col-2 {
    grid-column: span 2;
}

.col-1 {
    grid-column: span 1;
}

/* Block display on mobile */
/*
@media screen and (max-width: 575px) {
    .wrapper {
      display: block;
      }
  }
*/

I've only replaced text in the html with "..." because it revealed my information. Thanks for understanding.
The problem is the top grid with all the div boxes is working fine like a pyramid, but the birds isn't.

A: edit:
You should add grid-template-columns: repeat(12, 1fr); on the bird-gallery class too.


text:
Q: Issue with ng-model and ng-repeat, input value is duplicated on each form field on the page I have a page where multiple forms are created based on ng-repeat. everything works fine until write something into the input and everything gets duplicated on all the other repeated forms input elements. I have used ng-model="Notify.message" which is nothing but object which takes the value from the input and sends to control on button submit and hence rest of the logic.
I am looking for when if one form is been filled, other forms should keep quite and shouldnt duplicate the values written in input text of form 1.
Here is the code:

 0">

                    <form class="text-center" role="form" id=f1{{userpost.id}} name="userForm"
                          ng-submit="notify(userForm.$valid, userpost, apiMe)" novalidate>

                                    <input data-container="body" data-toggle="popover" data-placement="top"
                                           data-content="Any message which you would like to convey to post owner"
                                           type="text" ng-model="Notify.message" data-ng-init="Notify.message=''"
                                           id="u{{userpost.id}}"
                                           placeholder="Enter a Message or Phone number" class="form-control"
                                           required>

It is
                                        required.

                                    <input type="hidden" ng-model="Notify.loggedInEmail"
                                           ng-init="Notify.loggedInEmail = result.email"/>
                                    <input type="hidden" ng-model="Notify.postId" ng-init="Notify.postId = userpost.id"/>
                                    <input type="hidden" ng-model="Notify.destEmail"
                                           ng-init="Notify.destEmail = userpost.userEmail"/>

                                <button class="btn btn-primary" ng-disabled="userForm.$invalid || !userForm.$dirty"
                                        type="submit">
                                    Notify Post Owner
                                </button>

                    </form>

A: I will attempt following solution to implement it.
create a nested json object with number of forms to display in angularjs controller.
for example
$scope.FormsCollection = {
         "Form1" : [
             {"title" : "Rockband", "details" : "1hr"},
         ],
         "Form2" : [
             {"title" : "The Old You", "details" : "Dr. Smith"}
         ]

}

obviously, you can use loop to build it or whatever approach suits you best in your context to build the forms collection  in angularjs controller.
then in html page you can use following convention to correctly populate each form data
you need two ng-repeat, first for index of each form, and then to iterate nested form object.
<input type="text" ng-model="form[index].firstName"/>

as result you will have $scope.FormsCollection with correct form object data
Please check the example code in following jsfiddle
http://jsfiddle.net/CMnxW/4/
jsfiddle should contain following code.

{{$index}}
                <input type="text" ng-model="post.userEmail"  />
                <button class="btn btn-danger" ng-click="notify(post)" type="button">Notify</button>

                destEmail is:
                {{Notify.destEmail}}

JS:
function controller($scope) {
    $scope.Notify = {
        destEmail: ''
    };

    $scope.posts = [{userEmail: 'e@mail.com'}, {userEmail: 'f@mail.com'}];

    $scope.notify = function(post) {
        $scope.Notify.destEmail = post.userEmail;
        //set other $scope.Notify properties from post
        //your other notify code...
    }
}


text:
Q: How to convert a character to a numeric Below a specific cell from my dataset:
PT23M55.39S

The cell tells me how many minutes (23 minutes) and seconds (55.39 seconds) a user has spent on a webpage.
The cell is of the property char (character).
How do I convert it to a numeric where I express the visit time in only seconds (23 * 60 + 55.39 = 1435.39 seconds)?

A: Using lubridate functions ms and period_to_seconds you can do -
library(lubridate)

x <- 'PT23M55.39S'
period_to_seconds(ms(x))
#[1] 1435.39

In base R, you may use strcapture to extract the data using regex into minutes and seconds separately, multiply minutes value by 60 and add the two numbers.
strcapture('[A-Z]+(\\d+)M(\\d+\\.\\d+)', x,
           proto = list(minutes = numeric(), seconds = numeric())) |>
  transform(duration_in_seconds = minutes * 60 + seconds)


text:
Q: data role page dynamic display I am creating a HTML page with multiple data-role pages.loading time we will check some condition and display that particular data-role page.currently id display first data-role, how can i display data role page conditionally.

A: Take a look at the docs section "autoInitializePage". Here you can disable the default initialization until $.mobile.initializePage is manually called.

Because the mobileinit event is triggered immediately, you'll need to
  bind your event handler before jQuery Mobile is loaded. Link to your
  JavaScript files in the following order:
  jquery.js
  custom-scripting.js
  jquery-mobile.js

Please take a look at this fiddle. What it basibally does is adding a hash to your url thus redirecting to the subpage.
Source


text:
Q: Помогите разбить сообщения по дням Пишу чат, сообщения с сервера приходят в виде JSON за вывод сообщений отвечает JS. Проблема возникла с разбитием сообщений по дням вот не понимаю как сделать на JS, а на PHP могу. Можно на сервере PHPкой разбивать по датам формировать в JSON и уже JS это разбирать, но хотелось бы на JS.
Стандартный Ajax с передачей JSON
JSON:
   {"success":1,"chat_user_id":"7","user_id":"7","user_first_name":null,"user_last_name":null,"user_photo":null,"user_screen_name":null,"number_contact":null,"chat_client_info":{"first_name":null,"last_name":null,"patronymic_name":null,"user_avatar":null},"message_list":{"10":{"from":"client","agent_id":null,"user_full_name":"\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u21167","user_avatar":"\/img\/none_foto.png","text":"\u043f\u0440\u0438\u0432\u0435\u0442\n","datetime":"2019-10-29 23:02:20"},"11":{"from":"agent","agent_id":"1","user_full_name":"\u0410\u0433\u0435\u043d\u0442","user_avatar":"\/images\/user\/mini\/1513786871698.jpg","text":"\u043f\u0440\u0438\u0432\u0435\u0442\n","datetime":"2019-10-29 20:10:07"},"12":{"from":"client","agent_id":"1","user_full_name":"\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u21167","user_avatar":"\/img\/none_foto.png","text":"\u043f\u0440\u0438\u0432\u0435\u0442 \n","datetime":"2019-10-30 21:52:13"},"32":{"from":"client","agent_id":"1","user_full_name":"\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u21167","user_avatar":"\/img\/none_foto.png","text":"\u043f\u0440\u0438\u0432\u0435\u0442\n","datetime":"2019-11-03 20:35:42"},"33":{"from":"client","agent_id":"1","user_full_name":"\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u21167","user_avatar":"\/img\/none_foto.png","text":"\u043f\u0440\u0438\u0432\u0435\u0442\n","datetime":"2019-11-03 20:37:51"},"36":{"from":"agent","agent_id":"1","user_full_name":"\u0410\u0433\u0435\u043d\u0442","user_avatar":"\/images\/user\/mini\/1513786871698.jpg","text":"\u043f\u0440\u0438\u0432\u0435\u0442\n","datetime":"2019-11-03 19:19:50"},"39":{"from":"client","agent_id":"1","user_full_name":"\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u21167","user_avatar":"\/img\/none_foto.png","text":"gg\n","datetime":"2019-11-03 22:32:26"}}}

в цикл forEach:
let obj = data.message_list;
var message_list = '';
Object.keys(obj).forEach(function(key){

     templateMessage(obj[key]['from'],obj[key]['user_avatar'],obj[key]['user_full_name'],obj[key]['text'],obj[key]['datetime']); // шаблон сообщений
});

function templateMessage(from,avatar,user_full_name,text,datetime) {
var from_class = '';
var avatar_src = '//placekitten.com/g/50/50';
if(from == 'client') {  from_class = 'dialogs-user-message agent';}
if(from == 'agent') {   from_class = 'dialogs-user-message';}
if(!!avatar) {avatar_src = avatar;}
var sp = document.createElement("div");
sp.innerHTML = '

'+user_full_name+' '+datetime+'

'+text+'

';
sp.className = from_class;

document.querySelector(".dialogs-user-message-body").appendChild(sp);
}

Может функцию обработчик сделать, чтобы она разбивала на даты.

A: Разбивка сообщений по дням.

const z = {"success":1,"chat_user_id":"7","user_id":"7","user_first_name":null,"user_last_name":null,"user_photo":null,"user_screen_name":null,"number_contact":null,"chat_client_info":{"first_name":null,"last_name":null,"patronymic_name":null,"user_avatar":null},"message_list":{"10":{"from":"client","agent_id":null,"user_full_name":"\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u21167","user_avatar":"\/img\/none_foto.png","text":"\u043f\u0440\u0438\u0432\u0435\u0442\n","datetime":"2019-10-29 23:02:20"},"11":{"from":"agent","agent_id":"1","user_full_name":"\u0410\u0433\u0435\u043d\u0442","user_avatar":"\/images\/user\/mini\/1513786871698.jpg","text":"\u043f\u0440\u0438\u0432\u0435\u0442\n","datetime":"2019-10-29 20:10:07"},"12":{"from":"client","agent_id":"1","user_full_name":"\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u21167","user_avatar":"\/img\/none_foto.png","text":"\u043f\u0440\u0438\u0432\u0435\u0442 \n","datetime":"2019-10-30 21:52:13"},"32":{"from":"client","agent_id":"1","user_full_name":"\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u21167","user_avatar":"\/img\/none_foto.png","text":"\u043f\u0440\u0438\u0432\u0435\u0442\n","datetime":"2019-11-03 20:35:42"},"33":{"from":"client","agent_id":"1","user_full_name":"\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u21167","user_avatar":"\/img\/none_foto.png","text":"\u043f\u0440\u0438\u0432\u0435\u0442\n","datetime":"2019-11-03 20:37:51"},"36":{"from":"agent","agent_id":"1","user_full_name":"\u0410\u0433\u0435\u043d\u0442","user_avatar":"\/images\/user\/mini\/1513786871698.jpg","text":"\u043f\u0440\u0438\u0432\u0435\u0442\n","datetime":"2019-11-03 19:19:50"},"39":{"from":"client","agent_id":"1","user_full_name":"\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u21167","user_avatar":"\/img\/none_foto.png","text":"gg\n","datetime":"2019-11-03 22:32:26"}}};
const data = z.message_list;
const result = {};
Object.values(data).forEach(item => {
  const date = item.datetime.split(' ')[0];
  if (!result[date]) {
    result[date] = [];
  }
  result[date].push(item)
});

console.log(result)


text:
Q: Ignore less imports afterwards I want to use bootstrap and customize it via less. My main less file looks like this:
@import "../bower_components/bootstrap/less/bootstrap";
@import "custom-bootstrap-variables";

The bootstrap.less also contains multiple imports. Is it possible to "ignore" some imports in the bootstrap.less, for example well.less without altering the original bootstap.less.
Something like:
@import "../bower_components/bootstrap/less/bootstrap";
@import "custom-bootstrap-variables";
@ignore "bootstrap/well"


text:
Q: How to use a date slicer to filter two visualizations of two different columns in the same table in PowerBI I have searched for this query and attempted to implement some solutions i've found but i've not been able to apply the solutions to my problem so i'm hoping you can help.
We have a table with data, including "created" and "submitted" date columns.  I'm wanting to use one slicer to individually show how many results for items created on the selected date, and items submitted on the selected date.
Any help would be great.
Thanks in advance.

A: You will need a calendar table for this to work correctly as you will have to have a relationship between your data table and the calendar.
Using this example

In the above table, there is Order and Shipping Date, with a quantity column.

The calendar table is connected by the data column to the Order and Shipping Date. As you can only have one active relationship between the table, one is set as inactive. In this case the Shipping Date is Inactive.
So if I select a filter of 07/01/2018 on the Order data it will not show the quantity of items shipped, just the items ordered as it will filter out those rows.

In the above image, the table has been filtered using the active relationship and it only shows Orders for the 7th and Shipped on the 12th as that is what is in the table (Visual on the right)
So you will need two measures, one using the active and one using the inactive.
So you count the Orders as normal, and the Shipped with a relationship modifier:
Total Orders = SUM('TableName'[Quantity])
Total Shipped = CALCULATE(SUM(Billing[Quantity]), USERELATIONSHIP(Billing[Shipping Date], 'Calendar'[Date]))

USERELATIONSHIP forces the Total Shipped to ignore the filter context on active relationship and use the inactive one.

So it should return Shipped 366, Ordered 353 for the 7/01/2018. You'll need to use the calendar table in your visuals to drive the dates, not the dates in your data.


text:
Q: Is there a way to have button in a anchor tag, that acts like another link? I'm trying to have a button with an onclick event, that acts like a normal link inside another link.

Some text

Some other text

        <button onclick= 'window.location="http://www.google.de";'>Test</button>

I want to be able to click the whole div to get to link1, but if I click the button it should take me to google.de. Is there a possible way?

A: I found a solution.
I just put the button outside of the div, gave it an absolute position and then centered it in the div.
I couldn't manage to implement bootstrap here so the design is messed up.

body {
  margin: 0;
  margin-top: 30px;
  padding: 0;
  border: 0;
  font-size: 100%;
  vertical-align: baseline;
  font-family: Poppins;
  background-color: #f5f5f5;
  margin-left: auto;
  margin-right: auto;
}

a {
  color: black;
  text-decoration: none !important;
}

a:hover {
  color: inherit;
}

.person {
  border-bottom: 1px solid #e6e9ec;
  background-color: white;
  padding: 10px;
  line-height: 0.6;
  text-align: left;
  height: 160px;
}

.person:hover {
  transition: all ease-in-out 0.25s;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 2px 3px rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

.name {
  font-weight: bold;
  letter-spacing: 1px;
  font-size: 18px;
  padding-top: 20px;
}

.name:hover {
  text-decoration: underline;
}

.sector {
  margin-bottom: 20px;
}

/* FORM */

.connect-btn {
  position: relative;
  left: calc(90% - 50px);
  top: -100px;
  margin-right: 35px;
}

.custom-btn {
  border-color: #00008b;
  color: #00008b;
}

.custom-btn:hover {
  background-color: #00008b;
  border-color: #00008b;
  color: white;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

Some text

Other text

More text

  Connect

A: That's a bad markup. I modified the snippet added backgrounds for your understanding.
It is better to use anchor tags than using button with javascript redirect, but I'll just leave it the way you build it. If you plan to change it to an anchor then you need add css to make it look like a button or use .btn.btn-primary if your using bootstrap.

.item {
  position: relative;
  padding-bottom:20px;
  background: blue;
}
.item a {
  display: block;
  background: red;
}
.item button {
  display:inline-block;
  position: absolute;
  bottom: 0;
}

Some text

Some other text

  <button onclick= 'window.location="http://www.google.de";'>Test</button>


text:
Q: Constraint "PK" of relation "table" does not exist when generating migration with typeorm I have an ormconfig.ts like this:
const config: ConnectionOptions = {
  type: "postgres",
  host: "localhost",
  username: "postgres",
  password: "postgres",
  database: "dbname",
  entities: ["dist/database/entities/**/*.js"],
  migrations: ["dist/migration/**/*.js"],
  cli: {
    entitiesDir: "src/database/entities",
    migrationsDir: "src/migration",
  },
  synchronize: true,
  name: "app",
};

and an entity like so:
@Entity("follows")
export class Follow extends BaseEntity {
  @PrimaryColumn()
  followerAddress: string;

  @PrimaryColumn()
  followeeAddress: string;

  @OneToOne(() => User, (user) => user.address)
  @JoinColumn({ name: "followerAddress" })
  followerUser: User;

  @OneToOne(() => User, (user) => user.address)
  @JoinColumn({ name: "followeeAddress" })
  followeeUser: User;
}

If I rename the PrimaryColumns and make it like:
@Entity("follows")
export class Follow extends BaseEntity {
  @PrimaryColumn()
  followerAddressNew: string;

  @PrimaryColumn()
  followeeAddressNew: string;

  @OneToOne(() => User, (user) => user)
  @JoinColumn({ name: "followerAddress" })
  followerUser: User;

  @OneToOne(() => User, (user) => user)
  @JoinColumn({ name: "followeeAddress" })
  followeeUser: User;
}

Then I get the following error:
QueryFailedError: constraint "PK_0d65998d7ca318692c5021c8121" of relation "follows" does not exist

Synchronize is set to true, so I'm not sure if I need to generate and run a migration, but I tried that and got:
QueryFailedError: constraint "PK_439cf7d31c1f020884802168a8c" of relation "follows" does not exist

It seems that the generated migration file adds the constraint once and then drops it twice?
public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE "public"."follows" ADD "followerAddressfdsa" character varying NOT NULL`);
        await queryRunner.query(`ALTER TABLE "public"."follows" DROP CONSTRAINT "PK_3f7767cc6077ad78f956bffc8a7"`);
        await queryRunner.query(`ALTER TABLE "public"."follows" ADD CONSTRAINT "PK_59ecb7646bafb5e2ae63d6f8deb" PRIMARY KEY ("followerAddress", "followeeAddress", "followerAddressfdsa")`);
        await queryRunner.query(`ALTER TABLE "public"."follows" ADD "followeeAddressfdsa" character varying NOT NULL`);
        await queryRunner.query(`ALTER TABLE "public"."follows" DROP CONSTRAINT "PK_59ecb7646bafb5e2ae63d6f8deb"`);
        await queryRunner.query(`ALTER TABLE "public"."follows" ADD CONSTRAINT "PK_439cf7d31c1f020884802168a8c" PRIMARY KEY ("followerAddress", "followeeAddress", "followerAddressfdsa", "followeeAddressfdsa")`);
        await queryRunner.query(`ALTER TABLE "public"."follows" DROP CONSTRAINT "PK_439cf7d31c1f020884802168a8c"`);
        await queryRunner.query(`ALTER TABLE "public"."follows" ADD CONSTRAINT "PK_073836419485cc2ca626f9ce5a8" PRIMARY KEY ("followerAddressfdsa", "followeeAddressfdsa")`);
        await queryRunner.query(`ALTER TABLE "public"."follows" DROP CONSTRAINT "FK_e37f798c5697e8b84094d64a68f"`);
        await queryRunner.query(`ALTER TABLE "public"."follows" DROP CONSTRAINT "FK_70456987d622cd40a732aec83bd"`);
        await queryRunner.query(`ALTER TABLE "public"."follows" ALTER COLUMN "followerAddress" DROP NOT NULL`);
        await queryRunner.query(`ALTER TABLE "public"."follows" DROP CONSTRAINT "PK_439cf7d31c1f020884802168a8c"`);
        await queryRunner.query(`ALTER TABLE "public"."follows" ADD CONSTRAINT "PK_b9a8a76998607a9752a4d756814" PRIMARY KEY ("followeeAddress", "followerAddressfdsa", "followeeAddressfdsa")`);
        await queryRunner.query(`ALTER TABLE "public"."follows" ALTER COLUMN "followeeAddress" DROP NOT NULL`);
        await queryRunner.query(`ALTER TABLE "public"."follows" DROP CONSTRAINT "PK_b9a8a76998607a9752a4d756814"`);
        await queryRunner.query(`ALTER TABLE "public"."follows" ADD CONSTRAINT "PK_073836419485cc2ca626f9ce5a8" PRIMARY KEY ("followerAddressfdsa", "followeeAddressfdsa")`);
        await queryRunner.query(`ALTER TABLE "public"."follows" ADD CONSTRAINT "FK_e37f798c5697e8b84094d64a68f" FOREIGN KEY ("followerAddress") REFERENCES "users"("address") ON DELETE NO ACTION ON UPDATE NO ACTION`);
        await queryRunner.query(`ALTER TABLE "public"."follows" ADD CONSTRAINT "FK_70456987d622cd40a732aec83bd" FOREIGN KEY ("followeeAddress") REFERENCES "users"("address") ON DELETE NO ACTION ON UPDATE NO ACTION`);
    }

This line seems to be called twice:
    await queryRunner.query(`ALTER TABLE "public"."follows" DROP CONSTRAINT "PK_439cf7d31c1f020884802168a8c"`);

A: I don't know exactly what is happening with typeorm. Could be a bug with updating or creating schema using entity.
But I ran into this exact same problem and I found out that the tables were already created in the database. I deleted all the tables that were already created and ran the application so that typeorm (re)created the tables. That solved the problem for me.
I hope this works for you as well.


text:
Q: viewDidDisappear of child view controllers not called when tap on UITabBar I have an application with UITabBarController and some UINavigationViewControllers attached with it. Let say, on the first tab of UITabBarController, user navigates to view controller A, then to B, then to C, therefore created a stack of UINavigationController: A -> B -> C.
I need to do something in viewDidDisappear: of A, B and C. If user tap on Back button to go from C -> B -> A then viewDidDisappear: of B and C are called. But if user tap on first UITabBar of UITabBarController, they will go straight from C -> A, and only viewDidDisappear: of C is called, B is skipped.
If I use my custom UITabBarController subclass and return NO in tabBarController:shouldSelectViewController:, this behaviour will no more exist, but I don't want to do that, users will have to press Back button many times to go to root view controller. Is there any way to solve this problem but keep the UITabBarController's behaviour?

A: Make sure you keep your bottom bar as None(In view controllers B and C) as shown below.
This will hide the bottom bar from those view controllers and user won't be able to navigate to Viewcontroller A directly from Viewcontroller C.
The user will need to use the back button navigation to go to View controller A from C.
Which will solve your problem of calling viewDidDisappear.

A: when b->c,the viewDidDisappear method has been called,and when c->a,the method can't be called for another time.if you want b to do something,you should keep a weak reference object of b in a or c. Hope that can solve your problem.


text:
Q: jquery fullcalender: Assigning an array to jquery object I am working with
http://arshaw.com/fullcalendar/
I am facing a little issue. In the script it populates the events in the calender through following code.
events: [

            {
                title: 'Community informational meeting',
                start: new Date(y, 4, 25, 9, 0),
                end: new Date(y, m, d, 14, 0),
                allDay: false,
                backgroundColor: Theme.colors.red,
            },
            {
                title: 'SPA / SPOC annual meeting',
                start: new Date(y, 7, 16, 9, 0),
                end: new Date(y, m, d, 14, 0),
                allDay: false,
                backgroundColor: Theme.colors.red,
            },
            {
                title: 'SPSS First Day',
                start: new Date(y, 5, 30, 9, 0),
                end: new Date(y, m, d, 14, 0),
                allDay: true,
                backgroundColor: Theme.colors.red,
            }
        ]

the problem is the i have an array of events which is called events_array...
when i do the following
events: [
         events_array
]

It does not display anything. but when I put an index into the events_array
events: [
         events_array[0]
]

i.e. it starts showing that first event.
Any ideas how can i set it so that it shows all the events which are present in the array?
Thanks.

A: Based on what I've read here I think you should try setting assigning the events_array directly to the events FullCalendar's events option like this:
$('#calendar').fullCalendar({
    events: events_array
});

Obviously the selector '#calendar' will vary according to your needs.


text:
Q: Circular inclusion with Parent, Child and Other so I just can't work out my circular inclusions. Can anyone give me a hand? I know I need to be pre-declaring my classes, but I can not work out the combination (mostly guess-work though). OtherClass is meant to be like a container for ParentClass and its children.
My current class setup is along the lines of this:
OtherClass.h
class ParentClass; // includes
class ChildClass;

class OtherClass
{
    ParentClass* parent;
    ChildClass* child;
}

ParentClass.h
class OtherClass;
class ParentClass
{
    OtherClass* other;
}

ChildClass.h
#include "ParentClass.h";
#include "OtherClass.h";

class ChildClass: public ParentClass
{
    other->foo(); // Using OtherClass pointer declared in parent.
}

For that approach above, I am getting Member access into incomplete type 'ParentClass'.
This probably also needs to be expandable, as I'm sure in the future there will be more child classes of ChildClass.

A: It's not clear what you mean by ChildClass.cpp uses things from OtherClass as well, that is, if you want to inherit from the OtherClass type or just compose of it ('has a' vs. 'is a'), but you could use templates as well to make it a generic container class for various types:
OtherClass.h
#if !defined(OTHER_CLASS_HPP)
#define OTHER_CLASS_HPP

template < typename T1, typename T2 >
class OtherClass
{
    public: // private/protected ??
        T1* parent;
        T2* child;

        void foo()
        {
            this->parent->bar();
            this->child->baz();
            // this->parent->baz(); // compile error since no ParentClass::baz
        }
};

#endif

ParentClass.h
#if !defined(PARENT_CLASS_HPP)
#define PARENT_CLASS_HPP

#include "OtherClass.h"

template < typename T1 >
class ParentClass
{
    public:
        ParentClass() : other(new OtherClass<ParentClass, T1>) {}
        ~ParentClass() { delete this->other; }

        void bar() { }
    protected:
        OtherClass<ParentClass, T1>* other;
};

#endif

ChildClass.h
#if !defined(CHILD_CLASS_HPP)
#define CHILD_CLASS_HPP

#include "ParentClass.h"

class ChildClass : public ParentClass < ChildClass >
{
    public:
        void foo()
        {
            this->other->foo();
        }

        void baz() { }
};

#endif

And depending on what each class exactly does, this can abstract a little more for you to make it 'expandable'. You don't have to forward declare anything with this approach but it can add complexity elsewhere (again, depending on the exact needs of the parent/child relationship/classes).
Hope that can help.


text:
Q: Is it possible to make computer Historical record More detail in GLPI I met some problems when using GLPI, searched on google but get no answer:
In my compony , we want to record the life cycle of the server and the hardware (for example : record Hard disk, memory changes on the server; record  life cycle of a Hard Disk ), so I want to record the changes of server and hardware.
Problem is :

*

*Currently the Computer Historical record only model of components, for example when I add a Hard Disk, the Historical shows :Add a component: SSD - 960G (9)
what I want is to record the Hard Disk Serial number (eg. XXXXXX ) in Historical, for example : Add a component: SSD - 960G (9) - XXXXXX
which file should I modify to make Historical to record Hard Disk Serial number , thanks.

*the second question is also a problem about Historical: in Component --> "Item - Hard drive link" , historical record nothing,
I want to record associate and dissociate computer operation in "Item - Hard drive link"'s Historical, in my mind the  format should be :2018-11-1 9:01  associate - Computer Serial number
Can anyone help on it, Thanks in advance!

A: I just found the solution:
I use "Device" as Component: so that both computer and device could record the history.
And I search the device by its ID record in the computer's history.


text:
Q: C# error's question as type or namespace issue using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
public class PlayerMovement : MonoBehaviour
{
    [SerializeField] private float movementSpeed =100f;

    private float verticalDirection;

    private Rigidbody rb;

    private Animator animator;
    // Start is called before the first frame update
      public bool IsMoving()
    {
        return rb.velocity.magnitude > 0.1f;
    }

    void Awake()
    {
        rb=GetComponent<Rigidbody>();
        animator = GetComponentInChildren<Animator>();
    }
    private void Update()
    {
        verticalDirection=Input.GetAxis("Vertical");
        verticalDirection=Mathf.Clamp(verticalDirection,0,1);

        animator.SetFloat("Speed",verticalDirection);
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        rb.velocity=Vector3.forward*verticalDirection*movementSpeed*Time.fixedDeltaTime;
    }
}

Error1:
Assets\Scripts\PlayerMovement.cs(4,31): error CS0246: The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?)

Error2:
Assets\Scripts\PlayerMovement.cs(10,13): error CS0246: The type or namespace name 'Rigidbody' could not be found (are you missing a using directive or an assembly reference?)
Error3:
Assets\Scripts\PlayerMovement.cs(12,13): error CS0246: The type or namespace name 'Animator' could not be found (are you missing a using directive or an assembly reference?)
Error4:
Assets\Scripts\PlayerMovement.cs(12,13): error CS0246: The type or namespace name 'Animator' could not be found (are you missing a using directive or an assembly reference?)
Error5:
Assets\Scripts\PlayerMovement.cs(6,6): error CS0246: The type or namespace name 'SerializeFieldAttribute' could not be found (are you missing a using directive or an assembly reference?)
Error6:
Assets\Scripts\PlayerMovement.cs(6,6): error CS0246: The type or namespace name 'SerializeField' could not be found (are you missing a using directive or an assembly reference?)
Error7:
Assets\Scripts\Robot.cs(20,13): error CS0246: The type or namespace name 'PlayMovement' could not be found (are you missing a using directive or an assembly reference?)

It is my other code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Diagnostics;
//using System.Runtime.Serialization;
//using UnityEngine.UI;
//using System.web.Helpers;

enum RobotStates {Counting,Inspecting}
public class Robot : MonoBehaviour
{
    [SerializeField] private float startInspectionTime = 2f;
    [SerializeField] private AudioSource jingleSource;
    private float currentInspectionTime;

    private RobotStates currentState = RobotStates.Counting;

    private Animator animator;

    private PlayMovement player;

    // Start is called before the first frame update
    void Start()
    {
        player=FindObjectType<PlayerMovement>();
        animator=GetComponentInChildren<Animator>();

        currentInspectionTime = startInspectionTime;
    }

    // Update is called once per frame
    void Update()
    {
        StateMachine();
    }

    private void StateMachine()
    {
        switch(currentState)
        {
            case RobotStates.Counting:
                Count();
                break;
            case RobotStates.Inspecting:
                Inspect();
                break;
            default:
                break;
        }

    }

    private void Count()
    {
        if (!jingleSource.isPlaying){
            animator.SetTrigger("Look");
            currentState=RobotStates.Inspecting;
        }
    }

    private void Inspect()
    {
        if(currentInspectionTime>0)
        {
            currentInspectionTime -=Time.deltaTime;

            if (player.IsMoving())
            {
                Destroy(player.gameObject);
            }
        }
        else
        {
            currentInspectionTime=startInspectionTime;
            animator.SetTrigger("Look");

            jingleSource.Play();
            currentState=RobotStates.Counting;
        }

    }

}

I have 7 error about CS0246. I used all namespace whatever I can use but it does not work. I checked the briket and semicolon all of them but i am not sure why i get error. I used
**
using UnityEngine;
using UnityEngine.Video;
using UnityEngine.UI;
using UnityEditor;
using System.Diagnostics;

**
Those namespace but it does not work please help me............
**Please note the parenthesis which are causing the issue I have labelled Error Parethesis however I am not entirely sure these are causing the overall issue.

A: Try to put a space between the using System.Diagnostics; and the monobehaviour and also make sure it has the same name as the script file you created.

A: Reading the error messages:

Error2: Assets\Scripts\PlayerMovement.cs(10,13): error CS0246: The
type or namespace name 'Rigidbody' could not be found (are you missing
a using directive or an assembly reference?)

RigidBody requires a reference to UnityEngine.PhysicsModule

Error3:  Assets\Scripts\PlayerMovement.cs(12,13): error CS0246: The
type or namespace name 'Animator' could not be found (are you missing
a using directive or an assembly reference?)
Error4: Assets\Scripts\PlayerMovement.cs(12,13): error CS0246: The
type or namespace name 'Animator' could not be found (are you missing
a using directive or an assembly reference?)

Animator requires a reference to UnityEngine.AnimationModule

Error5: Assets\Scripts\PlayerMovement.cs(6,6): error CS0246: The type
or namespace name 'SerializeFieldAttribute' could not be found (are
you missing a using directive or an assembly reference?) Error6:
Assets\Scripts\PlayerMovement.cs(6,6): error CS0246: The type or
namespace name 'SerializeField' could not be found (are you missing a
using directive or an assembly reference?)

SerializeField requires a using reference to UnityEngine.CoreModule

Error7: Assets\Scripts\Robot.cs(20,13): error CS0246: The type or
namespace name 'PlayMovement' could not be found (are you missing a
using directive or an assembly reference?)

Should this be PlayerMovement rather than PlayMovement?


text:
Q: Android. Memory usage limits I am using a 'big' in-memory data object in my Android app. Object size is ~3MB. It works fine on my device and emulator. Will  I have any unusual problems on weak devices?
Which objects are too big and which are fine to use in Android mobile application?

A: You can check the approximate memory allowed per application on a device via the ActivityManager's getMemoryClass() function: http://developer.android.com/reference/android/app/ActivityManager.html#getMemoryClass%28%29
It returns an int, which specifies the approximate amount of memory available per app in megabytes.

A: A quick Google search led me to the Documentation from Google:
http://developer.android.com/training/articles/memory.html#CheckHowMuchMemory


text:
Q: New line character ini file inno setup In my inno code I write a string to ini file for instance:
{"TrackUrl"="http://ext-feed.databssint.com/"\n"Offers"=[{"DownloadUrl"="http://dehosting.dmccint.com/FeedStub/1.4.0.5.150107.02/stub.exe"\n"OfferCMD"="OfferID=553565;

Before I write this string to the ini file I wish to modify it and replace all the "," characters with new line character, I tried to use:
StringChangeEx(MyStringVar, ',', \n  , False);

but instead to add a new line it replace the "," with "\n"
does anybody know how to pass the ini file a new line command character ?


text:
Q: Duplicate Validation on Combined Fields in zend form Hi there I have a table in which combination of three fields is unique. I want to put the check of duplication on this combination. Table looks like

I know how to validate single field, But how to validate the combination is not know. To validate one field I use the following function
public function isValid($data) {

    // Options for name field validation
    $options = array(
        'adapter' => Zend_Db_Table::getDefaultAdapter(),
        'table' => 'currencies',
        'field' => 'name',
         'message'=> ('this currency name already exists in our DB'),
    );

    // Exclude if a id is given (edit action)
    if (isset($data['id'])) {
        $options['exclude'] = array('field' => 'id', 'value' => $data['id']);
    }

    // Validate that name  is not already in use
    $this->getElement('name')
            ->addValidator('Db_NoRecordExists', false, $options

    );

    return parent::isValid($data);
}

Will any body guide me how can I validate duplication on combined fields?

A: There is no ready to use validator for this, as far as I know. You have either to write your own, or do a check with SQL-query with three conditions (one for each field).

A: you have to Apply a validation on name element of zend form.
Here is code for add validation on name field.
$name->addValidator(
    'Db_NoRecordExists',
    true,
    array(
        'table' => 'currencies',
        'field' => 'name',
        'messages' => array( "recordFound" => "This Currency Name already exists in our DB") ,

    )
);

And you must set required true.


text:
Q: Allow moderators to merge an answer with the question, under some circumstances Maybe this is only a problem with small sites. What I notice on Drupal Answers, where users are not required to register an account to ask questions, is that sometimes a user asks a question with an account, somebody writes a comment for that question, and the user tries to edit the question with a different account; when the user notices he cannot edit the question, he instead writes an answer.

In the past, moderators could merge two accounts, but now they cannot. To tell the truth, merging the accounts just to be able to merge the answer with the question is probably a bit too much. In fact, it could be perfectly fine to have an account for the questions asked because of work, and one account for personal questions; as long as the accounts are not used to vote each other, or vote for users twice, there should not be any reason to merge the accounts.
As it is currently implemented, an answer can be merged with the question (that is, put the answer's text in the question, and delete the answer), when both the answer and the question have been written using the same account.
Considering users can use unregistered accounts, which exist uniquely in a single browser, and when the user doesn't clean cookies, I would request to make possible for the moderators to merge the answer with the question even if the accounts used for the posts are different.
Considering that it is always possible to reverse the operation done, since the answer is simply soft-deleted (and moderators and 10k+ users see the deleted post), and the appended text is added as new revision (and revisions can be reverted by moderators), I don't see any harm in allowing the moderators to always be able to merge an answer into a question, even when the involved accounts are different.
If that is excessive, I am fine also with allowing the operation only when some criteria are met. For example, the operation could be allowed if the gravatar is the same in both cases, or the IP used to access both the accounts is the same. I am perfectly fine also with a warning that alerts the moderators when the operation is done and the accounts are not the same; this would at least avoid inadvertently doing something by mistake.


text:
Q: How to fix: odd and even pages have different margin I want that all the pages (odd und even) of my thesis document have the same geometry but the problem is that the odd and the even pages have different margin
Here is my configuration:
-------
\geometry{
    paper=a4paper, % Change to letterpaper for US letter
    %showframe, % Uncomment to show how the type block is set on the page
    left=4cm,
  right=2cm,
  top=2.5cm,
  bottom=2cm,
}

Can someone help me please how to fix this problem.

A: This is what I obtain with your setting.
\documentclass{book}
\usepackage{geometry}
\geometry{
  paper=a4paper,
  left=4cm,
  right=2cm,
  top=2.5cm,
  bottom=2cm,
}
\usepackage{lipsum}
\begin{document}
\lipsum[1-15]
\end{document}

I suggest you to provide a MCVE. Don't post your full thesis.

A: Use option asymmetric:
\documentclass{book}
\usepackage{blindtext}% only for dummy text
\usepackage{geometry}
\geometry{
  paper=a4paper,
  %showframe,
  left=4cm,
  right=2cm,
  top=2.5cm,
  bottom=2cm,
  asymmetric% <- added
}
\begin{document}
\blinddocument
\end{document}

Result:


text:
Q: How can I get all the posts that are related with a specific taxonomy term? I'm using the technique below for that (getting all the post related with a taxonomy term), but for some reason if I have some posts with the term e and post with the term English I get  them all and not only those which are related to English.
 'tax_query' => array(
      array(
            'taxonomy' => 'origin',
            'field'    => 'name',
            'terms'    => 'English',

     )
 )

Is there a way to get all the post related with the English term only?
I'm not sure but right now seems to be working as a like operator.

A: Try this:
'tax_query' => array(
  'origin' => 'English'
)

Also, it should be pretty easy. Do some research.


text:
Q: Add input mask on Wordpress Login page I am looking to add an input mask into the wp-login.php file so that the username can only be entered in the format of 1 lettter followed by 9 digits e.g. u828382901 and for an error to be received if the format was not followed.
I have attempted to use several plugins to modify the login page but it seems like I must enter the login file and edit the php directly.
My attempted php code is;
<?php
function myplugin_check_fields( $errors, $sanitized_user_login, $username ) {

if ( ! preg_match('/u[0-9]{9}/', $_POST['username'] ) ) {
    $errors->add( 'username_error', __( 'ERROR: Invalid user code.', 'my_textdomain' ) );
}

return $errors;
add_filter( 'registration_errors', 'myplugin_check_fields', 10, 3 );
?>

** I understand the php is probably a mess, its just my best attempt at writing in php
Thanks


text:
Q: pykd: setBp with callback gives typeerror I am trying to write a heap tracer using windbg and pykd, but I am getting a TypeError when trying to set the callback.
Here is a part of the code:

def enter_call_back(bp):
    print "RtlAllocateHeap called"
    return False

def return_call_back(bp):
    print "RtlAllocateHeap returned"
    return False

add = get_address("ntdll!RtlAllocateHeap")
bp_init = pykd.setBp(int(add, 16), enter_call_back)
bp_end = None

When I try to run it I get the following error:
0:000> !py C:\Users\tobbe\Documents\Projects\HeapTrace\heap_trace.py
hej

TypeError: enter_call_back() takes exactly 1 argument (0 given)

I am using python version 2.7;
0:000> !py
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

and pykd version 2.0.0.22
0:000> !pykd.info

pykd bootstrapper version: 2.0.0.22

Installed python:

Version:        Status:     Image:
------------------------------------------------------------------------------
* 2.7 x86-32    Unloaded    C:\WINDOWS\SYSTEM32\python27.dll
  3.7 x86-32    Unloaded    C:\Users\Tobias.Lorek\AppData\Local\Programs\Python\Python37-32\python37.dll

I originally tried to follow the following tutorial but got a similar error, https://labs.f-secure.com/archive/heap-tracing-with-windbg-and-python/
Any help would be appreciated.
Regards,

A: enter_call_back should not has no argumnets.
see example from pykd tests:
https://githomelab.ru/pykd/pykd/blob/0.3.2/test/scripts/breakpoint.py#L67
 def stopOnBreak():
     return pykd.eventResult.Break

 def testBreakCallback(self):
      breakCount = callCounter(stopOnBreak)
      bp = pykd.setBp( self.targetModule.CdeclFunc, breakCount )
      self.assertEqual( pykd.executionStatus.Break, pykd.go() )
      self.assertEqual( 1, breakCount.count )


text:
Q: Mongoose / mongodb - Remove embedded document I have a Schema (called Event) with data that looks like this:
{ "_id" : ObjectId( "4f8dcb06ee21783d7400003c" ),
  "venue" : ObjectId( "4f8dcb06ee21783d7400003b" ),
  "name" : "Some event",
  "webite: "www.whatever.com",
  "attendees" : [
                    { "_id" : ObjectId( "4f8dfb06ee21783d7134503a" ), "firstName" : "Joe", "lastName" : "Blogs", "emailAddress" : "some@thing1.com" },
                    { "_id" : ObjectId( "4f8dfb06ee21783d7134503b" ), "firstName" : "John", "lastName" : "West", "emailAddress" : "some@thing2.com" }
                    { "_id" : ObjectId( "4f8dfb06ee21783d7134503c" ), "firstName" : "Simon", "lastName" : "Green", "emailAddress" : "some@thing3.com" }
                    { "_id" : ObjectId( "4f8dfb06ee21783d7134503d" ), "firstName" : "Harry", "lastName" : "Smith", "emailAddress" : "some@thing4.com" }
                ],
  "eventType" : "Party"
}

How can I 'delete' the attendees object with id 4f8dfb06ee21783d7134503c?
Basically something like....
Event.findOne('attendees._id' : ObjectId('4f8dfb06ee21783d7134503c'), function(err, eventItem){
    //delete the attendee embedded doc with id 4f8dfb06ee21783d7134503c
});

A: I think you're looking for $pull.
db.collection.update({_id: ObjectId( "4f8dcb06ee21783d7400003c" )},
                     {$pull: {attendees: {_id: ObjectId( "4f8dfb06ee21783d7134503a" )}}})


text:
Q: Firebase firestore get data from collections documents and then subcollection documents in one array I am using node server with express and trying to get data from the firestore database. My database structure is as follows
-Resource Collection
  - Documents with fields
     - comments subcollection
         - documents with fields
     - subresource subcollection
         - documents with fields

I am trying to map all the above data in a single array with subresource and comments being nested array inside the single array. Following is my code. The log has the correct data in one array but when I am sending the response back it only shows 1 resource and that too is random everytime. Shouldnt promise.all then block execute after all the data has been collected? Am i even using the promises correctly?
    response.set('Cache-Control','public, max-age=300, s-maxage=600');
    db.collection('Resources').get()
    .then(snapshot => {
        let Resources = snapshot.docs.map(doc => {
            var promises = [];
            let documentData = doc.data();
            documentData['id'] = doc.id;
            promises.push(db.collection('Resources').doc(documentData.id).collection('SubResources').get()
            .then(snapshot => {
                documentData['subresources'] = snapshot.docs.map(doc => {
                    let subResourceData = doc.data();
                    subResourceData['id'] = doc.id;
                    return subResourceData;
                })
            }));
            promises.push(db.collection('Resources').doc(documentData.id).collection('Comments').get()
            .then(snapshot => {
                documentData['comments'] = snapshot.docs.map(doc => {
                    return doc.data();
                })
            }));
            Promise.all(promises).then(function(){
                console.log(documentData);
                return response.json(documentData);
            })
        })

    })
    .catch(err => {
        console.log('Error getting documents', err);
    });
});

A: Your Promise.all() catches the promises of fetching subresource and comments only, and not the "Resource"s themselves. so for whichever Resource it can complete fetching the subresource and comments first, it resolves and returns the data.
Below is a slight modification to your code so that it waits for all the Resources to complete pulling comments/subresources and then returns them as an array.
response.set('Cache-Control','public, max-age=300, s-maxage=600');

db.collection('Resources').get()
.then(snapshot => {
    let ResourcePromises = snapshot.docs.map(doc => {
        var promises = [];
        let documentData = doc.data();
        documentData['id'] = doc.id;
        promises.push(db.collection('Resources').doc(documentData.id).collection('SubResources').get()
        .then(snapshot => {
            documentData['subresources'] = snapshot.docs.map(doc => {
                let subResourceData = doc.data();
                subResourceData['id'] = doc.id;
                return subResourceData;
            })
        }));
        promises.push(db.collection('Resources').doc(documentData.id).collection('Comments').get()
        .then(snapshot => {
            documentData['comments'] = snapshot.docs.map(doc => {
                return doc.data();
            })
        }));
        return Promise.all(promises).then(function(){
            //console.log(documentData);
            //return response.json(documentData);
            return documentData;
        })
    });

    Promise.all(ResourcePromises).then(function(allResources) {
        return response.json(allResources);
    })

})
.catch(err => {
    console.log('Error getting documents', err);
});

You may want to refactor the code to separate functions so that they're more readable.


text:
Q: Hibernate eager loading (fetch all properties does not work) Basically I want to eager-load properties. I have the following HQL query:
SELECT u.id AS id, u.name AS text, u AS obj FROM User AS u fetch all properties

I would expect this to execute one query only. Instead I got N+1 queries.
The code is the following:
Query q = mySession.createQuery(
    "SELECT u.id AS id, u.name AS text, u AS obj FROM User AS u fetch all properties")
    .setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);

for (Iterator i = q.iterate(); i.hasNext();) {
    Object line = i.next();
    System.out.println(line);
}

The output I get (with hibernate.show_sql set to true) is:
Hibernate: select user0_.id as col_0_0_, user0_.name as col_1_0_, user0_.id as col_2_0_ from user user0_
Hibernate: select user0_.id as id0_0_, user0_.name as name0_0_, user0_.location as location0_0_ from user user0_ where user0_.id=?
{id=1, obj=User@b6548 [id='1' name='John' ], text=John}
Hibernate: select user0_.id as id0_0_, user0_.name as name0_0_, user0_.location as location0_0_ from user user0_ where user0_.id=?
{id=2, obj=User@4865ce [id='2' name='Arnold' ], text=Arnold}

Ps: The situation is just the same without transformers.

Edit:
The file with the entity-mappings:
<hibernate-mapping>

    <class name="User" table="user">
        <id name="id" column="id">
            <generator class="native"/>
        </id>
        <property name="name"/>
        <property name="location"/>
        <map name="customPrices" table="custprice">
            <key column="user"/>
            <map-key-many-to-many column="product" class="Product"/>
            <element column="price" type="double"/>
        </map>
    </class>

    <class name="Product" table="product">
        <id name="id" column="id">
            <generator class="native"/>
        </id>
        <property name="name"/>
        <property name="listprice"/>
    </class>

</hibernate-mapping>

I tried adding lazy="false" to the class and to the individual properties. No difference.
My configuration file:
<hibernate-configuration>
<session-factory>
    <property name="connection.url">jdbc:mysql://192.168.0.203/hibtest</property>
    <property name="connection.username">hibtest</property>
    <property name="connection.password">hibb345</property>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <property name="current_session_context_class">thread</property>
    <property name="hibernate.show_sql">true</property>

    <mapping resource="combined.hbm.xml" />
</session-factory>
</hibernate-configuration>

Edit2:
Even the following code causes N+1 query. Although I only fetch the ID field, which according to documentation should not cause objects to load.
for (Iterator i = q.iterate(); i.hasNext();) {
    Object line = i.next();
    User u = (User)((Map)line).get("obj");
    System.out.println(u.getId());
}

A: The problem was with .iterate(). According to Hibernate API docs:

Entities returned as results are initialized on demand. The first SQL query returns identifiers only.

This is a special function to be used when we expect the resulting objects to be already cached. They will be (lazy) loaded when accessed.
So for general use, to get an iterator on a result of a query you should use .list().iterate().
Thanks for Eran Harel for the help.

A: In essense, the cause of your problem is an attempt to incorporate result transformation logic into a query.
I think it would be better to make a simple HQL query and then apply your specific result transformation logic in a custom ResultTransformer, something like this:
Query q = mySession.createQuery("FROM User")
    .setResultTransformer(new ResultTransformer() {
        public List transformList(List l) { return l; }
        public Object transformTuple(Object[] tuple, String[] aliases) {
            Map<String, Object> r = new HashMap<String, Object>();
            User u = (User) tuple[0];
            r.put("obj", u);
            r.put("id", u.getId());
            r.put("text", u.getName());
            return r;
        }
    });

A: Looks like it cannot retrieve the obj in a single query with separate columns.
Since you use the same values from User for the other columns, the example from @axtavt seems your best solution.


text:
Q: Capture all errors in form and ensure atomicity -rails I want to capture all the errors in a form and also ensure that the operation is atomic that is the form goes through if there are no errors else it just captures the error and no other correct fields are saved.
ActiveRecord::Base.transaction do
    @var_types.each_with_index do |var,index|
          begin
            var.save!
            puts "saving"
          rescue
            puts "rescued"
          end
    end

I am using the above block, although this captures all the errors in but atomicity is not guarenteed. Any way to correct this?
EDIT:
Example
 An example would be say something like a form where a user has to enter multiple fields and multiple fields may not conform to the db rules, so i expect all the errors to be shown at once so the save as to keep happening to get all the errors but at the same time ensure that no correct changes get saved if there is even one error.

A: You have to catch the exception outside the transaction.
The transactions are rollbacked when an exception goes out the transaction block
begin
  ActiveRecord::Base.transaction do
    @var_types.each_with_index do |var,index|
      var.save!
      puts "saving"
    end
  end
rescue
  puts "rescued"
end

UPDATE after reading your comment:
ActiveRecord::Base.transaction do
  raise ActiveRecord::Rollback unless @var_types.map(&:save).all? #passing here a block like { |res| res == true } is redundant.
  redirect_to some_index_path, notice: "Everything saved"
end

render action: 'edit' # something didn't pass the validation, re-render the view

Things to note here:
  If you raise ActiveRecord::Rollback inside a transaction block, you don't need a rescue for it (read the docs at http://api.rubyonrails.org/classes/ActiveRecord/Rollback.html)
Someone might say that you should not drive the flow based in exception-throwing, if you don't feel comfortable with it, you can do something like this:
all_saved = false # need to define this var outside, or it will a block-level variable, visible only in the block
ActiveRecord::Base.transaction do
  all_saved = @var_types.map(&:save).all?
  raise ActiveRecord::Rollback unless all_saved
end

if all_saved
  redirect_to some_index_path, notice: "Everything saved"
else
  render action: 'edit' # something didn't pass the validation, re-render the view
end


text:
Q: Show by counter example that $\{xy : x ∈ I,y ∈ J\}$ need not be an ideal On this page I find an example saying that $x^2+y^2$ is not a product of two elements in the set $(x, y) = \{ax + by : a, b ∈ \mathbb R\}$.
But so far I think we can take $x^2+y^2∈ I$ and $1∈ J$ and thus it is a product of $u ∈ I,v ∈ J$.
Is it wrong? Thanks for explanation.

A: In the example given, we have $I=J=\left\{ ax+by:a,b\in\mathbb{R}\right\}$. But we can not have $x^{2}+y^{2}\in I$ because $I$ consists only of polynomials of the form $ax+by$ for any real $a$ and $b$.
EDIT: As another user has pointed out, there is a typo in the pfd file. The $a$ and $b$ are supposed to be elements of $\mathbb{R}[x,y]$. In this case, it is not true that $1\in I$. Try and see why.


text:
Q: Grep in R using OR and NOT I have the following vector in R and I would like to find all the strings containing A's and B's but not the number 2.
vec1<-c("A_cont_1", "A_cont_12", "B_treat_8", "AB_cont_22", "cont_21_Aa")

The following does not work:
grep("A|B|!2", vec1)

It gives me back all the strings:
[1] 1 2 3 4 5

The same is true for this example:
grep("A|B|-2", vec1)

What would be the correct syntax?

A: You can do this with a fairly simple regular expression:
grep("^[^2]*[AB][^2]*$", vec1)

In words, it means:

*

*^ match the start of the string

*[^2]* match anything except "2", zero or more times

*[AB] match "A" or "B"

*[^2]* match anything except "2", zero or more times

*$ match the end of the string

A: grep generally does not work very well for doing a positive and a negative search in one invocation. You might be able to make it work with a complex regular expression, but you might be better off just doing:
 grep '[AB]' somefile.txt | grep -v '2'

The R equivalent of that would be:
grep("2", grep("A|B", vec1, value = T), invert = T)

A: I would use two grep calls:
intersect(grep("A|B",vec1),grep("2",vec1,invert=TRUE))
#[1] 1 3

A: OP, your attempt is pretty close, try this:
grep('^(A|B|[^2])*$', vec1)

A: I extended the answer provided by @eddi. I have tested it in R and it works for me. I changed the last variable in your example since they all contained A|B.
# Create the vector from the OP with one change
vec1<-c("A_cont_1", "A_cont_12", "B_treat_8", "AB_cont_22", "cont_21_dd")

I then ran the following code. It will tell you which results you should expect from each section of grep.
First, tell me which columns contain A or B
> grepl("A|B", vec1)
[1] TRUE TRUE TRUE TRUE FALSE

Now tell me which columns contain a "2"
> grepl("2", vec1)
[1] FALSE TRUE FALSE TRUE TRUE

The index we want is 2,4
> grep("2", grep("A|B", vec1, value = T))
[1] 2 4

Done!