问:
address an object by retrieving the ID name of the object from a variable
Good evening,

I am trying to get the following done. I have seen a similar post but it was related with Unity.

Anyway, I am on web forms in asp.net and I have a radiobuttonList with ID="id001"

so on my code behind, I would normally be able to get the selected value by just doing:

```<code>string value = id001.SelectedValue
</code>```

However, in this situation, I don't know the exact ID name, so I have a function that retrieves it. So now I have the variable with the name of the ID. So I want to be able to now, convert the value of that variable in something like this:

```<code>string foundid = "id001"

string foundidvalue = id001.SelectedValue
</code>```

I hope this makes sense.

Thanks in advance for the help.

答:
You want to use FindControl.</p>

```<code>string foundid = "id001";
var foundCtrl = (RadiobuttonList)FindControl(foundid);
var result = foundCtrl.SelectedValue;
</code>```

Body:
Good evening,

I am trying to get the following done. I have seen a similar post but it was related with Unity.

Anyway, I am on web forms in asp.net and I have a radiobuttonList with ID="id001"

so on my code behind, I would normally be able to get the selected value by just doing:

string value = id001.SelectedValue

However, in this situation, I don't know the exact ID name, so I have a function that retrieves it. So now I have the variable with the name of the ID. So I want to be able to now, convert the value of that variable in something like this:

string foundid = "id001"

string foundidvalue = id001.SelectedValue

I hope this makes sense.

Thanks in advance for the help.

Body:
You want to use FindControl.

string foundid = "id001";
var foundCtrl = (RadiobuttonList)FindControl(foundid);
var result = foundCtrl.SelectedValue;


来源: stackexchange

问:
Spark SQL Table not found after registerTempTable
I am trying to run sql query after adding my dataframe to a temporary table but everytime it displays table not found.

emp is the name of the dataframe.

COMMANDS:

```<code>scala> val sqlContext = new org.apache.spark.sql.SQLContext(sc)
sqlContext: org.apache.spark.sql.SQLContext = org.apache.spark.sql.SQLContext@6cb7a4c1

scala> import sqlContext.implicits._
import sqlContext.implicits._

scala> emp.registerTempTable("people")

scala> val teenagers = sqlContext.sql("SELECT name FROM people WHERE id >= 100 AND id <= 105")

java.lang.RuntimeException: Table Not Found: people
    at scala.sys.package$.error(package.scala:27)
    at org.apache.spark.sql.catalyst.analysis.SimpleCatalog$$anonfun$1.apply(Catalog.scala:111)
    at org.apache.spark.sql.catalyst.analysis.SimpleCatalog$$anonfun$1.apply(Catalog.scala:111)
    at scala.collection.MapLike$class.getOrElse(MapLike.scala:128)
    at scala.collection.AbstractMap.getOrElse(Map.scala:58)
    at org.apache.spark.sql.catalyst.analysis.SimpleCatalog.lookupRelation(Catalog.scala:111)
</code>```

答: I got it solved guys. Apparently I was directly using a DF created from RDD. If I create a duplicate of the DF(derived from RDD), registerTempTable will work. THanks for the help.</p>

ContentLicense: CC BY-SA 3.0

Body:
I am trying to run sql query after adding my dataframe to a temporary table but everytime it displays table not found.

emp is the name of the dataframe.

COMMANDS:

scala> val sqlContext = new org.apache.spark.sql.SQLContext(sc)
sqlContext: org.apache.spark.sql.SQLContext = org.apache.spark.sql.SQLContext@6cb7a4c1

scala> import sqlContext.implicits._
import sqlContext.implicits._

scala> emp.registerTempTable("people")

scala> val teenagers = sqlContext.sql("SELECT name FROM people WHERE id >= 100 AND id <= 105")

java.lang.RuntimeException: Table Not Found: people
    at scala.sys.package$.error(package.scala:27)
    at org.apache.spark.sql.catalyst.analysis.SimpleCatalog$$anonfun$1.apply(Catalog.scala:111)
    at org.apache.spark.sql.catalyst.analysis.SimpleCatalog$$anonfun$1.apply(Catalog.scala:111)
    at scala.collection.MapLike$class.getOrElse(MapLike.scala:128)
    at scala.collection.AbstractMap.getOrElse(Map.scala:58)
    at org.apache.spark.sql.catalyst.analysis.SimpleCatalog.lookupRelation(Catalog.scala:111)


问:
How to generate entity from existing table in symfony2?
I have table "my_table" with some fields.
I want generate Entity in MyBundle used "my_table". But I don't want recreate all entities in MyBundle.
How can I do this?</p>

答:
Although this is an old post but if someone gets following error,

Database does not have any mapping information.

Check

If your table name is blog_post then in filter option use BlogPost and not blog_post

Reference: https://stackoverflow.com/a/27019561/6504104

though this is covered by answers above but I missed it and was getting this error

So I wanted to make this explicit

Also in symfony >= 3.4 its' php bin/console e.g.

```<code>php bin/console doctrine:mapping:import --force AppBundle xml --filter="BlogPost"
</code>```

and then

```<code>php bin/console doctrine:mapping:convert annotation ./src/AppBundle/Entity --from-database --filter="BlogPost"
</code>```

Thanks...

Body:
Although this is an old post but if someone gets following error,

Database does not have any mapping information.

Check

If your table name is blog_post then in filter option use BlogPost and not blog_post

Reference: https://stackoverflow.com/a/27019561/6504104

though this is covered by answers above but I missed it and was getting this error

So I wanted to make this explicit

Also in symfony >= 3.4 its' php bin/console e.g.

php bin/console doctrine:mapping:import --force AppBundle xml --filter="BlogPost"

and then

php bin/console doctrine:mapping:convert annotation ./src/AppBundle/Entity --from-database --filter="BlogPost"

Thanks...

ContentLicense: CC BY-SA 4.0


问:
Unable to limit
I have the following query:

```<code>UPDATE pc
INNER JOIN cams
   ON cams.cam_id = pc.camuid
SET
    timestamp = NOW(),
    uid = @out_param:=uid
WHERE zone = 1
  AND (unable = '0' OR unable IS NULL)
  AND (corrected_plate = ''  OR corrected_plate IS NULL)
  AND (timestamp IS NULL OR timestamp < (NOW() - INTERVAL @interval MINUTE))
LIMIT 1;
SELECT @out_param;
</code>```

I am unable to run that query as I have a LIMITclause in a join query.  I cannot figure out how to spread it out into a subquery while maintaining performance.  I need this query to be as fast as possible, and the optimiser of MySQL has not provided much help so far.

This is the error obtained from MySQL, as the above is not allowed: Incorrect usage of UPDATE and LIMIT

答:
Just use a subquery to decide which uid update.</p>

```<code>UPDATE PC
SET timestamp = NOW(),
   uid = @out_param:=uid
WHERE uid = (SELECT uid
             FROM ( SELECT * FROM pc ) as pc2
             INNER JOIN cams
                ON cams.cam_id = pc2.camuid
             WHERE zone = 1
               AND (unable = '0' OR unable IS NULL)
               AND (corrected_plate = ''  OR corrected_plate IS NULL)
               AND (timestamp IS NULL OR timestamp < (NOW() - INTERVAL @interval MINUTE))
             ORDER BY uid -- optional
             LIMIT 1)
</code>```

Title: Unable to limit

Body:
I have the following query:

UPDATE pc
INNER JOIN cams
   ON cams.cam_id = pc.camuid
SET
    timestamp = NOW(),
    uid = @out_param:=uid
WHERE zone = 1
  AND (unable = '0' OR unable IS NULL)
  AND (corrected_plate = ''  OR corrected_plate IS NULL)
  AND (timestamp IS NULL OR timestamp < (NOW() - INTERVAL @interval MINUTE))
LIMIT 1;
SELECT @out_param;

I am unable to run that query as I have a LIMITclause in a join query.  I cannot figure out how to spread it out into a subquery while maintaining performance.  I need this query to be as fast as possible, and the optimiser of MySQL has not provided much help so far.

This is the error obtained from MySQL, as the above is not allowed: Incorrect usage of UPDATE and LIMIT

Body:
Just use a subquery to decide which uid update.

UPDATE PC
SET timestamp = NOW(),
   uid = @out_param:=uid
WHERE uid = (SELECT uid
             FROM ( SELECT * FROM pc ) as pc2
             INNER JOIN cams
                ON cams.cam_id = pc2.camuid
             WHERE zone = 1
               AND (unable = '0' OR unable IS NULL)
               AND (corrected_plate = ''  OR corrected_plate IS NULL)
               AND (timestamp IS NULL OR timestamp < (NOW() - INTERVAL @interval MINUTE))
             ORDER BY uid -- optional
             LIMIT 1)


问:
iPad receiving memory warning with low memory use
I have an UIWebKit with a HTML, this HTML have several images and text, but just displaying it gives me the memory warning. So I did some tests:
The same HTML with different images, fullsize, and after the same images but reduced 50% from it's original size, for the 50% reduced images, I went to preview and reduced all images in 50%

The surprising part is the 50% test, you can see that even with 16 images, the memory peak is 4.90MB. That's really surprising.
Notice that these values are not always the same, they change but there's not a huge difference between the tests.

In the 50% issue, in the 8 and 16 images, although the memory is low, sometimes a memory warning appears, but the performance enhance is noticeable compared to the full size images

standing still = memory after scrolling all article

1 Image = [standing still 5MB] [rotating 5.6MB]

2 Images = [standing still 6.99MB] [rotating 7.7MB]

3 Images = [standing still 9.04MB] [rotating 10.9MB]

4 Images = [standing still 10.89MB] [rotating 13.20MB]

8 Images = [standing still 23.14MB] [rotating 25.20MB]  (sometimes crashes)

16 Images = [standing still 27.14MB and app crashes]

50%

1 Image = [standing still 3.2MB] [rotating 3.67MB]

2 Image = [standing still 3.2MB] [rotating 3.70MB]

3 Image = [standing still 3.3MB] [rotating 3.79MB]

4 Image = [standing still 3.3MB] [rotating 3.80MB]

8 Images = [standing still 4.29MB] [rotating 4,63MB]  (sometimes crashes)

16 Images = [standing still 4.79MB] [rotating 4,90MB]  (sometimes crashes)

My question is: The app sometimes crashed with 16 small images. Why? The memory was much lower.

What is the limit of memory use?The maximum seemed different with the 50% size images. 13.2MB works for large images and 3.8 for small images. Anything higher sometimes crashes. That makes no sense.

Thanks

答:
It would help if you posted a crash log of what's going on, because it's very likely the crash isn't related as much to your memory consumption as it is to how you're handling that memory. Yes your image size may be exaccerbating the problem, since the amount of real memory used per image is sized according to this formula:

```<code>w * h * 4
</code>```

assuming of course, that the image is a 32-bit colour image, where w is the width of the image in pixels, and h is the height of the image in pixels. As a result, a 1024x1024 32-bit colour image will use approximately 4.2 MB of memory, whereas a 512x512 32-bit colour image will use 1 meg.

Your crash report will be telling. Also running in Instruments under the object allocations and leaks tool may be of tremendous insight (run with the side pane visible, it will show the call stack for any leaks you find). Also note, if you do find leaks that point at things like CIOImage or the like, that may be where the leak eventually occurs, but where the leak is happening will almost positively be in your code.

Also, when running Instruments, remember to run it attached to the app that is running on your device; don't take anything the sim says at face value in cases like this.

ContentLicense: CC BY-SA 2.5

Body:
It would help if you posted a crash log of what's going on, because it's very likely the crash isn't related as much to your memory consumption as it is to how you're handling that memory. Yes your image size may be exaccerbating the problem, since the amount of real memory used per image is sized according to this formula:

w * h * 4

