问:
rails - Model Methods, (Getting a PaperClip image URL off S3)
I have a rails 3 app with paperclip. The model looks a little like:

```<code>class Attachment < ActiveRecord::Base

  has_attached_file :attachment,
                    :styles => {
                      :large => '1024x758>',
                      :medium => "200x150#",
                      :thumb => "100x75#",
                      :small => "50x50>"
                    },
                    :default_style => :original,
                    :default_url => '/images/:attachment/default_:style.png',
                    :path => ":instance_id/:attachment/:id/:style/:basename.:extension",
                    :storage => :s3,
                    :s3_credentials => File.join(Rails.root, 'config', 's3.yml'),
                    :s3_protocol => 'https',
                    :s3_permissions => :private,
                    :use_timestamp => false

def authenticated_url(style = nil, expires_in = 90.minutes)
    AWS::S3::S3Object.url_for(attachment.path(style || attachment.default_style), attachment.bucket_name, :expires_in => expires_in, :use_ssl => attachment.s3_protocol == 'https')
end
</code>```

This is called from a user_mailer which is called via delayed_job:

In user_mailer.rb mailer it looks a little something like this:

```<code>  @comment.attachments.each do |a|
    attachments[a.attachment_file_name] = open(a.authenticated_url()) {|f| f.read }
  end
</code>```

The issue here is that delayed mailer is erroring with:

```<code>{uninitialized constant Attachment::AWS
/Users/bhellman/Sites/cline/app/models/attachment.rb:53:in `authenticated_url'\n/Users/bhellman/Sites/cline/app/mailers/user_mailer.rb:41:in
`conversation_notification'\n/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_collection.rb:430:in
`method_missing'\n/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_proxy.rb:216:in `method_missing'\n/
Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_proxy.rb:216:in
`each'\n/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_proxy.rb:216:in
`send'\n/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_proxy.rb:216:in `method_missing'\n/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_collection.rb:430:in `method_missing'\n/Users/bhellman/Sites/cline/app/mailers/user_mailer.rb:39:in `conversation_notification'\n/Library/Ruby/Gems/1.8/gems/actionpack-3.0.0/lib/abstract_controller/base.rb:150:in `send_action'\n/Library/Ruby/Gems/1.8/gems/actionpack-3.0.0/lib/abstract_controller/base.rb:150:in `process_action'\n/Library/Ruby/Gems/1.8/gems/actionpack-3.0.0/lib/abstract_controller/base.rb:119:in `process'\n/Library/Ruby/Gems/1.8/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:40:in `process'\n/Library/Ruby/Gems/1.8/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:75:in `process'\n/Library/Ruby/Gems/1.8/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:446:in `process'\n/Library/Ruby/Gems/1.8/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:441:in `initialize'\n/Library/Ruby/Gems/1.8/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:425:in `new'\n/Library/Ruby/Gems/1.8/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:425:in `method_missing'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/performable_mailer.rb:6:in `send'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/performable_mailer.rb:6:in `perform'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/backend/base.rb:83:in `invoke_job'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:119:in `run'\n/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:62:in `timeout'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:119:in `run'\n/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:118:in `run'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:176:in `reserve_and_run_one_job'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:103:in `work_off'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:102:in `times'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:102:in `work_off'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:77:in `start'\n/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:76:in `start'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:73:in `loop'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:73:in `start'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/tasks.rb:9\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'\n/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31\n/usr/bin/rake:19:in `load'\n/usr/bin/rake:19
</code>```

Any idea what could be going on?

答: You need to require "aws/s3" in your model.

Body:
I have a rails 3 app with paperclip. The model looks a little like:

class Attachment < ActiveRecord::Base

  has_attached_file :attachment,
                    :styles => {
                      :large => '1024x758>',
                      :medium => "200x150#",
                      :thumb => "100x75#",
                      :small => "50x50>"
                    },
                    :default_style => :original,
                    :default_url => '/images/:attachment/default_:style.png',
                    :path => ":instance_id/:attachment/:id/:style/:basename.:extension",
                    :storage => :s3,
                    :s3_credentials => File.join(Rails.root, 'config', 's3.yml'),
                    :s3_protocol => 'https',
                    :s3_permissions => :private,
                    :use_timestamp => false

def authenticated_url(style = nil, expires_in = 90.minutes)
    AWS::S3::S3Object.url_for(attachment.path(style || attachment.default_style), attachment.bucket_name, :expires_in => expires_in, :use_ssl => attachment.s3_protocol == 'https')
end

This is called from a user_mailer which is called via delayed_job:

In user_mailer.rb mailer it looks a little something like this:

  @comment.attachments.each do |a|
    attachments[a.attachment_file_name] = open(a.authenticated_url()) {|f| f.read }
  end

The issue here is that delayed mailer is erroring with:

