问:
Is it safe to derive the Argon2 type from the encoded hash value?
I'm trying to use the Argon2 reference implementation and I'm a bit confused on the use of the type parameter (i, d, id) during verification.

For password verification, I would need to call one of the *verify* functions of the library. These functions come with the "high-level" API:

```<code>/**
 * Verifies a password against an encoded string
 * Encoded string is restricted as in validate_inputs()
 * @param encoded String encoding parameters, salt, hash
 * @param pwd Pointer to password
 * @pre   Returns ARGON2_OK if successful
 */
ARGON2_PUBLIC int argon2i_verify(const char *encoded, const void *pwd, const size_t pwdlen);
ARGON2_PUBLIC int argon2d_verify(const char *encoded, const void *pwd, const size_t pwdlen);
ARGON2_PUBLIC int argon2id_verify(const char *encoded, const void *pwd, const size_t pwdlen);
/* generic function underlying the above ones */
ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen, argon2_type type);
</code>```

The confusing part is why do I have to choose which method to call (or what to put in argon2_type type on the generic function), since the type is already contained in char *encoded?

From an application point of view, I would need to know which type was used for each password, beforehand. But... that's what encoding is all about. Wouldn't it be great if there was only one *verify* function?

```<code>ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen);
</code>```

which would derive the type from the encoded value?

So, the questions are:

Does the RI current API design tells me something about security, or
usability was something the developers didn't really bulletproof?

Is it safe to derive the type from the encoded value, or should I choose one type and stick with it (aka hardcode it)?

Thanks

答:
The confusing part is why do I have to choose which method to call (or what to put in argon2_type type on the generic function), since the type is already contained in char *encoded? ... Does the RI current API design tells me something about security, or usability was something the developers didn't really bulletproof?

I'm afraid that's something only the authors can answer. However, generally reference implementations may not be as user friendly as those are meant for developers of argon2, not so much the users of the library.

Is it safe to derive the type from the encoded value, or should I choose one type and stick with it (aka hardcode it)?

It makes sense to disallow downgrading and it may be wise to make this kind of filtering configurable.

In the end it is unlikely that an adversary finds collision even if the adversary has full control over the parameters - so it is not overly critical.

Personally I like to specify a specific protocol version separate from the actual parameters, which then specifies which algorithm to use.

Body:
I'm trying to use the Argon2 reference implementation and I'm a bit confused on the use of the type parameter (i, d, id) during verification.

For password verification, I would need to call one of the *verify* functions of the library. These functions come with the "high-level" API:

/**
 * Verifies a password against an encoded string
 * Encoded string is restricted as in validate_inputs()
 * @param encoded String encoding parameters, salt, hash
 * @param pwd Pointer to password
 * @pre   Returns ARGON2_OK if successful
 */
ARGON2_PUBLIC int argon2i_verify(const char *encoded, const void *pwd, const size_t pwdlen);
ARGON2_PUBLIC int argon2d_verify(const char *encoded, const void *pwd, const size_t pwdlen);
ARGON2_PUBLIC int argon2id_verify(const char *encoded, const void *pwd, const size_t pwdlen);
/* generic function underlying the above ones */
ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen, argon2_type type);

The confusing part is why do I have to choose which method to call (or what to put in argon2_type type on the generic function), since the type is already contained in char *encoded?

From an application point of view, I would need to know which type was used for each password, beforehand. But... that's what encoding is all about. Wouldn't it be great if there was only one *verify* function?

ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen);

which would derive the type from the encoded value?

So, the questions are:

Does the RI current API design tells me something about security, or
usability was something the developers didn't really bulletproof?

Is it safe to derive the type from the encoded value, or should I choose one type and stick with it (aka hardcode it)?

Thanks


来源: stackexchange

问:
Pass integer value through pthread_create
I simply want to pass the value of an integer to a thread.

How can I do that?

I tried:

```<code>    int i;
    pthread_t thread_tid[10];
    for(i=0; i<10; i++)
    {
        pthread_create(&thread_tid[i], NULL, collector, i);
    }
</code>```

The thread method looks like this:

```<code>    void *collector( void *arg)
    {
        int a = (int) arg;
    ...
</code>```

I get the following warning:

```<code>    warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
</code>```

答:
It better to use of a struct for send more parameters in one :

```<code>struct PARAMS
{
    int i;
    char c[255];
    float f;
} params;

pthread_create(&thread_id, NULL, fun, (void*)(&params));
</code>```

then you can cast params to PARAMS* and use of it in pthread routine:

```<code>PARAMS *p = static_cast<PARAMS*>(params);
p->i = 5;
strcpy(p->c, "hello");
p->f = 45.2;
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I simply want to pass the value of an integer to a thread.

How can I do that?

I tried:

    int i;
    pthread_t thread_tid[10];
    for(i=0; i<10; i++)
    {
        pthread_create(&thread_tid[i], NULL, collector, i);
    }

The thread method looks like this:

    void *collector( void *arg)
    {
        int a = (int) arg;
    ...

I get the following warning:

    warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

Body:
It better to use of a struct for send more parameters in one :

struct PARAMS
{
    int i;
    char c[255];
    float f;
} params;

pthread_create(&thread_id, NULL, fun, (void*)(&params));

then you can cast params to PARAMS* and use of it in pthread routine:

PARAMS *p = static_cast<PARAMS*>(params);
p->i = 5;
strcpy(p->c, "hello");
p->f = 45.2;


问:
How to align text?
Is is possible to format the following text so the text after : is in specific column (like 70)?

```<code>body:
X  width:                                    100%
// This is comment
   min->
X    width:  960px
   a:
     &:hoover:
X      family:                       $main_fonts
   background->
X    image:                                  url('img/image.png')
X    position:     top center
X    repeat:         repeat
X  color: #000
</code>```

but just for lines which contain X (X at the front is just for showing which line to format, it's not in the real file). I tried to use Align by Charles Campbell but no luck :(

The resulting text should be like:

```<code>body:
  width:                                             100%
// This is comment
   min->
    width:                                           960px
   a:
     &:hoover:
      family:                                        $main_fonts
   background->
    image:                                           url('img/image.png')
    position:                                        top center
    repeat:                                          repeat
  color:                                             #000
</code>```

答:
In vim with the Tabular plugin, use  V  to linewise visually select the area you want to format and then  :'<,'>Tabular /:\s+\zs/l0l70
(and spiiph was right :)</p>

ContentLicense: CC BY-SA 2.5

Title: How to align text?

Body:
Is is possible to format the following text so the text after : is in specific column (like 70)?

body:
X  width:                                    100%
// This is comment
   min->
X    width:  960px
   a:
     &:hoover:
X      family:                       $main_fonts
   background->
X    image:                                  url('img/image.png')
X    position:     top center
X    repeat:         repeat
X  color: #000

but just for lines which contain X (X at the front is just for showing which line to format, it's not in the real file). I tried to use Align by Charles Campbell but no luck :(

The resulting text should be like:

body:
  width:                                             100%
// This is comment
   min->
    width:                                           960px
   a:
     &:hoover:
      family:                                        $main_fonts
   background->
    image:                                           url('img/image.png')
    position:                                        top center
    repeat:                                          repeat
  color:                                             #000


问:
JxBrowser with Java Swing (IntelliJ plugin) - "Received signal 10 BUS_ADRERR"
I'm writing an IntelliJ plugin, and attempting to integrate JxBrowser into the plugin's tool window via Java Swing.

I'm using the toolWindow extension to keep the tool window integration simple.

plugin.xml

```<code>  <extensions defaultExtensionNs="com.intellij">
    <toolWindow id="pluginid" anchor="right" factoryClass="com.solutionloft.codeclippy.MainWindowFactory" />
  </extensions>
</code>```

And so my main factory class looks like this:

```<code>public class MainWindowFactory implements ToolWindowFactory {

    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        Browser browser = new Browser();
        BrowserView view = new BrowserView(browser);
        Content content = toolWindow.getContentManager().getFactory().createContent(view, "", false);
        toolWindow.getContentManager().addContent(content);

        browser.loadHTML("<html><body><h1>Hello World!</h1></body></html>");
    }
}
</code>```

This appears to work when I run the plugin locally initially (the tool window comes up, and I can see Hello World), but if I terminate the process and then try to run it again, I run into this error:

```<code>Received signal 10 BUS_ADRERR 000103bc3000
 [0x00017cd9540c]
 [0x00017cd95301]
 [0x7fff572eef5a]
 [0x7fbe7e9f5000]
[end of stack trace]