assuming of course, that the image is a 32-bit colour image, where w is the width of the image in pixels, and h is the height of the image in pixels. As a result, a 1024x1024 32-bit colour image will use approximately 4.2 MB of memory, whereas a 512x512 32-bit colour image will use 1 meg.

Your crash report will be telling. Also running in Instruments under the object allocations and leaks tool may be of tremendous insight (run with the side pane visible, it will show the call stack for any leaks you find). Also note, if you do find leaks that point at things like CIOImage or the like, that may be where the leak eventually occurs, but where the leak is happening will almost positively be in your code.

Also, when running Instruments, remember to run it attached to the app that is running on your device; don't take anything the sim says at face value in cases like this.


问:
Take the mean of values in a list if a duplicate is found
I have 2 lists which are associated with each other. E.g., here, 'John' is associated with '1', 'Bob' is associated with 4, and so on:

```<code>l1 = ['John', 'Bob', 'Stew', 'John']
l2 = [1, 4, 7, 3]
</code>```

My problem is with the duplicate John. Instead of adding the duplicate John, I want to take the mean of the values associated with the Johns, i.e., 1 and 3, which is (3 + 1)/2 = 2. Therefore, I would like the lists to actually be:

```<code>l1 = ['John', 'Bob', 'Stew']
l2 = [2, 4, 7]
</code>```

I have experimented with some solutions including for-loops and the "contains" function, but can't seem to piece it together. I'm not very experienced with Python, but linked lists sound like they could be used for this.

Thank you

答:
The following might give you an idea. It uses an OrderedDict assuming that you want the items in the order of appearance from the original list:

```<code>from collections import OrderedDict

d = OrderedDict()
for x, y in zip(l1, l2):
    d.setdefault(x, []).get(x).append(y)
# OrderedDict([('John', [1, 3]), ('Bob', [4]), ('Stew', [7])])

names, values = zip(*((k, sum(v)/len(v)) for k, v in d.items()))
# ('John', 'Bob', 'Stew')
# (2.0, 4.0, 7.0)
</code>```

Body:
I have 2 lists which are associated with each other. E.g., here, 'John' is associated with '1', 'Bob' is associated with 4, and so on:

l1 = ['John', 'Bob', 'Stew', 'John']
l2 = [1, 4, 7, 3]

My problem is with the duplicate John. Instead of adding the duplicate John, I want to take the mean of the values associated with the Johns, i.e., 1 and 3, which is (3 + 1)/2 = 2. Therefore, I would like the lists to actually be:

l1 = ['John', 'Bob', 'Stew']
l2 = [2, 4, 7]

I have experimented with some solutions including for-loops and the "contains" function, but can't seem to piece it together. I'm not very experienced with Python, but linked lists sound like they could be used for this.

Thank you

Body:
The following might give you an idea. It uses an OrderedDict assuming that you want the items in the order of appearance from the original list:

from collections import OrderedDict

d = OrderedDict()
for x, y in zip(l1, l2):
    d.setdefault(x, []).get(x).append(y)
# OrderedDict([('John', [1, 3]), ('Bob', [4]), ('Stew', [7])])

names, values = zip(*((k, sum(v)/len(v)) for k, v in d.items()))
# ('John', 'Bob', 'Stew')
# (2.0, 4.0, 7.0)


问:
C string functions error
I'm working on an assignment, but I'm having trouble with my code :

```<code>int is_ascii_match(const char c1[], const char c2[], char res[MAX_STRING_SIZE]) {
....

    if (val_c1 == val_c2) {
        strcpy(res, strcat(strcat(c1, '&'),c2));
    }
    else
        return 0;
</code>```

I'm getting an error :

Access violation reading location

Do I pass the parameters wrong or..?

答:
strcat expects a non-const char*. You passed a const that's why compiler complained.

Also the second parameter would be "&". (Earlier you passed a char).

From standard §7.24.3.1

```<code>char *strcat(char * restrict s1, const char * restrict s2);
</code>```

The strcat function appends a copy of the string pointed to by s2
  (including the terminating null character) to the end of the string
  pointed to by s1.

So s1 will be modified (the first parameter) that's why it should be non-const.

Title: C string functions error

Body:
I'm working on an assignment, but I'm having trouble with my code :

