问:
Rails Executing migration ArgumentError
I'm having a strange problem executing rake db:migrate

```<code>== 20141127213559 CreateMovies: migrating =====================================
-- create_table(:movies)
   -> 0.0033s
== 20141127213559 CreateMovies: migrated (0.0034s) ============================

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (1 for 0)
ArgumentError: wrong number of arguments (1 for 0)

Tasks: TOP => db:migrate
(See full trace by running task with --trace)
</code>```

What I did was:

```<code>rails generate model Movie
</code>```

And then edit the migration CreateMovies

```<code>class CreateMovies < ActiveRecord::Migration
  def up
    #drop_table :movies
    create_table :movies do |t|
      t.string :title
      t.string :rating
      t.text :description
      t.datetime :release_date
      # Add fields that let Rails automatically keep track
      # of when movies are added or modified:
      t.timestamps
    end
  end

  def down
    drop_table :movies
  end
end
</code>```

This is the output of executing the command with --trace

```<code>[fran@arch rottenpotatoes]$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
== 20141127213559 CreateMovies: migrating =====================================
-- create_table(:movies)
   -> 0.0039s
== 20141127213559 CreateMovies: migrated (0.0041s) ============================

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (1 for 0)/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `initialize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `new'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `substitute_at'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:97:in `block in substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each_with_index'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:56:in `insert'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:521:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/counter_cache.rb:139:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:122:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_create_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:501:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_save_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:142:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/validations.rb:42:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `block in save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:345:in `block in with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:342:in `with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:51:in `create!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1015:in `record_version_state_after_migrating'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:985:in `block in execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `call'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:165:in `invoke'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:156:in `invoke_task'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block (2 levels) in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:121:in `run_with_threads'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:106:in `top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:84:in `block in run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:182:in `standard_exception_handling'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:79:in `run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/bin/rake:33:in `<top (required)>'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `load'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `<main>'
ArgumentError: wrong number of arguments (1 for 0)
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `initialize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `new'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `substitute_at'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:97:in `block in substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each_with_index'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:56:in `insert'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:521:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/counter_cache.rb:139:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:122:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_create_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:501:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_save_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:142:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/validations.rb:42:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `block in save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:345:in `block in with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:342:in `with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:51:in `create!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1015:in `record_version_state_after_migrating'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:985:in `block in execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `call'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:165:in `invoke'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:156:in `invoke_task'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block (2 levels) in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:121:in `run_with_threads'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:106:in `top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:84:in `block in run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:182:in `standard_exception_handling'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:79:in `run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/bin/rake:33:in `<top (required)>'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `load'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `<main>'
Tasks: TOP => db:migrate
</code>```

Any help would be really appreciated. Thanks.

答:
Maybe you should execute this after create movies table:

```<code>generate migration AddFieldsToMovies newfield:type
</code>```

This generates the correct migration, see this:

http://edgeguides.rubyonrails.org/active_record_migrations.html#changing-tables

Title: Rails Executing migration ArgumentError

Body:
I'm having a strange problem executing rake db:migrate

== 20141127213559 CreateMovies: migrating =====================================
-- create_table(:movies)
   -> 0.0033s
== 20141127213559 CreateMovies: migrated (0.0034s) ============================

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (1 for 0)
ArgumentError: wrong number of arguments (1 for 0)

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

What I did was:

rails generate model Movie

And then edit the migration CreateMovies

class CreateMovies < ActiveRecord::Migration
  def up
    #drop_table :movies
    create_table :movies do |t|
      t.string :title
      t.string :rating
      t.text :description
      t.datetime :release_date
      # Add fields that let Rails automatically keep track
      # of when movies are added or modified:
      t.timestamps
    end
  end

  def down
    drop_table :movies
  end
end

This is the output of executing the command with --trace

[fran@arch rottenpotatoes]$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
== 20141127213559 CreateMovies: migrating =====================================
-- create_table(:movies)
   -> 0.0039s
== 20141127213559 CreateMovies: migrated (0.0041s) ============================

rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (1 for 0)/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `initialize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `new'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `substitute_at'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:97:in `block in substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each_with_index'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:56:in `insert'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:521:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/counter_cache.rb:139:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:122:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_create_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:501:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_save_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:142:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/validations.rb:42:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `block in save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:345:in `block in with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:342:in `with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:51:in `create!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1015:in `record_version_state_after_migrating'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:985:in `block in execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `call'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:165:in `invoke'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:156:in `invoke_task'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block (2 levels) in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:121:in `run_with_threads'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:106:in `top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:84:in `block in run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:182:in `standard_exception_handling'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:79:in `run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/bin/rake:33:in `<top (required)>'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `load'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `'
ArgumentError: wrong number of arguments (1 for 0)
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `initialize'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `new'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract_adapter.rb:271:in `substitute_at'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:97:in `block in substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `each_with_index'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:96:in `substitute_values'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/relation.rb:56:in `insert'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:521:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/counter_cache.rb:139:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:122:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `block in _create_record'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_create_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:306:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/timestamp.rb:57:in `_create_record'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:501:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `call'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:88:in `_run_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0.beta4/lib/active_support/callbacks.rb:734:in `_run_save_callbacks'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/callbacks.rb:302:in `create_or_update'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:142:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/validations.rb:42:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/attribute_methods/dirty.rb:29:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `block in save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:345:in `block in with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:342:in `with_transaction_returning_status'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:289:in `save!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/persistence.rb:51:in `create!'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1015:in `record_version_state_after_migrating'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:985:in `block in execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `block in ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/transaction.rb:188:in `within_new_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/transactions.rb:218:in `transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:1030:in `ddl_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:983:in `execute_migration_in_transaction'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:945:in `block in migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `each'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:941:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:813:in `up'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/migration.rb:791:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/lib/ruby/gems/2.1.0/gems/activerecord-4.2.0.beta4/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `call'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:235:in `execute'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/task.rb:165:in `invoke'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:156:in `invoke_task'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block (2 levels) in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `each'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:112:in `block in top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:121:in `run_with_threads'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:106:in `top_level'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:84:in `block in run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:182:in `standard_exception_handling'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/lib/rake/application.rb:79:in `run'
/usr/lib/ruby/gems/2.1.0/gems/rake-10.4.0/bin/rake:33:in `<top (required)>'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `load'
/home/fran/.gem/ruby/2.1.0/bin/rake:23:in `'
Tasks: TOP => db:migrate

Any help would be really appreciated. Thanks.

Body:
Maybe you should execute this after create movies table:

generate migration AddFieldsToMovies newfield:type

This generates the correct migration, see this:

http://edgeguides.rubyonrails.org/active_record_migrations.html#changing-tables


来源: stackexchange

问:
MySQL Join vs. dot in table name
During the reproduction of the old client script, I encountered a problem.
They have two tables in a database called "content.articles" and "content.categories"

```<code>    SELECT content.articles.*, content.categories.id as category_id
    FROM `content.articles`
    INNER JOIN `content.categories`
    ON content.articles.category=content.articles.id
</code>```

I understand that the problem is the dots in the table name.
How should I select properly?

I tried:

```<code>    SELECT content.articles.*
    SELECT `content.articles`.*
    SELECT `content.articles.*`
</code>```

None of these options work.

Thank you very much for your help.

答:
If the table references in the FROM clause are correct, then the second form you tried should be valid... enclose the whole identifier in backticks. e.g.

```<code>SELECT `content.articles`.*
  FROM `content.articles`
</code>```

The backticks allow for a lot of wonky characters which would otherwise be interpretted as part SQL text and throw errors.

```<code>SELECT `ab.d@ AND '0'`.*
  FROM `ab.d@ AND '0'`
       ^             ^
</code>```

I'm a little suspicious of the table references in the FROM clause. The dot separator is used between the database name and the table name. If the table is named articles and is in the content database, the identifiers shouldn't be combined inside backticks.  And in that case, we omit the database qualifier from the column name in the SELECT list.

If articles is a table in the content database, then we'd do like this

```<code>SELECT `articles`.*
  FROM `content`.`articles`
       ^       ^ ^        ^