Process finished with exit code 138 (interrupted by signal 10: SIGBUS)
</code>```

Am I missing some kind of cleanup step? I'm not sure what could still be running - the only workaround I've found at this point is to do a full computer restart, so I guess some process must be still running that's causing it to conflict. What's the proper way to clean up? Does it have anything to do with browser.dispose()? I haven't had much luck finding documentation on when .dispose() would be appropriate / if it's needed.

I'm using:

* macOS High Sierra

* Java 1.8.0_151 as my JDK

* PyCharm Ultimate as my JRE

Thanks!

Update: Noticed if I kill this process /System/Library/Frameworks/LocalAuthentication.framework/Support/coreauthd, the problem goes away for the next few runs. But sometimes this process doesn't exist and killing a still-running java process is the fix... odd.

答: According to the article, all browser instances should disposed when you don't need them. Please try disposing all browser instances before closing your application.</p>

Body:
I'm writing an IntelliJ plugin, and attempting to integrate JxBrowser into the plugin's tool window via Java Swing.

I'm using the toolWindow extension to keep the tool window integration simple.

plugin.xml

  <extensions defaultExtensionNs="com.intellij">
    <toolWindow id="pluginid" anchor="right" factoryClass="com.solutionloft.codeclippy.MainWindowFactory" />
  </extensions>

And so my main factory class looks like this:

public class MainWindowFactory implements ToolWindowFactory {

    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        Browser browser = new Browser();
        BrowserView view = new BrowserView(browser);
        Content content = toolWindow.getContentManager().getFactory().createContent(view, "", false);
        toolWindow.getContentManager().addContent(content);

        browser.loadHTML("
Hello World!
");
    }
}

This appears to work when I run the plugin locally initially (the tool window comes up, and I can see Hello World), but if I terminate the process and then try to run it again, I run into this error:

Received signal 10 BUS_ADRERR 000103bc3000
 [0x00017cd9540c]
 [0x00017cd95301]
 [0x7fff572eef5a]
 [0x7fbe7e9f5000]
[end of stack trace]

Process finished with exit code 138 (interrupted by signal 10: SIGBUS)

Am I missing some kind of cleanup step? I'm not sure what could still be running - the only workaround I've found at this point is to do a full computer restart, so I guess some process must be still running that's causing it to conflict. What's the proper way to clean up? Does it have anything to do with browser.dispose()? I haven't had much luck finding documentation on when .dispose() would be appropriate / if it's needed.

I'm using:

* macOS High Sierra

* Java 1.8.0_151 as my JDK

* PyCharm Ultimate as my JRE

Thanks!

Update: Noticed if I kill this process /System/Library/Frameworks/LocalAuthentication.framework/Support/coreauthd, the problem goes away for the next few runs. But sometimes this process doesn't exist and killing a still-running java process is the fix... odd.


问:
Intellij filewatcher is compiling scss to CSS but is not updating server files
I have a compass scss file watcher setup

the files compile fine, but the produced CSS is not deployed to the server

I always manually have to deploy the folder, or like I did, I wrote a small ant script to do it for me. None the less, not what I want, this should get auto deployed

答:
Make sure to tick the 'Upload external changes' checkbox in Deployment/Options.
See http://www.jetbrains.com/webstorm/webhelp/deployment.html and related topics for more info</p>


问:
How can I split a UITableViewCell?
I would like to achieve a UITableViewCell to look like this image (following/tweets/etc):

alt text http://etch-reviews.com/wp-content/uploads/2009/10/tweetie-2-profile-screen.jpg

答:
What happens if you use such approach (using CoreGraphics) and then you tap the cell? Will it be colored totally in blue or just the slice you are touching?

Because that's the problem, and that's not even a button.

Title: How can I split a UITableViewCell?


问:
I need to want how to Post/Upload a recorded or selected video to server using binary formate and mp4 type in objective c
Hi I just used image picker view to record a video and convert the video formate mov to mp4 and change NSData for posting. But it is not working I get 415 error some times 500 errors. Please check below code for how I implemented. Anybody can guid or help me for this issue.

if I need to check my server side team , they test with postman it is working well when I am implement of below code it is not working if may did any mistakes please guid me thank you

```<code>-(void)camerabuttonHandlerqas{

UIAlertController * picker = [UIAlertController alertControllerWithTitle:@"Pick an image using" message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIImagePickerController * imagePicker = [[UIImagePickerController alloc]init];
imagePicker.delegate = self;

UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { }];

UIAlertAction* takeVideo = [UIAlertAction actionWithTitle:@"TakeVideo" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

imagePicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];

imagePicker.view.tag = 100;

[self presentViewController:imagePicker animated:YES completion:nil]; }];
[picker addAction:picture];

[picker addAction:cancel];

picker.view.tintColor = [UIColor grayColor];
[self presentViewController:picker animated:YES completion:nil];

}

#pragma mark - <UIImagePickerControllerDelegate>

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {

videoURL = info[UIImagePickerControllerMediaURL];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString* videoPath = [NSString stringWithFormat:@"%@/test_%d.mp4", [paths objectAtIndex:0],arc4random_uniform(1000)];

NSURL *outputURL = [NSURL fileURLWithPath:videoPath];

[self convertVideoToLowQuailtyWithInputURL:videoURL outputURL:outputURL handler:^(AVAssetExportSession *exportSession)

{

switch (exportSession.status) {
     case AVAssetExportSessionStatusFailed:
         NSLog(@"status failed");
         break;
     case AVAssetExportSessionStatusCompleted:{
         NSLog(@"status success %@ ",videoPath);
         NSMutableDictionary *data = [NSMutableDictionary new];

         videoURL = info[UIImagePickerControllerMediaURL];

         [data setObject:[self generatePostDataForData:[NSData dataWithContentsOfFile:videoPath]] forKey:@"SelectedvideoURL"];
         imagePickerIsSelected = YES;
         [self postData:data];
         break;

     }

}];

[picker dismissViewControllerAnimated:YES completion:nil]; }
- (NSData *)generatePostDataForData:(NSData *)uploadData

{    // Generate the post header:

NSString *post = [NSString stringWithCString:"--AaB03x\r\nContent-Disposition: form-data; name=\"upload[file]\";

filename=\"somefile\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n" encoding:NSASCIIStringEncoding];

    // Get the post header int ASCII format:

NSData *postHeaderData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

// Generate the mutable data variable:

NSMutableData *postData = [[NSMutableData alloc] initWithLength: [postHeaderData length] ];
[postData setData:postHeaderData];

// Add the image:
// Add the closing boundry:

[postData appendData: [@"\r\n--AaB03x--" dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];

// Return the post data:

return postData;
}

-(void) postData:(NSData *)data

{

service = [NSString stringWithFormat:@"http://1.1.1.1:8080/testing/postapi/photoUpload/uploadVideo?videoName=video_%d&type=mp4",arc4random_uniform(1000)]

delegate = delegateInstance;
service = [service stringByAddingPercentEncodingWithAllowedCharacters: [NSCharacterSet URLFragmentAllowedCharacterSet]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

[request setURL:[NSURL URLWithString:service]];
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];

[request setHTTPShouldHandleCookies:NO];

[request setTimeoutInterval:60];

[request setHTTPMethod:@"POST"];

// set Content-Type in HTTP header

[request setValue:@"mp4/MOV" forHTTPHeaderField: @"Content-Type"];

NSMutableData *body = [NSMutableData data];

// add image data

if (videoData) {
    [body appendData:videoData];
}

// setting the body of the post to the reqeust

[request setHTTPBody:videoData];

// set URL

NSURLSession *session = [NSURLSession sharedSession];

NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                        completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

                                            if (error) {
                                                NSLog(@"%@", error);
                                            } else {
                                                NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                NSLog(@"%@", httpResponse);

} }]; [dataTask resume]; }
</code>```

答: 415 error media type error check your server data type on which u r storing NSDATA. </p>

Body:
Hi I just used image picker view to record a video and convert the video formate mov to mp4 and change NSData for posting. But it is not working I get 415 error some times 500 errors. Please check below code for how I implemented. Anybody can guid or help me for this issue.

if I need to check my server side team , they test with postman it is working well when I am implement of below code it is not working if may did any mistakes please guid me thank you

-(void)camerabuttonHandlerqas{

UIAlertController * picker = [UIAlertController alertControllerWithTitle:@"Pick an image using" message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIImagePickerController * imagePicker = [[UIImagePickerController alloc]init];
imagePicker.delegate = self;

UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { }];

UIAlertAction* takeVideo = [UIAlertAction actionWithTitle:@"TakeVideo" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

imagePicker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];

imagePicker.view.tag = 100;

[self presentViewController:imagePicker animated:YES completion:nil]; }];
[picker addAction:picture];

[picker addAction:cancel];

picker.view.tintColor = [UIColor grayColor];
[self presentViewController:picker animated:YES completion:nil];

}

#pragma mark - <UIImagePickerControllerDelegate>

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {

videoURL = info[UIImagePickerControllerMediaURL];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString* videoPath = [NSString stringWithFormat:@"%@/test_%d.mp4", [paths objectAtIndex:0],arc4random_uniform(1000)];

NSURL *outputURL = [NSURL fileURLWithPath:videoPath];

[self convertVideoToLowQuailtyWithInputURL:videoURL outputURL:outputURL handler:^(AVAssetExportSession *exportSession)

{

switch (exportSession.status) {
     case AVAssetExportSessionStatusFailed:
         NSLog(@"status failed");
         break;
     case AVAssetExportSessionStatusCompleted:{
         NSLog(@"status success %@ ",videoPath);
         NSMutableDictionary *data = [NSMutableDictionary new];

         videoURL = info[UIImagePickerControllerMediaURL];

         [data setObject:[self generatePostDataForData:[NSData dataWithContentsOfFile:videoPath]] forKey:@"SelectedvideoURL"];
         imagePickerIsSelected = YES;
         [self postData:data];
         break;

     }

}];

[picker dismissViewControllerAnimated:YES completion:nil]; }
- (NSData *)generatePostDataForData:(NSData *)uploadData

{    // Generate the post header:

NSString *post = [NSString stringWithCString:"--AaB03x\r\nContent-Disposition: form-data; name=\"upload[file]\";

filename=\"somefile\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n" encoding:NSASCIIStringEncoding];

    // Get the post header int ASCII format:

NSData *postHeaderData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

// Generate the mutable data variable:

NSMutableData *postData = [[NSMutableData alloc] initWithLength: [postHeaderData length] ];
[postData setData:postHeaderData];

// Add the image:
// Add the closing boundry:

[postData appendData: [@"\r\n--AaB03x--" dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];

// Return the post data:

return postData;
}

-(void) postData:(NSData *)data

{

service = [NSString stringWithFormat:@"http://1.1.1.1:8080/testing/postapi/photoUpload/uploadVideo?videoName=video_%d&type=mp4",arc4random_uniform(1000)]

delegate = delegateInstance;
service = [service stringByAddingPercentEncodingWithAllowedCharacters: [NSCharacterSet URLFragmentAllowedCharacterSet]];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

[request setURL:[NSURL URLWithString:service]];
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];

[request setHTTPShouldHandleCookies:NO];

[request setTimeoutInterval:60];

[request setHTTPMethod:@"POST"];

// set Content-Type in HTTP header

[request setValue:@"mp4/MOV" forHTTPHeaderField: @"Content-Type"];

NSMutableData *body = [NSMutableData data];

// add image data

if (videoData) {
    [body appendData:videoData];
}

// setting the body of the post to the reqeust

[request setHTTPBody:videoData];

// set URL

NSURLSession *session = [NSURLSession sharedSession];

NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                        completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

                                            if (error) {
                                                NSLog(@"%@", error);
                                            } else {
                                                NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                NSLog(@"%@", httpResponse);

} }]; [dataTask resume]; }


问:
VBA - Worksheet activate macro
I have a dropdownlist on a spreadsheet which has a macro when particular items are selected. E.g. if they choose "Yes", some cells are unhidden.

I am trying to update this value using VBA, e.g. SheetName.Range("OptionDropDown").value = "Yes"

when this runs I want also the activation on the worksheet to run, however it just inputs the value but does not run the macro behind it to unhide the sheets. I've tried turning on/off autocalc with no luck. If I go into the spreadsheet and press enter on the cell the macro works

答:
If this needs to trigger each time the dropdown item is changed, I would suggest using the worksheet_change function.

in the sheets VBA page (Terminology isn't great, sorry!)

```<code>sub worksheet_change(ByVal Target as Range)