int is_ascii_match(const char c1[], const char c2[], char res[MAX_STRING_SIZE]) {
....

    if (val_c1 == val_c2) {
        strcpy(res, strcat(strcat(c1, '&'),c2));
    }
    else
        return 0;

I'm getting an error :

Access violation reading location

Do I pass the parameters wrong or..?

Body:
strcat expects a non-const char*. You passed a const that's why compiler complained.

Also the second parameter would be "&". (Earlier you passed a char).

From standard §7.24.3.1

char *strcat(char * restrict s1, const char * restrict s2);

The strcat function appends a copy of the string pointed to by s2
  (including the terminating null character) to the end of the string
  pointed to by s1.

So s1 will be modified (the first parameter) that's why it should be non-const.


问:
SQL querying two sources
I have a View and Table as example below

Table1

```<code>+---------+------+
| Country | City |
+---------+------+
| UK      | LDN  |
| US      | NEY  |
| US      | LAX  |
+---------+------+
</code>```

View1

```<code>+---------+---------+-------+
| Column1 | Column2 | Site  |
+---------+---------+-------+
| Test    | Test2   | UKLDN |
| Test    | Test2   | USNEY |
| Test    | Test2   | USLAX |
| Test    | Test2   | PELMA |
+---------+---------+-------+
</code>```

The result i'm trying to achieve is show all rows from View1, that have a View1.Site column matching Table1.Country and Table1.City. My confusion is how do to it as i'm not an sql person but more C# etc.

The resulting data I want to create is below. I don't know if I can do this solely from View1 or what functions to use.

Result

```<code>+---------+---------+-------+---------------+
| Column1 | Column2 | Site  | ExistInTable1 |
+---------+---------+-------+---------------+
| Test    | Test2   | UKLDN | Y             |
| Test    | Test2   | USNEY | Y             |
| Test    | Test2   | USLAX | Y             |
| Test    | Test2   | PELMA | N             |
+---------+---------+-------+---------------+
</code>```

Thanks

答:
This is T-SQL, but the format should be very similar for most other flavors of SQL.

SQL Fiddle

MS SQL Server 2014 Schema Setup:

```<code>CREATE TABLE Table1 (Country varchar(5),City varchar(5)) ;
INSERT INTO Table1 (Country,City)
VALUES ( 'UK','LDN'),('US','NEY'),('US','LAX')
;
CREATE TABLE View1 (Column1 varchar(10), Column2 varchar(10), Site varchar(10)) ;
INSERT INTO View1 (Column1,Column2,Site)
VALUES ('Test','Test2','UKLDN')
  , ('Test','Test2','USNEY')
  , ('Test','Test2','USLAX')
  , ('Test','Test2','PELMA')
;
</code>```

Query 1:

```<code>SELECT v.Column1, v.Column2
  , CASE WHEN LEN(COALESCE(t.Country,t.City)) > 0 THEN 'Y' ELSE 'N' END AS ExistsInTable1
FROM View1 v
LEFT OUTER JOIN Table1 t ON v.Site = (t.Country+t.City)
</code>```

Results:

```<code>| Column1 | Column2 | ExistsInTable1 |
|---------|---------|----------------|
|    Test |   Test2 |              Y |
|    Test |   Test2 |              Y |
|    Test |   Test2 |              Y |
|    Test |   Test2 |              N |
</code>```

Title: SQL querying two sources

Body:
I have a View and Table as example below

Table1

+---------+------+
| Country | City |
+---------+------+
| UK      | LDN  |
| US      | NEY  |
| US      | LAX  |
+---------+------+

View1

+---------+---------+-------+
| Column1 | Column2 | Site  |
+---------+---------+-------+
| Test    | Test2   | UKLDN |
| Test    | Test2   | USNEY |
| Test    | Test2   | USLAX |
| Test    | Test2   | PELMA |
+---------+---------+-------+

The result i'm trying to achieve is show all rows from View1, that have a View1.Site column matching Table1.Country and Table1.City. My confusion is how do to it as i'm not an sql person but more C# etc.

The resulting data I want to create is below. I don't know if I can do this solely from View1 or what functions to use.

Result

+---------+---------+-------+---------------+
| Column1 | Column2 | Site  | ExistInTable1 |
+---------+---------+-------+---------------+
| Test    | Test2   | UKLDN | Y             |
| Test    | Test2   | USNEY | Y             |
| Test    | Test2   | USLAX | Y             |
| Test    | Test2   | PELMA | N             |
+---------+---------+-------+---------------+

Thanks

Body:
This is T-SQL, but the format should be very similar for most other flavors of SQL.

SQL Fiddle

MS SQL Server 2014 Schema Setup:

CREATE TABLE Table1 (Country varchar(5),City varchar(5)) ;
INSERT INTO Table1 (Country,City)
VALUES ( 'UK','LDN'),('US','NEY'),('US','LAX')
;
CREATE TABLE View1 (Column1 varchar(10), Column2 varchar(10), Site varchar(10)) ;
INSERT INTO View1 (Column1,Column2,Site)
VALUES ('Test','Test2','UKLDN')
  , ('Test','Test2','USNEY')
  , ('Test','Test2','USLAX')
  , ('Test','Test2','PELMA')
;

Query 1:

SELECT v.Column1, v.Column2
  , CASE WHEN LEN(COALESCE(t.Country,t.City)) > 0 THEN 'Y' ELSE 'N' END AS ExistsInTable1
FROM View1 v
LEFT OUTER JOIN Table1 t ON v.Site = (t.Country+t.City)

Results:

| Column1 | Column2 | ExistsInTable1 |
|---------|---------|----------------|
|    Test |   Test2 |              Y |
|    Test |   Test2 |              Y |
|    Test |   Test2 |              Y |
|    Test |   Test2 |              N |


问:
Apache Ignite as transparent cache for Postgresql tables
Is it possible to use Apache Ignite as transparent cache for several tables in PostgreSQL RDBMS and to query that cache using Ignite SQL?

For example like this:

Application (via SQL) ---> Apache Ignite (if data is not loaded) ---> Postgresql

I'm new to Ignite and cannot figure out how to do that or is it even possible.

答:
Ignite's SQL works over in-memory data only so you need to load data into caches beforehand. In other words, read-through doesn't work for SQL queries.

Starting with version 2.1 Ignite provides its custom persistent store that allows running SQL queries against the data both in memory and on disk.


问:
Specify to use volatile table in query
I created a volatile table with the same name as a table in one of our databases. When I run a query specifying only the table name I'm getting the following error: Table/view/trigger name '...' is ambiguous.

Giving the volatile table a different name solves this issue, but I'm curious if there is a way to specify in a query to use the volatile table. I think that if I specify the database name the DB engine knows that it has to pick the materialized table. Is there "database name" for volatile tables?

答: You can use the fully-qualified name of the database object in your query which will prevent problems and confusion</p>

Title: Specify to use volatile table in query


问:
Why are my Cocoa bindings broken?
I have a window with an NSTextField (in Snow Leopard), which I have binded to an NSString function in my WindowController class. This string will combine information about my table view's selection and count, provided by my array controller. It gets an initial value, "0 0", but doesn't ever update, when the selection or count changes. The binding looks like this (File's Owner is MyWindowController):

I implemented + (NSSet *)keyPathsForValuesAffecting<key> (below), but the binding never updates, even when the array controller's total count and selection change.

(Additional troubleshooting performed) I had originally been using the Display Pattern Value binding of the NSTextField, but I needed more complicated logic than that binding afforded. I then started listening to the selection changed/changing events of the TableView that displays the array controller's contents and changing the Display Pattern Value bindings dynamically, but that felt like a hack, and overly complicated.

I'm sure there's something I'm missing, but I can't tell what. Does anyone have any ideas? I've read through Apple's key-value-observing documentation, and this seems to be all that's necessary. I've checked, and my keyPathsForValuesAffectingMyString is getting called, but myString only gets called once. I've distilled my code below (updated x3).

Update 1/21

I'm still plugging away trying to figure this out. When I addObserver to self for the arrayController key paths, the notifications do fire as expected, so my key paths and the key value observing mechanism is fine. When I call [self didChangeValueForKey:@"myString"]; within my observeValueForKeyPath method for the same keys, the binding still doesn't update, leading me to believe it's a bindings problem rather than a KVO problem. I'm going to be reading up on the bindings mechanism more...

```<code>@interface MyWindowController : NSWindowController {
    IBOutlet NSArrayController *arrayController;
}

- (NSArrayController *)arrayController;
- (NSString *)myString;

@end

@implementation MyWindowController

+ (NSSet *)keyPathsForValuesAffectingMyString {
    return [NSSet setWithObjects:
            @"arrayController.arrangedObjects",
            @"arrayController.selection",
            nil];
}

- (NSArrayController *)arrayController {
    return arrayController;
}

- (NSString *)myString {
    // Just as an example; I have more complicated logic going on in my real code
    return [NSString stringWithFormat:@"%@, %@",
            [arrayController valueForKeyPath:@"arrangedObjects.@count"],
            [arrayController valueForKeyPath:@"selection.@count"]];
}

@end
</code>```

答:
I've got a workaround, but I'm not happy about it, since it shouldn't be necessary, and I would still prefer to get the bindings working properly. I won't accept this answer, and will delete it if someone posts an actual fix. </disclaimer>

```<code>@interface MyWindowController : NSWindowController {
    IBOutlet NSArrayController *arrayController;
    IBOutlet NSTextField *fieldThatShouldBeBinded;
}

- (NSString *)myString;

@end

@implementation MyWindowController

- (void)awakeFromNib {
    [arrayController addObserver:self
                      forKeyPath:@"selection"
                         options:0
                         context:NULL];
    [arrayController addObserver:self
                      forKeyPath:@"arrangedObjects"
                         options:0
                         context:NULL];
}

- (void)observeValueForKeyPath:(NSString *)keyPath
                      ofObject:(id)object
                        change:(NSDictionary *)change
                       context:(void *)context {
    if( object == arrayController )
        [fieldThatShouldBeBinded setStringValue:[self myString]];
}

- (NSString *)myString {
    return [NSString stringWithFormat:@"%@, %@",
            [arrayController valueForKeyPath:@"arrangedObjects.@count"],
            [arrayController valueForKeyPath:@"selection.@count"]];
}

@end
</code>```

Title: Why are my Cocoa bindings broken?

Body:
I have a window with an NSTextField (in Snow Leopard), which I have binded to an NSString function in my WindowController class. This string will combine information about my table view's selection and count, provided by my array controller. It gets an initial value, "0 0", but doesn't ever update, when the selection or count changes. The binding looks like this (File's Owner is MyWindowController):

I implemented + (NSSet *)keyPathsForValuesAffecting<key> (below), but the binding never updates, even when the array controller's total count and selection change.

(Additional troubleshooting performed) I had originally been using the Display Pattern Value binding of the NSTextField, but I needed more complicated logic than that binding afforded. I then started listening to the selection changed/changing events of the TableView that displays the array controller's contents and changing the Display Pattern Value bindings dynamically, but that felt like a hack, and overly complicated.

I'm sure there's something I'm missing, but I can't tell what. Does anyone have any ideas? I've read through Apple's key-value-observing documentation, and this seems to be all that's necessary. I've checked, and my keyPathsForValuesAffectingMyString is getting called, but myString only gets called once. I've distilled my code below (updated x3).

Update 1/21

I'm still plugging away trying to figure this out. When I addObserver to self for the arrayController key paths, the notifications do fire as expected, so my key paths and the key value observing mechanism is fine. When I call [self didChangeValueForKey:@"myString"]; within my observeValueForKeyPath method for the same keys, the binding still doesn't update, leading me to believe it's a bindings problem rather than a KVO problem. I'm going to be reading up on the bindings mechanism more...

@interface MyWindowController : NSWindowController {
    IBOutlet NSArrayController *arrayController;
}

- (NSArrayController *)arrayController;
- (NSString *)myString;

@end

@implementation MyWindowController

+ (NSSet *)keyPathsForValuesAffectingMyString {
    return [NSSet setWithObjects:
            @"arrayController.arrangedObjects",
            @"arrayController.selection",
            nil];
}

- (NSArrayController *)arrayController {
    return arrayController;
}

- (NSString *)myString {
    // Just as an example; I have more complicated logic going on in my real code
    return [NSString stringWithFormat:@"%@, %@",
            [arrayController valueForKeyPath:@"arrangedObjects.@count"],
            [arrayController valueForKeyPath:@"selection.@count"]];
}

@end

Body:
I've got a workaround, but I'm not happy about it, since it shouldn't be necessary, and I would still prefer to get the bindings working properly. I won't accept this answer, and will delete it if someone posts an actual fix. </disclaimer>

@interface MyWindowController : NSWindowController {
    IBOutlet NSArrayController *arrayController;
    IBOutlet NSTextField *fieldThatShouldBeBinded;
}

- (NSString *)myString;

@end

@implementation MyWindowController

- (void)awakeFromNib {
    [arrayController addObserver:self
                      forKeyPath:@"selection"
                         options:0
                         context:NULL];
    [arrayController addObserver:self
                      forKeyPath:@"arrangedObjects"
                         options:0
                         context:NULL];
}

- (void)observeValueForKeyPath:(NSString *)keyPath
                      ofObject:(id)object
                        change:(NSDictionary *)change
                       context:(void *)context {
    if( object == arrayController )
        [fieldThatShouldBeBinded setStringValue:[self myString]];
}

- (NSString *)myString {
    return [NSString stringWithFormat:@"%@, %@",
            [arrayController valueForKeyPath:@"arrangedObjects.@count"],
            [arrayController valueForKeyPath:@"selection.@count"]];
}

@end


答:
It will work, if you preload data to cache before querying.

You can do it by configuring a CacheStore and calling IgniteCache#loadCache(). Here is documentation: https://apacheignite.readme.io/v2.3/docs/3rd-party-store#cachestore

Another option is to enable readThrough parameter and use cache API. Unfortunately, this option has no effect on Ignite SQL and works for cache API only.

Title: Apache Ignite as transparent cache for Postgresql tables

Body:
Is it possible to use Apache Ignite as transparent cache for several tables in PostgreSQL RDBMS and to query that cache using Ignite SQL?

For example like this:

Application (via SQL) ---> Apache Ignite (if data is not loaded) ---> Postgresql

I'm new to Ignite and cannot figure out how to do that or is it even possible.


问:
JSON_EXTRACT multidimensional data from MySQL
I have a table, structure as below.

```<code>CREATE TABLE `layout` (
  `id` int(11) NOT NULL,
  `title` varchar(100) NOT NULL,
  `slug` varchar(100) NOT NULL,
  `structure` json NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
</code>```

The field named structure, holds data as below.

```<code>[{"Field":"Name","Type":"Text"},{"Field":"DOB","Type":"Date"}]
</code>```

I want to run query where I give "Field" value and I get "Type" value.

答:
Try:

SET @`Field` := 'Name';

SELECT
  `id`,
  JSON_UNQUOTE(
    JSON_EXTRACT(
      `structure`,
      JSON_UNQUOTE(
        REPLACE(
          JSON_SEARCH(
            `structure`,
            'one',
            @`Field`,
            NULL,
            '$[*].Field'
          ),
          'Field',
          'Type'
        )
      )
    )
  )
FROM
  `layout`;
```

See db-fiddle.

Body:
I have a table, structure as below.

CREATE TABLE `layout` (
  `id` int(11) NOT NULL,
  `title` varchar(100) NOT NULL,
  `slug` varchar(100) NOT NULL,
  `structure` json NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

The field named structure, holds data as below.

[{"Field":"Name","Type":"Text"},{"Field":"DOB","Type":"Date"}]

I want to run query where I give "Field" value and I get "Type" value.

Body:
Try:

SET @`Field` := 'Name';

SELECT
  `id`,
  JSON_UNQUOTE(
    JSON_EXTRACT(
      `structure`,
      JSON_UNQUOTE(
        REPLACE(
          JSON_SEARCH(
            `structure`,
            'one',
            @`Field`,
            NULL,
            '$[*].Field'
          ),
          'Field',
          'Type'
        )
      )
    )
  )
FROM
  `layout`;

See db-fiddle.


问:
React date in Select Mysql
How can I select rows from my database with date more than 2017-12-05 but less than 2017-12-12 ?

```<code>const start = moment().format('YYYY-MM-05');
const end = moment().format('YYYY-MM-12');
</code>```

This is my mysql request:

```<code>'SELECT id, content, date, own FROM quests
WHERE  '+start+'>="date" AND "date">='+end+'
ORDER BY date DESC'
</code>```

In my mysql I have date format YYYY-MM-DD. This request select rows with date 0000-00-00.

答:
Use between operator

```<code>'SELECT id, content, date, own FROM quests
WHERE  `date` BETWEEN \''+start+'\' AND \''+end+'\'
ORDER BY date DESC'
</code>```

Title: React date in Select Mysql

Body:
How can I select rows from my database with date more than 2017-12-05 but less than 2017-12-12 ?

const start = moment().format('YYYY-MM-05');
const end = moment().format('YYYY-MM-12');

This is my mysql request:

'SELECT id, content, date, own FROM quests
WHERE  '+start+'>="date" AND "date">='+end+'
ORDER BY date DESC'

In my mysql I have date format YYYY-MM-DD. This request select rows with date 0000-00-00.

Body:
Use between operator

'SELECT id, content, date, own FROM quests
WHERE  `date` BETWEEN \''+start+'\' AND \''+end+'\'
ORDER BY date DESC'


问:
Each column of a data.frame as a factor of two levels
I have the following data.frame:

```<code># Define data.frame
  u<-data.frame(matrix(c(0,0,0,1,0,1,1,1,0), nrow=3))
# Define each column as a factor with two levels
  r <- as.data.frame(apply(u,2,function(x) factor(x, levels = c(0,1))))
</code>```

Although I apply the factor function to each column defining the levels, the first column only presents one of them (the 0; the only value in the column) and I want it to be a factor with two levels (0 and 1).

Any idea about how to solve it?

The problem is that using apply function there is a problem with columns with all the same values; if I do it manually there is not any problem.

答:
Use lapply instead:

```<code>r <- data.frame(lapply(u, function(x) factor(x, levels = c(0,1))))
</code>```

All data frames are list of lists, so this naturally works.

apply works good for functions like mean,sum,median etc., but if you wan't to adjust the data frame you're working on, lapply is more suitable.

Body:
I have the following data.frame:

# Define data.frame
  u<-data.frame(matrix(c(0,0,0,1,0,1,1,1,0), nrow=3))
# Define each column as a factor with two levels
  r <- as.data.frame(apply(u,2,function(x) factor(x, levels = c(0,1))))

Although I apply the factor function to each column defining the levels, the first column only presents one of them (the 0; the only value in the column) and I want it to be a factor with two levels (0 and 1).

Any idea about how to solve it?

The problem is that using apply function there is a problem with columns with all the same values; if I do it manually there is not any problem.

Body:
Use lapply instead:

r <- data.frame(lapply(u, function(x) factor(x, levels = c(0,1))))

All data frames are list of lists, so this naturally works.

apply works good for functions like mean,sum,median etc., but if you wan't to adjust the data frame you're working on, lapply is more suitable.


问:
java - cannot find file in jersey project
I am trying to load Properties from a file in a resource class of a jersey webapp. This is the resource and I followed the advice here

```<code>import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("persons")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class PersonResource {

public PersonResource()
{
     Properties props = new Properties();
     InputStream is = PersonResource.class.getClass().getClassLoader().getResourceAsStream("WEB-INF/test.txt");
     if(is == null) { System.out.println("Inputstream is null");}
     else
     {
         try
         {
             props.load(is);
             System.out.println(props.propertyNames());
         }
         catch (IOException e) { e.printStackTrace(); }
     }

}

@GET
public List<Person> getAllPersons()
{
    List<Person> res = new ArrayList<>();
    res.add(new Person("peter", "sullivan"));
    res.add(new Person("claire", "wood"));
    return res;
}

@GET
@Path("/{fn}")
public Person getPerson(@PathParam("fn") String fn)
{
    return new Person("peter", "sullivan");
}
</code>```

}

This is my folder structure

where the test.txt is located in WebContent/WEB-INF/. The file is just a single line "key=value". I added the WebContent folder as a source folder.

When I run the app on tomcat 7, I get

```<code>java.lang.NullPointerException
demo.rest.jersey.resource.PersonResource.<init>(PersonResource.java:25)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1375)
org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:272)
org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:366)
org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487)
org.glassfish.jersey.process.internal.RequestScope.findOrCreate(RequestScope.java:162)
org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2022)
</code>```

Line 25 where the error occurs is InputStream is = PersonResource.class.getClass().getClassLoader().getResourceAsStream("WebContent/WEB-INF/test.txt");

Thanks for the help!

答:
The problem is around the path itself. it should be relative path.
like you have to come out from the current folder and go to the folder where we have the test.txt.

OR

copy that test.txt in the folder where you have  PersonResource .java and the path should be "test.txt"

Body:
I am trying to load Properties from a file in a resource class of a jersey webapp. This is the resource and I followed the advice here

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("persons")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class PersonResource {

public PersonResource()
{
     Properties props = new Properties();
     InputStream is = PersonResource.class.getClass().getClassLoader().getResourceAsStream("WEB-INF/test.txt");
     if(is == null) { System.out.println("Inputstream is null");}
     else
     {
         try
         {
             props.load(is);
             System.out.println(props.propertyNames());
         }
         catch (IOException e) { e.printStackTrace(); }
     }

}

@GET
public List<Person> getAllPersons()
{
    List<Person> res = new ArrayList<>();
    res.add(new Person("peter", "sullivan"));
    res.add(new Person("claire", "wood"));
    return res;
}

@GET
@Path("/{fn}")
public Person getPerson(@PathParam("fn") String fn)
{
    return new Person("peter", "sullivan");
}

}

This is my folder structure

where the test.txt is located in WebContent/WEB-INF/. The file is just a single line "key=value". I added the WebContent folder as a source folder.

When I run the app on tomcat 7, I get

java.lang.NullPointerException
demo.rest.jersey.resource.PersonResource.<init>(PersonResource.java:25)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1375)
org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:272)
org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:366)
org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:487)
org.glassfish.jersey.process.internal.RequestScope.findOrCreate(RequestScope.java:162)
org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2022)

Line 25 where the error occurs is InputStream is = PersonResource.class.getClass().getClassLoader().getResourceAsStream("WebContent/WEB-INF/test.txt");

Thanks for the help!


问:
How to wait for a response from a modal before continuing with ajax action link?
Currently I have an actionlink which an OnBegin method which calls a modal asking to either "Save", "Don't Save" or "Cancel". I need to be able to wait for the users selection before continuing.

For example: if the user selects cancel then the modal closes and I return false to stop the ajax action link from continuing.

I know there is AjaxOption of Confirm which does something similar but there are a few issues with that:

The styling doesn't match the rest of my site.

It only has the options of canceling or continuing without an option for saving

ActionLink:

```<code>    @Ajax.ActionLink("Edit", "BrandCategoryModal", "BrandCategory", new AjaxOptions { UpdateTargetId = "DisplayModal", InsertionMode = InsertionMode.Replace, HttpMethod = "GET", OnBegin = "CheckForChanges()"})
</code>```

javascript:

```<code>var hasChanged = false;
var catId = 0;
var form = document.getElementById("CheckForChanges");