</code>```

A convenient pattern is to assign an alias to the table, and use that to qualify column references. Here is an example assigning alias ca to the table reference, and using ca. to qualify the column references in the SELECT list:

```<code>SELECT ca.*
  FROM `content`.`articles` ca
       ^       ^ ^        ^
</code>```

ContentLicense: CC BY-SA 3.0

Title: MySQL Join vs. dot in table name

Body:
During the reproduction of the old client script, I encountered a problem.
They have two tables in a database called "content.articles" and "content.categories"

    SELECT content.articles.*, content.categories.id as category_id
    FROM `content.articles`
    INNER JOIN `content.categories`
    ON content.articles.category=content.articles.id

I understand that the problem is the dots in the table name.
How should I select properly?

I tried:

    SELECT content.articles.*
    SELECT `content.articles`.*
    SELECT `content.articles.*`

None of these options work.

Thank you very much for your help.

Body:
If the table references in the FROM clause are correct, then the second form you tried should be valid... enclose the whole identifier in backticks. e.g.

SELECT `content.articles`.*
  FROM `content.articles`

The backticks allow for a lot of wonky characters which would otherwise be interpretted as part SQL text and throw errors.

SELECT `ab.d@ AND '0'`.*
  FROM `ab.d@ AND '0'`
       ^             ^

I'm a little suspicious of the table references in the FROM clause. The dot separator is used between the database name and the table name. If the table is named articles and is in the content database, the identifiers shouldn't be combined inside backticks.  And in that case, we omit the database qualifier from the column name in the SELECT list.

If articles is a table in the content database, then we'd do like this

SELECT `articles`.*
  FROM `content`.`articles`
       ^       ^ ^        ^

A convenient pattern is to assign an alias to the table, and use that to qualify column references. Here is an example assigning alias ca to the table reference, and using ca. to qualify the column references in the SELECT list:

SELECT ca.*
  FROM `content`.`articles` ca
       ^       ^ ^        ^


问:
Xcode 9 Typedef redefinition with different types ('NSString *' vs 'AVMediaType')
After updated to Xcode 9.0 final, I can't build my Objective-C project. It said:</p>

```<code>/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVMediaFormat.h:14:20: Typedef redefinition with different types ('NSString *' vs 'AVMediaType')

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVAssetWriter.h:135:41: Type argument 'AVMediaType' is neither an Objective-C object nor a block type

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:513:102: Nullability specifier 'nullable' cannot be applied to non-pointer type 'AVMediaType'
</code>```

答: You need to see where you are using AVMediaType in your project such as when using ffmpeg library and rename 'AVMediaType' to something else everywhere it is referenced in ffmpeg like in avutil.h avformat.h avcodec.h etc. </p>

Body:
After updated to Xcode 9.0 final, I can't build my Objective-C project. It said:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVMediaFormat.h:14:20: Typedef redefinition with different types ('NSString *' vs 'AVMediaType')

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVAssetWriter.h:135:41: Type argument 'AVMediaType' is neither an Objective-C object nor a block type

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h:513:102: Nullability specifier 'nullable' cannot be applied to non-pointer type 'AVMediaType'


问:
PHP MVC Framework : Yii vs DooPHP
I've only experienced with CodeIgniter 1.7 roughly two years ago, quite okay but there were flaws such as you can have only one controller, no redirection to another controller, etc; I was also playing around with CakePHP a little bit but to be frank I was not very used to its "Ruby on Rails" approach of convention over configuration, so in the end I just gave up.

I am planning to have a new casual web application after work for myself, and this time I'd like to try something new, I've done a little research and found two candidates:

Yii and DooPHP

Both sound very promising but I'd also like to hear the advise from their users, hopefully this would get a decent feature comparison like the thread about CakePHP vs CodeIgniter on SO

答: If the debate is between Yii and DooPHP, go for Yii. Not only is DooPHP a horrible name (seriously, would you ever want to tell a business client "I used DooPHP"?), but Yii is simply solid. Thus far, the versioning has been fair. When I used Rails, I was bombarded by crazy changes every month or two and "forced" to upgrade constantly. Yii has added real value features each version, without all the hype that forces a ton of upgrading all the time. The community is solid, the performance is great, and despite a decent learning curve it's not difficult to get up and running quickly.</p>

ContentLicense: CC BY-SA 2.5

Title: PHP MVC Framework : Yii vs DooPHP


问:
include leading zeros while exporting to csv in ssis
I have a package which exports data from table to .csv file, it exports 600 000 records.

I have few columns which has leading zeros and trailing zeros, while exporting the data both leading and trailing zeros are missing.

EX: actual data coming from source

```<code> column1   column2
 001       67.50
</code>```

exported data in csv file

```<code> column1   column2
 1         67.5
</code>```

I tried many methods like placing data conversion, and also Replicate function in derived column.

i also tried by exporting the data to .txt file and use .cmd file to change the .txt file .csv file, all these methods yielded no results.

is there a way to achieve this?

答:
Open the Flat File Connection manager used in the Destination csc, Go to Advanced Tab change all columns data type to DT_STR or DT_WSTR (Note that when data is saved to a flat file, there is no data type taken into consideration)

If it still not working, then add a derived column that convert these values to DT_STR before assigning them to Destination

Body:
I have a package which exports data from table to .csv file, it exports 600 000 records.

I have few columns which has leading zeros and trailing zeros, while exporting the data both leading and trailing zeros are missing.

EX: actual data coming from source

 column1   column2
 001       67.50

exported data in csv file

 column1   column2
 1         67.5

I tried many methods like placing data conversion, and also Replicate function in derived column.

i also tried by exporting the data to .txt file and use .cmd file to change the .txt file .csv file, all these methods yielded no results.

is there a way to achieve this?


问:
How to call js extern function from asp net page
I have this page in cshtml.
This page execute submit in "formImpressao" (ASP.NET PAGE)

CSHTML page

```<code>@using Web.Mvc.Helpers
@{
    string msgSucesso = "test";
}
<div id="divSucess">
<h5 style="background-image: url('themes/base/images/48/ico_ok.gif'); text-align:center; background-repeat: no-repeat; font-family: Verdana; color: #1d7100; font-size:'72'">@msgSucesso</h5>
</div>

<div id="HiddenFormTarget" style="display:none;">
    <form id="formImpressao" method="post" target="frmPrint" action="/VisualizarRelatorios/ImprimirRelatorio.aspx"></form>
</div>
<iframe id="frmPrint" name="frmPrint" width="0" height="0" runat="server">
</iframe>

<script language="javascript" type="text/javascript">
    $("#formImpressao").submit();
</script>
</code>```

ASPX Page (ImprimirRelatorio.aspx)

```<code><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImprimirRelatorio.aspx.cs" Inherits="Views.Views.ImprimirRelatorios.ImprimirRelatorio" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
</head>
<body style="margin: 0px">

    <form id="form1" runat="server"  style=" width:100%; height:100%;" >
    <div style=" width:100%; height:100%; overflow-y:hidden; overflow-x:hidden" >
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <rsweb:ReportViewer ID="rptRelatorio" runat="server" Width="100%"
            Height="100%" ProcessingMode="Remote" >
        </rsweb:ReportViewer>
    </div>
    </form>
</body>
</html>
<script language="javascript">

    function Imprimir()
    {
        var viewer = $find("rptRelatorio");
        var isLoading = viewer.get_isLoading();
        var impresso = false;

        if (!isLoading) {
            $("input[type='image']:not(:disabled)[title*='Print']").click();
            impresso = true;
        }

        if (!impresso) {
            setTimeout(Imprimir, 1000);
        }else {
          $("#divSucess").style.backgroundColor = "red";
        }

    }

    $(document).ready(function () {
        setTimeout(Imprimir, 4000);
    });