if instr(1,target.address,"letter of column effected"),1)>0 then

     'run code here
else
'Do nothing or other stuff
End if
</code>```

This will trigger each time a cell changes, which in this instance would be the cell linked to the dropdown box or the cell set to pull a value based on the drop down.

Hope this helps

Title: VBA - Worksheet activate macro

Body:
If this needs to trigger each time the dropdown item is changed, I would suggest using the worksheet_change function.

in the sheets VBA page (Terminology isn't great, sorry!)

sub worksheet_change(ByVal Target as Range)

if instr(1,target.address,"letter of column effected"),1)>0 then

     'run code here
else
'Do nothing or other stuff
End if

This will trigger each time a cell changes, which in this instance would be the cell linked to the dropdown box or the cell set to pull a value based on the drop down.

Hope this helps


问:
How can I access a list that is created in a static object that is part of another class?
What I would like to do is to have a list that is in an object counts that is defined in the App class as a static when my application starts:

Here's the object:

```<code>public class Counts
{
    public Counts()
    {
       public static List<CntQty> CardClicks2m;
    }
}
</code>```

In my application I declare this

am using the following code:

```<code>public partial class App : Application
{
    public static Counts counts = new Counts();

    public App()
    {
    }
}
</code>```

Now I try to use load some data into the list but it gives me the error below. Note that this function is in another class.

```<code>public void GetClickHistory()
{
   App.counts.CardClicks2m = db2.Query<CntQty>(sql);
</code>```

The last line of the code is giving me an error saying

counts.CardClicks2m cannot be accessed with an instance reference;
  qualify it with a type name instead.

I have tried a few different ways to make this work. One by removing the static and creating the object in the app constructor. This also didn't seem to work so I am hoping someone can point me in the right direction or at least suggest something.

答:
As your CardClicks2m-member is static there´s no need to have any instance of your Counts- or aven your App-class. The member exists once per appdomain however. Having said this in order to access CardClicks2m you don´t have to create an instance of your Counts-class within App.

Use this instead:

```<code>class MyClass
{
    void DoSometjing()
    {
        Counts.CardClicks2m = db2.Query<CntQty>(sql).ToList();
    }
}
</code>```

Be aware to that Query will surely not return a List<CntQty>, but an IQueryable<CntQty>, that´s why you should call ToList afterwards.

Furthermore you can´t declare a member within a method or constructor. Thus declare it within the class´-body instead of the constructor:

```<code>public class Counts
{
    public static List<CntQty> CardClicks2m;
    public Counts() { /* any further initialzation */ }   }
}
</code>```

Body:
What I would like to do is to have a list that is in an object counts that is defined in the App class as a static when my application starts:

Here's the object:

public class Counts
{
    public Counts()
    {
       public static List<CntQty> CardClicks2m;
    }
}

In my application I declare this

am using the following code:

public partial class App : Application
{
    public static Counts counts = new Counts();

    public App()
    {
    }
}

Now I try to use load some data into the list but it gives me the error below. Note that this function is in another class.

public void GetClickHistory()
{
   App.counts.CardClicks2m = db2.Query<CntQty>(sql);

The last line of the code is giving me an error saying

counts.CardClicks2m cannot be accessed with an instance reference;
  qualify it with a type name instead.

I have tried a few different ways to make this work. One by removing the static and creating the object in the app constructor. This also didn't seem to work so I am hoping someone can point me in the right direction or at least suggest something.

Body:
As your CardClicks2m-member is static there´s no need to have any instance of your Counts- or aven your App-class. The member exists once per appdomain however. Having said this in order to access CardClicks2m you don´t have to create an instance of your Counts-class within App.

Use this instead:

class MyClass
{
    void DoSometjing()
    {
        Counts.CardClicks2m = db2.Query<CntQty>(sql).ToList();
    }
}

Be aware to that Query will surely not return a List<CntQty>, but an IQueryable<CntQty>, that´s why you should call ToList afterwards.

Furthermore you can´t declare a member within a method or constructor. Thus declare it within the class´-body instead of the constructor:

public class Counts
{
    public static List<CntQty> CardClicks2m;
    public Counts() { /* any further initialzation */ }   }
}


问:
Use the result of a function call in next function
I want to combine the result of two asynchronouse function calls. I tried to get that as seperate functions.

```<code>$scope.showPage = function () {
    var base ="";
    var menu= "";
    service.getGUI('menu', function (reply) {
            if (reply.status === 200 && reply.data !== null) {
               menu = reply.data;
            }
        });

    service.getGUI('base', function (reply) {
            if (reply.status === 200 && reply.data !== null) {
               base=reply.data;
        });

console.log("base:"+ base);
console.log("menu:"+ menu);
}
</code>```

But the console output is not updating as expected. How can I execute is one by one and use the result of the first one in second function.

答:
const asyncFunction = (x, cb) => setTimeout(cb.bind(null, x), 100 * Math.random())

// What you have
asyncFunction('Async 1', console.log)
asyncFunction('Async 2', console.log)

asyncFunction('Async 3', (x) => {
  console.log(x)
  asyncFunction('Async 4', console.log)
})```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.as-console-wrapper { max-height: 100% !important; top: 0; }</code>```

As you can see Async 1/2 values are printed in a different order each time but Async 4 is always printed after Async 3.

Body:
I want to combine the result of two asynchronouse function calls. I tried to get that as seperate functions.

$scope.showPage = function () {
    var base ="";
    var menu= "";
    service.getGUI('menu', function (reply) {
            if (reply.status === 200 && reply.data !== null) {
               menu = reply.data;
            }
        });

    service.getGUI('base', function (reply) {
            if (reply.status === 200 && reply.data !== null) {
               base=reply.data;
        });

console.log("base:"+ base);
console.log("menu:"+ menu);
}

But the console output is not updating as expected. How can I execute is one by one and use the result of the first one in second function.

Body:
const asyncFunction = (x, cb) => setTimeout(cb.bind(null, x), 100 * Math.random())

// What you have
asyncFunction('Async 1', console.log)
asyncFunction('Async 2', console.log)

asyncFunction('Async 3', (x) => {
  console.log(x)
  asyncFunction('Async 4', console.log)
})

.as-console-wrapper { max-height: 100% !important; top: 0; }

As you can see Async 1/2 values are printed in a different order each time but Async 4 is always printed after Async 3.


问:
Why 'datas' array is always empty?
My code

```<code> $.getJSON('/load4',
    function (data) {
        for (var i = 0; i < data.length; i++) {
            var counter = data[i];
            datas.push([counter.Id, counter.login.substr(0, 25),'3', counter.hash , 'MA']);
        }
    });
console.log("Datas " + datas);
</code>```

I'm trying to fill my array like [[a,b],[a,c]], but can't.

```<code>datas[i] = [counter.Id, counter.login.substr(0, 25),'3', counter.hash , 'MA'];
</code>```

Also doesn't work.

答: That's because you are loading your JSON asynchronously. Which means that the log runs before the callback function passed as parameter to getJSON.

Title: Why 'datas' array is always empty?

Body:
My code

 $.getJSON('/load4',
    function (data) {
        for (var i = 0; i < data.length; i++) {
            var counter = data[i];
            datas.push([counter.Id, counter.login.substr(0, 25),'3', counter.hash , 'MA']);
        }
    });
console.log("Datas " + datas);

I'm trying to fill my array like [[a,b],[a,c]], but can't.

datas[i] = [counter.Id, counter.login.substr(0, 25),'3', counter.hash , 'MA'];

Also doesn't work.


问:
How to get Rails root_path to redirect to /en/ locale?
I have an application that is available in EN and DE. Currently, when you enter the website www.example.com it does not redirect to default locale. Ideally, I would like root to immediately redirect so I get: www.example.com/en.

When I click a root_path link in the app, it goes to the frontpage including the locale www.example.org/en as expected.

Question: How do I ensure that users that enters www.example.com is redirected to www.example.com/en immediately?

Routes:

```<code>Rails.application.routes.draw do
  scope '(:locale)', locale: /en|de/ do
  root 'pages#landingpage'
</code>```

Application controller:

```<code>def set_locale
  I18n.locale = params[:locale] || I18n.default_locale
end

def default_url_options(options = {})
  {locale: I18n.locale}
end
</code>```

答:
First of all please go through this
Internationalization guidelines

Now try this in the routes:

```<code>scope "(/:locale)" {}
</code>```

and use the config.default_locale option in the configuration. you can configure fallbacks for localization.

if you are using cookies to keep track of your locale, you can can skip the default_url_options, you will have to keep the unlocalized versions anyways for backward compatibility.

Body:
I have an application that is available in EN and DE. Currently, when you enter the website www.example.com it does not redirect to default locale. Ideally, I would like root to immediately redirect so I get: www.example.com/en.

When I click a root_path link in the app, it goes to the frontpage including the locale www.example.org/en as expected.

Question: How do I ensure that users that enters www.example.com is redirected to www.example.com/en immediately?

Routes:

Rails.application.routes.draw do
  scope '(:locale)', locale: /en|de/ do
  root 'pages#landingpage'

Application controller:

def set_locale
  I18n.locale = params[:locale] || I18n.default_locale
end

def default_url_options(options = {})
  {locale: I18n.locale}
end

Body:
First of all please go through this
Internationalization guidelines

Now try this in the routes:

scope "(/:locale)" {}

and use the config.default_locale option in the configuration. you can configure fallbacks for localization.

if you are using cookies to keep track of your locale, you can can skip the default_url_options, you will have to keep the unlocalized versions anyways for backward compatibility.


问:
DataGridView - force empty DataSource for anonymous objects
I have a DataGridView which has two columns designed: their DataPropertyName are Name and Value.

DataSource for this DGV comes from collection of SomeObject class which looks like:

```<code>public class SomeObject
{
    public string Name { get; set; }
    public int Value { get; set; }
    public int SomeOtherProp1 { get; set; }
    public int SomeOtherProp2 { get; set; }
}
</code>```

I want only Name and Value properties be used in DataSource, so I create an anonymous object with those two properties (someObjectCollection is a collection of SomeObject objects):

```<code>dgv.DataSource = someObjectCollection.Select(o => new { o.Name, o.Value }).ToArray();
</code>```

And that is ok - what I need to achieve now, is to manually assign an empty collection to dgv.DataSource to clear it out.

I cannot assign null, because then the DataGridView control just disappears on the form.
I also would ommit creating an additional viev model class with only those two properties used in DataSource.

So, is there any other way?

答: You can try the set the empty result with the last valid result, case the object is null .</p>

Body:
I have a DataGridView which has two columns designed: their DataPropertyName are Name and Value.

DataSource for this DGV comes from collection of SomeObject class which looks like:

public class SomeObject
{
    public string Name { get; set; }
    public int Value { get; set; }
    public int SomeOtherProp1 { get; set; }
    public int SomeOtherProp2 { get; set; }
}

I want only Name and Value properties be used in DataSource, so I create an anonymous object with those two properties (someObjectCollection is a collection of SomeObject objects):

dgv.DataSource = someObjectCollection.Select(o => new { o.Name, o.Value }).ToArray();

And that is ok - what I need to achieve now, is to manually assign an empty collection to dgv.DataSource to clear it out.

I cannot assign null, because then the DataGridView control just disappears on the form.
I also would ommit creating an additional viev model class with only those two properties used in DataSource.

So, is there any other way?


问:
strange behavior of python function time.time()
consider the following python function:

```<code>def prandom():
    t = time.time()
    s = t - int(t)
    s = str('{0:.16f}'.format(s))
    print s
    s = int(s[5])
    print(s)
    return s
</code>```

the naive intention is to get a pseudorandom digit.
However: how do you explain that, no matter how many times I run the function (on a Windows 10 machine) I get either a 0 or a 9? Is there something I am missing?

答:
Some modification in your code better modify your function:

```<code>def prandom():
    t = time.time()
    return str("{0:.16f}".format(t))[-1]
</code>```

This will give all the values

Best way to generate random number is to use random function

import random

```<code>a = random.randint(0, 9) # two argument will generate number between those numbers
print a # random digit from 0 to 9
</code>```

OUTPUT:

```<code>8
</code>```

Body:
consider the following python function:

def prandom():
    t = time.time()
    s = t - int(t)
    s = str('{0:.16f}'.format(s))
    print s
    s = int(s[5])
    print(s)
    return s

the naive intention is to get a pseudorandom digit.
However: how do you explain that, no matter how many times I run the function (on a Windows 10 machine) I get either a 0 or a 9? Is there something I am missing?

Body:
Some modification in your code better modify your function:

def prandom():
    t = time.time()
    return str("{0:.16f}".format(t))[-1]

This will give all the values

Best way to generate random number is to use random function

import random

a = random.randint(0, 9) # two argument will generate number between those numbers
print a # random digit from 0 to 9

OUTPUT:

8


问:
Provide alternate (international) spelling for defined Swagger route
I'm working on an API spec in swagger that has an endpoint:

```<code>/authorizations
</code>```

I would like to define an alternative spelling (authorisations) for this endpoint as well. Is this possible? Or do I need to define a separate route for each spelling?

```<code>/authorizations:
    get:
      description: Returns a list of authorizations
</code>```

答:
A possible workaround is to define another path that $refs the original path, this way you end up with two copies of the same path.

paths:
  /authorizations:
    get:
      description: Returns a list of authorizations
      responses:
        200:
          description: OK
  /authorisations:
    $ref: '#/paths/~1authorizations'
```

One limitation of this technique is that you cannot have operationId for these paths, because both paths will end up with the same ID, which is not allowed.

If you need to have different operationId in paths, you'll need to define the 2nd path in the usual way (i.e. copy-paste the definition from the 1st path).

Body:
I'm working on an API spec in swagger that has an endpoint:

/authorizations

I would like to define an alternative spelling (authorisations) for this endpoint as well. Is this possible? Or do I need to define a separate route for each spelling?

/authorizations:
    get:
      description: Returns a list of authorizations

Body:
A possible workaround is to define another path that $refs the original path, this way you end up with two copies of the same path.

paths:
  /authorizations:
    get:
      description: Returns a list of authorizations
      responses:
        200:
          description: OK
  /authorisations:
    $ref: '#/paths/~1authorizations'

One limitation of this technique is that you cannot have operationId for these paths, because both paths will end up with the same ID, which is not allowed.

If you need to have different operationId in paths, you'll need to define the 2nd path in the usual way (i.e. copy-paste the definition from the 1st path).

ContentLicense: CC BY-SA 4.0


问:
Segfault when using *this
I'm getting a segfault when I try to access a member of a class from within a method of that same class, which does not make sense to me at all.

I have the Tree class:

```<code>class Tree
{

public:

Coord* root;

Tree(int x, int y)
{
    root = new Coord(x, y);
    populateTree();
}

void populateTree()
{
    queue<Coord*> nodes;
    nodes.push(root);

    while (nodes.size() > 0)
    {
        Coord* currnode = nodes.front();
        nodes.pop();

        if ( !(currnode->getValidMoves()) )
        {
            return;
        }

        else
        {
            for (int i = 0; i < MAX_CHILDREN_PER_COORD; i++)
            {
                if (currnode->children[i] != NULL)
                {
                    nodes.push(currnode->children[i]);
                }
            }
        }
    }
}
</code>```

...and the Coord class...

```<code>class Coord : public Loc
{
    public:

    Coord(int xPos, int yPos);

    Coord* children[MAX_CHILDREN_PER_COORD];

    bool getValidMoves();

    bool operator==(Coord coord);
    bool operator==(Loc loc);

};

Coord::Coord(int xPos, int yPos) : Loc(xPos, yPos) {}

bool Coord::getValidMoves()
{
    //This line segfaults
    Coord test = *this;

    //Global boolean method. Checks found
    if (!foundTrue())
    {
        for (int i = 0; i < MAX_CHILDREN_PER_COORD; i++)
        {
            //If the above segfaulting line is commented out, this is the first place that segfaults
            int newX = x + knightPositions[i].x;
            int newY = y + knightPositions[i].y;

            if ( !(newX > GRID_X || newX < 0 || newY > GRID_Y || newY < 0) )
            {
                //knightPositions is a Loc array of length MAX_CHILDREN_PER_COORD
                children[i] = new Coord(x + knightPositions[i].x, y + knightPositions[i].y);
                //Global 2d array of ints. Gets checked by foundTrue()
                found[x + knightPositions[i].x][y + knightPositions[i].y] = true;
            }
        }

        return true;
    }

    else
    {
        return false;
    }

    //Otherwise, just leave it as a blank array
}

bool Coord::operator==(Coord coord)
{
    return coord.x == x && coord.y == y;
}

bool Coord::operator==(Loc loc)
{
    return loc.x == x && loc.y == y;
}
</code>```

... and the Loc class, from which Coord inheirits...

```<code>class Loc
{
    public:
        int x, y;

        //Constructor
        Loc(int xPos, int yPos) : x(xPos), y(yPos) {}
};
</code>```

The segfault occurs in Coord::getValidMoves() as indicated by the comments. If step through the code to that point, then make a watch for *this or x or this->x, I get a "Cannot access memory at 0xbaadf00d"

Why is this happening? Where have I messed up? I just don't understand how trying to access *this in a method could possibly result in a segfault.

答:
You need to initialise the elements of Coord::children. They aren't guaranteed to be NULL, so in populateTree(), when you do the null test on each child, you will get non-null children although they will not point to a valid Coord. When they are popped off the queue, and you call getValidMoves() on the invalid Coord you'll get the seg-fault.

Change the Coord constructor to:

```<code>Coord::Coord(int xPos, int yPos) : Loc(xPos, yPos)
{
    std::fill( children, children + MAX_CHILDREN_PER_COORD, NULL );
}
</code>```

(you'll need to #include <algorithm> for std::fill.

Note that the segfault occurs on the attempt to dereference this because that's the first time you try to access the invalid memory.

Title: Segfault when using *this

Body:
I'm getting a segfault when I try to access a member of a class from within a method of that same class, which does not make sense to me at all.

I have the Tree class:

class Tree
{

public:

Coord* root;

Tree(int x, int y)
{
    root = new Coord(x, y);
    populateTree();
}

void populateTree()
{
    queue<Coord*> nodes;
    nodes.push(root);

    while (nodes.size() > 0)
    {
        Coord* currnode = nodes.front();
        nodes.pop();

        if ( !(currnode->getValidMoves()) )
        {
            return;
        }

        else
        {
            for (int i = 0; i < MAX_CHILDREN_PER_COORD; i++)
            {
                if (currnode->children[i] != NULL)
                {
                    nodes.push(currnode->children[i]);
                }
            }
        }
    }
}

...and the Coord class...

class Coord : public Loc
{
    public:

    Coord(int xPos, int yPos);

    Coord* children[MAX_CHILDREN_PER_COORD];

    bool getValidMoves();

    bool operator==(Coord coord);
    bool operator==(Loc loc);

};

Coord::Coord(int xPos, int yPos) : Loc(xPos, yPos) {}

bool Coord::getValidMoves()
{
    //This line segfaults
    Coord test = *this;

    //Global boolean method. Checks found
    if (!foundTrue())
    {
        for (int i = 0; i < MAX_CHILDREN_PER_COORD; i++)
        {
            //If the above segfaulting line is commented out, this is the first place that segfaults
            int newX = x + knightPositions[i].x;
            int newY = y + knightPositions[i].y;

            if ( !(newX > GRID_X || newX < 0 || newY > GRID_Y || newY < 0) )
            {
                //knightPositions is a Loc array of length MAX_CHILDREN_PER_COORD
                children[i] = new Coord(x + knightPositions[i].x, y + knightPositions[i].y);
                //Global 2d array of ints. Gets checked by foundTrue()
                found[x + knightPositions[i].x][y + knightPositions[i].y] = true;
            }
        }

        return true;
    }

    else
    {
        return false;
    }

    //Otherwise, just leave it as a blank array
}

bool Coord::operator==(Coord coord)
{
    return coord.x == x && coord.y == y;
}

bool Coord::operator==(Loc loc)
{
    return loc.x == x && loc.y == y;
}

... and the Loc class, from which Coord inheirits...

class Loc
{
    public:
        int x, y;

        //Constructor
        Loc(int xPos, int yPos) : x(xPos), y(yPos) {}
};

The segfault occurs in Coord::getValidMoves() as indicated by the comments. If step through the code to that point, then make a watch for *this or x or this->x, I get a "Cannot access memory at 0xbaadf00d"

Why is this happening? Where have I messed up? I just don't understand how trying to access *this in a method could possibly result in a segfault.

Body:
You need to initialise the elements of Coord::children. They aren't guaranteed to be NULL, so in populateTree(), when you do the null test on each child, you will get non-null children although they will not point to a valid Coord. When they are popped off the queue, and you call getValidMoves() on the invalid Coord you'll get the seg-fault.

Change the Coord constructor to:

Coord::Coord(int xPos, int yPos) : Loc(xPos, yPos)
{
    std::fill( children, children + MAX_CHILDREN_PER_COORD, NULL );
}

(you'll need to #include <algorithm> for std::fill.

Note that the segfault occurs on the attempt to dereference this because that's the first time you try to access the invalid memory.


问:
Google Maps API - Stops after 11 time ran on single page
I'm running through my posts on wordpress and getting them to show up on google maps but when it gets to number 12 in the list it throws back an error the 12 one in the list is not set up any diffrent to the rest. I have removed what was number 12 and replaced with a new one.

```<code>function initMap() {
    geocoder = new google.maps.Geocoder();
    map = new google.maps.Map(document.getElementById('club-map'), {
        zoom: 14,
        center: { lat: 41.383682, lng: 2.176591 },
        styles: [{elementType:"geometry",stylers:[{color:"#212121"}]},{elementType:"labels.icon",stylers:[{visibility:"off"}]},{elementType:"labels.text.fill",stylers:[{color:"#757575"}]},{elementType:"labels.text.stroke",stylers:[{color:"#212121"}]},{featureType:"administrative",elementType:"geometry",stylers:[{color:"#757575"}]},{featureType:"administrative.country",elementType:"labels.text.fill",stylers:[{color:"#9e9e9e"}]},{featureType:"administrative.land_parcel",stylers:[{visibility:"off"}]},{featureType:"administrative.locality",elementType:"labels.text.fill",stylers:[{color:"#bdbdbd"}]},{featureType:"poi",elementType:"labels.text.fill",stylers:[{color:"#757575"}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#181818"}]},{featureType:"poi.park",elementType:"labels.text.fill",stylers:[{color:"#616161"}]},{featureType:"poi.park",elementType:"labels.text.stroke",stylers:[{color:"#1b1b1b"}]},{featureType:"road",elementType:"geometry.fill",stylers:[{color:"#2c2c2c"}]},{featureType:"road",elementType:"labels.text.fill",stylers:[{color:"#8a8a8a"}]},{featureType:"road.arterial",elementType:"geometry",stylers:[{color:"#373737"}]},{featureType:"road.highway",elementType:"geometry",stylers:[{color:"#3c3c3c"}]},{featureType:"road.highway.controlled_access",elementType:"geometry",stylers:[{color:"#4e4e4e"}]},{featureType:"road.local",elementType:"labels.text.fill",stylers:[{color:"#616161"}]},{featureType:"transit",elementType:"labels.text.fill",stylers:[{color:"#757575"}]},{featureType:"water",elementType:"geometry",stylers:[{color:"#000000"}]},{featureType:"water",elementType:"labels.text.fill",stylers:[{color:"#3d3d3d"}]}]
    });

    var address;
    <?php
        // Add club pins
        $args = array( 'post_type' => 'clubs', 'posts_per_page' => '25','nopaging' => true, 'order' => 'ASC');
        $wp_query = new WP_Query($args);
        while(have_posts()){
            the_post();
    ?>
        address = "<?= get_field('address'); ?>";
            geocoder.geocode( { 'address': address}, function(results, status){
            console.log('result');
            console.log(results);
            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location,
                icon: '<?= get_template_directory_uri(); ?>/dist/images/map-pin.png',
                animation: google.maps.Animation.DROP,
                clubId: <?= get_the_ID(); ?>,
                name: '<?= addslashes(get_the_title()); ?>',
                age: <?= get_field('age_requirement'); ?>,
                logo: '<?= get_field('club_logo'); ?>',
                cost: '<?= number_format(get_field('membership_cost'), 2); ?>',
                rating: <?= get_field('rating'); ?>
            });

            google.maps.event.addListener(marker, 'click', function(){
                clubDetails(marker.clubId,marker.name,marker.age,marker.logo,marker.cost,marker.rating);
            });

            var infowindow =  new google.maps.InfoWindow({
                content: '<?= addslashes(get_the_title()); ?>',
                map: map,
                // position: homeLatlng
            });

            marker.addListener('mouseover', function() {
                infowindow.open(map, this);
            });

            marker.addListener('mouseout', function() {
                infowindow.close();
            })
        });
    <?php } ?>
 }
</code>```

I get this error in my console

```<code>(index):987 Uncaught TypeError: Cannot read property '0' of null
    at (index):987
    at geocoder.js:5
    at FU (geocoder.js:3)
    at Object.HU.geocode (geocoder.js:5)
    at Array.<anonymous> (js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:133)
    at js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:124
    at Object.<anonymous> (js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:62)
    at js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:124
    at js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:62
    at js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:124
</code>```

And this is the line it is pointing too

```<code>position: results[0].geometry.location,
</code>```

EDIT

This is what my console.log(results) looks like it also includes the error https://gyazo.com/b3c91e3feb34ea61068bb1e0102ec554

EDIT V2

I have commented out the //position: results[0].geometry.location, and after the 11 time it runs it its just not giving back a result

答:
I have modified the GeoCoder Method Section, check once by replacing this one with your code, let me know if there,</p>

```<code>geocoder.geocode( { 'address': address}, function(results, status) {

    var markers = results.map(function(location, i) {

        var marker = new google.maps.Marker({
            map: map,
            position: location.geometry.location,
            icon: '<?= get_template_directory_uri(); ?>/dist/images/map-pin.png',
            animation: google.maps.Animation.DROP,
            clubId: <?= get_the_ID(); ?>,
            name: '<?= addslashes(get_the_title()); ?>',
            age: <?= get_field('age_requirement'); ?>,
            logo: '<?= get_field('club_logo'); ?>',
            cost: '<?= number_format(get_field('membership_cost'), 2); ?>',
            rating: <?= get_field('rating'); ?>
        });

        var infowindow = new google.maps.InfoWindow({
            content: '<?= addslashes(get_the_title()); ?>',
        });

        google.maps.event.addListener(infowindow, 'domready', function() {

            var iwOuter = jQuery('.gm-style-iw');

            // Reference to the div that groups the close button elements.
            var iwCloseBtn = iwOuter.next();

            // Apply the desired effect to the close button
            iwCloseBtn.remove()
        });

        marker.addListener('mouseover', function() {
            infowindow.open(map, this);
        });

        marker.addListener('mouseout', function() {
            infowindow.close();
        })

        return marker;
    });
});
</code>```

Body:
I'm running through my posts on wordpress and getting them to show up on google maps but when it gets to number 12 in the list it throws back an error the 12 one in the list is not set up any diffrent to the rest. I have removed what was number 12 and replaced with a new one.

function initMap() {
    geocoder = new google.maps.Geocoder();
    map = new google.maps.Map(document.getElementById('club-map'), {
        zoom: 14,
        center: { lat: 41.383682, lng: 2.176591 },
        styles: [{elementType:"geometry",stylers:[{color:"#212121"}]},{elementType:"labels.icon",stylers:[{visibility:"off"}]},{elementType:"labels.text.fill",stylers:[{color:"#757575"}]},{elementType:"labels.text.stroke",stylers:[{color:"#212121"}]},{featureType:"administrative",elementType:"geometry",stylers:[{color:"#757575"}]},{featureType:"administrative.country",elementType:"labels.text.fill",stylers:[{color:"#9e9e9e"}]},{featureType:"administrative.land_parcel",stylers:[{visibility:"off"}]},{featureType:"administrative.locality",elementType:"labels.text.fill",stylers:[{color:"#bdbdbd"}]},{featureType:"poi",elementType:"labels.text.fill",stylers:[{color:"#757575"}]},{featureType:"poi.park",elementType:"geometry",stylers:[{color:"#181818"}]},{featureType:"poi.park",elementType:"labels.text.fill",stylers:[{color:"#616161"}]},{featureType:"poi.park",elementType:"labels.text.stroke",stylers:[{color:"#1b1b1b"}]},{featureType:"road",elementType:"geometry.fill",stylers:[{color:"#2c2c2c"}]},{featureType:"road",elementType:"labels.text.fill",stylers:[{color:"#8a8a8a"}]},{featureType:"road.arterial",elementType:"geometry",stylers:[{color:"#373737"}]},{featureType:"road.highway",elementType:"geometry",stylers:[{color:"#3c3c3c"}]},{featureType:"road.highway.controlled_access",elementType:"geometry",stylers:[{color:"#4e4e4e"}]},{featureType:"road.local",elementType:"labels.text.fill",stylers:[{color:"#616161"}]},{featureType:"transit",elementType:"labels.text.fill",stylers:[{color:"#757575"}]},{featureType:"water",elementType:"geometry",stylers:[{color:"#000000"}]},{featureType:"water",elementType:"labels.text.fill",stylers:[{color:"#3d3d3d"}]}]
    });

    var address;
    <?php
        // Add club pins
        $args = array( 'post_type' => 'clubs', 'posts_per_page' => '25','nopaging' => true, 'order' => 'ASC');
        $wp_query = new WP_Query($args);
        while(have_posts()){
            the_post();
    ?>
        address = "<?= get_field('address'); ?>";
            geocoder.geocode( { 'address': address}, function(results, status){
            console.log('result');
            console.log(results);
            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location,
                icon: '<?= get_template_directory_uri(); ?>/dist/images/map-pin.png',
                animation: google.maps.Animation.DROP,
                clubId: <?= get_the_ID(); ?>,
                name: '<?= addslashes(get_the_title()); ?>',
                age: <?= get_field('age_requirement'); ?>,
                logo: '<?= get_field('club_logo'); ?>',
                cost: '<?= number_format(get_field('membership_cost'), 2); ?>',
                rating: <?= get_field('rating'); ?>
            });

            google.maps.event.addListener(marker, 'click', function(){
                clubDetails(marker.clubId,marker.name,marker.age,marker.logo,marker.cost,marker.rating);
            });

            var infowindow =  new google.maps.InfoWindow({
                content: '<?= addslashes(get_the_title()); ?>',
                map: map,
                // position: homeLatlng
            });

            marker.addListener('mouseover', function() {
                infowindow.open(map, this);
            });

            marker.addListener('mouseout', function() {
                infowindow.close();
            })
        });
    <?php } ?>
 }

I get this error in my console

(index):987 Uncaught TypeError: Cannot read property '0' of null
    at (index):987
    at geocoder.js:5
    at FU (geocoder.js:3)
    at Object.HU.geocode (geocoder.js:5)
    at Array.<anonymous> (js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:133)
    at js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:124
    at Object.<anonymous> (js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:62)
    at js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:124
    at js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:62
    at js?key=AIzaSyAgDZJic9rlx9ZV9PRynFo76d9gSlAE-UY&callback=initMap:124

And this is the line it is pointing too

position: results[0].geometry.location,

EDIT

This is what my console.log(results) looks like it also includes the error https://gyazo.com/b3c91e3feb34ea61068bb1e0102ec554

EDIT V2

I have commented out the //position: results[0].geometry.location, and after the 11 time it runs it its just not giving back a result

Body:
I have modified the GeoCoder Method Section, check once by replacing this one with your code, let me know if there,

geocoder.geocode( { 'address': address}, function(results, status) {

    var markers = results.map(function(location, i) {

        var marker = new google.maps.Marker({
            map: map,
            position: location.geometry.location,
            icon: '<?= get_template_directory_uri(); ?>/dist/images/map-pin.png',
            animation: google.maps.Animation.DROP,
            clubId: <?= get_the_ID(); ?>,
            name: '<?= addslashes(get_the_title()); ?>',
            age: <?= get_field('age_requirement'); ?>,
            logo: '<?= get_field('club_logo'); ?>',
            cost: '<?= number_format(get_field('membership_cost'), 2); ?>',
            rating: <?= get_field('rating'); ?>
        });

        var infowindow = new google.maps.InfoWindow({
            content: '<?= addslashes(get_the_title()); ?>',
        });

        google.maps.event.addListener(infowindow, 'domready', function() {

            var iwOuter = jQuery('.gm-style-iw');

            // Reference to the div that groups the close button elements.
            var iwCloseBtn = iwOuter.next();

            // Apply the desired effect to the close button
            iwCloseBtn.remove()
        });

        marker.addListener('mouseover', function() {
            infowindow.open(map, this);
        });

        marker.addListener('mouseout', function() {
            infowindow.close();
        })

        return marker;
    });
});


问:
Object reference not set to an instance of an object in _Layout.cshtml after updated packages
The project was running fine until I updated all NuGet packages via
NuGet Manager (I was trying to get the latest OWIN packages).

This error is in the _Layout.cshtml and I have not touched it at all.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Source Error:

```<code>Line 13:
Line 14:     <!-- Custom Fonts -->
Line 15:     @Scripts.Render("~/Content/fonts")
</code>```

Source File: f:\Workplace\lrc\lrc\Views\Shared_Layout.cshtml    Line:
15

Update

Here is the code in the _Layout.cshtml (they are automatically generated when creating the project):

<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="LRC - We are aiming at building up a healthier life style.">
    <meta name="author" content="Winston Fan">
    <title>@ViewBag.Title - LRC</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

    @Scripts.Render("~/Content/fonts")

    <link href="http://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
```
<p>So it is complaining this line of code:</p>
```@Scripts.Render("~/Content/fonts")
```
<p>But as you can see that, this is VS generated code, how could I make it wrong?</p>
<p>I also checked the content in the <code>Conntent/font-awesome/fonts</code> folder and all required resources are there.</p>
<p>Here is the code inside the <code>BundleConfig</code> (which is also the auto-generated code):</p>
<pre class="lang-csharp prettyprint-override"><code>bundles.Add(new ScriptBundle("~/Content/fonts").Include(
              "~/Content/font-awesome/fonts/fontawesome-*",
              "~/Content/font-awesome/fonts/FontAwesome.otf"));
</code>```

My Microsoft.OWin.Security, Microsoft.OWin.Security.Google and Microsoft.OWin are version 3.0.1.0.

Update 2

Here is the stack trace:

```<code>[NullReferenceException: Object reference not set to an instance of an
object.]    Microsoft.Ajax.Utilities.JSParser.ParseExpression(AstNode
leftHandSide, Boolean single, Boolean bCanAssign, JSToken inToken)
+1007    Microsoft.Ajax.Utilities.JSParser.ParseExpressionStatement(Boolean
fSourceElement) +268
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean
fSourceElement, Boolean skipImportantComment) +1552
Microsoft.Ajax.Utilities.JSParser.ParseBlock() +164
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean
fSourceElement, Boolean skipImportantComment) +498
Microsoft.Ajax.Utilities.JSParser.ParseBlock() +164
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean
fSourceElement, Boolean skipImportantComment) +498
Microsoft.Ajax.Utilities.JSParser.ParseBlock() +164
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean
fSourceElement, Boolean skipImportantComment) +498
Microsoft.Ajax.Utilities.JSParser.ParseStatements(Block block) +159
Microsoft.Ajax.Utilities.JSParser.InternalParse() +1011
Microsoft.Ajax.Utilities.JSParser.Parse(DocumentContext sourceContext)
+123    Microsoft.Ajax.Utilities.JSParser.Parse(DocumentContext sourceContext, CodeSettings settings) +54
Microsoft.Ajax.Utilities.Minifier.MinifyJavaScript(String source,
CodeSettings codeSettings) +987
System.Web.Optimization.JsMinify.Process(BundleContext context,
BundleResponse response) +310
System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context,
String bundleContent, IEnumerable`1 bundleFiles) +263
System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext
context) +355
System.Web.Optimization.Bundle.GetBundleResponse(BundleContext
context) +104
System.Web.Optimization.BundleResolver.GetBundleContents(String
virtualPath) +254
System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1
assets) +252
System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat,
String[] paths) +75
System.Web.Optimization.Scripts.RenderFormat(String tagFormat,
String[] paths) +292
System.Web.Optimization.Scripts.Render(String[] paths) +51
ASP._Page_Views_Shared__Layout_cshtml.Execute() in
f:\Workplace\lrc\lrc\Views\Shared\_Layout.cshtml:15
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +271
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +121
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
pageContext, TextWriter writer, WebPageRenderingBase startPage) +145
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
pageContext, TextWriter writer) +41
System.Web.WebPages.<>c__DisplayClass3.<RenderPageCore>b__2(TextWriter
writer) +335    System.Web.WebPages.HelperResult.WriteTo(TextWriter
writer) +42
System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer,
HelperResult content) +45
System.Web.WebPages.WebPageBase.Write(HelperResult result) +53
System.Web.WebPages.WebPageBase.RenderSurrounding(String
partialViewName, Action`1 body) +178
System.Web.WebPages.WebPageBase.PopContext() +229
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
pageContext, TextWriter writer, WebPageRenderingBase startPage) +154
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext,
TextWriter writer, Object instance) +695
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext
viewContext, TextWriter writer) +382
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
+431    System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
controllerContext, ActionResult actionResult) +39
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1
filters, Int32 filterIndex, ResultExecutingContext preContext,
ControllerContext controllerContext, ActionResult actionResult) +116
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1
filters, Int32 filterIndex, ResultExecutingContext preContext,
ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
controllerContext, IList`1 filters, ActionResult actionResult) +106
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
+321    System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult
asyncResult) +185
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult
asyncResult) +42
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +56
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult
asyncResult) +40
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult
asyncResult, ExecuteCoreState innerState) +34
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult
asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +40
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult
asyncResult, Controller controller) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult
asyncResult) +62
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +40    System.Web.Mvc.Controller.EndExecute(IAsyncResult
asyncResult) +39
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
asyncResult) +39
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult
asyncResult, ProcessRequestState innerState) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult
asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
+40    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+932    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +188
</code>```

Update 3

Here is the Content folder:

Update 4

Here is the content of the packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Antlr" version="3.5.0.2" targetFramework="net451" />
  <package id="bootstrap" version="3.3.4" targetFramework="net451" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="jQuery" version="2.1.3" targetFramework="net451" />
  <package id="jQuery.Validation" version="1.13.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.Owin" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Facebook" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Twitter" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
  <package id="Modernizr" version="2.8.3" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
  <package id="Owin" version="1.0" targetFramework="net451" />
  <package id="Respond" version="1.4.2" targetFramework="net451" />
  <package id="WebGrease" version="1.6.0" targetFramework="net451" />
</packages>
```