{uninitialized constant Attachment::AWS
/Users/bhellman/Sites/cline/app/models/attachment.rb:53:in `authenticated_url'\n/Users/bhellman/Sites/cline/app/mailers/user_mailer.rb:41:in
`conversation_notification'\n/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_collection.rb:430:in
`method_missing'\n/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_proxy.rb:216:in `method_missing'\n/
Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_proxy.rb:216:in
`each'\n/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_proxy.rb:216:in
`send'\n/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_proxy.rb:216:in `method_missing'\n/Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/associations/association_collection.rb:430:in `method_missing'\n/Users/bhellman/Sites/cline/app/mailers/user_mailer.rb:39:in `conversation_notification'\n/Library/Ruby/Gems/1.8/gems/actionpack-3.0.0/lib/abstract_controller/base.rb:150:in `send_action'\n/Library/Ruby/Gems/1.8/gems/actionpack-3.0.0/lib/abstract_controller/base.rb:150:in `process_action'\n/Library/Ruby/Gems/1.8/gems/actionpack-3.0.0/lib/abstract_controller/base.rb:119:in `process'\n/Library/Ruby/Gems/1.8/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:40:in `process'\n/Library/Ruby/Gems/1.8/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:75:in `process'\n/Library/Ruby/Gems/1.8/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:446:in `process'\n/Library/Ruby/Gems/1.8/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:441:in `initialize'\n/Library/Ruby/Gems/1.8/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:425:in `new'\n/Library/Ruby/Gems/1.8/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:425:in `method_missing'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/performable_mailer.rb:6:in `send'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/performable_mailer.rb:6:in `perform'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/backend/base.rb:83:in `invoke_job'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:119:in `run'\n/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:62:in `timeout'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:119:in `run'\n/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:118:in `run'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:176:in `reserve_and_run_one_job'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:103:in `work_off'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:102:in `times'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:102:in `work_off'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:77:in `start'\n/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:76:in `start'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:73:in `loop'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/worker.rb:73:in `start'\n/Library/Ruby/Gems/1.8/bundler/gems/delayed_job-411719b38c51/lib/delayed/tasks.rb:9\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'\n/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'\n/Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31\n/usr/bin/rake:19:in `load'\n/usr/bin/rake:19

Any idea what could be going on?


来源: stackexchange

问:
How to read a number above 999 that is separated by a comma (eg. 10,000)?
I'm new to C (and programming) and it's possible that my question can be answered with some basic searching and reading; please point me to an answer to the question if it exists.

Let's say that I want to read a number that can possibly be above 999 from the user. From my experience, if I enter the value 10,000 (including the comma), the program would read the number until the comma and then stop taking input. Thus, the input would be 10 instead of 10000.

How can I make it read '10,000' as if it is 10000?

答:
```<code>#include <stdio.h>
#include <stdlib.h>

void RemoveChar(char* Number, char chartoberemoved)
{
    char *p, *s;
    p = s = Number;
    while (*s)//Run until last \r\n
    {

        if (*s != chartoberemoved)
        {
            *p++ = *s;
        }
        /* We always advance s. */
        s++;

    }
    /* We 0-terminate p. */
    *p = 0;
}

int main(int argc, char* argv[])
{
    char array[32];
    if (!argv[1])
        return -1;
    strcpy(array, argv[1]);
    RemoveChar(array, ',');
    int num = atoi(array);
    printf("%d\n", num);

    return 0;
}
</code>```

ContentLicense: CC BY-SA 3.0


答: use strtok its information and documentation can be found here. link

Title: How to read a number above 999 that is separated by a comma (eg. 10,000)?

Body:
I'm new to C (and programming) and it's possible that my question can be answered with some basic searching and reading; please point me to an answer to the question if it exists.

Let's say that I want to read a number that can possibly be above 999 from the user. From my experience, if I enter the value 10,000 (including the comma), the program would read the number until the comma and then stop taking input. Thus, the input would be 10 instead of 10000.

How can I make it read '10,000' as if it is 10000?


答:
I think you can use query like this:

```<code>select *
from (
    select *
        , row_number() over (partition by date, blocked order by creation_date desc) seq
     from datasource) t
where t.seq = 1;
</code>```

SQL Server Fiddle Demo

Title: Specific group by latest date in SQL Server

Body:
I want to run a SQL query on the following set of data

date       creation_date    value
------------------------------------
2018-01-01 2017-05-05       1
2018-01-02 2017-05-05       0
2018-01-03 2017-05-05       1
2018-01-04 2017-05-05       0
2018-01-05 2017-05-05       1
2018-01-06 2017-05-05       1
2018-01-02 2017-05-11       5

I want to get the following results

2018-01-01 2017-05-05       1
2018-01-02 2017-05-11       5
2018-01-03 2017-05-05       1
2018-01-04 2017-05-05       0
2018-01-05 2017-05-05       1
2018-01-06 2017-05-05       1

Basically I want to get all the dates, group it by dates and get the latest creation date and get the value for that creation date.

I tried

select date, max(Creation_date), value
from datasource
group by date, blocked

but that doesn't do it.

Body:
I think you can use query like this:

select *
from (
    select *
        , row_number() over (partition by date, blocked order by creation_date desc) seq
     from datasource) t
where t.seq = 1;

SQL Server Fiddle Demo


问:
How to programatically remove focus from an inline tinyMCE instance?
When editing a div using the inline mode of tinyMCE, clicking outside of the editor will deactivate it (hide the toolbar, and basically return the div to "normal"). This is good.

There are some cases when the editor stays where it is even after losing focus:

Hitting tab will make the editor lose focus (and bring focus to the address bar, for example), but the editor and toolbar stay there.

Clicking on an element whose click event is captured by another script (like a Jquery-UI-Sortable element) will take focus away from the editor but keep the editor there.

In both cases, I have to click the body of the editor and then click out of it to get it to deactivate and disappear.

Is there a way to tell the inline editor instance to deactivate?

答:
I can try below ways.

Remove class from tinymce editor.
$(editor.bodyElement).removeClass("mce-edit-focus")

One can define dummy(no action) button in HTML page and call onclick of that button.

document.getElementById("noAction").click();


问:
Is it a bad idea to use Bootstrap 3.x's grid system instead of angular-flex-layout with angular2-material?
I have recently started using angular2-material and angular-flex is driving me insane with inconsistent behavior/confusing/cluttered documentation(...).  I now want to get rid of angular-flex-layout and use the bootstrap 3.x grid system.  I read on another question that bootstrap might overwrite some angular-material styles.  So my question is: has anyone has done this before (used angular-material components in combination with bootstrap 3.x grid system)?  If so was there anything major that went wrong/got overwritten?</p>

答:
Been there, done that. I cannot think of a reason why the flex-layout system is worse/better than Bootstrap's grid system but I can accept some personal preference behind the decision. My experience was with Angular 1.x and its material design components but I believe the answer stands still.

Grid/Layout vs. Components

If you are careful enough not to mix the grid settings of Bootstrap and the layout settings of AMD then for positioning it can work pretty well and easy. The issues rise when using different components:

1. Using both Bootstrap and AMD components at the same time

When using a form that includes labels, different types of inputs, buttons, tooltips, icons, etc. you will find yourself in a huge mess of CSS hierarchy which keeps overwriting each other in the most unforeseen places. Just a few examples: BS 3.x and AMD handles some browser compatibility and accessibility somewhat differently in a few cases. AMD components' width and positioning highly relies on their parent containers layout settings which they not 100% get if those are in BS's grid system (this is probably the most blocking issue). Try to imagine the disabled/required/placeholder/etc. settings of an input: yes, it will become a huge mess of positioning, text sizes, and in any possible way.

2. DOM heavy approach

Both systems are quite heavy regarding DOM rendering, now imagine adding both. If you are displaying larger sets of data (not in the millions but in the few hundreds or thousands) then applying several (many times overlapping and overwriting each other) styles and JS features to the same element will put a huge burden on the browser that tries to render it. This was a really huge issue in my experience since we had to display ~2k items in a list that contained some action buttons. Shouldn't have been causing a hard time for any (IE10+) browser but it did.

3. Behaviour of styling, interaction

Last but not least I found it unreliable in the sense that it created way too many unforeseen issues. While creating the UI and trying to focus on the UX and responsivity I found myself debugging tiny positioning issues every 5 minutes. It was a huge hassle and I was never sure whether it would look the same (or at least similar!) in different browsers on different screens. Optimizing the UI took me at least 3 times the usual and at the end I was standing there with a huge bowl of spaghetti of CSS and JS.

Solution? (kind of)

MD Bootstrap is a great tool which pointed me in a good direction with my next project. So is Materialize. I am not saying that these will solve all your problems and that they are the only things to do but they pointed me to a great direction: think through what your UI will need the most and then choose wisely. If you will be doing plenty of grid-like positioning then go with BS and use CSS libraries to imitate MD. If you need angular's MVC and JS flexibility then you shall go with AMD but come up with a good layout handling.

I hope my experience sharing helped you or at least pointed to the good direction. Some further reading which helped me with my research back a few months ago:

Using Bootstrap for Angular and Material design for Angular together

Combining angular material with twitter bootstrap without conflicts


问:
Accessibility Label for radio button on action?
In TableViewCell, I have custom imageview which act as a radio button. This imageview has two states

Selected

Not Selected

By default I have given, Accessibility label as "Selected Checkbox" and "checkbox". Now I want to speak voice text as "new item selected" when it selects and "item deselected" when deselected.

Can we give all four different label? How can I get the same.

Updated: I tried using

```<code>UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification,@"text")
</code>```

but it skips the text which need to speak.

答:
I'm not entirely sure what you are attempting to do here but I'll try to provide an alternative way of making this accessible.

Instead of treating each radio button as either selected or deselected would it not be better to treat the entire group of radio buttons as one combined accessibility element.

So if you have radio buttons for [cat, dog, rabbit, guinea pig]. Then your accessibility should read something like...

Animal selection group: none selected

or

Animal selection group: rabbit selected

etc...

Having said all of that... what is this UI you are trying to create?

Radio buttons are fundamentally not a part of iOS. It would be a much better alternative to use UI that users know. And then by doing this you make your accessibility issue a non-issue.

Perhaps a UIPickerView or a UITableView might be better alternatives to radio buttons?

Body:
In TableViewCell, I have custom imageview which act as a radio button. This imageview has two states

Selected

Not Selected

By default I have given, Accessibility label as "Selected Checkbox" and "checkbox". Now I want to speak voice text as "new item selected" when it selects and "item deselected" when deselected.

Can we give all four different label? How can I get the same.

Updated: I tried using

UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification,@"text")

but it skips the text which need to speak.


问:
Why does it seem to be that several different hexadecimal numbers represented as the dot (".") symbol?
I noticed that the symbol . doesn't represent the same hexadecimal number when I tried to tune my YARA rules that I run on VirusTotal. When I tried to exclude the false positive-generating text string .sample., it would not get excluded because . converted from text representation was 2E in this case, meanwhile in the string, that was actually contained in the false positives, . represented 00.

I assume that when the files are matched, text is converted to hex, the hex string is then matched in a hexdump of a file and the whole hexdump is converted to text in the VT preview.

Then I noticed that there were actually more hexadecimal numbers that were represented as . in VirusTotal's text preview. For example, 0A, 99, 09 (screenshot).

I tried seeing the text representation of these hex numbers using an online converter (http://www.unit-conversion.info/texttools/hexadecimal/) and some of them were represented as � or a blank symbol (not a space symbol, as the number 20, but just a blank space).

So my questions are - why do different numbers seem to represent the same symbol? In addition, what do the "blank spaces" represent in a file's hexdump?

答:
The 0A characters are line feed characters, as can be seen from the table in this doc, while the 2E characters are actual periods.

As per this answer on the same issue:

These are whitespace characters, and if included literally would mess up the ASCII table. That's why they (as well as the unprintable control characters below 32, and any binary values above 127, which aren't defined by ASCII and would need another character set to be interpreted correctly) are represented by .

Essentially, the '.' character is a catch-all for things which can't be shown properly in the table.

As for the online converter, it appears to generate characters  until 7F, after which ASCII's 128 bit implementation is no longer defined and the translator provides a � symbol. Even from 00 to 7F we find the translator has issues with a few hex values including the line feed character 0A.

The ASCII table linked earlier hints at a few characters which the translator might have trouble with, such the DEL character (7F), the bell (07), and ENQ (05).

I would expect that blank spaces are whitespace characters, this should be possible to verify in the ASCII table.


问:
Sending E-mail when JBoss eap 6.3 server is downn
I want to send the email notification to the admin when JBoss server is down.Kindly suggest the best way to implement that.</p>

答:
Just a suggestion, maybe not the ideal answer...
You could implement a dedicated standalone process that periodically sends a request to your JBoss (e.g. a known index.html of an application deployed on the server), then sends a notification depending on the returned response's HTTP code.</p>


问:
LINQ query to SQL Script
Is anyone heard of any tool writing LINQ queries and converting them to SQL queries?

I mostly need this because I am a .NET developer and I'm weak in this section of SQL queries where sometimes I need them.

Thank you.

答: Use sql profiler to get the sql as it is executed against the sql database.</p>

ContentLicense: CC BY-SA 2.5

Title: LINQ query to SQL Script


问:
Entity Framework Connection wizard cant find my Database
I have a unexpected problem.

I create a database on Sql Server 2012. I want to connect this database using Entity Framework on Visual Studio 2012. But Entity framework wizard can't find Servers.

The steps that I followed;

I clicked to "add New İtem ->Add Ado.Net Entity Data Model.

I chose "Generate From Database" on "model content" page. Clicked Next.

On "choose your model connection" page, I clicked "New connection" button. After this, a new window opened.

On this window, I chose "Microsoft Sql Server" as data source and ".Net Framework Provider for sql server" as data provider. Clicked Continue.

After all of them, a window named as "Connection Properties" opened.

On this page, I have to choose Server Name. Unfortunately, there is no Server Name on server name combobox. I refreshed the list of servers. Still, the list is empty. But, I know I have a server. I worked on this. But the Entity Framework wizard can't find it.