</script>
</code>```

The Imprimir function on validates whether the report was printed within Reporting Services.

If printed, it needs to assign to div divSuccess, the attribute: style.backgroundColor = "red".

The problem is that the asp form does not see the divSuccess and the cshtml page does not display the asp form.

How can I call a js function inside the asp page to play the DOM of the page that has the "divSuccess"?

Are there other ways to do this?

The two pages do not talk.

答: You could send AJAX request to get content of ImprimirRelatorio.aspx page. In success handler you could parse response to get inner HTML of body tag of the ImprimirRelatorio.aspx page, set result to some container (without ) and call Imprimir function (see details in AJAX documentation). Note, the Imprimir function should be a part of success event handler of should be defined in the calling page.

Body:
I have this page in cshtml.
This page execute submit in "formImpressao" (ASP.NET PAGE)

CSHTML page

@using Web.Mvc.Helpers
@{
    string msgSucesso = "test";
}

@msgSucesso

    <form id="formImpressao" method="post" target="frmPrint" action="/VisualizarRelatorios/ImprimirRelatorio.aspx"></form>

ASPX Page (ImprimirRelatorio.aspx)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImprimirRelatorio.aspx.cs" Inherits="Views.Views.ImprimirRelatorios.ImprimirRelatorio" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%>

    <title></title>

    <form id="form1" runat="server"  style=" width:100%; height:100%;" >

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <rsweb:ReportViewer ID="rptRelatorio" runat="server" Width="100%"
            Height="100%" ProcessingMode="Remote" >
        </rsweb:ReportViewer>

    </form>

The Imprimir function on validates whether the report was printed within Reporting Services.

If printed, it needs to assign to div divSuccess, the attribute: style.backgroundColor = "red".

The problem is that the asp form does not see the divSuccess and the cshtml page does not display the asp form.

How can I call a js function inside the asp page to play the DOM of the page that has the "divSuccess"?

Are there other ways to do this?

The two pages do not talk.

Body: You could send AJAX request to get content of ImprimirRelatorio.aspx page. In success handler you could parse response to get inner HTML of body tag of the ImprimirRelatorio.aspx page, set result to some container (without <iframe>) and call Imprimir function (see details in AJAX documentation). Note, the Imprimir function should be a part of success event handler of should be defined in the calling page.


问:
Core dumped when using closedir if pathname is not printed after opendir
I have to code a ls like in C but I have some problems.
After opening a directory using opendir, if I'm not printing the pathname using printf or puts, I'll get a core dumped error when executing at closedir but if I do print the path, the code works fine.

```<code>const char * cwd=".";
DIR * dir=opendir(cwd);
//that print --> printf("%s",cwd);
if(dir==NULL){
    puts("ohlala");
}
char * filename;
struct dirent * truc;
struct stat * filestat=malloc(sizeof(struct stat *));
while((truc=readdir(dir))!=NULL){
    filename=truc->d_name;
    if(strcmp(filename,"..")!=0 && strcmp(filename,".")!=0){
        if(l==0){
            printf("%-s ",filename);
        }else if(l==1){
            if(stat(filename,filestat)!=0){
                printf("Erreur stat de %s\n",filename);
                exit(1);
            }
            printf("%ld %-s ",filestat->st_ino,filename);

        }
    }
}
//gdb is telling me the probleme is here
closedir(dir);
return 0;
</code>```

Any ideas ? Thanks.

答:
You are not allocating filestat correctly: this line

```<code>struct stat * filestat = malloc(sizeof(struct stat *))
</code>```

should be

```<code>struct stat * filestat = malloc(sizeof(struct stat))
</code>```

with no asterisk. Currently, the call to stat writes past the allocated memory block, causing undefined behavior.

Note that you don't need to allocate filestat dynamically: make it a local variable, and pass &filestat to stat call:

```<code>struct stat filestat;
...
if(stat(filename, &filestat) != 0) {
    ...
}
...
printf("%ld %-s ", filestat.st_ino, filename);
</code>```

Body:
I have to code a ls like in C but I have some problems.
After opening a directory using opendir, if I'm not printing the pathname using printf or puts, I'll get a core dumped error when executing at closedir but if I do print the path, the code works fine.

const char * cwd=".";
DIR * dir=opendir(cwd);
//that print --> printf("%s",cwd);
if(dir==NULL){
    puts("ohlala");
}
char * filename;
struct dirent * truc;
struct stat * filestat=malloc(sizeof(struct stat *));
while((truc=readdir(dir))!=NULL){
    filename=truc->d_name;
    if(strcmp(filename,"..")!=0 && strcmp(filename,".")!=0){
        if(l==0){
            printf("%-s ",filename);
        }else if(l==1){
            if(stat(filename,filestat)!=0){
                printf("Erreur stat de %s\n",filename);
                exit(1);
            }
            printf("%ld %-s ",filestat->st_ino,filename);

        }
    }
}
//gdb is telling me the probleme is here
closedir(dir);
return 0;

Any ideas ? Thanks.

Body:
You are not allocating filestat correctly: this line

struct stat * filestat = malloc(sizeof(struct stat *))

should be

struct stat * filestat = malloc(sizeof(struct stat))

with no asterisk. Currently, the call to stat writes past the allocated memory block, causing undefined behavior.

Note that you don't need to allocate filestat dynamically: make it a local variable, and pass &filestat to stat call:

struct stat filestat;
...
if(stat(filename, &filestat) != 0) {
    ...
}
...
printf("%ld %-s ", filestat.st_ino, filename);


问:
Laravel 5.5 - Only log 500 error, never send error details via api?
I made the below controller to demonstrate the issue of handling 500 errors I am having with the api. I want to be able to detect when a 500 error will be thrown so it never makes it to the client (as it is too much details to share with the client and they should only be logged by Laravel).

The methodgetUser() returns a 500 error intentionally due to the typo firsgt()

```<code>class TestController extends Controller {
  public function getUser() {
    $data = User::firsgt(); //returns 500 error
    return $data;
  }
}
</code>```

This is what the client sees:

How can we return an error message like 'Error occurred' instead of the too much details for client 'Call to undefined method App\User::firsgt()'?

Note: I don't want to handle it one by one for each controller method, but instead capture any 500 before it is returned to client, and return the custom 500 generic message 'Error occurred'

答:
The detailed explanation of the error are shown in develpment environments, for production you don't want to show them -for security reasons- so, as @Hamoud stated, go to your .ENV file find the line:

APP_DEBUG=true
```

<p>change it to:</p>

<pre class="lang-php prettyprint-override"><code>APP_DEBUG=false
</code>```

This will show only the standard error responses. Check the documentation about error details.

Body:
I made the below controller to demonstrate the issue of handling 500 errors I am having with the api. I want to be able to detect when a 500 error will be thrown so it never makes it to the client (as it is too much details to share with the client and they should only be logged by Laravel).

The methodgetUser() returns a 500 error intentionally due to the typo firsgt()

class TestController extends Controller {
  public function getUser() {
    $data = User::firsgt(); //returns 500 error
    return $data;
  }
}

This is what the client sees:

How can we return an error message like 'Error occurred' instead of the too much details for client 'Call to undefined method App\User::firsgt()'?

Note: I don't want to handle it one by one for each controller method, but instead capture any 500 before it is returned to client, and return the custom 500 generic message 'Error occurred'

Body:
The detailed explanation of the error are shown in develpment environments, for production you don't want to show them -for security reasons- so, as @Hamoud stated, go to your .ENV file find the line:

APP_DEBUG=true

change it to:

APP_DEBUG=false

This will show only the standard error responses. Check the documentation about error details.


问:
gensim doc2vec, why the order of the sentences affects the doc2vec vector
when I use model.infer_vector  to compute the vectors, differ order of
        document results different.

```<code>size=200;negative=15; min_count=1;iterNum=20;
windows = 5
modelName = "datasets/dm-sum.bin_"+str(windows)+"_"
+str(size)+"_"+str(negative)
model = loadDoc2vecModel(modelName)
vecNum = 200
</code>```

call infer_vector

```<code>test_docs = [ x.strip().split() for x in
codecs.open("datasets/test_keyword_f1", "r", "utf-8").readlines() ]
for item in test_docs:

    print("%s" %(resStr.strip()))
    vecTmp = model.infer_vector(item,  alpha=0.05, steps=20)
    print(vecTmp)