答:
In my case, it's due to changes in verdor libs so I can't fix the js file directly.

My work around is to use the min version which is indicate to the bundle: DO not minify this file.

For example: Simply move from select2.js to select2.min.js

Body:
The project was running fine until I updated all NuGet packages via
NuGet Manager (I was trying to get the latest OWIN packages).

This error is in the _Layout.cshtml and I have not touched it at all.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Source Error:

Line 13:
Line 14:
Line 15:     @Scripts.Render("~/Content/fonts")

Source File: f:\Workplace\lrc\lrc\Views\Shared_Layout.cshtml    Line:
15

Update

Here is the code in the _Layout.cshtml (they are automatically generated when creating the project):

<!DOCTYPE html>

    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="LRC - We are aiming at building up a healthier life style.">
    <meta name="author" content="Winston Fan">
    <title>@ViewBag.Title - LRC</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

    @Scripts.Render("~/Content/fonts")

    <link href="http://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet" type="text/css">
    <link href="http://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">

So it is complaining this line of code:

@Scripts.Render("~/Content/fonts")

But as you can see that, this is VS generated code, how could I make it wrong?

I also checked the content in the Conntent/font-awesome/fonts folder and all required resources are there.

Here is the code inside the BundleConfig (which is also the auto-generated code):

bundles.Add(new ScriptBundle("~/Content/fonts").Include(
              "~/Content/font-awesome/fonts/fontawesome-*",
              "~/Content/font-awesome/fonts/FontAwesome.otf"));