form.addEventListener("input", function () {
    hasChanged = true;
    console.log("Change");
});

$('input[name=Active]').change(function () {
    if ($(this).is(':checked')) {
        hasChanged = true;
        console.log("Change");
    } else {
        hasChanged = true;
        console.log("Change");
    }
});
    function CheckForChanges() {
        if (hasChanged)
        {
            showModal('#SaveOrCancel');
      }
        showModal('#DisplayModal')
    }
    function showModal(modalId) { //Displays Modal
        $(modalId).modal('show');
    }
</code>```

Modal:

```<code><div class="modal fade" id="SaveOrCancel" role="dialog">
    <div class="modal-dialog" style="width: 20%; margin-top: 5%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">×</button>
                <h4 class="modal-title">Before Continuing:</h4>
            </div>
            <div class="modal-body">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h4>Select Your option:</h4>
                    </div>
                    <div class="panel-body" style="text-align: center">
                        <button class="btn btn-success" type="button" style="margin:auto"><b>Save</b></button>
                        <button class="btn btn-danger" type="button" style="margin:auto"><b>Don't Save</b></button>
                        <button class="btn btn-info" type="button" data-dismiss="modal" style="margin:auto"><b>Cancel</b></button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</code>```

答:
Change your ajax call for a XMLHttpRequest, lets you handle the events when success, also let you decide when to continue waiting:</p>

```<code>var request = new XMLHttpRequest();
request.open('GET', '/my/url', true);

request.onload = function() {
  if (this.status >= 200 && this.status < 400) {
    // Success ! <--- THERE IT IS
    var data = JSON.parse(this.response);
  } else {
    // Reached server, but it returned an error. Your call. You can retry
  }
};

request.onerror = function() {
  // connection error of some sort
};

request.send();
</code>```

Body:
Currently I have an actionlink which an OnBegin method which calls a modal asking to either "Save", "Don't Save" or "Cancel". I need to be able to wait for the users selection before continuing.

For example: if the user selects cancel then the modal closes and I return false to stop the ajax action link from continuing.

I know there is AjaxOption of Confirm which does something similar but there are a few issues with that:

The styling doesn't match the rest of my site.

It only has the options of canceling or continuing without an option for saving

ActionLink:

    @Ajax.ActionLink("Edit", "BrandCategoryModal", "BrandCategory", new AjaxOptions { UpdateTargetId = "DisplayModal", InsertionMode = InsertionMode.Replace, HttpMethod = "GET", OnBegin = "CheckForChanges()"})

javascript:

var hasChanged = false;
var catId = 0;
var form = document.getElementById("CheckForChanges");

form.addEventListener("input", function () {
    hasChanged = true;
    console.log("Change");
});

$('input[name=Active]').change(function () {
    if ($(this).is(':checked')) {
        hasChanged = true;
        console.log("Change");
    } else {
        hasChanged = true;
        console.log("Change");
    }
});
    function CheckForChanges() {
        if (hasChanged)
        {
            showModal('#SaveOrCancel');
      }
        showModal('#DisplayModal')
    }
    function showModal(modalId) { //Displays Modal
        $(modalId).modal('show');
    }

Modal:

                <button type="button" class="close" data-dismiss="modal">×</button>

Before Continuing:

Select Your option:

                        <button class="btn btn-success" type="button" style="margin:auto">Save</button>
                        <button class="btn btn-danger" type="button" style="margin:auto">Don't Save</button>
                        <button class="btn btn-info" type="button" data-dismiss="modal" style="margin:auto">Cancel</button>

Body:
Change your ajax call for a XMLHttpRequest, lets you handle the events when success, also let you decide when to continue waiting:

var request = new XMLHttpRequest();
request.open('GET', '/my/url', true);

request.onload = function() {
  if (this.status >= 200 && this.status < 400) {
    // Success ! <--- THERE IT IS
    var data = JSON.parse(this.response);
  } else {
    // Reached server, but it returned an error. Your call. You can retry
  }
};

request.onerror = function() {
  // connection error of some sort
};

request.send();


问:
Two models in a view
I have a view in cshtml and some model to view values in a columns. In a columns Name4 and Name5 I want to show values from second model and I don't know how to do it. For example now I showing values from model Project.Models.Names but in a column Name4 and Name5 I want to show values from model Project.Models.Surnames for example.</p>

```<code>@model IEnumerable<Project.Models.Names>

@{
ViewBag.Title = "Smt";

}

<h2>Smt</h2>

<table class="table">
<tr>
    <th>
        Name
    </th>
    <th>
        Name1
    </th>
    <th>
        Name2
    </th>
    <th>
        Name3
    </th>
    <th>
        Name4
    </th>
    <th>
        Name5
    </th>
    <th>

    </th>
</tr>

@foreach (var item in Model) {
<tr>
    <td>
        @Html.DisplayFor(modelItem => item.Name)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.Name1)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.Name2)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.Name3)
    </td>
    <td>
        ...value from second model
    </td>
    <td>
        ...value from second model
    </td>