</code>```

When I executed call infer_vector twice, the results were as follows.

I don't know why did this happen.

this link is the result

答:
The Doc2Vec training/inference algorithm (in most modes) includes elements of randomization, so you won't necessarily get identical results from repeated runs, unless you force specific extra constraints to force determinism.

Instead, with a strong model and sufficient training/inference (more steps), you should get very-similar-quality vectors on repeated runs.

More steps may be especially important for short texts. It's hard to tell in your screenshot – it'd be better if you pasted the text into your question – but it looks like the space-delimitation in your text results in documents of 13-17 tokens each.

Also, if a model was initially trained on very different kinds of texts, or very little data compared to its overall size (in dimensions/vocabulary), it may not have much generalizable capability for inferring new vectors on new texts. That sort of model-weakness also tends to make the vectors from repeated runs less similar to each other.

(I don't recommend trying to force determinism from run-to-run. To do so is to essentially cover-up the inherent randomness/instability in your setup. It's better to recognize it and adapt tangible measures to tighten the outputs, like a stronger model or more iterations. But if you want to try anyway, there's a discussion of the ways to do so in this gensim issue.)

Body:
when I use model.infer_vector  to compute the vectors, differ order of
        document results different.

size=200;negative=15; min_count=1;iterNum=20;
windows = 5
modelName = "datasets/dm-sum.bin_"+str(windows)+"_"
+str(size)+"_"+str(negative)
model = loadDoc2vecModel(modelName)
vecNum = 200

call infer_vector

test_docs = [ x.strip().split() for x in
codecs.open("datasets/test_keyword_f1", "r", "utf-8").readlines() ]
for item in test_docs:

    print("%s" %(resStr.strip()))
    vecTmp = model.infer_vector(item,  alpha=0.05, steps=20)
    print(vecTmp)

When I executed call infer_vector twice, the results were as follows.

I don't know why did this happen.

this link is the result

ContentLicense: CC BY-SA 4.0


问:
How to move the x axis to the bottom of a svg
I am trying to create a barplot using javascript. I have created a barplot, but want to add two axis. Currently stuck on the x-axis.

I am unable to move my x-axis to the bottom of my barplot. I am Using d3 to tailor the svg. I am currently able to showcase it at the top, but want to show it at the bottom.

Any input would be useful!

My attempts  thus far have been to use transform, but when I execute this my axis disappears.

Googled several other solutions, none of them being successful.

Code:

```<code><script>

d3.json("data_week3.json", function(data){

    var data_renewables = [];
    var data_nations = [];

    for (i = 0; i < data.length; i++)
    {
      data_renewables.push(data[i].Renewable);
      data_nations.push(data[i].Nation)
    }

    var width = 1000,
    height = 500;

    var y = d3.scale.linear()
        .domain([0, d3.max(data_renewables)])
        .range([height, 0]);

    var chart = d3.select(".chart")
        .attr("width", width)
        .attr("height", height);

    var barWidth  = width / data_renewables.length;

    var bar = chart.selectAll("g")
        .data(data_renewables)
      .enter().append("g")
        .attr("transform", function(d, i) { return "translate(" + i * barWidth + ",0)"; });

    bar.append("rect")
        .attr("y", function(d) { return y(d); })
        .attr("height", function(d) { return height - y(d); })
        .attr("width", barWidth - 1);

    bar.append("text")
        .attr("x", barWidth / 2)
        .attr("y", function(d) { return y(d); + 3; })
        .attr("dy", ".75em")
        .text(function(d) { return d; });

    var axisScale = d3.scale.linear()
        .domain([0, 30])
        .range([0, 1000]);

    var xAxis = d3.svg.axis()
        .scale(axisScale)
        .orient("bottom");

    chart.append("g")
        .attr("transform", "translate(0," + height + ")")
        .call(xAxis);

})

</script>
</code>```

答: You're giving the chart a height of height and then your transform is moving the top of the x axis by a value of height so it will always be cut off. I suggest you look at the margin convention: https://bl.ocks.org/mbostock/3019563


问:
Overlay transparent colour on preview
I am writting a motion detector. I am able to detect motion in specific areas of the frame. Now, i want to highlight that area with a transparent colour.

I am using OpenCV for Android.

I found other tutorials using other languages, like this.

They use addWeighted() to blend two images.

At the moment, i just try to overlay the preview frame. I tried the following code:

```<code>public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame {
mRgba = inputframe.rgba();
//defined a Mat that overlays the frame:
Mat greenOverlay = mRgba.submat(0, mRgba.height(), 0, mRgba.width()/5)
mGreenOverlay.setTo(GREEN);

Core.addWeighted(mGreenOverlay,0.5,mRgba,0.5, 0.0, mRgba);
return mRgba;
}
</code>```

The problem (logcat shows this) is that greenOverlay and inputFrame do not have the same size.
Logcat message:

```<code>OpenCV Error: Sizes of input arguments do not match
(The operation is neither 'array op array'
(where arrays have the same size and the same number of channels),
nor 'array op scalar', nor 'scalar op array')
</code>```

How can i solve this problem?

Solution

Toris answer works. Code looks like this:

```<code>Mat greenOverlay = mRgba.clone();
Imgproc.rectangle(greenOverlay, new Point(0, 0), new
                  Point(mRgba.width()/5, mRgba.height()), GREEN, -1);
Core.addWeighted(greenOverlay,0.25,mRgba,0.75, 0.0, mRgba);
</code>```

答:
From tutorial (written in python) shown in question:

```<code>overlay = image.copy()
output = image.copy()

cv2.rectangle(overlay, ...)
</code>```

And from reference of OpenCV:

https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#addweighted

addWeighted()

  src2 – second input array of the same size and channel number as src1.

So, clone mRgba to make greenOverlay and draw rect on it.

Sample code (not tested):

Replace

```<code>Mat greenOverlay = mRgba.submat(0, mRgba.height(), 0, mRgba.width()/5);
mGreenOverlay.setTo(GREEN);
</code>```

With

```<code>Mat greenOverlay = mRgba.clone();
Core.rectangle(greenOverlay, new Point(0, 0), new Point(mRgba.width()/5, mRgba.height()), GREEN, -1);
</code>```

Title: Overlay transparent colour on preview

Body:
I am writting a motion detector. I am able to detect motion in specific areas of the frame. Now, i want to highlight that area with a transparent colour.

I am using OpenCV for Android.

I found other tutorials using other languages, like this.

They use addWeighted() to blend two images.

At the moment, i just try to overlay the preview frame. I tried the following code:

public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame {
mRgba = inputframe.rgba();
//defined a Mat that overlays the frame:
Mat greenOverlay = mRgba.submat(0, mRgba.height(), 0, mRgba.width()/5)
mGreenOverlay.setTo(GREEN);

Core.addWeighted(mGreenOverlay,0.5,mRgba,0.5, 0.0, mRgba);
return mRgba;
}

The problem (logcat shows this) is that greenOverlay and inputFrame do not have the same size.
Logcat message:

OpenCV Error: Sizes of input arguments do not match
(The operation is neither 'array op array'
(where arrays have the same size and the same number of channels),
nor 'array op scalar', nor 'scalar op array')

How can i solve this problem?

Solution

Toris answer works. Code looks like this:

Mat greenOverlay = mRgba.clone();
Imgproc.rectangle(greenOverlay, new Point(0, 0), new
                  Point(mRgba.width()/5, mRgba.height()), GREEN, -1);
Core.addWeighted(greenOverlay,0.25,mRgba,0.75, 0.0, mRgba);

Body:
From tutorial (written in python) shown in question:

overlay = image.copy()
output = image.copy()

cv2.rectangle(overlay, ...)

And from reference of OpenCV:

https://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#addweighted

addWeighted()

  src2 – second input array of the same size and channel number as src1.

So, clone mRgba to make greenOverlay and draw rect on it.

Sample code (not tested):

Replace

Mat greenOverlay = mRgba.submat(0, mRgba.height(), 0, mRgba.width()/5);
mGreenOverlay.setTo(GREEN);

With

Mat greenOverlay = mRgba.clone();
Core.rectangle(greenOverlay, new Point(0, 0), new Point(mRgba.width()/5, mRgba.height()), GREEN, -1);


问:
Filter based on a string and count number of rows
I have recently started working with VBA and I have to filter a column with string 'NEWV' and to count number of rows that end after that filtering,Currently am using the below code but that doesnt seem to work,</p>

```<code>ByrNbr = Watchlist.Range("B" & i).Value