Do you have any idea to overcome this problem ?

Thanks!

答:
I dont know how relevant it is now but just thought to put this details so that it could be helpful for someone who come across the same problem.

As user3508580 rightly pointed out the VS Entity Data Model Wizard may not list the local db in that case we need to add the Server name manually.

In Visual Studio 2012 the Server Name is:

(localdb)\v11.0

In Visual Studio 2015/2017 the Server Name is:

(localdb)\MSSQLLocalDB

To know the details of localDb running in your system you can use SqlLocalDB.exe infocommand in Windows command prompt. It will list the DB's running in the machine.


问:
2 documents merge in MongoDB
I need to get data from two documents from different collections(1 common field in them, no change to the db) in MongoDB. I am a newbie and please help me with this

```<code>a = db.users.find(username:'abc@xyz.com')
b = db.tasks.find(username:'abc@xyz.com')
</code>```

How to I get a variable c which has a and b merged?

Please help. This may be trivial but help me.

答:
I know it will probably be not your case, but if you are using clojure, an elegant solution is to use the merge-with function after retrieving the documents from mongo.

```<code>(def a {
        :scA {:a [1, 2]}
        :scB {:b [3, 4]}
})
; {:scA {:a [1 2]}, :scB {:b [3 4]}}

(def b {
        :scA {:c [5, 6]}
        :scC {:d [7, 8]}
})
; {:scA {:c [5 6]}, :scC {:d [7 8]}}

(merge-with into a b)
; {:scA {:a [1 2], :c [5 6]}, :scB {:b [3 4]}, :scC {:d [7 8]}}
</code>```

Title: 2 documents merge in MongoDB

Body:
I need to get data from two documents from different collections(1 common field in them, no change to the db) in MongoDB. I am a newbie and please help me with this

a = db.users.find(username:'abc@xyz.com')
b = db.tasks.find(username:'abc@xyz.com')

How to I get a variable c which has a and b merged?

Please help. This may be trivial but help me.

Body:
I know it will probably be not your case, but if you are using clojure, an elegant solution is to use the merge-with function after retrieving the documents from mongo.

(def a {
        :scA {:a [1, 2]}
        :scB {:b [3, 4]}
})
; {:scA {:a [1 2]}, :scB {:b [3 4]}}

(def b {
        :scA {:c [5, 6]}
        :scC {:d [7, 8]}
})
; {:scA {:c [5 6]}, :scC {:d [7 8]}}

(merge-with into a b)
; {:scA {:a [1 2], :c [5 6]}, :scB {:b [3 4]}, :scC {:d [7 8]}}


问:
Step 7: XS_SECURITY LIB not available to P-users
in this blog https://blogs.sap.com/2017/07/18/step-7-with-sap-s4hana-cloud-sdk-secure-your-application-on-sap-cloud-platform-cloudfoundry/ there is a link to download the XS security library. Unfortunately, it seems that P-users cannot access the SAP ONE Support Launchpad. Is there another repository where P-users can download this package from?Image of the received message</p>

答:
Unfortunately, there is no way to download these libraries with a public (p) user at the moment. You need to get a support (s) user. The process to do this is:

Go to https://launchpad.support.sap.com/

Click on "User Management" tile

Click "Request User" on the lower right

Enter the user details

Click "Submit"

Please note this might take up to 24 hours.

This process is also described in this video https://www.youtube.com/watch?v=4wICiRTP8u0.


问:
Angular 5 Material 2: Datepickerstyle
I have started to use Material 2 in a new Angular 5 project.
I noticed that the style of the Datepicker-toogle seems to have changed.

The old one works fine for me. It opens under the Icon

The new one starts on the bottom of the whole page and takes the whole width.

Does anyone know if this is a material related problem? I tested it with Chrome and the new Firefox Quantum. It has the same Result.
Is there a possibility to get the old Datepicker back?

答:
There is no issue with Datepicker :

Here is the link to WORKING DEMO (Used latest Material package)

Please check your css, must be conflicting with datepickers style.

Title: Angular 5 Material 2: Datepickerstyle


问:
No public static parameters method with Galen
In a project in which I'm working, I'm trying to use Galen without TestNG (so, the JUnit based version).

This is the code that I have for the sample class that I've made:

```<code>import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import com.galenframework.support.GalenJavaTestBase;
import com.galenframework.testng.GalenTestNgTestBase;
import org.apache.xmlbeans.impl.tool.Extension;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import com.galenframework.junit.GalenJUnitTestBase;

public class GalenTesting extends GalenJUnitTestBase {

    @Override

    public WebDriver createDriver() {
        System.setProperty("webdriver.chrome.driver","C:/Drivers/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        return driver;
    }

    @Test
    public void welcomePage_shouldLookGood_onDesktopDevice() throws IOException {
        super.load("http://www.google.com", 1024, 768);
        super.checkLayout("/specs/welcomePage.spec", Arrays.asList("mobile"));
    }
</code>```

Which is pretty much the code that can be found in the Galen doc for Java usage.
I am having an issue with running this code, because it states that:

```<code>java.lang.Exception: No public static parameters method on class it.automationTest.GalenTesting

    at org.junit.runners.Parameterized.getParametersMethod(Parameterized.java:299)
    at org.junit.runners.Parameterized.<init>(Parameterized.java:246)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

Process finished with exit code -1
</code>```

At first, I thought it was referring to the methods' calls inside the "welcomePage_shouldLookGood_onDesktopDevice()" method, so I've inserted a super.methodName() to try fix that but it didn't work.
I've also tried to read the source code of all the superclasses but I couldn't find anything useful that could help me preventing this Exception.
Could someone point me in the right direction?

 EDIT

As requested, this is the updated version of the code.
It now contains an iterable method for the Test Devices (as kindly pointed out hypery2k).
The original question is solved, because there createDriver() method was annotated just with @Overriden, while it should have been only with a @Test annotation. Now I'm facing the following issue, for which first I'll put the new updated code, then the stack error.

```<code>import java.io.IOException;
import java.util.Arrays;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import com.galenframework.junit.GalenJUnitTestBase;

public class GalenTesting extends GalenJUnitTestBase {

WebDriver driver;

public GalenTesting() {
    super();

}

@Override
public WebDriver createDriver() {
    createDriverVoid();
    return driver;
}

@Test
public void createDriverVoid() {
    System.setProperty("webdriver.chrome.driver","C:/Drivers/chromedriver.exe");
    driver = new ChromeDriver();
}

@Test
public void welcomePage_shouldLookGood_onDesktopDevice() throws IOException {
    super.load("http://www.google.com", 1024, 768);
    super.checkLayout("/specs/welcomePage.spec", Arrays.asList("mobile"));
}

@Parameterized.Parameters
public static Iterable<Object[]> devices() {
    return Arrays.asList(new Object[][]{// @formatter:off
            {new TestDevice("desktop", new Dimension(1024, 800), Arrays.asList("normal", "desktop"))},
            {new TestDevice("fullhd", new Dimension(1920, 1080), Arrays.asList("fullhd", "desktop"))},// @formatter:on
    });
}

}
</code>```

The class is now giving the following error:

```<code>java.lang.Exception: No tests found matching createDriver with any parameter from org.junit.runner.Request$1@2d6a9952

    at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:40)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

Process finished with exit code -1
</code>```

I've been trying to mess around with some methods that I've added (like the constructor that calls the super()) but it still gives the same error. It returns the same error even with the original fixed code.

答:
As you are using JUnit based Galen framework, I would recommend 2 quick changes as follows:

Change the @Override Annotation into @Test Annotation or to a valid one.

Change crome to chrome within "webdriver.crome.driver"

Body:
In a project in which I'm working, I'm trying to use Galen without TestNG (so, the JUnit based version).

This is the code that I have for the sample class that I've made:

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import com.galenframework.support.GalenJavaTestBase;
import com.galenframework.testng.GalenTestNgTestBase;
import org.apache.xmlbeans.impl.tool.Extension;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import com.galenframework.junit.GalenJUnitTestBase;

public class GalenTesting extends GalenJUnitTestBase {

    @Override