My Microsoft.OWin.Security, Microsoft.OWin.Security.Google and Microsoft.OWin are version 3.0.1.0.

Update 2

Here is the stack trace:

[NullReferenceException: Object reference not set to an instance of an
object.]    Microsoft.Ajax.Utilities.JSParser.ParseExpression(AstNode
leftHandSide, Boolean single, Boolean bCanAssign, JSToken inToken)
+1007    Microsoft.Ajax.Utilities.JSParser.ParseExpressionStatement(Boolean
fSourceElement) +268
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean
fSourceElement, Boolean skipImportantComment) +1552
Microsoft.Ajax.Utilities.JSParser.ParseBlock() +164
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean
fSourceElement, Boolean skipImportantComment) +498
Microsoft.Ajax.Utilities.JSParser.ParseBlock() +164
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean
fSourceElement, Boolean skipImportantComment) +498
Microsoft.Ajax.Utilities.JSParser.ParseBlock() +164
Microsoft.Ajax.Utilities.JSParser.ParseStatement(Boolean
fSourceElement, Boolean skipImportantComment) +498
Microsoft.Ajax.Utilities.JSParser.ParseStatements(Block block) +159
Microsoft.Ajax.Utilities.JSParser.InternalParse() +1011
Microsoft.Ajax.Utilities.JSParser.Parse(DocumentContext sourceContext)
+123    Microsoft.Ajax.Utilities.JSParser.Parse(DocumentContext sourceContext, CodeSettings settings) +54
Microsoft.Ajax.Utilities.Minifier.MinifyJavaScript(String source,
CodeSettings codeSettings) +987
System.Web.Optimization.JsMinify.Process(BundleContext context,
BundleResponse response) +310
System.Web.Optimization.Bundle.ApplyTransforms(BundleContext context,
String bundleContent, IEnumerable`1 bundleFiles) +263
System.Web.Optimization.Bundle.GenerateBundleResponse(BundleContext
context) +355
System.Web.Optimization.Bundle.GetBundleResponse(BundleContext
context) +104
System.Web.Optimization.BundleResolver.GetBundleContents(String
virtualPath) +254
System.Web.Optimization.AssetManager.DeterminePathsToRender(IEnumerable`1
assets) +252
System.Web.Optimization.AssetManager.RenderExplicit(String tagFormat,
String[] paths) +75
System.Web.Optimization.Scripts.RenderFormat(String tagFormat,
String[] paths) +292
System.Web.Optimization.Scripts.Render(String[] paths) +51
ASP._Page_Views_Shared__Layout_cshtml.Execute() in
f:\Workplace\lrc\lrc\Views\Shared\_Layout.cshtml:15
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +271
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +121
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
pageContext, TextWriter writer, WebPageRenderingBase startPage) +145
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
pageContext, TextWriter writer) +41
System.Web.WebPages.<>c__DisplayClass3.<RenderPageCore>b__2(TextWriter
writer) +335    System.Web.WebPages.HelperResult.WriteTo(TextWriter
writer) +42
System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer,
HelperResult content) +45
System.Web.WebPages.WebPageBase.Write(HelperResult result) +53
System.Web.WebPages.WebPageBase.RenderSurrounding(String
partialViewName, Action`1 body) +178
System.Web.WebPages.WebPageBase.PopContext() +229
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
pageContext, TextWriter writer, WebPageRenderingBase startPage) +154
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext,
TextWriter writer, Object instance) +695
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext
viewContext, TextWriter writer) +382
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
+431    System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
controllerContext, ActionResult actionResult) +39
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1
filters, Int32 filterIndex, ResultExecutingContext preContext,
ControllerContext controllerContext, ActionResult actionResult) +116
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1
filters, Int32 filterIndex, ResultExecutingContext preContext,
ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
controllerContext, IList`1 filters, ActionResult actionResult) +106
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
+321    System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult
asyncResult) +185
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult
asyncResult) +42
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +56
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult
asyncResult) +40
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult
asyncResult, ExecuteCoreState innerState) +34
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult
asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +40
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult
asyncResult, Controller controller) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult
asyncResult) +62
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +40    System.Web.Mvc.Controller.EndExecute(IAsyncResult
asyncResult) +39
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
asyncResult) +39
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult
asyncResult, ProcessRequestState innerState) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult
asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,
Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
+40    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult
result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+932    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +188