</code>```

答: Create a Viewmodel class that has properties of Name and Surname.  Then bind to that.</p>

Title: Two models in a view

Body:
I have a view in cshtml and some model to view values in a columns. In a columns Name4 and Name5 I want to show values from second model and I don't know how to do it. For example now I showing values from model Project.Models.Names but in a column Name4 and Name5 I want to show values from model Project.Models.Surnames for example.

@model IEnumerable<Project.Models.Names>

@{
ViewBag.Title = "Smt";

}

Smt

        Name

        Name1

        Name2

        Name3

        Name4

        Name5

@foreach (var item in Model) {

        @Html.DisplayFor(modelItem => item.Name)

        @Html.DisplayFor(modelItem => item.Name1)

        @Html.DisplayFor(modelItem => item.Name2)

        @Html.DisplayFor(modelItem => item.Name3)

        ...value from second model

        ...value from second model


问:
Highscore list comes out as undefined
I'm finished with a game for school and it's functioning well. But I need to store the score from each game in local storage. I can present the individual score but if I want to have an array with scores the values are 'undefined'. Not sure where I get it wrong because the local storage shows the data, although twice over...
Any chance i could get a hint from you?

At the start of the game I want to display the scores, if there are any. I do this with:

```<code>let score = document.querySelector('#score')
let scores = []
if (scores.length > 0) {
  let score = document.querySelector('#score')
  let extract = JSON.parse(window.localStorage.getItem('scores'))
  let highscore = document.createTextNode(extract.Nickname + ' - ' +
  extract.Score)
  score.appendChild(highscore)
}
</code>```

When the player is finished with the game and got all the correct answers I use this code to push the object:

```<code>window.scoreNickname = document.getElementById('name').value
window.scoreTime = seconds + 's ' + totalTimeSum % 1000 + 'ms'
let scoreData = {
    Nickname: window.scoreNickname,
    Score: window.scoreTime
}
scores.push(scoreData)
window.localStorage.setItem('scores', JSON.stringify(scores))
let extract = JSON.parse(window.localStorage.getItem('scores'))
let highscore = document.createTextNode(extract.Nickname + ' - ' +
extract.Score)
score.appendChild(highscore)
</code>```

But all I get us undefined. In local storage I have this information:

```<code>scores: [{"Nickname":"Adam","Score":"18s768ms"},
{"Nickname":"Adam","Score":"18s768ms"}
</code>```

答:
Try with :

```<code>let extract = window.localStorage.getItem('scores');
</code>```

I think you don't need to JSON.parse a JSON object

Title: Highscore list comes out as undefined

Body:
I'm finished with a game for school and it's functioning well. But I need to store the score from each game in local storage. I can present the individual score but if I want to have an array with scores the values are 'undefined'. Not sure where I get it wrong because the local storage shows the data, although twice over...
Any chance i could get a hint from you?

At the start of the game I want to display the scores, if there are any. I do this with:

let score = document.querySelector('#score')
let scores = []
if (scores.length > 0) {
  let score = document.querySelector('#score')
  let extract = JSON.parse(window.localStorage.getItem('scores'))
  let highscore = document.createTextNode(extract.Nickname + ' - ' +
  extract.Score)
  score.appendChild(highscore)
}

When the player is finished with the game and got all the correct answers I use this code to push the object:

window.scoreNickname = document.getElementById('name').value
window.scoreTime = seconds + 's ' + totalTimeSum % 1000 + 'ms'
let scoreData = {
    Nickname: window.scoreNickname,
    Score: window.scoreTime
}
scores.push(scoreData)
window.localStorage.setItem('scores', JSON.stringify(scores))
let extract = JSON.parse(window.localStorage.getItem('scores'))
let highscore = document.createTextNode(extract.Nickname + ' - ' +
extract.Score)
score.appendChild(highscore)

But all I get us undefined. In local storage I have this information:

scores: [{"Nickname":"Adam","Score":"18s768ms"},
{"Nickname":"Adam","Score":"18s768ms"}

Body:
Try with :

let extract = window.localStorage.getItem('scores');

I think you don't need to JSON.parse a JSON object


问:
SQL Table Locking
I have an SQL Server locking question regarding an application we have in house. The application takes submissions of data and persists them into an SQL Server table. Each submission is also assigned a special catalog number (unrelated to the identity field in the table) which is a sequential alpha numeric number. These numbers are pulled from another table and are not generated at run time. So the steps are

Insert Data into Submission Table

Grab next Unassigned Catalog
Number from Catalog Table

Assign the Catalog Number to the
Submission in the Submission table

All these steps happen sequentially in the same stored procedure.

Its, rate but sometimes we manage to get two submission at the same second and they both get assigned the same Catalog Number which causes a localized version of the Apocalypse in our company for a small while.

What can we do to limit the over assignment of the catalog numbers?

答:
Here's the easy solution. No race condition. No blocking from a restrictive transaction isolation level. Probably won't work in SQL dialects other than T-SQL, though.

I assume their is some outside force at work to keep your catalog number table populated with unassigned catalog numbers.

This technique should work for you: just do the same sort of "interlocked update" that retrieves a value, something like:

```<code>update top 1 CatalogNumber
set in_use            = 1 ,
    @newCatalogNumber = catalog_number
from CatalogNumber
where in_use = 0
</code>```

Anyway, the following stored procedure just just ticks up a number on each execution and hands back the previous one. If you want fancier value, add a computed column that applies the transform of choice to the incrementing value to get the desired value.

```<code>drop table dbo.PrimaryKeyGenerator
go
create table dbo.PrimaryKeyGenerator
(
  id            varchar(100) not null ,
  current_value int          not null default(1) ,

  constraint PrimaryKeyGenerator_PK primary key clustered ( id ) ,

)
go
drop procedure dbo.GetNewPrimaryKey
go
create procedure dbo.GetNewPrimaryKey

  @name varchar(100)

as

  set nocount                 on
  set ansi_nulls              on
  set concat_null_yields_null on
  set xact_abort              on

  declare
    @uniqueValue int

  --
  -- put the supplied key in canonical form
  --
  set @name = ltrim(rtrim(lower(@name)))

  --
  -- if the name isn't already defined in the table, define it.
  --
  insert dbo.PrimaryKeyGenerator ( id )
  select id = @name
  where not exists ( select *
                     from dbo.PrimaryKeyGenerator pkg
                     where pkg.id = @name
                   )

  --
  -- now, an interlocked update to get the current value and increment the table
  --
  update PrimaryKeyGenerator
  set @uniqueValue  = current_value ,
      current_value = current_value + 1
  where id = @name

  --
  -- return the new unique value to the caller
  --
  return @uniqueValue
go
</code>```

To use it:

declare @pk int
  exec @pk = dbo.GetNewPrimaryKey 'foobar'
  select @pk

Trivial to mod it to return a result set or return the value via an OUTPUT parameter.

Title: SQL Table Locking

Body:
Here's the easy solution. No race condition. No blocking from a restrictive transaction isolation level. Probably won't work in SQL dialects other than T-SQL, though.

I assume their is some outside force at work to keep your catalog number table populated with unassigned catalog numbers.

This technique should work for you: just do the same sort of "interlocked update" that retrieves a value, something like:

update top 1 CatalogNumber
set in_use            = 1 ,
    @newCatalogNumber = catalog_number
from CatalogNumber
where in_use = 0

Anyway, the following stored procedure just just ticks up a number on each execution and hands back the previous one. If you want fancier value, add a computed column that applies the transform of choice to the incrementing value to get the desired value.

drop table dbo.PrimaryKeyGenerator
go
create table dbo.PrimaryKeyGenerator
(
  id            varchar(100) not null ,
  current_value int          not null default(1) ,

  constraint PrimaryKeyGenerator_PK primary key clustered ( id ) ,

)
go
drop procedure dbo.GetNewPrimaryKey
go
create procedure dbo.GetNewPrimaryKey

  @name varchar(100)

as

  set nocount                 on
  set ansi_nulls              on
  set concat_null_yields_null on
  set xact_abort              on

  declare
    @uniqueValue int

  --
  -- put the supplied key in canonical form
  --
  set @name = ltrim(rtrim(lower(@name)))

  --
  -- if the name isn't already defined in the table, define it.
  --
  insert dbo.PrimaryKeyGenerator ( id )
  select id = @name
  where not exists ( select *
                     from dbo.PrimaryKeyGenerator pkg
                     where pkg.id = @name
                   )

  --
  -- now, an interlocked update to get the current value and increment the table
  --
  update PrimaryKeyGenerator
  set @uniqueValue  = current_value ,
      current_value = current_value + 1
  where id = @name

  --
  -- return the new unique value to the caller
  --
  return @uniqueValue
go

To use it:

declare @pk int
  exec @pk = dbo.GetNewPrimaryKey 'foobar'
  select @pk

Trivial to mod it to return a result set or return the value via an OUTPUT parameter.


问:
Content of unmatched string
I am parsing input from stdin, which is in the following format:

```<code>1
2
3
done
</code>```

My current code is:

```<code>while(<> =~ /(\d+)/) {
    # do something with $1
}
# I want to access the line following the last number here
</code>```

which is fine for the 1st part of the file (with the list of numbers).
However, I would like the content of the line immediately following the last number.

Is there any elegant way to do it?

答:
You could use:

```<code>my $line;
while( ($line = <>) =~ /^(\d+)$/ ) {
  # do something with $1
}
chomp $line;
# Do something with $line (done)
</code>```

As another answer states, it is a good idea to use chomp with a line of input. It will deal with the newline char or chars in a platform-independent way. If you use a regex to match the number, $1 will be "clean".

Also as another answer states, /(\d+)/ will match a number anywhere in the line. /^(\d+)$/ will match a line that only contains a number.

Another way:

```<code>foreach my $line (<>) {
  if( $line =~ /^(\d+)$/ ) {
    # Do something with $1
  }
  else {
    chomp $line;
    # Do something with $line (done)
  }
}
</code>```

This will let you deal with multiple or even alternating lines of numbers and other text.

Title: Content of unmatched string

Body:
I am parsing input from stdin, which is in the following format:

1
2
3
done

My current code is:

while(<> =~ /(\d+)/) {
    # do something with $1
}
# I want to access the line following the last number here

which is fine for the 1st part of the file (with the list of numbers).
However, I would like the content of the line immediately following the last number.

Is there any elegant way to do it?

Body:
You could use:

my $line;
while( ($line = <>) =~ /^(\d+)$/ ) {
  # do something with $1
}
chomp $line;
# Do something with $line (done)

As another answer states, it is a good idea to use chomp with a line of input. It will deal with the newline char or chars in a platform-independent way. If you use a regex to match the number, $1 will be "clean".

Also as another answer states, /(\d+)/ will match a number anywhere in the line. /^(\d+)$/ will match a line that only contains a number.

Another way:

foreach my $line (<>) {
  if( $line =~ /^(\d+)$/ ) {
    # Do something with $1
  }
  else {
    chomp $line;
    # Do something with $line (done)
  }
}

This will let you deal with multiple or even alternating lines of numbers and other text.


问:
Why append don't work, pass by reference?
I have writtern the below codes

```<code>a = [1,2,3]
b = a.append(4)
</code>```

Why there is nothing inside b?

答:
I am not 100% sure what it is you want the value of b to be. But here is what it is when you run the code.

The value of b is None, because it is the return value of the method (.append())
Every method will return a value. In this case it is None, because a.append(4) is appending to the array a. Returning a value means to SIMPLY return a value. This doesn't require a value.

Body:
I have writtern the below codes

a = [1,2,3]
b = a.append(4)

Why there is nothing inside b?


问:
Source Code Protection
When you compile a program to publish with Visual Studio 2010, does that have any advanced methods to keep your program being decompiled to source code? Are there any methods you would use to encrypt yoursource code before compiling?</p>

答: VS 2010 comes with Dotfuscator community edition which will obfuscate your code to a point making it harder to read once decompiled. The only real choice is to encrypt your code if you need the absolute best security. You might want to check out the paid edition http://www.preemptive.com/products/dotfuscator/overview to see if it suits your needs and budget</p>

Title: Source Code Protection


问:
Adjusting Kubernetes configurations depending on environment
I want to describe my services in kubernetes template files. Is it possible to parameterise values like number or replicas, so that I can set this at deploy time.

The goal here is to be able to run my services locally in minikube (where I'll only need one replica) and have them be as close to those running in staging/live as possible.

I'd like to be able to change the number of replicas, use locally mounted volumes and make other minor changes, without having to write a seperate template files that would inevitably diverge from each other.

答:
I'm hoping someone will give me a better answer, but in the meantime, you can feed your configuration through envsubst (see gettext and this for mac).

Example config, text.yaml:

```<code>apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: test
spec:
  replicas: ${NUM_REPLICAS}
  ...
</code>```

Then run:

```<code>$ NUM_REPLICAS=2 envsubst < test.yaml | kubectl apply -f -
deployment "test" configured
</code>```

The final dash is required. This doesn't solve the problem with volumes of course, but it helps a little. You could write a script/makefile to automate this for environment.

Body:
I'm hoping someone will give me a better answer, but in the meantime, you can feed your configuration through envsubst (see gettext and this for mac).

Example config, text.yaml:

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  name: test
spec:
  replicas: ${NUM_REPLICAS}
  ...

Then run:

$ NUM_REPLICAS=2 envsubst < test.yaml | kubectl apply -f -
deployment "test" configured

The final dash is required. This doesn't solve the problem with volumes of course, but it helps a little. You could write a script/makefile to automate this for environment.


问:
Very simple code, not working
I am trying to elicit two responses depending on user input, and can't get it to work. It just keeps printing "Correct, seems you're smarter than I thought...". Any help would be much appreciated, thank you

```<code>print ("Welcome to UTOPIA")

river= ""
while not river:
    river = input ("\n\n\n\nYou come across a raging river, what do you do? ")

if river == "swim" or "swim through it":
    print ("Correct, seems you're smarter than I thought...")

elif river == "walk through it" or "walk through":
    print ("You cant walk through such a big river... silly!")

else:
    print ("Well, sensible suggestions now...")
</code>```

答:
The issue has to do with your if statements. An or will not automatically look at the last variable used so it must be specified again. If "some string" will always evaluate to true as long as the string isn't empty.</p>

```<code>print ("Welcome to UTOPIA")

river= ""
while not river:
    river = input ("\n\n\n\nYou come across a raging river, what do you do? ")

if river == "swim" or river == "swim through it": #Notice the change
    print ("Correct, seems you're smarter than I thought...")

elif river == "walk through it" or river == "walk through": #Notice the change
    print ("You cant walk through such a big river... silly!")

else:
    print ("Well, sensible suggestions now...")
</code>```

Title: Very simple code, not working

Body:
I am trying to elicit two responses depending on user input, and can't get it to work. It just keeps printing "Correct, seems you're smarter than I thought...". Any help would be much appreciated, thank you

print ("Welcome to UTOPIA")

river= ""
while not river:
    river = input ("\n\n\n\nYou come across a raging river, what do you do? ")

if river == "swim" or "swim through it":
    print ("Correct, seems you're smarter than I thought...")

elif river == "walk through it" or "walk through":
    print ("You cant walk through such a big river... silly!")

else:
    print ("Well, sensible suggestions now...")

Body:
The issue has to do with your if statements. An or will not automatically look at the last variable used so it must be specified again. If "some string" will always evaluate to true as long as the string isn't empty.

print ("Welcome to UTOPIA")

river= ""
while not river:
    river = input ("\n\n\n\nYou come across a raging river, what do you do? ")

if river == "swim" or river == "swim through it": #Notice the change
    print ("Correct, seems you're smarter than I thought...")

elif river == "walk through it" or river == "walk through": #Notice the change
    print ("You cant walk through such a big river... silly!")

else:
    print ("Well, sensible suggestions now...")


问:
NHibernate updates row before deleting it?
I'm having a strange behavior with nhibernate. The problem is that
nhibernate performs an update before it deletes an entity.
I have a Category class and a Product class. Category has a bag of
products. When I remove a product from Category, nhibernate does the
following:

It updates the product entity which I removed from collection

It deletes the product entity from database.

Here's mapping

```<code>  <class name="Category">
    <id name="Id">
      <generator class="hilo" />
    </id>
    <property name="Name" lazy="false" length="20" />

    <bag name="Products" cascade="all-delete-orphan" lazy="false"
inverse="false">
      <key column="CategoryId" />
      <one-to-many class="Product" />
    </bag>
  </class>

  <class name="Product">
    <id name="Id">
      <generator class="hilo" />
    </id>
    <property name="Name" lazy="false" />
    <property name="Discontinued" lazy="false" />
    <property name="Price" lazy="false" />
    <many-to-one name="Category"
             class="Category"
             column="CategoryId"
             cascade="none" />
  </class>
</code>```

Here's the code

```<code>    using (var session = NHibernateHelper.OpenSession())
    using (var transaction = session.BeginTransaction())
    {
        var c1 = session.Load<Category>(32768);
        c1.Ps.RemoveAt(0);

        session.SaveOrUpdate(c1);
        transaction.Commit();
    }
</code>```

and here's the result:

```<code>exec sp_executesql N'UPDATE Product SET CategoryId = null WHERE
CategoryId = @p0 AND Id = @p1',N'@p0 int,@p1 int',@p0=32768,@p1=65537
go

exec sp_executesql N'DELETE FROM Product WHERE Id = @p0',N'@p0
int',@p0=65537
go
</code>```

Anyone can explain this strange behavior?

Thanks.

答:
Change inverse to true on your definition for your Products bag on Category.  Setting inverse to false tells NHibernate that the Category objects is the owner of the key on the relationship.

With inverse set to false on the Products collection, NHibernate sees the Category as an owner of the relationship.  So when the Products collection changes it issues the update statement to remove the Product from the Category.  Then the delete occurs because the Product was deleted.

Body:
I'm having a strange behavior with nhibernate. The problem is that
nhibernate performs an update before it deletes an entity.
I have a Category class and a Product class. Category has a bag of
products. When I remove a product from Category, nhibernate does the
following:

It updates the product entity which I removed from collection

It deletes the product entity from database.

Here's mapping

  <class name="Category">
    <id name="Id">
      <generator class="hilo" />
    </id>
    <property name="Name" lazy="false" length="20" />

    <bag name="Products" cascade="all-delete-orphan" lazy="false"
inverse="false">
      <key column="CategoryId" />
      <one-to-many class="Product" />
    </bag>
  </class>

  <class name="Product">
    <id name="Id">
      <generator class="hilo" />
    </id>
    <property name="Name" lazy="false" />
    <property name="Discontinued" lazy="false" />
    <property name="Price" lazy="false" />
    <many-to-one name="Category"
             class="Category"
             column="CategoryId"
             cascade="none" />
  </class>

Here's the code

    using (var session = NHibernateHelper.OpenSession())
    using (var transaction = session.BeginTransaction())
    {
        var c1 = session.Load<Category>(32768);
        c1.Ps.RemoveAt(0);

        session.SaveOrUpdate(c1);
        transaction.Commit();
    }

and here's the result:

exec sp_executesql N'UPDATE Product SET CategoryId = null WHERE
CategoryId = @p0 AND Id = @p1',N'@p0 int,@p1 int',@p0=32768,@p1=65537
go

exec sp_executesql N'DELETE FROM Product WHERE Id = @p0',N'@p0
int',@p0=65537
go

Anyone can explain this strange behavior?

Thanks.


答:
```<code>library(dplyr)
library(purrr)
library(broom)
library(tidyr)

df %>%
  group_by(variable) %>%                                        # group by your desired variable
  nest() %>%                                                    # split data using that variable
  mutate(res = map(data, ~ tidy(t.test(SBR~Class, data = .))))  # apply t.test to each subset and keep results in a tidy format / tidy dataset

# # A tibble: 5 x 3
#     variable               data                   res
#       <fctr>             <list>                <list>
#   1     100% <tibble [126 x 4]> <data.frame [1 x 10]>
#   2      75% <tibble [126 x 4]> <data.frame [1 x 10]>
#   3    66.6% <tibble [126 x 4]> <data.frame [1 x 10]>
#   4      50% <tibble [126 x 4]> <data.frame [1 x 10]>
#   5      25% <tibble [126 x 4]> <data.frame [1 x 10]>
</code>```

So far, you have everything you need on a single dataset. You have the variable to split your data (variable), the dataset you used each time (data) and the results of the t.test (res).

You can unnest the results and keep the columns you like:

```<code>df %>%
  group_by(variable) %>%
  nest() %>%
  mutate(res = map(data, ~ tidy(t.test(SBR~Class, data = .)))) %>%
  unnest(res) %>%
  select(variable, estimate1, estimate2, p.value)

# # A tibble: 5 x 4
#   variable estimate1 estimate2      p.value
#     <fctr>     <dbl>     <dbl>        <dbl>
# 1     100%  9.484195  5.018591 1.146367e-12
# 2      75%  9.429390  4.895682 1.558697e-12
# 3    66.6%  9.421500  4.629750 2.110422e-14
# 4      50%  9.268463  4.683409 3.325438e-13
# 5      25%  9.580171  4.482977 7.025362e-15
</code>```

You can use options(scipen = 999) before you run the code if you prefer to have the p values in a non scientific format:

```<code># # A tibble: 5 x 4
#   variable estimate1 estimate2                 p.value
#     <fctr>     <dbl>     <dbl>                   <dbl>
# 1     100%  9.484195  5.018591 0.000000000001146367091
# 2      75%  9.429390  4.895682 0.000000000001558696898
# 3    66.6%  9.421500  4.629750 0.000000000000021104215
# 4      50%  9.268463  4.683409 0.000000000000332543837
# 5      25%  9.580171  4.482977 0.000000000000007025362
</code>```

Title: R - neat way to do t.test for different data groups

Body:
I have the following data.frame (appended to question). I would like to do a t.test comparing the means of the quantity SBR for class = 0 vs class = 1 for each variable (100%, 75%, 66%,50% and 25%). Ideally I'd like a data.frame out giving me mean(SBR,class=0), mean(SBR,class=1), variable, p-value). At the moment I can get the p-value for each count density but in a really cumbersome manner)

eg

t.test(jr_all_melt[jr_all_melt$Class == 0 & jr_all_melt$variable == "100%",5], jr_all_melt[jr_all_melt$Class == 1 & jr_all_melt$variable == "100%",5])

I'm sure I can do it with a package such as plyr but can't find  a workable example.

 structure(list(Age = c(50.2916666666667, 50.2916666666667, 81.7666666666667,
81.7666666666667, 72.4333333333333, 72.4333333333333, 62.1916666666667,
62.1916666666667, 79.3694444444444, 79.3694444444444, 81.0583333333333,
81.0583333333333, 67.4194444444445, 67.4194444444445, 82.6361111111111,
82.6361111111111, 49.2638888888889, 49.2638888888889, 79.5416666666667,
79.5416666666667, 53.8833333333333, 53.8833333333333, 53.7416666666667,
53.7416666666667, 91.1, 91.1, 79.6138888888889, 79.6138888888889,
64.8388888888889, 64.8388888888889, 81.0444444444445, 81.0444444444445,
64.3305555555555, 64.3305555555555, 67.0083333333333, 67.0083333333333,
56.3972222222222, 56.3972222222222, 83.1777777777778, 83.1777777777778,
75.9027777777778, 75.9027777777778, 79.7944444444445, 79.7944444444445,
56.4277777777778, 56.4277777777778, 67.5083333333333, 67.5083333333333,
70.9888888888889, 70.9888888888889, 67.5805555555555, 67.5805555555555,
67.7388888888889, 67.7388888888889, 58.3083333333333, 58.3083333333333,
68.2805555555556, 68.2805555555556, 52.6055555555556, 52.6055555555556,
84.2861111111111, 84.2861111111111, 70.7861111111111, 70.7861111111111,
75.5222222222222, 75.5222222222222, 82.8361111111111, 82.8361111111111,
80.2361111111111, 80.2361111111111, 76.3888888888889, 76.3888888888889,
73.4, 73.4, 59.3055555555556, 59.3055555555556, 74.6972222222222,
74.6972222222222, 76.025, 76.025, 65.0944444444444, 65.0944444444444,
64.1888888888889, 61.9722222222222, 52.0472222222222, 64.8055555555556,
72.5083333333333, 83.0416666666667, 72.9, 68.9666666666667, 60.3694444444444,
80.3027777777778, 70.9333333333333, 68.4555555555555, 70.825,
73.9972222222222, 60.0916666666667, 77.2833333333333, 73.0722222222222,
66.4861111111111, 66.4777777777778, 41.7722222222222, 78.1861111111111,
74.8305555555555, 72.1638888888889, 71.725, 78.7416666666667,
65.0055555555556, 77.7083333333333, 54.1722222222222, 62.8583333333333,
73.0361111111111, 78.4944444444444, 77.4027777777778, 75.2472222222222,
68.475, 64.7222222222222, 81.1972222222222, 51.5861111111111,
60.8833333333333, 73.3972222222222, 76.8694444444444, 53.8805555555556,
63.3083333333333, 78.1083333333333, 78.4666666666667, 50.2916666666667,
50.2916666666667, 81.7666666666667, 81.7666666666667, 72.4333333333333,
72.4333333333333, 62.1916666666667, 62.1916666666667, 79.3694444444444,
79.3694444444444, 81.0583333333333, 81.0583333333333, 67.4194444444445,
67.4194444444445, 82.6361111111111, 82.6361111111111, 49.2638888888889,
49.2638888888889, 79.5416666666667, 79.5416666666667, 53.8833333333333,
53.8833333333333, 53.7416666666667, 53.7416666666667, 91.1, 91.1,
79.6138888888889, 79.6138888888889, 64.8388888888889, 64.8388888888889,
81.0444444444445, 81.0444444444445, 64.3305555555555, 64.3305555555555,
67.0083333333333, 67.0083333333333, 56.3972222222222, 56.3972222222222,
83.1777777777778, 83.1777777777778, 75.9027777777778, 75.9027777777778,
79.7944444444445, 79.7944444444445, 56.4277777777778, 56.4277777777778,
67.5083333333333, 67.5083333333333, 70.9888888888889, 70.9888888888889,
67.5805555555555, 67.5805555555555, 67.7388888888889, 67.7388888888889,
58.3083333333333, 58.3083333333333, 68.2805555555556, 68.2805555555556,
52.6055555555556, 52.6055555555556, 84.2861111111111, 84.2861111111111,
70.7861111111111, 70.7861111111111, 75.5222222222222, 75.5222222222222,
82.8361111111111, 82.8361111111111, 80.2361111111111, 80.2361111111111,
76.3888888888889, 76.3888888888889, 73.4, 73.4, 59.3055555555556,
59.3055555555556, 74.6972222222222, 74.6972222222222, 76.025,
76.025, 65.0944444444444, 65.0944444444444, 64.1888888888889,
61.9722222222222, 52.0472222222222, 64.8055555555556, 72.5083333333333,
83.0416666666667, 72.9, 68.9666666666667, 60.3694444444444, 80.3027777777778,
70.9333333333333, 68.4555555555555, 70.825, 73.9972222222222,
60.0916666666667, 77.2833333333333, 73.0722222222222, 66.4861111111111,
66.4777777777778, 41.7722222222222, 78.1861111111111, 74.8305555555555,
72.1638888888889, 71.725, 78.7416666666667, 65.0055555555556,
77.7083333333333, 54.1722222222222, 62.8583333333333, 73.0361111111111,
78.4944444444444, 77.4027777777778, 75.2472222222222, 68.475,
64.7222222222222, 81.1972222222222, 51.5861111111111, 60.8833333333333,
73.3972222222222, 76.8694444444444, 53.8805555555556, 63.3083333333333,
78.1083333333333, 78.4666666666667, 50.2916666666667, 50.2916666666667,
81.7666666666667, 81.7666666666667, 72.4333333333333, 72.4333333333333,
62.1916666666667, 62.1916666666667, 79.3694444444444, 79.3694444444444,
81.0583333333333, 81.0583333333333, 67.4194444444445, 67.4194444444445,
82.6361111111111, 82.6361111111111, 49.2638888888889, 49.2638888888889,
79.5416666666667, 79.5416666666667, 53.8833333333333, 53.8833333333333,
53.7416666666667, 53.7416666666667, 91.1, 91.1, 79.6138888888889,
79.6138888888889, 64.8388888888889, 64.8388888888889, 81.0444444444445,
81.0444444444445, 64.3305555555555, 64.3305555555555, 67.0083333333333,
67.0083333333333, 56.3972222222222, 56.3972222222222, 83.1777777777778,
83.1777777777778, 75.9027777777778, 75.9027777777778, 79.7944444444445,
79.7944444444445, 56.4277777777778, 56.4277777777778, 67.5083333333333,
67.5083333333333, 70.9888888888889, 70.9888888888889, 67.5805555555555,
67.5805555555555, 67.7388888888889, 67.7388888888889, 58.3083333333333,
58.3083333333333, 68.2805555555556, 68.2805555555556, 52.6055555555556,
52.6055555555556, 84.2861111111111, 84.2861111111111, 70.7861111111111,
70.7861111111111, 75.5222222222222, 75.5222222222222, 82.8361111111111,
82.8361111111111, 80.2361111111111, 80.2361111111111, 76.3888888888889,
76.3888888888889, 73.4, 73.4, 59.3055555555556, 59.3055555555556,
74.6972222222222, 74.6972222222222, 76.025, 76.025, 65.0944444444444,
65.0944444444444, 64.1888888888889, 61.9722222222222, 52.0472222222222,
64.8055555555556, 72.5083333333333, 83.0416666666667, 72.9, 68.9666666666667,
60.3694444444444, 80.3027777777778, 70.9333333333333, 68.4555555555555,
70.825, 73.9972222222222, 60.0916666666667, 77.2833333333333,
73.0722222222222, 66.4861111111111, 66.4777777777778, 41.7722222222222,
78.1861111111111, 74.8305555555555, 72.1638888888889, 71.725,
78.7416666666667, 65.0055555555556, 77.7083333333333, 54.1722222222222,
62.8583333333333, 73.0361111111111, 78.4944444444444, 77.4027777777778,
75.2472222222222, 68.475, 64.7222222222222, 81.1972222222222,
51.5861111111111, 60.8833333333333, 73.3972222222222, 76.8694444444444,
53.8805555555556, 63.3083333333333, 78.1083333333333, 78.4666666666667,
50.2916666666667, 50.2916666666667, 81.7666666666667, 81.7666666666667,
72.4333333333333, 72.4333333333333, 62.1916666666667, 62.1916666666667,
79.3694444444444, 79.3694444444444, 81.0583333333333, 81.0583333333333,
67.4194444444445, 67.4194444444445, 82.6361111111111, 82.6361111111111,
49.2638888888889, 49.2638888888889, 79.5416666666667, 79.5416666666667,
53.8833333333333, 53.8833333333333, 53.7416666666667, 53.7416666666667,
91.1, 91.1, 79.6138888888889, 79.6138888888889, 64.8388888888889,
64.8388888888889, 81.0444444444445, 81.0444444444445, 64.3305555555555,
64.3305555555555, 67.0083333333333, 67.0083333333333, 56.3972222222222,
56.3972222222222, 83.1777777777778, 83.1777777777778, 75.9027777777778,
75.9027777777778, 79.7944444444445, 79.7944444444445, 56.4277777777778,
56.4277777777778, 67.5083333333333, 67.5083333333333, 70.9888888888889,
70.9888888888889, 67.5805555555555, 67.5805555555555, 67.7388888888889,
67.7388888888889, 58.3083333333333, 58.3083333333333, 68.2805555555556,
68.2805555555556, 52.6055555555556, 52.6055555555556, 84.2861111111111,
84.2861111111111, 70.7861111111111, 70.7861111111111, 75.5222222222222,
75.5222222222222, 82.8361111111111, 82.8361111111111, 80.2361111111111,
80.2361111111111, 76.3888888888889, 76.3888888888889, 73.4, 73.4,
59.3055555555556, 59.3055555555556, 74.6972222222222, 74.6972222222222,
76.025, 76.025, 65.0944444444444, 65.0944444444444, 64.1888888888889,
61.9722222222222, 52.0472222222222, 64.8055555555556, 72.5083333333333,
83.0416666666667, 72.9, 68.9666666666667, 60.3694444444444, 80.3027777777778,
70.9333333333333, 68.4555555555555, 70.825, 73.9972222222222,
60.0916666666667, 77.2833333333333, 73.0722222222222, 66.4861111111111,
66.4777777777778, 41.7722222222222, 78.1861111111111, 74.8305555555555,
72.1638888888889, 71.725, 78.7416666666667, 65.0055555555556,
77.7083333333333, 54.1722222222222, 62.8583333333333, 73.0361111111111,
78.4944444444444, 77.4027777777778, 75.2472222222222, 68.475,
64.7222222222222, 81.1972222222222, 51.5861111111111, 60.8833333333333,
73.3972222222222, 76.8694444444444, 53.8805555555556, 63.3083333333333,
78.1083333333333, 78.4666666666667, 50.2916666666667, 50.2916666666667,
81.7666666666667, 81.7666666666667, 72.4333333333333, 72.4333333333333,
62.1916666666667, 62.1916666666667, 79.3694444444444, 79.3694444444444,
81.0583333333333, 81.0583333333333, 67.4194444444445, 67.4194444444445,
82.6361111111111, 82.6361111111111, 49.2638888888889, 49.2638888888889,
79.5416666666667, 79.5416666666667, 53.8833333333333, 53.8833333333333,
53.7416666666667, 53.7416666666667, 91.1, 91.1, 79.6138888888889,
79.6138888888889, 64.8388888888889, 64.8388888888889, 81.0444444444445,
81.0444444444445, 64.3305555555555, 64.3305555555555, 67.0083333333333,
67.0083333333333, 56.3972222222222, 56.3972222222222, 83.1777777777778,
83.1777777777778, 75.9027777777778, 75.9027777777778, 79.7944444444445,
79.7944444444445, 56.4277777777778, 56.4277777777778, 67.5083333333333,
67.5083333333333, 70.9888888888889, 70.9888888888889, 67.5805555555555,
67.5805555555555, 67.7388888888889, 67.7388888888889, 58.3083333333333,
58.3083333333333, 68.2805555555556, 68.2805555555556, 52.6055555555556,
52.6055555555556, 84.2861111111111, 84.2861111111111, 70.7861111111111,
70.7861111111111, 75.5222222222222, 75.5222222222222, 82.8361111111111,
82.8361111111111, 80.2361111111111, 80.2361111111111, 76.3888888888889,
76.3888888888889, 73.4, 73.4, 59.3055555555556, 59.3055555555556,
74.6972222222222, 74.6972222222222, 76.025, 76.025, 65.0944444444444,
65.0944444444444, 64.1888888888889, 61.9722222222222, 52.0472222222222,
64.8055555555556, 72.5083333333333, 83.0416666666667, 72.9, 68.9666666666667,
60.3694444444444, 80.3027777777778, 70.9333333333333, 68.4555555555555,
70.825, 73.9972222222222, 60.0916666666667, 77.2833333333333,
73.0722222222222, 66.4861111111111, 66.4777777777778, 41.7722222222222,
78.1861111111111, 74.8305555555555, 72.1638888888889, 71.725,
78.7416666666667, 65.0055555555556, 77.7083333333333, 54.1722222222222,
62.8583333333333, 73.0361111111111, 78.4944444444444, 77.4027777777778,
75.2472222222222, 68.475, 64.7222222222222, 81.1972222222222,
51.5861111111111, 60.8833333333333, 73.3972222222222, 76.8694444444444,
53.8805555555556, 63.3083333333333, 78.1083333333333, 78.4666666666667
), Sex = c("M", "M", "M", "M", "F", "F", "M", "M", "M", "M",
"M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F", "F", "M",
"M", "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M", "M",
"M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "F", "F", "F",
"F", "F", "F", "F", "F", "M", "M", "M", "M", "F", "F", "F", "F",
"M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M", "M",
"M", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M", "M", "F",
"M", "F", "M", "M", "M", "M", "M", "M", "F", "M", "M", "M", "F",
"M", "F", "M", "M", "M", "F", "M", "F", "F", "F", "M", "F", "M",
"M", "F", "F", "M", "F", "F", "M", "M", "M", "M", "F", "F", "M",
"M", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M",
"F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "F", "F", "F",
"F", "F", "F", "M", "M", "F", "F", "M", "M", "M", "M", "F", "F",
"M", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "F", "F",
"F", "M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F", "F",
"M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "F", "F", "F",
"F", "F", "F", "F", "M", "M", "M", "M", "F", "M", "F", "M", "M",
"M", "M", "M", "M", "F", "M", "M", "M", "F", "M", "F", "M", "M",
"M", "F", "M", "F", "F", "F", "M", "F", "M", "M", "F", "F", "M",
"F", "F", "M", "M", "M", "M", "F", "F", "M", "M", "M", "M", "F",
"F", "M", "M", "M", "M", "M", "M", "M", "M", "F", "F", "F", "F",
"M", "M", "F", "F", "M", "M", "F", "F", "F", "F", "F", "F", "M",
"M", "F", "F", "M", "M", "M", "M", "F", "F", "M", "M", "M", "M",
"M", "M", "F", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M",
"M", "F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "M", "M",
"M", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "F", "F",
"M", "M", "M", "M", "F", "M", "F", "M", "M", "M", "M", "M", "M",
"F", "M", "M", "M", "F", "M", "F", "M", "M", "M", "F", "M", "F",
"F", "F", "M", "F", "M", "M", "F", "F", "M", "F", "F", "M", "M",
"M", "M", "F", "F", "M", "M", "M", "M", "F", "F", "M", "M", "M",
"M", "M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F", "F",
"M", "M", "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M",
"M", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "F", "F",
"F", "F", "F", "F", "F", "F", "M", "M", "M", "M", "F", "F", "F",
"F", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M", "M",
"M", "M", "F", "F", "F", "F", "F", "F", "F", "M", "M", "M", "M",
"F", "M", "F", "M", "M", "M", "M", "M", "M", "F", "M", "M", "M",
"F", "M", "F", "M", "M", "M", "F", "M", "F", "F", "F", "M", "F",
"M", "M", "F", "F", "M", "F", "F", "M", "M", "M", "M", "F", "F",
"M", "M", "M", "M", "F", "F", "M", "M", "M", "M", "M", "M", "M",
"M", "F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "F", "F",
"F", "F", "F", "F", "M", "M", "F", "F", "M", "M", "M", "M", "F",
"F", "M", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F", "F",
"F", "F", "M", "M", "M", "M", "F", "F", "F", "F", "M", "M", "F",
"F", "M", "M", "M", "M", "M", "M", "M", "M", "M", "M", "F", "F",
"F", "F", "F", "F", "F", "M", "M", "M", "M", "F", "M", "F", "M",
"M", "M", "M", "M", "M", "F", "M", "M", "M", "F", "M", "F", "M",
"M", "M", "F", "M", "F", "F", "F", "M", "F", "M", "M", "F", "F",
"M", "F", "F", "M", "M", "M", "M", "F", "F"), Class = c(0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), variable = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L,
5L, 5L, 5L, 5L, 5L), .Label = c("100%", "75%", "66.6%", "50%",
"25%"), class = "factor"), SBR = c(12.681, 13.04, 11.72, 10.124,
10.69, 11.764, 8.561, 6.438, 4.263, 7.568, 9.231, 8.922, 12.651,
12.43, 8.281, 7.087, 12.944, 12.538, 11.443, 10.491, 12.792,
13.091, 7.091, 7.082, 5.406, 5.044, 11.007, 11.679, 9.909, 10.501,
10.268, 9.312, 16.485, 16.838, 11.743, 9.811, 13.447, 13.355,
5.138, 5.475, 8.883, 8.323, 9.054, 9.72, 21.538, 23.007, 8.842,
9.027, 5.757, 4.229, 5.293, 5.56, 9.714, 9.559, 13.698, 13.965,
7.364, 9.345, 9.309, 9.641, 6.893, 5.765, 7.45, 7.414, 3.651,
3.594, 8.243, 9.381, 7.068, 6.376, 7.011, 8.016, 9.391, 8.884,
8.24, 8.142, 9.045, 8.306, 5.427, 6.813, 10.123, 12.302, 3.953,
9.049, 4.292, 4.182, 5.084, 1.839, 2.693, 3.541, 4.079, 5.09,
5.655, 2.735, 8.321, -0.761, 4.331, 3.822, 1.403, 8.115, 7.87,
8.127, 3.931, 7.447, 1.362, 4.431, -1.583, 6.545, 2.851, 4.957,
6.518, 5.894, 3.874, 8.008, 4.72, 7.651, 8.212, 6.915, 9.625,
7.094, 2.291, 8.13, 7.71, 6.319, 2.494, 2.002, 12.478, 13.372,
12.212, 12.551, 10.571, 11.693, 8.674, 6.894, 5.061, 7.714, 8.512,
8.35, 12.251, 12.375, 7.898, 6.654, 12.89, 12.83, 12.24, 10.638,
13.615, 13.877, 6.845, 7.28, 5.224, 4.883, 10.742, 11.542, 10.308,
10.896, 9.356, 11.338, 15.793, 16.179, 12.567, 11.429, 13.431,
13.99, 6.123, 5.167, 8.709, 7.829, 7.599, 8.454, 19.393, 20.918,
8.33, 9.136, 4.824, 3.95, 6.425, 6.67, 8.22, 7.626, 13.909, 13.971,
8.425, 8.845, 8.887, 9.942, 7.078, 5.547, 6.837, 6.094, 4.576,
4.528, 8.619, 10.478, 3.125, 3.382, 7.22, 8.293, 11.238, 10.548,
7.197, 7.097, 9.659, 8.863, 5.577, 6.025, 10.77, 11.954, 3.814,
9.114, 4.435, 3.592, 5.265, 1.093, 3.903, 3.581, 3.602, 4.468,
5.451, 1.995, 7.03, -0.539, 4.875, 3.812, 1.476, 8.107, 8.628,
9.107, 2.54, 6.902, 1.553, 5.64, -2.762, 6.625, 2.715, 5.475,
6.085, 6.385, 2.794, 7.813, 4.801, 5.883, 7.837, 4.8, 9.527,
8.804, 2.988, 5.729, 7.275, 8.683, 2.627, 1.882, 11.884, 12.791,
10.861, 9.382, 9.525, 10.237, 9.299, 7.338, 5.075, 7.583, 10.324,
9.143, 14.003, 12.861, 7.687, 6.719, 13.422, 13.595, 11.828,
10.943, 12.296, 12.836, 7.069, 7.523, 5.691, 5.309, 11.494, 12.253,
8.711, 8.991, 9.009, 8.809, 15.387, 15.631, 11.948, 12.295, 15.034,
13.889, 5.454, 6.518, 9.535, 8.777, 8.436, 8.396, 18.508, 20.444,
9.505, 8.998, 4.705, 3.47, 5.202, 4.86, 7.532, 7.451, 14.499,
14.114, 6.872, 9.877, 9.077, 9.33, 6.009, 4.583, 5.988, 6.252,
4.766, 4.273, 11.44, 10.971, 6.393, 5.551, 7.107, 6.959, 11.844,
10.795, 9.183, 8.909, 9.142, 7.753, 6.055, 7.152, 9.566, 11.637,
3.668, 8.697, 4.701, 3.218, 4.292, 0.273, 2.713, 3.579, 5.496,
6.322, 4.852, 3.553, 6.82, -0.745, 4.581, 4.12, 1.886, 7.633,
8.07, 8.381, 3.627, 7.156, 1.669, 2.754, -2.56, 5.437, 2.587,
4.361, 4.959, 4.653, 3.2, 7.943, 5.922, 6.379, 5.403, 4.698,
9.665, 6.82, 2.432, 8.587, 6.4, 6.454, 2.054, 0.999, 10.129,
11.129, 13.195, 11.133, 10.702, 12.333, 9.4, 7.665, 5.538, 8.751,
8.868, 8.25, 12.695, 12.2, 8.346, 6.802, 12.007, 11.245, 11.456,
9.58, 12.941, 12.826, 6.239, 6.829, 5.887, 4.896, 10.303, 11.478,
8.972, 9.636, 9.538, 8.34, 16.686, 16.453, 10.827, 8.923, 13.867,
13.964, 5.016, 5.51, 7.635, 7.577, 7.725, 9.532, 21.083, 21.567,
9.417, 8.435, 5.635, 4.206, 4.299, 6.018, 8.642, 8.961, 12.613,
12.665, 8.861, 10.567, 9.365, 9.341, 6.435, 5.435, 7.099, 7.285,
5.467, 4.823, 8.959, 10.568, 6.085, 4.575, 7.267, 8.206, 9.589,
9.242, 7.504, 7.43, 9.171, 7.967, 3.426, 5.843, 10.341, 12.598,
4.001, 9.796, 4.188, 5.943, 6.093, 0.063, 2.512, 3.094, 3.106,
5.35, 6.468, 3.677, 7.964, -0.355, 4.088, 3.271, 0.608, 7.864,
7.941, 7.409, 1.796, 6.667, 0.731, 5.275, -1.904, 5.552, 2.487,
4.371, 6.181, 6.772, 2.993, 7.824, 4.659, 5.242, 5.33, 5.572,
9.409, 6.97, 2.791, 7.5, 6.753, 6.453, 1.955, 1.61, 13.193, 13.31,
12.485, 9.241, 11.773, 12.114, 9.747, 6.474, 5.956, 9.922, 11.264,
10.741, 15.046, 14.575, 6.828, 5.505, 13.366, 12.29, 10.432,
10.353, 12.386, 11.557, 6.68, 7.691, 5.158, 5.553, 10.371, 11.818,
9.635, 9.746, 8.955, 7.844, 18.448, 17.837, 11.19, 11.44, 13.722,
13.807, 7.387, 6.504, 8.724, 8.63, 9.441, 11.918, 19.074, 21.111,
8.849, 8.582, 3.558, 3.453, 4.963, 5.903, 9.605, 9.247, 12.929,
14.318, 7.057, 8.258, 9.982, 9.598, 8.709, 6.397, 7.797, 5.743,
5.742, 5.503, 7.563, 8.864, 5.685, 5.297, 7.63, 7.469, 10.426,
9.266, 7.451, 7.535, 9.941, 8.376, 4.793, 5.155, 9.867, 12.821,
3.052, 5.617, 2.7, 4.793, 6.38, 0.828, 2.281, 2.713, 4.508, 5.245,
5.325, 3.849, 6.326, 0.197, 5.909, 3.548, 1.077, 8.596, 10.599,
6.268, 1.86, 7.651, 1.083, 4.869, -2.972, 4.83, 2.146, 5.991,
4.333, 7.388, 2.181, 6.888, 4.85, 5.289, 5.878, 4.706, 4.609,
6.398, 2.106, 10.709, 6.243, 7.267, 1.431, 1.706)), row.names = c(NA,
-630L), .Names = c("Age", "Sex", "Class", "variable", "SBR"), class = "data.frame")

Body:
library(dplyr)
library(purrr)
library(broom)
library(tidyr)

df %>%
  group_by(variable) %>%                                        # group by your desired variable
  nest() %>%                                                    # split data using that variable
  mutate(res = map(data, ~ tidy(t.test(SBR~Class, data = .))))  # apply t.test to each subset and keep results in a tidy format / tidy dataset

# # A tibble: 5 x 3
#     variable               data                   res
#       <fctr>             <list>                <list>
#   1     100% <tibble [126 x 4]> <data.frame [1 x 10]>
#   2      75% <tibble [126 x 4]> <data.frame [1 x 10]>
#   3    66.6% <tibble [126 x 4]> <data.frame [1 x 10]>
#   4      50% <tibble [126 x 4]> <data.frame [1 x 10]>
#   5      25% <tibble [126 x 4]> <data.frame [1 x 10]>

So far, you have everything you need on a single dataset. You have the variable to split your data (variable), the dataset you used each time (data) and the results of the t.test (res).

You can unnest the results and keep the columns you like:

df %>%
  group_by(variable) %>%
  nest() %>%
  mutate(res = map(data, ~ tidy(t.test(SBR~Class, data = .)))) %>%
  unnest(res) %>%
  select(variable, estimate1, estimate2, p.value)

# # A tibble: 5 x 4
#   variable estimate1 estimate2      p.value
#     <fctr>     <dbl>     <dbl>        <dbl>
# 1     100%  9.484195  5.018591 1.146367e-12
# 2      75%  9.429390  4.895682 1.558697e-12
# 3    66.6%  9.421500  4.629750 2.110422e-14
# 4      50%  9.268463  4.683409 3.325438e-13
# 5      25%  9.580171  4.482977 7.025362e-15

You can use options(scipen = 999) before you run the code if you prefer to have the p values in a non scientific format:

# # A tibble: 5 x 4
#   variable estimate1 estimate2                 p.value
#     <fctr>     <dbl>     <dbl>                   <dbl>
# 1     100%  9.484195  5.018591 0.000000000001146367091
# 2      75%  9.429390  4.895682 0.000000000001558696898
# 3    66.6%  9.421500  4.629750 0.000000000000021104215
# 4      50%  9.268463  4.683409 0.000000000000332543837
# 5      25%  9.580171  4.482977 0.000000000000007025362