    public WebDriver createDriver() {
        System.setProperty("webdriver.chrome.driver","C:/Drivers/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        return driver;
    }

    @Test
    public void welcomePage_shouldLookGood_onDesktopDevice() throws IOException {
        super.load("http://www.google.com", 1024, 768);
        super.checkLayout("/specs/welcomePage.spec", Arrays.asList("mobile"));
    }

Which is pretty much the code that can be found in the Galen doc for Java usage.
I am having an issue with running this code, because it states that:

java.lang.Exception: No public static parameters method on class it.automationTest.GalenTesting

    at org.junit.runners.Parameterized.getParametersMethod(Parameterized.java:299)
    at org.junit.runners.Parameterized.<init>(Parameterized.java:246)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

Process finished with exit code -1

At first, I thought it was referring to the methods' calls inside the "welcomePage_shouldLookGood_onDesktopDevice()" method, so I've inserted a super.methodName() to try fix that but it didn't work.
I've also tried to read the source code of all the superclasses but I couldn't find anything useful that could help me preventing this Exception.
Could someone point me in the right direction?

 EDIT

As requested, this is the updated version of the code.
It now contains an iterable method for the Test Devices (as kindly pointed out hypery2k).
The original question is solved, because there createDriver() method was annotated just with @Overriden, while it should have been only with a @Test annotation. Now I'm facing the following issue, for which first I'll put the new updated code, then the stack error.

import java.io.IOException;
import java.util.Arrays;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import com.galenframework.junit.GalenJUnitTestBase;

public class GalenTesting extends GalenJUnitTestBase {

WebDriver driver;

public GalenTesting() {
    super();

}

@Override
public WebDriver createDriver() {
    createDriverVoid();
    return driver;
}

@Test
public void createDriverVoid() {
    System.setProperty("webdriver.chrome.driver","C:/Drivers/chromedriver.exe");
    driver = new ChromeDriver();
}

@Test
public void welcomePage_shouldLookGood_onDesktopDevice() throws IOException {
    super.load("http://www.google.com", 1024, 768);
    super.checkLayout("/specs/welcomePage.spec", Arrays.asList("mobile"));
}

@Parameterized.Parameters
public static Iterable<Object[]> devices() {
    return Arrays.asList(new Object[][]{// @formatter:off
            {new TestDevice("desktop", new Dimension(1024, 800), Arrays.asList("normal", "desktop"))},
            {new TestDevice("fullhd", new Dimension(1920, 1080), Arrays.asList("fullhd", "desktop"))},// @formatter:on
    });
}

}

The class is now giving the following error:

java.lang.Exception: No tests found matching createDriver with any parameter from org.junit.runner.Request$1@2d6a9952

    at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:40)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

Process finished with exit code -1

I've been trying to mess around with some methods that I've added (like the constructor that calls the super()) but it still gives the same error. It returns the same error even with the original fixed code.


问:
Search multiple columns for multiple values
Very new to R
Have a very large data frame (ie looking to avoid using a loop for efficiency) with many columns. I want to scan multiple columns (ex ss1:ss15) for a vector of characters (ex c(‘9515’,’8231’)). If any of these are true/match I am trying to get a new column in the data frame with value 1 if any in that row are true and 0 if not. I’m stuck on how to even begin going about this...</p>

答:
Alternative using magrittr and data.tables and allowing to manipulate the intermediary matrix:

```<code>library ( "magrittr" )
vect = c ( "9515", "8231" )

# Creating the data table
N <- 150
dt1 <- matrix (
    sample ( c ( vect, "other" ), N, prob = c ( .05, .05, .9 ), replace = TRUE ),
    ncol = 15, dimnames = list ( NULL, paste0 ( "ss", 1:15 ))) %>% as.data.table

# Initiatilzing the new column
dt1 [, NewCol := rep ( 0, N / 15 )]

# Define query function
InVect <- function ( x ) x %in% vect

# Querying the data table
dt1 [( apply ( dt1, 1:2, InVect ) %>% which ( arr.ind = TRUE ))[, 1 ] %>%
  unique, NewCol := 1 ]
dt1
</code>```

,and another way looping over vect instead (may have pros in some situations):

```<code># Initiatilzing the new column
dt1 [, NewCol := rep ( 0, N / 15 )]

# Define query function
RowIDs <- function ( x ) ( which ( dt1 == x, arr.ind = TRUE ))[, 1 ]

# querying the data table
dt1 [ lapply ( vect, RowIDs ) %>% unlist %>% unique, NewCol := 1 ]
</code>```

Body:
Alternative using magrittr and data.tables and allowing to manipulate the intermediary matrix:

library ( "magrittr" )
vect = c ( "9515", "8231" )

# Creating the data table
N <- 150
dt1 <- matrix (
    sample ( c ( vect, "other" ), N, prob = c ( .05, .05, .9 ), replace = TRUE ),
    ncol = 15, dimnames = list ( NULL, paste0 ( "ss", 1:15 ))) %>% as.data.table

# Initiatilzing the new column
dt1 [, NewCol := rep ( 0, N / 15 )]

# Define query function
InVect <- function ( x ) x %in% vect

# Querying the data table
dt1 [( apply ( dt1, 1:2, InVect ) %>% which ( arr.ind = TRUE ))[, 1 ] %>%
  unique, NewCol := 1 ]
dt1

,and another way looping over vect instead (may have pros in some situations):

# Initiatilzing the new column
dt1 [, NewCol := rep ( 0, N / 15 )]

# Define query function
RowIDs <- function ( x ) ( which ( dt1 == x, arr.ind = TRUE ))[, 1 ]

# querying the data table
dt1 [ lapply ( vect, RowIDs ) %>% unlist %>% unique, NewCol := 1 ]


问:
Multiple loops issue in matlab
Sorry for asking really basic question but I am confused in multiple loops.

I want to run loops all at same time and then break the loop and go to next loop for R, e and x combine.

```<code>Means for R =1 ,e=1 ,x=1 and then R=2 ,e=2 ,x=2 and so on.
</code>```

Can someone tell me where I am at fault or what is missing to get my desired results?

Code:

```<code> threshold = [0.4:0.1:1.1];
 limit_for_idx  = [0.4:0.1:1.1];
 limit = [0.4:0.1:1.1];

 D=1;
 E=1;
 J=0;
  for R = 1:numel(threshold);
      for e = 1:numel(limit_for_idx);
          for x = 1:numel(limit)

          J = J+1 ;
          % Perform Tasks and go to next loop for R ,e and x
          break
      end
        break
    end
  end
</code>```

答:
The wrong in your code is that in the 2nd iteration and so on, e and x will get 1 again, and not 2 or which value that you want.

To solve that, just iterate one variable and equal them all to it:

```<code>threshold = [0.4:0.1:1.1];
limit_for_idx  = [0.4:0.1:1.1];
limit = [0.4:0.1:1.1];
D=1;
E=1;
J=0;
for R=1:numel(threshold)
   e=R;
   x=R;
   % do your stuff...
end
</code>```

Title: Multiple loops issue in matlab

Body:
Sorry for asking really basic question but I am confused in multiple loops.

I want to run loops all at same time and then break the loop and go to next loop for R, e and x combine.

Means for R =1 ,e=1 ,x=1 and then R=2 ,e=2 ,x=2 and so on.

Can someone tell me where I am at fault or what is missing to get my desired results?

Code:

 threshold = [0.4:0.1:1.1];
 limit_for_idx  = [0.4:0.1:1.1];
 limit = [0.4:0.1:1.1];

 D=1;
 E=1;
 J=0;
  for R = 1:numel(threshold);
      for e = 1:numel(limit_for_idx);
          for x = 1:numel(limit)