Update 3

Here is the Content folder:

Update 4

Here is the content of the packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Antlr" version="3.5.0.2" targetFramework="net451" />
  <package id="bootstrap" version="3.3.4" targetFramework="net451" />
  <package id="EntityFramework" version="6.1.3" targetFramework="net451" />
  <package id="jQuery" version="2.1.3" targetFramework="net451" />
  <package id="jQuery.Validation" version="1.13.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net451" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net451" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net451" />
  <package id="Microsoft.Owin" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Facebook" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Owin.Security.Twitter" version="3.0.1" targetFramework="net451" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
  <package id="Modernizr" version="2.8.3" targetFramework="net451" />
  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" />
  <package id="Owin" version="1.0" targetFramework="net451" />
  <package id="Respond" version="1.4.2" targetFramework="net451" />
  <package id="WebGrease" version="1.6.0" targetFramework="net451" />
</packages>


问:
Python MySQLQuery result returns extra characters
I'm making a mysql request with python, when I'm printing the result it gives me the results but it adds some characters extra for me xD

What I need is:

Asia TAG

Australia TAG

...

What I get is:

('Asia TAG',)

('Australia TAG',)

...

Those ('...',) how does this get in my results?

```<code>current = con_mysql.cursor()
current_query = "SELECT name FROM event_categories WHERE visible=1"
current.execute(current_query)

for name in current:
    print(name)
</code>```