LookFor = ByrNbr

Set Age_rng = Total.Sheets("Counts").Range("A:S")

If Total.Sheets("Counts").Range("G:G").Value = "NEWV" Then

 .Range("L27").Value = Application.WorksheetFunction.CountIf(Age_rng, Range("A:A"))

End If
</code>```

答:
Try testing this line without the If statement

```<code>Range("L27").Value = Application.WorksheetFunction.COUNTIF(Age_rng,"NEWV")
</code>```

Body:
I have recently started working with VBA and I have to filter a column with string 'NEWV' and to count number of rows that end after that filtering,Currently am using the below code but that doesnt seem to work,

ByrNbr = Watchlist.Range("B" & i).Value

LookFor = ByrNbr

Set Age_rng = Total.Sheets("Counts").Range("A:S")

If Total.Sheets("Counts").Range("G:G").Value = "NEWV" Then

 .Range("L27").Value = Application.WorksheetFunction.CountIf(Age_rng, Range("A:A"))

End If

Body:
Try testing this line without the If statement

Range("L27").Value = Application.WorksheetFunction.COUNTIF(Age_rng,"NEWV")


问:
read.csv and skip last column in R
I have read several other posts about how to import csv files with read.csv but skipping specific columns. However, all the examples I have found had very few columns, and so it was easy to do something like:

```<code> columnHeaders <- c("column1", "column2", "column_to_skip")
 columnClasses <- c("numeric", "numeric", "NULL")
 data <- read.csv(fileCSV, header = FALSE, sep = ",", col.names =
 columnHeaders, colClasses = columnClasses)
</code>```

I have 201 columns, without column labels. I would like to skip the last column. How would it be possible to do this without naming all the other columns to keep? Many thanks.

答:
You can just read in all the data and then eliminate the offenders afterwards.

```<code>data <- read.csv("../CAASPP_clustering/ca2016_1_csv_v3.zip")
data_trimmed <- data[,1:(ncol(data)-1)]
</code>```

If you prefer to screen the classes more programmatically then you could do something like this:

```<code>class_list <- lapply(data, class)
chosen_cols <- names(class_list[class_list != "NULL"])
data_trimmed <- data[chosen_cols]
</code>```

Title: read.csv and skip last column in R

Body:
I have read several other posts about how to import csv files with read.csv but skipping specific columns. However, all the examples I have found had very few columns, and so it was easy to do something like:

 columnHeaders <- c("column1", "column2", "column_to_skip")
 columnClasses <- c("numeric", "numeric", "NULL")
 data <- read.csv(fileCSV, header = FALSE, sep = ",", col.names =
 columnHeaders, colClasses = columnClasses)

I have 201 columns, without column labels. I would like to skip the last column. How would it be possible to do this without naming all the other columns to keep? Many thanks.

Body:
You can just read in all the data and then eliminate the offenders afterwards.

data <- read.csv("../CAASPP_clustering/ca2016_1_csv_v3.zip")
data_trimmed <- data[,1:(ncol(data)-1)]

If you prefer to screen the classes more programmatically then you could do something like this:

class_list <- lapply(data, class)
chosen_cols <- names(class_list[class_list != "NULL"])
data_trimmed <- data[chosen_cols]


问:
Adding dll's to the project and making functions work
I have to do one project and I was given dll and a header file with implemented functions needed for the project. I was told just to add the header file to the project but this way i get unresolve externals error if i try to use functions referenced in header. So what needs to be done to make everything work? Visual Studio 2010.
Here are the files i have: http://www.ipix.lt/images/33871682.png
And this is header file:

```<code>#ifndef __BIM482_RADAR__
#define __BIM482_RADAR__

int BIM482OpenRadar();
int BIM482AddPlane(double x, double y);
int BIM482SetPlaneColor(int planeidx, int coloridx);
int BIM482SetPlanePos(int planeidx, double x, double y);
void BIM482UpdateRadar();

#endif // __BIM482_RADAR__
</code>```

I need to initiate gui with OpenRadar and pass information with those functions. How to start this thing?

答:
You don't have a .lib-file to link against.

Maybe this can help you

http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/

or this:

http://support.microsoft.com/default.aspx?scid=kb;en-us;131313

or this:

http://www.asawicki.info/news_1420_generating_lib_file_for_dll_library.html

when you have generated the lib-file ,you must use __declspec(dllimport) on yuor functions in the header file.

An alternative to all of the above is to use LoadLibrary(...) in your source and write wrapper function for those function in the dll and call those dll funcions via GetProcAddress(...).

```<code>struct
{
   HMODULE hDll;

   int   (*BIM482OpenRadar)     ();
   int   (*BIM482AddPlane)      (double x, double y);
   int   (*BIM482SetPlaneColor) (int planeidx, int coloridx);
   int   (*BIM482SetPlanePos)   (int planeidx, double x, double y);
   void  (*BIM482UpdateRadar)   ();
} dll_funcs = {0};

bool ExitRadar( LPCTSTR szDllPath )
{
   if (dll_funcs.hDll)
      FreeLibrary( dll_funcs.hDll );

   return true;
}

bool InitRadar( LPCTSTR szDllPath )
{
   if (dll_funcs.hDll)
      return true;
   dll_funcs.hDll = LoadLibrary( szDllPath );
   if (!dll_funcs.hDll)
      return false;

   dll_funcs.BIM482OpenRadar     = (int(*)())GetProcAddress( dll_funcs.hDll ,("BIM482OpenRadar") );
   dll_funcs.BIM482AddPlane      = (int(*)(double,double))GetProcAddress( dll_funcs.hDll ,("BIM482AddPlane") );
   dll_funcs.BIM482SetPlaneColor = (int(*)(int,int))GetProcAddress( dll_funcs.hDll ,("BIM482SetPlaneColor") );
   dll_funcs.BIM482SetPlanePos   = (int(*)(int,double,double))GetProcAddress( dll_funcs.hDll ,("BIM482SetPlanePos") );
   dll_funcs.BIM482UpdateRadar   = (void(*)())GetProcAddress( dll_funcs.hDll ,("BIM482UpdateRadar") );
   return true;
}

int   BIM482OpenRadar     ()
{ return (*dll_funcs.BIM482OpenRadar)(); };

int   BIM482AddPlane      (double x, double y)
{ return (*dll_funcs.BIM482AddPlane)( x ,y ); }

int   BIM482SetPlaneColor (int planeidx, int coloridx )
{ return (*dll_funcs.BIM482SetPlaneColor)( planeidx ,coloridx ); }

int   BIM482SetPlanePos   (int planeidx, double x, double y)
{ return (*dll_funcs.BIM482SetPlanePos)( planeidx ,x ,y ); }