          J = J+1 ;
          % Perform Tasks and go to next loop for R ,e and x
          break
      end
        break
    end
  end

Body:
The wrong in your code is that in the 2nd iteration and so on, e and x will get 1 again, and not 2 or which value that you want.

To solve that, just iterate one variable and equal them all to it:

threshold = [0.4:0.1:1.1];
limit_for_idx  = [0.4:0.1:1.1];
limit = [0.4:0.1:1.1];
D=1;
E=1;
J=0;
for R=1:numel(threshold)
   e=R;
   x=R;
   % do your stuff...
end


问:
Java Spring SQL how to combine/join 3 tables into one
I have 3 tables that I want to combine/join into one, I have tried different methods like join, left/right join but somehow i lose myself in the amount of statements i write so i cant get it to work properly.

I want to map the name in measurement to measurement_id in measurement_data_points and then map data_points_id in measurement_data_points to id in measurement_point

I have included a made-up result that i would like at the bottom to give a clear understanding.

My Tables:

```<code>+-------------------------+
| Tables_in_db_datapoints |
+-------------------------+
| measurement             |
| measurement_data_points |
| measurement_point       |
+-------------------------+
</code>```

measurement table

```<code>mysql> select * from measurement;
+----+----------------------+
| id | name                 |
+----+----------------------+
|  1 | identifiedNeed       |
|  2 | identifiedBackground |
|  3 | identifiedGoal       |
+----+----------------------+
</code>```

measurement_data_points table

```<code>mysql> select * from measurement_data_points;
+----------------+----------------+
| measurement_id | data_points_id |
+----------------+----------------+
|              1 |              1 |
|              1 |              2 |
|              1 |              3 |
|              1 |              4 |
|              2 |              5 |
|              2 |              6 |
|              2 |              7 |
|              2 |              8 |
|              3 |              9 |
|              3 |             10 |
|              3 |             11 |
|              3 |             12 |
+----------------+----------------+
</code>```

measurement_point table

```<code>+----+------------+-----+----------+--------+
| id | date       | f1  | precison | recall |
+----+------------+-----+----------+--------+
|  1 | 2017-11-19 | 0.3 |      0.5 |    0.2 |
|  2 | 2017-11-12 | 0.7 |      0.4 |   0.15 |
|  3 | 2017-11-15 | 0.5 |      0.3 |    0.1 |
|  4 | 2017-11-18 | 0.6 |      0.2 |   0.05 |
|  5 | 2017-11-19 | 0.2 |      0.4 |    0.2 |
|  6 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
|  7 | 2017-11-15 | 0.5 |      0.2 |    0.1 |
|  8 | 2017-11-18 | 0.6 |      0.1 |   0.05 |
|  9 | 2017-11-19 | 0.1 |      0.4 |    0.2 |
| 10 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
| 11 | 2017-11-15 | 0.3 |      0.2 |    0.1 |
| 12 | 2017-11-18 | 0.2 |      0.1 |   0.05 |
+----+------------+-----+----------+--------+
</code>```

I want the result to mainly be like this:

```<code>+-----------------------+----------------+------------+-----+----------+
| measurement_id        | data_points_id |  date      | f1  | precison | recall |
+-----------------------+----------------+------------+-----+----------+
| identifiedNeed        |              1 | 2017-11-19 | 0.3 |      0.5 |    0.2 |
| identifiedNeed        |              2 | 2017-11-12 | 0.7 |      0.4 |   0.15 |
| identifiedNeed        |              3 | 2017-11-15 | 0.5 |      0.3 |    0.1
| identifiedNeed        |              4 | 2017-11-18 | 0.6 |      0.2 |   0.05 |
| identifiedBackground  |              5 | 2017-11-19 | 0.2 |      0.4 |    0.2 |
| identifiedBackground  |              6 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
| identifiedBackground  |              7 | 2017-11-15 | 0.5 |      0.2 |    0.1 |
| identifiedBackground  |              8 | 2017-11-18 | 0.6 |      0.1 |   0.05 |
| identifiedGoal        |              9 | 2017-11-19 | 0.1 |      0.4 |    0.2 |
| identifiedGoal        |             10 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
| identifiedGoal        |             11 | 2017-11-15 | 0.3 |      0.2 |    0.1 |
| identifiedGoal        |             12 | 2017-11-18 | 0.2 |      0.1 |   0.05 |
+-----------------------+----------------+------------+-----+----------+
</code>```

If that doesnt work then this works as well

```<code>+----------------+----------------+------------+-----+----------+--------+
| measurement_id | data_points_id | date       | f1  | precison | recall |
+----------------+----------------+------------+-----+----------+--------+
|              1 |              1 | 2017-11-19 | 0.3 |      0.5 |    0.2 |
|              1 |              2 | 2017-11-12 | 0.7 |      0.4 |   0.15 |
|              1 |              3 | 2017-11-15 | 0.5 |      0.3 |    0.1 |
|              1 |              4 | 2017-11-18 | 0.6 |      0.2 |   0.05 |
|              2 |              5 | 2017-11-19 | 0.2 |      0.4 |    0.2 |
|              2 |              6 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
|              2 |              7 | 2017-11-15 | 0.5 |      0.2 |    0.1 |
|              2 |              8 | 2017-11-18 | 0.6 |      0.1 |   0.05 |
|              3 |              9 | 2017-11-19 | 0.1 |      0.4 |    0.2 |
|              3 |             10 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
|              3 |             11 | 2017-11-15 | 0.3 |      0.2 |    0.1 |
|              3 |             12 | 2017-11-18 | 0.2 |      0.1 |   0.05 |
+----------------+----------------+------------+-----+----------+--------+
</code>```

答:
The query you request is quite simple.  It uses the "main" table (measurement) joined with the other two.
A "join" is a way to link two tables, using one or more fields.
In your case, for example, you can join measurement with measurement_data_points using the field measurement_id using following sintax (inside a SELECT command):

```<code>...
FROM measurement A
LEFT JOIN measurement_data_points B ON A.measurement_id= B.measurement_id
</code>```

Once joined, you can use in your SELECT every fields of the two tables.  Eg.

```<code>...
SELECT  measurement.name
    , measurement_data_points.data_points_id
...
</code>```

Putting all together, it should be simply:

```<code> SELECT measurement.measurement_id
    , measurement_data_points.data_points_id
    , measurement_point.date
    , measurement_point.f1
    , measurement_point.precison
    , measurement_point.recall
FROM measurement
LEFT JOIN measurement_data_points  ON measurement.measurement_id= measurement_data_points.measurement_id
LEFT JOIN measurement_point ON measurement_data_points.data_points_id = measurement_point.id ;
</code>```

Query with measurement name instead of measurement id:

```<code>SELECT measurement.name
    , measurement_data_points.data_points_id
    , measurement_point.date
    , measurement_point.f1
    , measurement_point.precison
    , measurement_point.recall
FROM measurement
LEFT JOIN measurement_data_points  ON measurement.measurement_id= measurement_data_points.measurement_id
LEFT JOIN measurement_point ON measurement_data_points.data_points_id = measurement_point.id ;
</code>```

Tip: all these are very simple queries and if you just use a few of your time to read something about SQL SELECT  and SQL JOIN (look on Internet) you will be capable to make queries like this by yourself and with satisfatcion.

Body:
I have 3 tables that I want to combine/join into one, I have tried different methods like join, left/right join but somehow i lose myself in the amount of statements i write so i cant get it to work properly.

I want to map the name in measurement to measurement_id in measurement_data_points and then map data_points_id in measurement_data_points to id in measurement_point

I have included a made-up result that i would like at the bottom to give a clear understanding.

My Tables:

+-------------------------+
| Tables_in_db_datapoints |
+-------------------------+
| measurement             |
| measurement_data_points |
| measurement_point       |
+-------------------------+

measurement table

mysql> select * from measurement;
+----+----------------------+
| id | name                 |
+----+----------------------+
|  1 | identifiedNeed       |
|  2 | identifiedBackground |
|  3 | identifiedGoal       |
+----+----------------------+

measurement_data_points table

mysql> select * from measurement_data_points;
+----------------+----------------+
| measurement_id | data_points_id |
+----------------+----------------+
|              1 |              1 |
|              1 |              2 |
|              1 |              3 |
|              1 |              4 |
|              2 |              5 |
|              2 |              6 |
|              2 |              7 |
|              2 |              8 |
|              3 |              9 |
|              3 |             10 |
|              3 |             11 |
|              3 |             12 |
+----------------+----------------+

measurement_point table

+----+------------+-----+----------+--------+
| id | date       | f1  | precison | recall |
+----+------------+-----+----------+--------+
|  1 | 2017-11-19 | 0.3 |      0.5 |    0.2 |
|  2 | 2017-11-12 | 0.7 |      0.4 |   0.15 |
|  3 | 2017-11-15 | 0.5 |      0.3 |    0.1 |
|  4 | 2017-11-18 | 0.6 |      0.2 |   0.05 |
|  5 | 2017-11-19 | 0.2 |      0.4 |    0.2 |
|  6 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
|  7 | 2017-11-15 | 0.5 |      0.2 |    0.1 |
|  8 | 2017-11-18 | 0.6 |      0.1 |   0.05 |
|  9 | 2017-11-19 | 0.1 |      0.4 |    0.2 |
| 10 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
| 11 | 2017-11-15 | 0.3 |      0.2 |    0.1 |
| 12 | 2017-11-18 | 0.2 |      0.1 |   0.05 |
+----+------------+-----+----------+--------+

I want the result to mainly be like this:

+-----------------------+----------------+------------+-----+----------+
| measurement_id        | data_points_id |  date      | f1  | precison | recall |
+-----------------------+----------------+------------+-----+----------+
| identifiedNeed        |              1 | 2017-11-19 | 0.3 |      0.5 |    0.2 |
| identifiedNeed        |              2 | 2017-11-12 | 0.7 |      0.4 |   0.15 |
| identifiedNeed        |              3 | 2017-11-15 | 0.5 |      0.3 |    0.1
| identifiedNeed        |              4 | 2017-11-18 | 0.6 |      0.2 |   0.05 |
| identifiedBackground  |              5 | 2017-11-19 | 0.2 |      0.4 |    0.2 |
| identifiedBackground  |              6 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
| identifiedBackground  |              7 | 2017-11-15 | 0.5 |      0.2 |    0.1 |
| identifiedBackground  |              8 | 2017-11-18 | 0.6 |      0.1 |   0.05 |
| identifiedGoal        |              9 | 2017-11-19 | 0.1 |      0.4 |    0.2 |
| identifiedGoal        |             10 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
| identifiedGoal        |             11 | 2017-11-15 | 0.3 |      0.2 |    0.1 |
| identifiedGoal        |             12 | 2017-11-18 | 0.2 |      0.1 |   0.05 |
+-----------------------+----------------+------------+-----+----------+

If that doesnt work then this works as well

+----------------+----------------+------------+-----+----------+--------+
| measurement_id | data_points_id | date       | f1  | precison | recall |
+----------------+----------------+------------+-----+----------+--------+
|              1 |              1 | 2017-11-19 | 0.3 |      0.5 |    0.2 |
|              1 |              2 | 2017-11-12 | 0.7 |      0.4 |   0.15 |
|              1 |              3 | 2017-11-15 | 0.5 |      0.3 |    0.1 |
|              1 |              4 | 2017-11-18 | 0.6 |      0.2 |   0.05 |
|              2 |              5 | 2017-11-19 | 0.2 |      0.4 |    0.2 |
|              2 |              6 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
|              2 |              7 | 2017-11-15 | 0.5 |      0.2 |    0.1 |
|              2 |              8 | 2017-11-18 | 0.6 |      0.1 |   0.05 |
|              3 |              9 | 2017-11-19 | 0.1 |      0.4 |    0.2 |
|              3 |             10 | 2017-11-12 | 0.4 |      0.3 |   0.15 |
|              3 |             11 | 2017-11-15 | 0.3 |      0.2 |    0.1 |
|              3 |             12 | 2017-11-18 | 0.2 |      0.1 |   0.05 |
+----------------+----------------+------------+-----+----------+--------+

Body:
The query you request is quite simple.  It uses the "main" table (measurement) joined with the other two.
A "join" is a way to link two tables, using one or more fields.
In your case, for example, you can join measurement with measurement_data_points using the field measurement_id using following sintax (inside a SELECT command):

...
FROM measurement A
LEFT JOIN measurement_data_points B ON A.measurement_id= B.measurement_id

Once joined, you can use in your SELECT every fields of the two tables.  Eg.

...
SELECT  measurement.name
    , measurement_data_points.data_points_id
...

Putting all together, it should be simply:

 SELECT measurement.measurement_id
    , measurement_data_points.data_points_id
    , measurement_point.date
    , measurement_point.f1
    , measurement_point.precison
    , measurement_point.recall
FROM measurement
LEFT JOIN measurement_data_points  ON measurement.measurement_id= measurement_data_points.measurement_id
LEFT JOIN measurement_point ON measurement_data_points.data_points_id = measurement_point.id ;

Query with measurement name instead of measurement id:

SELECT measurement.name
    , measurement_data_points.data_points_id
    , measurement_point.date
    , measurement_point.f1
    , measurement_point.precison
    , measurement_point.recall
FROM measurement
LEFT JOIN measurement_data_points  ON measurement.measurement_id= measurement_data_points.measurement_id
LEFT JOIN measurement_point ON measurement_data_points.data_points_id = measurement_point.id ;

Tip: all these are very simple queries and if you just use a few of your time to read something about SQL SELECT  and SQL JOIN (look on Internet) you will be capable to make queries like this by yourself and with satisfatcion.


问:
ImageSearch not working on different displays
Currently have a couple of ImageSearch AHKScripts for clicking on images within a GUI. This GUI is used on multiple screen sizes (laptops, larger monitors, vertical monitors, ect.). The scripts run without issues on my laptop and monitor as long as the scaling is set the same between each monitor ( 100% or 125%). I tried sharing these scripts with a friend so that he could use them on his laptop but the images cannot be found. We're using the same resolution settings (1920x1080), both laptops are using 100% scaling settings, both laptops are of the same make and very similar model but use slightly different graphics cards. (Intel HD Graphics 520 vs Intel HD Graphics 530). We can visually see a slight color difference on his monitor compared to mine and have tried to adjust this as close as possible but these changes do not seem to effect the imagesearch performance. We've tried copying ICM color profile files from one another laptops and still don't have luck. Is there a work-a-round anyone is aware of so we don't need to implement images from each display we use these scripts on? I've played with the "*N variation" parameters from *50-*200 without any luck as well. Any and all suggestions are greatly appreciated, thanks.</p>

```<code>'
IfWinExist, GUI
{
    WinActivate  ; Automatically uses the window found above.

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\UsersIcon.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Sleep, 3500

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\ChangeUserIcon.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Sleep, 500

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\Administrator.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Sleep, 100

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn1.png
if (!errorlevel){
Click %foundX%, %foundY%, 1
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn2.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn3.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn4.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Send {WheelDown 5}

Sleep, 500

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\Accept.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}
Send {WheelUp 3}
}

ExitApp

esc::ExitApp
'
</code>```

答: A_ScreenWidth or A_ScreenHeight does not always works on [multiple Monitors] , if you now both resolution you can try to calculate and put manually these value's - example monitor 1 and 2 -replace A_ScreenWidth into 3840  (1920+1920=3840) [or/and] replace A_ScreenHeight into 2160 (1080+1080) - if this not help you can try to change the 3d settings in the NVIDIA CONTROL PANEL for example disable anti aliasing. (Compare it, and look if your friend does have the same settings like you.)

Body:
Currently have a couple of ImageSearch AHKScripts for clicking on images within a GUI. This GUI is used on multiple screen sizes (laptops, larger monitors, vertical monitors, ect.). The scripts run without issues on my laptop and monitor as long as the scaling is set the same between each monitor ( 100% or 125%). I tried sharing these scripts with a friend so that he could use them on his laptop but the images cannot be found. We're using the same resolution settings (1920x1080), both laptops are using 100% scaling settings, both laptops are of the same make and very similar model but use slightly different graphics cards. (Intel HD Graphics 520 vs Intel HD Graphics 530). We can visually see a slight color difference on his monitor compared to mine and have tried to adjust this as close as possible but these changes do not seem to effect the imagesearch performance. We've tried copying ICM color profile files from one another laptops and still don't have luck. Is there a work-a-round anyone is aware of so we don't need to implement images from each display we use these scripts on? I've played with the "*N variation" parameters from *50-*200 without any luck as well. Any and all suggestions are greatly appreciated, thanks.

'
IfWinExist, GUI
{
    WinActivate  ; Automatically uses the window found above.

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\UsersIcon.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Sleep, 3500

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\ChangeUserIcon.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Sleep, 500

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\Administrator.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Sleep, 100

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn1.png
if (!errorlevel){
Click %foundX%, %foundY%, 1
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn2.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn3.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\LogIn4.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}

Send {WheelDown 5}

Sleep, 500

ImageSearch, foundX, foundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *50 %A_ScriptDir%\\..\Images\Accept.png
if (!errorlevel){
Click %foundX%, %foundY%
}else if (ErrorLevel == 1){
MsgBox, Image cannot be found
}else{
MsgBox, Cannot Conduct Search
}
Send {WheelUp 3}
}

ExitApp

esc::ExitApp
'


问:
How to render a React component with survey.js?
Here is a working survey.js with react example: http://plnkr.co/edit/qXdeQa6x2FHRg0YrOlPL?p=preview

My html also does have in head the  included.

In my main.jsx I'm calling the rendering of a div that will be filled up based on a json file and by multiple react components, in my json array I have a questions json object too for survey.js. What I would like to achieve is to render a survey when the questions object is being reached in parsing the array.

In my top level component I have this calling for it:

```<code>  if (section.hasOwnProperty('questions')){
            return <Questions key={i+"questions"} id={i+"questions"} questions={section.questions} />;
</code>```

The Questions.jsx:

```<code>var React = require('react');
var ReactDOM = require('react-dom');
var Survey = require('survey-react');
var Questions = React.createClass({
    render: function() {
      Survey.Survey.cssType = "bootstrap";
      Survey.defaultBootstrapCss.navigationButton = "btn btn-green";
      window[this.props.id] = new Survey.Model( this.props.questions );
      var questionid = this.props.id;
        var idi = this.props.id.replace("questions","");
        return (
            <dt>
          <div id={this.props.id}></div>
          </div>
     </dt>
        );
    }
});
module.exports = Questions;
ReactDOM.render(<Survey.Survey model={window[questionid]} />, document.getElementById({questionid}));
</code>```

It does compile without errors but then in the browser I get the console errors:

TypeError: WEBPACK_IMPORTED_MODULE_1_react is undefined[Learn
  More]
  ReferenceError: questionid is not defined

Seems like I try to do it the wrong way, but how to do it right? I'm new to react and not familiar with using reactDOM inside of a component and is my first project on survey.js as well.

Thank you for helping out.

答:
Please check this code:

```<code>import React, { Component } from 'react';
import { render } from 'react-dom';

import * as Survey from 'survey-react';
import 'survey-react/survey.css';

import 'bootstrap/dist/css/bootstrap.css'
import './style.css';

class App extends Component {
  componentWillMount() {
    Survey.Survey.cssType = "bootstrap";
    Survey.defaultBootstrapCss.navigationButton = "btn btn-green";
  }

  render() {
    var json = { title: "Product Feedback Survey Example", showProgressBar: "top", pages: [
        {questions: [
            { type: "matrix", name: "Quality", title: "Please indicate if you agree or disagree with the following statements",
                columns: [{ value: 1, text: "Strongly Disagree" },
                    { value: 2, text: "Disagree" },
                    { value: 3, text: "Neutral" },
                    { value: 4, text: "Agree" },
                    { value: 5, text: "Strongly Agree" }],
                rows: [{ value: "affordable", text: "Product is affordable" },
                    { value: "does what it claims", text: "Product does what it claims" },
                    { value: "better then others", text: "Product is better than other products on the market" },
                    { value: "easy to use", text: "Product is easy to use" }]},
            { type: "rating", name: "satisfaction", title: "How satisfied are you with the Product?",
                mininumRateDescription: "Not Satisfied", maximumRateDescription: "Completely satisfied" },
            { type: "rating", name: "recommend friends", visibleIf: "{satisfaction} > 3",
                title: "How likely are you to recommend the Product to a friend or co-worker?",
                mininumRateDescription: "Will not recommend", maximumRateDescription: "I will recommend" },
            { type: "comment", name: "suggestions", title:"What would make you more satisfied with the Product?", }
        ]},
        {questions: [
            { type: "radiogroup", name: "price to competitors",
                title: "Compared to our competitors, do you feel the Product is",
                choices: ["Less expensive", "Priced about the same", "More expensive", "Not sure"]},
            { type: "radiogroup", name: "price", title: "Do you feel our current price is merited by our product?",
                choices: ["correct|Yes, the price is about right",
                    "low|No, the price is too low for your product",
                    "high|No, the price is too high for your product"]},
            { type: "multipletext", name: "pricelimit", title: "What is the... ",
                items: [{ name: "mostamount", title: "Most amount you would every pay for a product like ours" },
                    { name: "leastamount", title: "The least amount you would feel comfortable paying" }]}
        ]},
        { questions: [
            { type: "text", name: "email",
                title: "Thank you for taking our survey. Your survey is almost complete, please enter your email address in the box below if you wish to participate in our drawing, then press the 'Submit' button."}
        ]}
    ]};

    var model = new Survey.Model(json);
    return (
      <Survey.Survey model={model}/>
    );
  }
}

render(<App />, document.getElementById('root'));
</code>```

and here a live example: https://stackblitz.com/edit/surveyjs-react-stackoverflow45544026

Body:
Here is a working survey.js with react example: http://plnkr.co/edit/qXdeQa6x2FHRg0YrOlPL?p=preview

My html also does have in head the  included.

In my main.jsx I'm calling the rendering of a div that will be filled up based on a json file and by multiple react components, in my json array I have a questions json object too for survey.js. What I would like to achieve is to render a survey when the questions object is being reached in parsing the array.

In my top level component I have this calling for it:

  if (section.hasOwnProperty('questions')){
            return <Questions key={i+"questions"} id={i+"questions"} questions={section.questions} />;

The Questions.jsx:

var React = require('react');
var ReactDOM = require('react-dom');
var Survey = require('survey-react');
var Questions = React.createClass({
    render: function() {
      Survey.Survey.cssType = "bootstrap";
      Survey.defaultBootstrapCss.navigationButton = "btn btn-green";
      window[this.props.id] = new Survey.Model( this.props.questions );
      var questionid = this.props.id;
        var idi = this.props.id.replace("questions","");
        return (

        );
    }
});
module.exports = Questions;
ReactDOM.render(<Survey.Survey model={window[questionid]} />, document.getElementById({questionid}));

It does compile without errors but then in the browser I get the console errors:

TypeError: WEBPACK_IMPORTED_MODULE_1_react is undefined[Learn
  More]
  ReferenceError: questionid is not defined

Seems like I try to do it the wrong way, but how to do it right? I'm new to react and not familiar with using reactDOM inside of a component and is my first project on survey.js as well.

Thank you for helping out.

Body:
Please check this code:

import React, { Component } from 'react';
import { render } from 'react-dom';

import * as Survey from 'survey-react';
import 'survey-react/survey.css';

import 'bootstrap/dist/css/bootstrap.css'
import './style.css';

class App extends Component {
  componentWillMount() {
    Survey.Survey.cssType = "bootstrap";
    Survey.defaultBootstrapCss.navigationButton = "btn btn-green";
  }

  render() {
    var json = { title: "Product Feedback Survey Example", showProgressBar: "top", pages: [
        {questions: [
            { type: "matrix", name: "Quality", title: "Please indicate if you agree or disagree with the following statements",
                columns: [{ value: 1, text: "Strongly Disagree" },
                    { value: 2, text: "Disagree" },
                    { value: 3, text: "Neutral" },
                    { value: 4, text: "Agree" },
                    { value: 5, text: "Strongly Agree" }],
                rows: [{ value: "affordable", text: "Product is affordable" },
                    { value: "does what it claims", text: "Product does what it claims" },
                    { value: "better then others", text: "Product is better than other products on the market" },
                    { value: "easy to use", text: "Product is easy to use" }]},
            { type: "rating", name: "satisfaction", title: "How satisfied are you with the Product?",
                mininumRateDescription: "Not Satisfied", maximumRateDescription: "Completely satisfied" },
            { type: "rating", name: "recommend friends", visibleIf: "{satisfaction} > 3",
                title: "How likely are you to recommend the Product to a friend or co-worker?",
                mininumRateDescription: "Will not recommend", maximumRateDescription: "I will recommend" },
            { type: "comment", name: "suggestions", title:"What would make you more satisfied with the Product?", }
        ]},
        {questions: [
            { type: "radiogroup", name: "price to competitors",
                title: "Compared to our competitors, do you feel the Product is",
                choices: ["Less expensive", "Priced about the same", "More expensive", "Not sure"]},
            { type: "radiogroup", name: "price", title: "Do you feel our current price is merited by our product?",
                choices: ["correct|Yes, the price is about right",
                    "low|No, the price is too low for your product",
                    "high|No, the price is too high for your product"]},
            { type: "multipletext", name: "pricelimit", title: "What is the... ",
                items: [{ name: "mostamount", title: "Most amount you would every pay for a product like ours" },
                    { name: "leastamount", title: "The least amount you would feel comfortable paying" }]}
        ]},
        { questions: [
            { type: "text", name: "email",
                title: "Thank you for taking our survey. Your survey is almost complete, please enter your email address in the box below if you wish to participate in our drawing, then press the 'Submit' button."}
        ]}
    ]};

    var model = new Survey.Model(json);
    return (
      <Survey.Survey model={model}/>
    );
  }
}

render(<App />, document.getElementById('root'));

and here a live example: https://stackblitz.com/edit/surveyjs-react-stackoverflow45544026


问:
Vue.js lazy loading
I'm using Laravel mix for compiling my vue.js components. Now I would like to lazy load my components found it here:

https://v2.vuejs.org/v2/guide/components.html#Async-Components

When I try this:

```<code>Vue.component('setting', () => import('./components/settings/setting.vue'));
</code>```

I get:

```<code> error  in ./resources/assets/admin/vue/core.js

Syntax Error: Unexpected token (36:31)

  34 |  */
  35 |
> 36 | Vue.component('setting', () => import('./components/settings/setting.vue'));
     |                                ^
</code>```

What could be wrong here? When I register the component 'normal' everything is working?

答:
Following from the comments. You need to specify the publicPath.
Here's a small version of a working webpack.mix.js file tested on laravel 5.5 with laravel-mix

```<code>const { mix } = require('laravel-mix');
mix.setPublicPath('public/');

mix.webpackConfig({
    output: {
      chunkFilename: 'js/[name].[chunkhash].js',
         publicPath: '/'
     },
    module: {
        rules: [{
            test: /\.js?$/,
            exclude: /node_modules/,
            loader: 'babel-loader',
            options: {
              presets: ['babel-preset-env'],
              plugins:['babel-plugin-dynamic-import-webpack']
            }
        },

  ]
    }
});

mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.version();
</code>```

You probably had your manifest.json producing wrong paths and thus the webpack is not being able to find the correct chunk file paths. So your solution is either to modifiy the paths or just stick with default paths as the example above.
The code above should produce app.js inside public/js and as well the chunked files. Also it will produce the manifest.json in public directory
Now finally just reference your app.js file in your blade

Note that you need to have babel loader and babel dynamic import plugins installed the first is needed to be able to use babel plugins in webpack as i'm not sure if laravel mix reads the .babelrc file and if it does then that should be enough

ContentLicense: CC BY-SA 4.0

Title: Vue.js lazy loading

Body:
I'm using Laravel mix for compiling my vue.js components. Now I would like to lazy load my components found it here:

https://v2.vuejs.org/v2/guide/components.html#Async-Components

When I try this:

Vue.component('setting', () => import('./components/settings/setting.vue'));

I get:

 error  in ./resources/assets/admin/vue/core.js

Syntax Error: Unexpected token (36:31)

  34 |  */
  35 |
> 36 | Vue.component('setting', () => import('./components/settings/setting.vue'));
     |                                ^

What could be wrong here? When I register the component 'normal' everything is working?

Body:
Following from the comments. You need to specify the publicPath.
Here's a small version of a working webpack.mix.js file tested on laravel 5.5 with laravel-mix

const { mix } = require('laravel-mix');
mix.setPublicPath('public/');

mix.webpackConfig({
    output: {
      chunkFilename: 'js/[name].[chunkhash].js',
         publicPath: '/'
     },
    module: {
        rules: [{
            test: /\.js?$/,
            exclude: /node_modules/,
            loader: 'babel-loader',
            options: {
              presets: ['babel-preset-env'],
              plugins:['babel-plugin-dynamic-import-webpack']
            }
        },

  ]
    }
});

mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.version();

You probably had your manifest.json producing wrong paths and thus the webpack is not being able to find the correct chunk file paths. So your solution is either to modifiy the paths or just stick with default paths as the example above.
The code above should produce app.js inside public/js and as well the chunked files. Also it will produce the manifest.json in public directory
Now finally just reference your app.js file in your blade

<script src="{{mix('/js/app.js')}}"></script>

Note that you need to have babel loader and babel dynamic import plugins installed the first is needed to be able to use babel plugins in webpack as i'm not sure if laravel mix reads the .babelrc file and if it does then that should be enough


问:
(mongoDB) find with empty or null values
how to make a mongodb collection find (db.collection.find) with empty values?

currently i have:

```<code>function test(s) {
    if (!s) {
        return null;
    } else {
        return s;
    }
}

var content = {
    date: {
        from: '2017-10-15',
        to: '2017-11-15'
    },

    'name': 'some text', //this can be null or empty
    'text': 'some other text' //this can be null or empty
}

col.find({
    "date": {
        $gte: new Date(content.date.from),
        $lte: new Date(content.date.to)
    },

    "name": {
        $ne: {
            $type: null
        },

        $eq: test(content.name)
    },

    "text": {
        $ne: {
            $type: null
        },

        $eq: test(content.text)
    },
}).toArray((err, items) => {
    console.log(items)
});
</code>```

but it returns an empty array, because "name" or "text" is null / an empty string,
i want that it query only the values that have something specified or ignore it (like content.name is something in it or its empty)

how do i get it? i already searched ... but didnt found something

thanks!

( already testet mongoDB : multi value field search ignoring null fields)

Versions:
Node: 8.9.0
(npm) mongodb: 2.2.33
mongodb: 3.4

答:
Try using $and, $or operators. Something like.</p>

```<code>col.find({
$and:[
    {"date": {$gte: new Date(content.date.from),$lte: new Date(content.date.to)}},
    {"$or":[{"name": {$ne: {$type: null}}},{"name":test(content.name)}]},
    {"$or":[{"text": {$ne: {$type: null}}},{"text":test(content.text)}]}
 ]
}).toArray((err, items) => {
  console.log(items)
});
</code>```

Body:
how to make a mongodb collection find (db.collection.find) with empty values?

currently i have:

function test(s) {
    if (!s) {
        return null;
    } else {
        return s;
    }
}

var content = {
    date: {
        from: '2017-10-15',
        to: '2017-11-15'
    },

    'name': 'some text', //this can be null or empty
    'text': 'some other text' //this can be null or empty
}

col.find({
    "date": {
        $gte: new Date(content.date.from),
        $lte: new Date(content.date.to)
    },

    "name": {
        $ne: {
            $type: null
        },

        $eq: test(content.name)
    },

    "text": {
        $ne: {
            $type: null
        },

        $eq: test(content.text)
    },
}).toArray((err, items) => {
    console.log(items)
});

but it returns an empty array, because "name" or "text" is null / an empty string,
i want that it query only the values that have something specified or ignore it (like content.name is something in it or its empty)

how do i get it? i already searched ... but didnt found something

thanks!

( already testet mongoDB : multi value field search ignoring null fields)

Versions:
Node: 8.9.0
(npm) mongodb: 2.2.33
mongodb: 3.4

Body:
Try using $and, $or operators. Something like.

col.find({
$and:[
    {"date": {$gte: new Date(content.date.from),$lte: new Date(content.date.to)}},
    {"$or":[{"name": {$ne: {$type: null}}},{"name":test(content.name)}]},
    {"$or":[{"text": {$ne: {$type: null}}},{"text":test(content.text)}]}
 ]
}).toArray((err, items) => {
  console.log(items)
});


问:
Delete from three table in sql or YII
Please Anyone there

Please anyone give me A query to delete from three tables of the
  following tables

```<code>DELETE FROM adl_auth_user A JOIN user_details B
ON A.user_id= B.user_id JOIN adl_user_master C ON A.user_id = C.id where A.user_id = '1920' and B.type_id = 1
</code>```

its not working

Table adl_auth_user A

```<code>id      user_id     type_id     type_value
66428     1919          1           97
</code>```

table user_details B

```<code>user_id     first_name      last_nam
1919        Rins TE       Kola
</code>```

table adl_user C

```<code>id         email                   password
1919    email@DOMAIN.COM         SOME PASSWORD
</code>```

i want delete from these three

```<code>tables table1. user_id = table2.
> user_id and table1. user_id = table3.id
</code>```

答:
Sorry I Got the Answer </p>

```<code>DELETE A,
B,
C FROM adl_auth_user A JOIN user_details B ON A.user_id = B.user_id JOIN adl_user C ON A.user_id = C.id WHERE A.user_id = '1920' AND A.type_id =1
</code>```

Title: Delete from three table in sql or YII

Body:
Please Anyone there

Please anyone give me A query to delete from three tables of the
  following tables

DELETE FROM adl_auth_user A JOIN user_details B
ON A.user_id= B.user_id JOIN adl_user_master C ON A.user_id = C.id where A.user_id = '1920' and B.type_id = 1

its not working

Table adl_auth_user A

id      user_id     type_id     type_value
66428     1919          1           97

table user_details B

user_id     first_name      last_nam
1919        Rins TE       Kola

table adl_user C

id         email                   password
1919    email@DOMAIN.COM         SOME PASSWORD

i want delete from these three

tables table1. user_id = table2.
> user_id and table1. user_id = table3.id

Body:
Sorry I Got the Answer

DELETE A,
B,
C FROM adl_auth_user A JOIN user_details B ON A.user_id = B.user_id JOIN adl_user C ON A.user_id = C.id WHERE A.user_id = '1920' AND A.type_id =1


问:
SQL 2005: Agent job step output file naming
Does anyone know, please, if there's a way to specify "this machine" in a file path that SQL Server will like?

I have an Agent job I want to script onto all my servers. It outputs to a file on the local machine so I want to script the file name as

```<code>\\localhost\<shared-folder-name>\<file-name>
</code>```

Another reason is I'm planning to use log shipping for disaster recovery and I want the jobs to work the same whichever server they're running on. The script sets the job up fine but when I run the job I get an error "Unable to open Step output file". I think I've eliminated share and folder permissions: it works fine with C:\<folder-name>\<file-name>.

答:
have you tried @@SERVERNAME?

```<code>SELECT @@SERVERNAME
</code>```

Or you can use this, the second one you can use if you have multiple instances of SQl server running

```<code>SELECT serverproperty('MachineName'),serverproperty('Instancename')
</code>```

OwnerDisplayName: David Wimbush

Body:
Does anyone know, please, if there's a way to specify "this machine" in a file path that SQL Server will like?

I have an Agent job I want to script onto all my servers. It outputs to a file on the local machine so I want to script the file name as

\\localhost\<shared-folder-name>\<file-name>

Another reason is I'm planning to use log shipping for disaster recovery and I want the jobs to work the same whichever server they're running on. The script sets the job up fine but when I run the job I get an error "Unable to open Step output file". I think I've eliminated share and folder permissions: it works fine with C:\<folder-name>\<file-name>.

LastEditorDisplayName: David Wimbush

Body:
have you tried @@SERVERNAME?

SELECT @@SERVERNAME

Or you can use this, the second one you can use if you have multiple instances of SQl server running

SELECT serverproperty('MachineName'),serverproperty('Instancename')

OwnerDisplayName: SQLMenace


问:
How does one get a code-behind file to recognize type of a user control?
I have a custom control in my mater page that represents a menu, let's call it CustomMenu. The control code files are located in a non special directory.

I want to give each page that uses that master page the ability to access the control and, using a public property, tell the control whether or not it should render itself.

I have a public property on the control to do that, and I know I can get the control by referencing Page.Master.FindControl('IdOfControlIwant');

The problem I'm having is that I can't seem to get the control Type recognized by the compiler, so when I do find the menu control, I can't actually work with it. The only way I can get the code behind to recognize the type is to register it in the ascx file, and then add at least one control to the page, which is undesirable.

Thoughts?

答:
You have to combine what both Jacob and dzendras have posted. Add the MasterType directive to your content page's aspx file:

```<code><%@ MasterType VirtualPath="~/your.master"  %>
</code>```

And in the master page create a property:

```<code>public CustomMenu MyCustomMenu {get{ return myCustomMenu;}}
</code>```

Where myCustomeMenu is the ID of the Usercontrol in your masterpage.

You should now be able to reference the usercontrol from a content page.  So, if the CustomMenu usercontrol had a property called SelectedItem, you should be able to access it like this:

```<code>   public void Page_Load(object o, EventArgs e)
   {
       Master.MyCustomMenu.SelectedItem = 1;
   }
</code>```

Body:
You have to combine what both Jacob and dzendras have posted. Add the MasterType directive to your content page's aspx file:

<%@ MasterType VirtualPath="~/your.master"  %>

And in the master page create a property:

public CustomMenu MyCustomMenu {get{ return myCustomMenu;}}

Where myCustomeMenu is the ID of the Usercontrol in your masterpage.

You should now be able to reference the usercontrol from a content page.  So, if the CustomMenu usercontrol had a property called SelectedItem, you should be able to access it like this:

   public void Page_Load(object o, EventArgs e)
   {
       Master.MyCustomMenu.SelectedItem = 1;
   }


问:
Post Author ID in wordpress permalinks settings
I am making my custom permalinks and want to get the post author id in it I have tried many things but all in vain, Please help me on this one. </p>

答:
STEP 1 add this into your functions.php

Guidance here
 https://wordpress.stackexchange.com/questions/112719/how-to-use-author-id-in-post-permalink

```<code>function wpse_112719_pre_post_link( $permalink, $post, $leavename ) {
    if ( strpos( $permalink, '%author%' ) !== false ) {
        $authordata = get_userdata( $post->post_author );
        $author_id = $authordata->ID;
        $permalink = str_replace( '%author%', $author_id, $permalink );
    }

    return $permalink;
}

add_filter( 'pre_post_link', 'wpse_112719_pre_post_link', 10, 3 );

function wpse_112730_add_rewrite_rules() {
    add_rewrite_rule(
        "([0-9]+)/(.*)",
        'index.php?name=$matches[2]',
        'top'
    );
}

add_action( 'init', 'wpse_112730_add_rewrite_rules' );
</code>```

STEP 2 login to admin end and set the permalinks Custom Structure some thing like this : /%postname%/%author%

Body:
STEP 1 add this into your functions.php

Guidance here
 https://wordpress.stackexchange.com/questions/112719/how-to-use-author-id-in-post-permalink

function wpse_112719_pre_post_link( $permalink, $post, $leavename ) {
    if ( strpos( $permalink, '%author%' ) !== false ) {
        $authordata = get_userdata( $post->post_author );
        $author_id = $authordata->ID;
        $permalink = str_replace( '%author%', $author_id, $permalink );
    }

    return $permalink;
}

add_filter( 'pre_post_link', 'wpse_112719_pre_post_link', 10, 3 );

function wpse_112730_add_rewrite_rules() {
    add_rewrite_rule(
        "([0-9]+)/(.*)",
        'index.php?name=$matches[2]',
        'top'
    );
}

add_action( 'init', 'wpse_112730_add_rewrite_rules' );

STEP 2 login to admin end and set the permalinks Custom Structure some thing like this : /%postname%/%author%