答:
Another approach would be using pythons built in format function to get a better output </p>

```<code>current = con_mysql.cursor()
current_query = "SELECT name FROM event_categories WHERE visible=1"
current.execute(current_query)

for name in current:
    print("{}".format(name[0])
</code>```

Body:
I'm making a mysql request with python, when I'm printing the result it gives me the results but it adds some characters extra for me xD

What I need is:

Asia TAG

Australia TAG

...

What I get is:

('Asia TAG',)

('Australia TAG',)

...

Those ('...',) how does this get in my results?

current = con_mysql.cursor()
current_query = "SELECT name FROM event_categories WHERE visible=1"
current.execute(current_query)

for name in current:
    print(name)

Body:
Another approach would be using pythons built in format function to get a better output

current = con_mysql.cursor()
current_query = "SELECT name FROM event_categories WHERE visible=1"
current.execute(current_query)

for name in current:
    print("{}".format(name[0])


问:
Font rendering issue on iOS mobile devices
I have one problem what find only on iOS and don't know to solve.

On image above you can see checkmark list where is complete font bad rendered and pixelate. I don't know why and how to solve this. I try various things from transform and text-rendering options to shaddow tricks.

I realy need help on this. Thanks!

答:
I think -webkit-font-smoothing is the culprit here; -webkit-font-smoothing:none looks pretty bad on my iPhone 6s.

Christoph Zillgens has a really good test page for -webkit-font-smoothing which shows this clearly.


问:
How to move an object along a spline or sine function in Flex 3
I am trying to create a similar effect to what is used in CityVille for dropping coins and experience icons, they do a custom move animation and it first moves a little bit up and then down. It looks like it is following a spline or a sine function.

The Move effect in flex 3 only moves linearly.

Any help?

答:
Use a tweening library such as Actuate http://code.google.com/p/actuate/
It lets you animate an object along a bezier curve or custom motion path like this:

```<code>var xPath:MotionPath = MotionPath.bezier (200, 20).line (400);
var yPath:MotionPath = MotionPath.bezier (0, 300).line (0);

Actuate.motionPath (MySprite, 1, { x: xPath, y: yPath } );
</code>```

A very similar library is eaze
http://code.google.com/p/eaze-tween/
and it's mxml friendly wrapper:
http://code.google.com/p/eazefx/

Body:
Use a tweening library such as Actuate http://code.google.com/p/actuate/
It lets you animate an object along a bezier curve or custom motion path like this:

var xPath:MotionPath = MotionPath.bezier (200, 20).line (400);
var yPath:MotionPath = MotionPath.bezier (0, 300).line (0);

Actuate.motionPath (MySprite, 1, { x: xPath, y: yPath } );

A very similar library is eaze
http://code.google.com/p/eaze-tween/
and it's mxml friendly wrapper:
http://code.google.com/p/eazefx/


问:
Optimize sql Query which take too long to execute
The following sql query is taking to much to return a result

```<code>SELECT count(*)
FROM List_declarations
WHERE  Id_antenne IN (
   SELECT id
   FROM Service
   WHERE id_direction IN (
      SELECT id_dr
      FROM affectation_service_dr
      WHERE id_service = 15
   )
)
</code>```

How I can do better  ?

答:
I would think of changing the IN's to JOIN's:

```<code>select count(*)
from list_declarations d join service s on d.id_antenne = s.id
                         join affectation_service_dr sdr on sdr.id_dr = s.id_direction
where sdr.id_service = 15
</code>```

Then I would again check performance and see if there are any indexes on the columns used in the where clause and on the foreign keys.

Body:
The following sql query is taking to much to return a result

SELECT count(*)
FROM List_declarations
WHERE  Id_antenne IN (
   SELECT id
   FROM Service
   WHERE id_direction IN (
      SELECT id_dr
      FROM affectation_service_dr
      WHERE id_service = 15
   )
)

How I can do better  ?

Body:
I would think of changing the IN's to JOIN's:

select count(*)
from list_declarations d join service s on d.id_antenne = s.id
                         join affectation_service_dr sdr on sdr.id_dr = s.id_direction
where sdr.id_service = 15

Then I would again check performance and see if there are any indexes on the columns used in the where clause and on the foreign keys.


答:
The error you are receiving is because you are trying to access to a static member from a instance object

```<code>public void GetClickHistory()
{
   App.counts.CardClicks2m = db2.Query<CntQty>(sql);
</code>```

EDITED after comments:
Try this (accessing the static member from the class):

```<code>public void GetClickHistory()
{
   Counts.CardClicks2m = db2.Query<CntQty>(sql);
</code>```

As CardClicks2m is declared static, it must be accessed from the class scope. If Counts class doen't have any other code, you can declare

```<code>public static class Counts
</code>```

And there is not neccesary to create an instance of counts

```<code>public static Counts counts = new Counts(); //this is not neccesary
</code>```

Title: How can I access a list that is created in a static object that is part of another class?

Body:
What I would like to do is to have a list that is in an object counts that is defined in the App class as a static when my application starts:

Here's the object:

public class Counts
{
    public Counts()
    {
       public static List<CntQty> CardClicks2m;
    }
}

In my application I declare this

am using the following code:

public partial class App : Application
{
    public static Counts counts = new Counts();

    public App()
    {
    }
}

Now I try to use load some data into the list but it gives me the error below. Note that this function is in another class.

public void GetClickHistory()
{
   App.counts.CardClicks2m = db2.Query<CntQty>(sql);

The last line of the code is giving me an error saying

counts.CardClicks2m cannot be accessed with an instance reference;
  qualify it with a type name instead.

I have tried a few different ways to make this work. One by removing the static and creating the object in the app constructor. This also didn't seem to work so I am hoping someone can point me in the right direction or at least suggest something.

Body:
The error you are receiving is because you are trying to access to a static member from a instance object

public void GetClickHistory()
{
   App.counts.CardClicks2m = db2.Query<CntQty>(sql);

EDITED after comments:
Try this (accessing the static member from the class):

public void GetClickHistory()
{
   Counts.CardClicks2m = db2.Query<CntQty>(sql);

As CardClicks2m is declared static, it must be accessed from the class scope. If Counts class doen't have any other code, you can declare

public static class Counts

And there is not neccesary to create an instance of counts

public static Counts counts = new Counts(); //this is not neccesary


问:
How to open Apple Map App on iOS App inside HTML
Now, I embed an HTML via WKWebView. If a user clicks the a element, I want to open the Apple Map APP. It seems nothing to happen, only the background color changed.
My code:

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        a {
            display: block;
            font-size: 20px;
            width: 200px;
            height: 100px;
            margin: 100px auto;
            text-align: center;
        }
    </style>
</head>
<body>

<h1>open the  apple map</h1>

<a href="maps:ll=38.897096,-77.036545" class="context-block-button map-button" id="map-button-1"><i class="ss-map icon-left"></i><span>Open in map (maps:)</span></a>

</body>
<script src="../js/jquery.min.js"></script>
<script>
    $('body').on('click','a',function () {
            $('body').css('background-color','blue');
      window.location.href = " http://maps.apple.com/?q=Mexican+Restaurant&sll=50.894967,4.341626&z=10&t=s";
    })
</script>
</html>
</code>```

In the safari, I copy " http://maps.apple.com/?q=Mexican+Restaurant&sll=50.894967,4.341626&z=10&t=s".Then the safari will open the Apple App on Mac.

Must I use the Swift4 API to open the Apple Map App?
One more thing, if the solution must change the info.plist or change the App target setting, thank you for writing this for me.

答:
Yes, you need to use Swift API and need to implement WKNavigationDelegate, add decidePolicyForNavigationAction method.

Check this answer from another thread.

Body:
Now, I embed an HTML via WKWebView. If a user clicks the a element, I want to open the Apple Map APP. It seems nothing to happen, only the background color changed.
My code:

<!DOCTYPE html>

    <meta charset="UTF-8">
    <title>Title</title>

open the  apple map

Open in map (maps:)

In the safari, I copy " http://maps.apple.com/?q=Mexican+Restaurant&sll=50.894967,4.341626&z=10&t=s".Then the safari will open the Apple App on Mac.

Must I use the Swift4 API to open the Apple Map App?
One more thing, if the solution must change the info.plist or change the App target setting, thank you for writing this for me.


问:
Calling mono c# code from Microsoft .net?
I have some neural net code written in c# that would benefit from using SIMD support. Mono 2.2 just came out that supports SIMD but Microsoft's c# does not support this yet.  Being happy with my c# setup I was wondering if I could write a lib in mono for that piece and call it from .net.

Edit:
I guess what I really want to know is it possible to compile mono down to something like a DLL that I then can call from dotnet. I heard Miguel de Icaza on a podcast saying that for the iphone the mono compiler would allow them to compile down to an exe for moonlight so it did not violate the terms of service for iphone so it got me thinking what else can you compile to.

I heard Miguel de Icaza on another pod cast Herding Code Episode 28 say that you could use the mono complier to compile to an exe not just to intermediate code. What are the implications of this?

This got my curiosity up so I thought that I would throw a bounty at it.

答:
From Miguel de Icaza's blog:

Our library provides C# fallbacks for
  all of the accelerated instructions.
  This means that if your code runs on a
  machine that does not provide any SIMD
  support, or one of the operations that
  you are using is not supported in your
  machine, the code will continue to
  work correctly.

This also means that you can use the
  Mono.Simd API with Microsoft's .NET on
  Windows to prototype and develop your
  code, and then run it at full speed
  using Mono.

As I understand it, this means that you can write code that uses Mono.Simd, and will be able to run it under .Net, but it won't be any faster than regular code, because the .Net runtime doesn't support SIMD yet.

OwnerDisplayName: Rex Logan

LastEditorDisplayName: Rex Logan

OwnerDisplayName: oefe