void  BIM482UpdateRadar   ()
{ return (*dll_funcs.BIM482UpdateRadar)(); }
</code>```

Body:
I have to do one project and I was given dll and a header file with implemented functions needed for the project. I was told just to add the header file to the project but this way i get unresolve externals error if i try to use functions referenced in header. So what needs to be done to make everything work? Visual Studio 2010.
Here are the files i have: http://www.ipix.lt/images/33871682.png
And this is header file:

#ifndef __BIM482_RADAR__
#define __BIM482_RADAR__

int BIM482OpenRadar();
int BIM482AddPlane(double x, double y);
int BIM482SetPlaneColor(int planeidx, int coloridx);
int BIM482SetPlanePos(int planeidx, double x, double y);
void BIM482UpdateRadar();

#endif // __BIM482_RADAR__

I need to initiate gui with OpenRadar and pass information with those functions. How to start this thing?

Body:
You don't have a .lib-file to link against.

Maybe this can help you

http://www.coderetard.com/2009/01/21/generate-a-lib-from-a-dll-with-visual-studio/

or this:

http://support.microsoft.com/default.aspx?scid=kb;en-us;131313

or this:

http://www.asawicki.info/news_1420_generating_lib_file_for_dll_library.html

when you have generated the lib-file ,you must use __declspec(dllimport) on yuor functions in the header file.

An alternative to all of the above is to use LoadLibrary(...) in your source and write wrapper function for those function in the dll and call those dll funcions via GetProcAddress(...).

struct
{
   HMODULE hDll;

   int   (*BIM482OpenRadar)     ();
   int   (*BIM482AddPlane)      (double x, double y);
   int   (*BIM482SetPlaneColor) (int planeidx, int coloridx);
   int   (*BIM482SetPlanePos)   (int planeidx, double x, double y);
   void  (*BIM482UpdateRadar)   ();
} dll_funcs = {0};

bool ExitRadar( LPCTSTR szDllPath )
{
   if (dll_funcs.hDll)
      FreeLibrary( dll_funcs.hDll );

   return true;
}

bool InitRadar( LPCTSTR szDllPath )
{
   if (dll_funcs.hDll)
      return true;
   dll_funcs.hDll = LoadLibrary( szDllPath );
   if (!dll_funcs.hDll)
      return false;

   dll_funcs.BIM482OpenRadar     = (int(*)())GetProcAddress( dll_funcs.hDll ,("BIM482OpenRadar") );
   dll_funcs.BIM482AddPlane      = (int(*)(double,double))GetProcAddress( dll_funcs.hDll ,("BIM482AddPlane") );
   dll_funcs.BIM482SetPlaneColor = (int(*)(int,int))GetProcAddress( dll_funcs.hDll ,("BIM482SetPlaneColor") );
   dll_funcs.BIM482SetPlanePos   = (int(*)(int,double,double))GetProcAddress( dll_funcs.hDll ,("BIM482SetPlanePos") );
   dll_funcs.BIM482UpdateRadar   = (void(*)())GetProcAddress( dll_funcs.hDll ,("BIM482UpdateRadar") );
   return true;
}

int   BIM482OpenRadar     ()
{ return (*dll_funcs.BIM482OpenRadar)(); };

int   BIM482AddPlane      (double x, double y)
{ return (*dll_funcs.BIM482AddPlane)( x ,y ); }

int   BIM482SetPlaneColor (int planeidx, int coloridx )
{ return (*dll_funcs.BIM482SetPlaneColor)( planeidx ,coloridx ); }

int   BIM482SetPlanePos   (int planeidx, double x, double y)
{ return (*dll_funcs.BIM482SetPlanePos)( planeidx ,x ,y ); }

void  BIM482UpdateRadar   ()
{ return (*dll_funcs.BIM482UpdateRadar)(); }


问:
Drawable resource files not found for Google Play component
I have previously been using Xamarin Studio to code a Google Maps application and have copied the files into a new folder to use in Visual Studio.

I am getting many resource errors all in relation to the Google Play component when building the Android application in Visual Studio.

Here is one of the errors:

```<code>No resource found that matches the given name (at 'drawable' with value '@drawable/common_signin_btn_icon_pressed_dark')
</code>```

Here is the XML file:

```<code><?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_pressed="true"
        android:drawable="@drawable/common_signin_btn_icon_pressed_dark" />
    <item
        android:state_enabled="false"
        android:state_focused="true"
        android:drawable="@drawable/common_signin_btn_icon_disabled_focus_dark" />
    <item
        android:state_focused="true"
        android:drawable="@drawable/common_signin_btn_icon_focus_dark" />
    <item
        android:state_enabled="false"
        android:drawable="@drawable/common_signin_btn_icon_disabled_dark" />
    <item
        android:drawable="@drawable/common_signin_btn_icon_normal_dark" />
</selector>
</code>```

How important are these resource files in the code? Can I just remove the references in the XML file?

Thanks in advance

答: I got the same error in Android Studio, the problem was long path, so i shifted the project to another partition with a smaller path and the error solved</p>

Body:
I have previously been using Xamarin Studio to code a Google Maps application and have copied the files into a new folder to use in Visual Studio.

I am getting many resource errors all in relation to the Google Play component when building the Android application in Visual Studio.

Here is one of the errors:

No resource found that matches the given name (at 'drawable' with value '@drawable/common_signin_btn_icon_pressed_dark')

Here is the XML file:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_pressed="true"
        android:drawable="@drawable/common_signin_btn_icon_pressed_dark" />
    <item
        android:state_enabled="false"
        android:state_focused="true"
        android:drawable="@drawable/common_signin_btn_icon_disabled_focus_dark" />
    <item
        android:state_focused="true"
        android:drawable="@drawable/common_signin_btn_icon_focus_dark" />
    <item
        android:state_enabled="false"
        android:drawable="@drawable/common_signin_btn_icon_disabled_dark" />
    <item
        android:drawable="@drawable/common_signin_btn_icon_normal_dark" />
</selector>

How important are these resource files in the code? Can I just remove the references in the XML file?

Thanks in advance


问:
Dynamically constructing bootstrap 4 modal link from inside Datatables.js plugin
I'm using Datatables.js jquery plugin to build html tables (jquery version 3.2.1); The html table that is being generated by datatables also needs to have one of the column cells (author_id) to be a clickable link that opens a bootstrap 4 modal, and passes the unique id of the author_id to the modal.

I'm able to (kinda) generate the href tag with all the attributes and am able to open the modal but for some reason the id's (author_id) that are being generated inside my DataTable initialization function are being displayed multiple times when I do a console.log (I put a comment before console.log in caps, to indicate where the multiples are being generated). Not sure what I'm doing wrong. Following is the code that I have:

```<code>$(document).ready(function() {
   $.ajax({
    type: "GET",
    url: "https://sonosfarm.com/prod/authors.cfc?method=Authors",
    dataType: "json",
    cache: false,
    success: function(response){
        if(response.length != 0){
            $("#authorsHiddenVar").val("");
            $("#authorsHiddenVar").val(JSON.stringify(response));
            $("#Authors").DataTable({
                data: response,
                columns:[
                    {
                        data: 'author_id',
                        "render": function(data, type, row, meta){
                            if(type== 'display'){
                               data = '<a  data-toggle="modal" data-
  target="#mymodal" data-backdrop="static" data-keyboard="false"
    href="#mymodal" data-id=' + data + '>' + data + '</a>';
                            }

                        //THIS IS WHERE THE SAME UNIQUE author_id IS BEING
                       //SHOWN MULTIPLE TIMES!
                            console.log(data);
                            return data;
                        }
                    },
                    {
                        data: 'joined_date'
                    },
                    {data: 'country'}
                ],
                responsive: true,
                order: [1, 'desc']
            });

        }
        else{
            console.log("There was no response from server!");
        }
    },
    error: function(XMLHttpRequest, textStatus, errorThrown){
        console.log("An Ajax server error was returned");
        console.log(XMLHttpRequest);
        console.log(textStatus);
        console.log(errorThrown);
    }
   });

});
</code>```

The second issue I'm having is parsing the href tag inside the mymodal bootstrap modal - I tried the following code but I get undefined (when I try to retrieve the value of data-id:

```<code>   var mypostid = $("#mymodal").data('id');
   console.log( mypostid );
   //GETTING ERROR HERE
</code>```

How do I retrieve the data-id (which is unique author_id) that is being passed to modal, and show various input fields based on the data-id?

答:
In your example, you're missing quotes around the data-id value (i.e.  the HTML will render as data-id=something rather than data-id="something").

So, your datatable init would look like:

```<code> $("#Authors").DataTable({
    data: response,
    columns:[
        {
            data: 'author_id',
            "render": function(data, type, row, meta){
                if(type== 'display'){
                   return '<a data-toggle="modal" data-target="#mymodal" data-backdrop="static" data-keyboard="false" href="#mymodal" data-id="' + data + '">' + data + '</a>';
                }
                return data;
            }
        },
        {
            data: 'joined_date'
        },
        {data: 'country'}
    ],
    responsive: true,
    order: [1, 'desc']
});
</code>```

Then, to get the author_id in your modal, you'll need to modify the jQuery that shows the modal.  You haven't provided that in your question, so I will give a generic example:

```<code>$('#mymodal').on('show.bs.modal', function (event) {
  var link = $(event.relatedTarget) // link that triggered the modal
  var author = link.data('id') // Extract info from data-* attributes
  var modal = $(this)
  modal.find('.modal-title').text('New message to ' + author)
});
</code>```

More on that from Bootstrap docs.

Body:
I'm using Datatables.js jquery plugin to build html tables (jquery version 3.2.1); The html table that is being generated by datatables also needs to have one of the column cells (author_id) to be a clickable link that opens a bootstrap 4 modal, and passes the unique id of the author_id to the modal.

I'm able to (kinda) generate the href tag with all the attributes and am able to open the modal but for some reason the id's (author_id) that are being generated inside my DataTable initialization function are being displayed multiple times when I do a console.log (I put a comment before console.log in caps, to indicate where the multiples are being generated). Not sure what I'm doing wrong. Following is the code that I have:

$(document).ready(function() {
   $.ajax({
    type: "GET",
    url: "https://sonosfarm.com/prod/authors.cfc?method=Authors",
    dataType: "json",
    cache: false,
    success: function(response){
        if(response.length != 0){
            $("#authorsHiddenVar").val("");
            $("#authorsHiddenVar").val(JSON.stringify(response));
            $("#Authors").DataTable({
                data: response,
                columns:[
                    {
                        data: 'author_id',
                        "render": function(data, type, row, meta){
                            if(type== 'display'){
                               data = '' + data + '';
                            }

                        //THIS IS WHERE THE SAME UNIQUE author_id IS BEING
                       //SHOWN MULTIPLE TIMES!
                            console.log(data);
                            return data;
                        }
                    },
                    {
                        data: 'joined_date'
                    },
                    {data: 'country'}
                ],
                responsive: true,
                order: [1, 'desc']
            });

        }
        else{
            console.log("There was no response from server!");
        }
    },
    error: function(XMLHttpRequest, textStatus, errorThrown){
        console.log("An Ajax server error was returned");
        console.log(XMLHttpRequest);
        console.log(textStatus);
        console.log(errorThrown);
    }
   });

});

The second issue I'm having is parsing the href tag inside the mymodal bootstrap modal - I tried the following code but I get undefined (when I try to retrieve the value of data-id:

   var mypostid = $("#mymodal").data('id');
   console.log( mypostid );
   //GETTING ERROR HERE

How do I retrieve the data-id (which is unique author_id) that is being passed to modal, and show various input fields based on the data-id?

Body:
In your example, you're missing quotes around the data-id value (i.e.  the HTML will render as data-id=something rather than data-id="something").

So, your datatable init would look like:

 $("#Authors").DataTable({
    data: response,
    columns:[
        {
            data: 'author_id',
            "render": function(data, type, row, meta){
                if(type== 'display'){
                   return '<a data-toggle="modal" data-target="#mymodal" data-backdrop="static" data-keyboard="false" href="#mymodal" data-id="' + data + '">' + data + '</a>';
                }
                return data;
            }
        },
        {
            data: 'joined_date'
        },
        {data: 'country'}
    ],
    responsive: true,
    order: [1, 'desc']
});

Then, to get the author_id in your modal, you'll need to modify the jQuery that shows the modal.  You haven't provided that in your question, so I will give a generic example:

$('#mymodal').on('show.bs.modal', function (event) {
  var link = $(event.relatedTarget) // link that triggered the modal
  var author = link.data('id') // Extract info from data-* attributes
  var modal = $(this)
  modal.find('.modal-title').text('New message to ' + author)
});

More on that from Bootstrap docs.


问:
html adding up from a form and displaying a checkout total
ive done a form for multiple checkouts where a visitor to site clicks a radio button to select a product for printing...

i need to add;
a dropdown for selecting 1 or 2 sided print where selecting 2 sided adds £5 to the "amount" total
a dropdown for selecting artwork: customer supplies art, 1 side design or 2 sides where none is default, 1 side adds £10 to order, 2 side adds £15

then display a total preferably updates as radio and dropdowns selected rather than a recalculate button

how can you add dropdowns that recalculate a running total of the radio resulting amount and the two dropdown charges and display it???

can anyone help... im new to coding but had a real good go at this, code so far is;

```<code>    <FORM name = "orderform">
<input type="radio" name="amount1" value="99.99"> product 1 <br>
<input type="radio" name="amount1" value="129.00" checked> product 2<br>
<input type="radio" name="amount1" value="149.00"> product 3
<hr>
<input type="radio" name="amount1” value="199.00"> pack 1<br>
<input type="radio" name="amount1" value="229.00"> pack 2<br>
<input type="radio" name="amount1" value="249.00" checked> pack 3<br>

<input type="hidden" name="merchant_id" value="info@creaitve.co.uk"> <!-- nochex required -->
<input type="hidden" name="business" value="info@creaitve.co.uk">  <!-- paypal required -->
<input type="hidden" name="currency_code" value="GBP"> <!-- paypal required -->
<input type="hidden" name="cmd" value="_xclick"> <!-- paypal required -->
<input name="instId" type="hidden" value="1243833" /> <!-- worldpay required -->
<input type="hidden" name="currency" value="GBP"> <!-- worldpay required -->

<input type="hidden" name="cartId" value="CreaITve"> <!-- worldpay cart name -->
<input type="hidden" name="description" value="CreaITve"> <!-- nochex cart name -->
<input type="hidden" name="item_name" value="CreaITve"> <!-- paypal cart name  -->

<input type="hidden" name="desc" value="Print Service A7 Leaflets"> <!-- worldpay product name -->
<input type="hidden" name="description" value="Print Service A7 Leaflets"> <!-- nochex product name -->
<input type="hidden" name="item_name" value="Print Service A7 Leaflets"> <!-- paypal product name  -->

<SELECT name="printsides" onchange="a = this.options[selectedIndex].value; alert (a)">
<OPTION selected value="blank">Single Or Double Side Print</OPTION>
<OPTION value="0.00">Single Sided Print</OPTION>
<OPTION value="10.00">Double Sided Print</OPTION>
</SELECT>

<SELECT name="artwork" onchange="a = this.options[selectedIndex].value; alert (a)">
<OPTION selected value="blank">Choose an option</OPTION>
<OPTION value="0.00">I Will Supply Artwork</OPTION>
<OPTION value="10.00">1 Sided Artwork Design</OPTION>
<OPTION value="15.00">2 Sided Artwork Design</OPTION>
</SELECT>

var amount = amount1 + printsides + artwork

<!-- box here displaying the total preferable without having to click a recalculate button -->

<input type='submit' name='worldpay' value='WorldPay' formAction="https://secure.worldpay.com/wcc/purchase" method="POST"><autocomplete="off" onsubmit="return verifyfields()">
<input type='submit' name='nochex' value='NoChex' formAction="https://secure.nochex.com/"><autocomplete="off" onsubmit="return verifyfields()">
<input type='submit' name='paypal' value='Paypal' formAction="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
</FORM>
</code>```

答:
Here is a decent prototype to get you going (you can merge it with your existing approach):</p>

```<code><!DOCTYPE html>
<html>
<head>

<script type="text/javascript" language="javascript">
function calcTotal(form)
{
    var totalElem = null;
    var prodAmt = 0;
    var packAmt = 0;
    var printAmt = 0;
    var designAmt = 0;
    var totalAmt = 0;

    try
    {
        prodAmt=parseFloat(form["prodamount"].value,2);
        packAmt=parseFloat(form["packamount"].value,2);

        printAmt=parseFloat(form["printOpt"].value,2);
        designAmt=parseFloat(form["graphicOpt"].value,2);

        totalAmt = parseFloat(prodAmt+packAmt+printAmt+designAmt,2);

        totalElem=document.getElementById("Amount");
        totalElem.value = totalAmt.toString();
    }
    catch(e)
    {
        alert("calcTotal Error:  " + e.Message);
    }
    finally
    {

    }

}
</script>
</head>
<body>
<form id="orderform" name = "orderform" onchange="calcTotal(this)">
<input type="radio" name="prodamount" value="99.99"> product 1 <br/>
<input type="radio" name="prodamount" value="129.00" checked> product 2<br/>
<input type="radio" name="prodamount" value="149.00"> product 3
<hr/>
<input type="radio" name="packamount" value="199.00"> pack 1<br/>
<input type="radio" name="packamount" value="229.00"> pack 2<br/>
<input type="radio" name="packamount" value="249.00" checked> pack 3<br/>

<!-- need to add in here a dropdown for selecting single or double side print (single stays same price but selecting double side adds £5 to the "amount" variable -->
<select id="printOpt" name="printOpt">
<option value="0" selected>none</option>
<option value="0">single</option>
<option value="5">double</option>
</select>
<br/>
<!-- another dropdown to select graphic design either 1 or 2 sides - 1 side adds £10 to total, 2 side add £15 to total -->
<select id="graphicOpt" name="graphicOpt">
<option value="0" selected>none</option>
<option value="10">1 side</option>
<option value="15">2 side</option>
</select>
<br/>
<!-- box here displaying the total preferable without having to click a recalculate button -->
<br/><br/><br/><br/><br/><br/><br/><br/><br/>
<input type="text" id="Amount" name="Amount" value="0"/>
<div id="totalAmt"></div>

</form>
<script type="text/javascript" language="javascript">
    // Calculate the initial total
    calcTotal(document.getElementById("orderform"));
</script>
</body>
</html>
</code>```

Body:
ive done a form for multiple checkouts where a visitor to site clicks a radio button to select a product for printing...

i need to add;
a dropdown for selecting 1 or 2 sided print where selecting 2 sided adds £5 to the "amount" total
a dropdown for selecting artwork: customer supplies art, 1 side design or 2 sides where none is default, 1 side adds £10 to order, 2 side adds £15

then display a total preferably updates as radio and dropdowns selected rather than a recalculate button

how can you add dropdowns that recalculate a running total of the radio resulting amount and the two dropdown charges and display it???

can anyone help... im new to coding but had a real good go at this, code so far is;

    <FORM name = "orderform">
<input type="radio" name="amount1" value="99.99"> product 1

<input type="radio" name="amount1" value="129.00" checked> product 2

<input type="radio" name="amount1" value="149.00"> product 3

<input type="radio" name="amount1” value="199.00"> pack 1

<input type="radio" name="amount1" value="229.00"> pack 2

<input type="radio" name="amount1" value="249.00" checked> pack 3

<input type="hidden" name="merchant_id" value="info@creaitve.co.uk">
<input type="hidden" name="business" value="info@creaitve.co.uk">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="cmd" value="_xclick">
<input name="instId" type="hidden" value="1243833" />
<input type="hidden" name="currency" value="GBP">

<input type="hidden" name="cartId" value="CreaITve">
<input type="hidden" name="description" value="CreaITve">
<input type="hidden" name="item_name" value="CreaITve">

<input type="hidden" name="desc" value="Print Service A7 Leaflets">
<input type="hidden" name="description" value="Print Service A7 Leaflets">
<input type="hidden" name="item_name" value="Print Service A7 Leaflets">

<SELECT name="printsides" onchange="a = this.options[selectedIndex].value; alert (a)">
<OPTION selected value="blank">Single Or Double Side Print</OPTION>
<OPTION value="0.00">Single Sided Print</OPTION>
<OPTION value="10.00">Double Sided Print</OPTION>
</SELECT>

<SELECT name="artwork" onchange="a = this.options[selectedIndex].value; alert (a)">
<OPTION selected value="blank">Choose an option</OPTION>
<OPTION value="0.00">I Will Supply Artwork</OPTION>
<OPTION value="10.00">1 Sided Artwork Design</OPTION>
<OPTION value="15.00">2 Sided Artwork Design</OPTION>
</SELECT>

var amount = amount1 + printsides + artwork

<input type='submit' name='worldpay' value='WorldPay' formAction="https://secure.worldpay.com/wcc/purchase" method="POST"><autocomplete="off" onsubmit="return verifyfields()">
<input type='submit' name='nochex' value='NoChex' formAction="https://secure.nochex.com/"><autocomplete="off" onsubmit="return verifyfields()">
<input type='submit' name='paypal' value='Paypal' formAction="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
</FORM>

Body:
Here is a decent prototype to get you going (you can merge it with your existing approach):

<!DOCTYPE html>
<html>
<head>

<script type="text/javascript" language="javascript">
function calcTotal(form)
{
    var totalElem = null;
    var prodAmt = 0;
    var packAmt = 0;
    var printAmt = 0;
    var designAmt = 0;
    var totalAmt = 0;

    try
    {
        prodAmt=parseFloat(form["prodamount"].value,2);
        packAmt=parseFloat(form["packamount"].value,2);

        printAmt=parseFloat(form["printOpt"].value,2);
        designAmt=parseFloat(form["graphicOpt"].value,2);

        totalAmt = parseFloat(prodAmt+packAmt+printAmt+designAmt,2);

        totalElem=document.getElementById("Amount");
        totalElem.value = totalAmt.toString();
    }
    catch(e)
    {
        alert("calcTotal Error:  " + e.Message);
    }
    finally
    {

    }

}
</script>
</head>
<body>
<form id="orderform" name = "orderform" onchange="calcTotal(this)">
<input type="radio" name="prodamount" value="99.99"> product 1 <br/>
<input type="radio" name="prodamount" value="129.00" checked> product 2<br/>
<input type="radio" name="prodamount" value="149.00"> product 3
<hr/>
<input type="radio" name="packamount" value="199.00"> pack 1<br/>
<input type="radio" name="packamount" value="229.00"> pack 2<br/>
<input type="radio" name="packamount" value="249.00" checked> pack 3<br/>

<!-- need to add in here a dropdown for selecting single or double side print (single stays same price but selecting double side adds £5 to the "amount" variable -->
<select id="printOpt" name="printOpt">
<option value="0" selected>none</option>
<option value="0">single</option>
<option value="5">double</option>
</select>
<br/>
<!-- another dropdown to select graphic design either 1 or 2 sides - 1 side adds £10 to total, 2 side add £15 to total -->
<select id="graphicOpt" name="graphicOpt">
<option value="0" selected>none</option>
<option value="10">1 side</option>
<option value="15">2 side</option>
</select>
<br/>
<!-- box here displaying the total preferable without having to click a recalculate button -->
<br/><br/><br/><br/><br/><br/><br/><br/><br/>
<input type="text" id="Amount" name="Amount" value="0"/>
<div id="totalAmt"></div>

</form>
<script type="text/javascript" language="javascript">
    // Calculate the initial total
    calcTotal(document.getElementById("orderform"));
</script>
</body>
</html>