问:
Javascript get data attribute from selected option in a table
I got the following html:

```<code><td class="" data-id="46" contenteditable="true">
<select class="form-control">
   <option data-key="end" selected>Opt1</option>
   <option data-key="operator_transfer">Opt2</option>
   <option data-key="process_script">Opt3</option>
</select>
</td>
</code>```

I need to get data attribute of the selected option. I am trying to do it that way:

```<code>var cell = $row.find(':nth-child(4)');
dataattr = cell[0].getAttribute('data-id');
var selectObject = cell.find("select");
if(selectObject.length){// if it is a select
    localobj[dataattr] = selectObject[0].getAttribute('data-key');//val(); previously it was val() here but now I want data-key
}
</code>```

I tried with this:

```<code>$(selectObject/*need to insert something here*/ + ' option:selected').data('key');
</code>```

but it is showing me an error saying that it is an object Object. I need to insert something after selectObject. Any ideas how to fix that?

Thank you.

答:
Try this $('.form-control').children('option:selected').attr('data-key') using jquery function attr()

console.log($('.form-control').children('option:selected').attr('data-key'))```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<td class="" data-id="46" contenteditable="true">
<select class="form-control">
   <option data-key="end" selected>Opt1</option>
   <option data-key="operator_transfer">Opt2</option>
   <option data-key="process_script">Opt3</option>
</select>
</td></code>```

For your code you could do like this

```<code>var cell = $row.find(':nth-child(4)');
dataattr = cell[0].getAttribute('data-id');
var selectObject = cell.find("select");
if(selectObject.length){// if it is a select
    localobj[dataattr] = selectObject[0].getAttribute('data-key');
}
$(selectObject).children('option:selected').data('key');
</code>```

Body:
I got the following html:

<select class="form-control">
   <option data-key="end" selected>Opt1</option>
   <option data-key="operator_transfer">Opt2</option>
   <option data-key="process_script">Opt3</option>
</select>

I need to get data attribute of the selected option. I am trying to do it that way:

var cell = $row.find(':nth-child(4)');
dataattr = cell[0].getAttribute('data-id');
var selectObject = cell.find("select");
if(selectObject.length){// if it is a select
    localobj[dataattr] = selectObject[0].getAttribute('data-key');//val(); previously it was val() here but now I want data-key
}

I tried with this:

$(selectObject/*need to insert something here*/ + ' option:selected').data('key');

but it is showing me an error saying that it is an object Object. I need to insert something after selectObject. Any ideas how to fix that?

Thank you.

Body:
Try this $('.form-control').children('option:selected').attr('data-key') using jquery function attr()

console.log($('.form-control').children('option:selected').attr('data-key'))

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<td class="" data-id="46" contenteditable="true">
<select class="form-control">
   <option data-key="end" selected>Opt1</option>
   <option data-key="operator_transfer">Opt2</option>
   <option data-key="process_script">Opt3</option>
</select>
</td>

For your code you could do like this

var cell = $row.find(':nth-child(4)');
dataattr = cell[0].getAttribute('data-id');
var selectObject = cell.find("select");
if(selectObject.length){// if it is a select
    localobj[dataattr] = selectObject[0].getAttribute('data-key');
}
$(selectObject).children('option:selected').data('key');


来源: stackexchange

问:
R: what is the vector of quantiles in density function dvmnorm
```<code>library(mvtnorm)
dmvnorm(x, mean = rep(0, p), sigma = diag(p), log = FALSE)
</code>```

The dmvnorm provides the density function for a multivariate normal distribution. What exactly does the first parameter, x represent? The documentation says "vector or matrix of quantiles. If x is a matrix, each row is taken to be a quantile."

```<code>> dmvnorm(x=c(0,0), mean=c(1,1))
[1] 0.0585
</code>```

Here is the sample code on the help page. In that case are you generating the probability of having quantile 0 at a normal distribution with mean 1 and sd 1 (assuming that's the default). Since this is a multivariate normal density function, and a vector of quantiles (0, 0) was passed in, why isn't the output a vector of probabilities?

答:
Just taking bivariate normal (X1, X2) as an example, by passing in x = (0, 0), you get P(X1 = 0, X2 = 0) which is a single value. Why do you expect to get a vector?

If you want a vector, you need to pass in a matrix. For example, x = cbind(c(0,1), c(0,1)) gives

```<code>P(X1 = 0, X2 = 0)
P(X1 = 1, X2 = 1)
</code>```

In this situation, each row of the matrix is processed in parallel.

ContentLicense: CC BY-SA 3.0

Body:
library(mvtnorm)
dmvnorm(x, mean = rep(0, p), sigma = diag(p), log = FALSE)

The dmvnorm provides the density function for a multivariate normal distribution. What exactly does the first parameter, x represent? The documentation says "vector or matrix of quantiles. If x is a matrix, each row is taken to be a quantile."

> dmvnorm(x=c(0,0), mean=c(1,1))
[1] 0.0585

Here is the sample code on the help page. In that case are you generating the probability of having quantile 0 at a normal distribution with mean 1 and sd 1 (assuming that's the default). Since this is a multivariate normal density function, and a vector of quantiles (0, 0) was passed in, why isn't the output a vector of probabilities?

Body:
Just taking bivariate normal (X1, X2) as an example, by passing in x = (0, 0), you get P(X1 = 0, X2 = 0) which is a single value. Why do you expect to get a vector?

If you want a vector, you need to pass in a matrix. For example, x = cbind(c(0,1), c(0,1)) gives

P(X1 = 0, X2 = 0)
P(X1 = 1, X2 = 1)

In this situation, each row of the matrix is processed in parallel.


问:
Caching policies and techniques for matrices
as explained before, I'm currently working on a small linear algebra library to use in a personal project. Matrices are implemented as C++ vectors and element assignment ( a(i,j) = v; ) is delegated to the assignment to the vector's elements. For my project I'll need to solve tons of square equation systems and, in order to do that, I implemented the LU factorization (Gaussian Elimination) for square matrices. In the current implementation I'm avoiding to recalculate each time the LU factorization by caching the L and U matrices, the problem is that since I'm delegating the element assignment to vector, I can't find a way to say if the matrix is being changed and whether to recalculate the factorization. Any ideas on how to solve this?

Thank you

答: The setElement and getElement version suggested by Frederick was an option, but it's just too boring to use it. I want to access a(i,j) in reading and writing with the same syntax, withouth bothering if I'm modifying the matrix or not. Probably the best thing to do is let the user modify the Matrix and delegate to him the responsibility to recalculate the LU factorization when he judges that's necessary. Yet it will be very boring.</p>

OwnerDisplayName: Tunnuz

ContentLicense: CC BY-SA 2.5

LastEditorDisplayName: Tunnuz


问:
Wordpress: isHome function
is there any native function in wordpress to check if the page is home page?

because i want to make some script like this

```<code>if (isHome){
    include 'somescript.php';
}
</code>```

PS:
i use wordpress 3.0.1

thanks,

GusDe

答:
Yes, is_home()
change it to

```<code>if (is_home()){
    include 'somescript.php';
}
</code>```

Title: Wordpress: isHome function

Body:
is there any native function in wordpress to check if the page is home page?

because i want to make some script like this

if (isHome){
    include 'somescript.php';
}

PS:
i use wordpress 3.0.1

thanks,

GusDe

Body:
Yes, is_home()
change it to

if (is_home()){
    include 'somescript.php';
}


问:
Multiple bar chart group spacing issue
I'm working with an application, where charts are used to display reports.
I use https://github.com/danielgindi/Charts. here im able to bind data, but the groups are placed in wrong position with respect to x-axis. Please refer the image displayed below.

Please help me to group the bars properly.

答:
```<code>    - (void)setDataCount:(int)count range:(double)range
{
    float groupSpace = 0.08f;
    float barSpace = 0.03f;
    float barWidth = 0.2f;
    // (0.2 + 0.03) * 4 + 0.08 = 1.00 -> interval per "group"

    NSMutableArray *yVals1 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals2 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals3 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals4 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals5 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals6 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals7 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals8 = [[NSMutableArray alloc] init];
    NSMutableArray *yVals9 = [[NSMutableArray alloc] init];

    NSMutableArray *xVals = [[NSMutableArray alloc] init];

   // double randomMultiplier = range * 100000.f;

    int groupCount = count+1;
    int startYear = 1980;
    //int endYear = startYear + groupCount;

    //NSArray *getFloatingVal = [[NSUserDefaults standardUserDefaults] objectForKey:@"selectedFloatValTrend"];

    for (int i = 0; i < count; i++)
    {

        if ([arrForChartsDisplay containsObject:@"Total Production"] && flagTotal==true) {
        [yVals1 addObject:[[BarChartDataEntry alloc]
                           initWithX:[[[getDataToLoadChart valueForKey:@"date"] objectAtIndex:i] doubleValue]
                           y:[[[getDataToLoadChart valueForKey:@"totalProd"] objectAtIndex:i]doubleValue]]];
        }

         if ([arrForChartsDisplay containsObject:@"eb/100sh"] && flageb==true) {
        [yVals2 addObject:[[BarChartDataEntry alloc]
                           initWithX:[[[getDataToLoadChart valueForKey:@"date"] objectAtIndex:i] doubleValue]
                           y:[[[getDataToLoadChart valueForKey:@"ebPerHunderedSh"] objectAtIndex:i] doubleValue]]];
         }

         if ([arrForChartsDisplay containsObject:@"Production Efficiency"] && flagProduction==true) {
        [yVals3 addObject:[[BarChartDataEntry alloc]
                           initWithX:[[[getDataToLoadChart valueForKey:@"date"] objectAtIndex:i] doubleValue]
                           y:[[[getDataToLoadChart valueForKey:@"productionEfficiency"] objectAtIndex:i] doubleValue]]];
         }

        if ([arrForChartsDisplay containsObject:@"End Break count"] && flagEnd==true) {
        [yVals4 addObject:[[BarChartDataEntry alloc]
                           initWithX:[[[getDataToLoadChart valueForKey:@"date"] objectAtIndex:i] doubleValue]
                           y:[[[getDataToLoadChart valueForKey:@"endBreakCount"] objectAtIndex:i] doubleValue]]];
         }

         if ([arrForChartsDisplay containsObject:@"Rouge Spindle Count"] && flagRouge==true) {
        [yVals5 addObject:[[BarChartDataEntry alloc]
                           initWithX:[[[getDataToLoadChart valueForKey:@"date"] objectAtIndex:i] doubleValue]
                           y:[[[getDataToLoadChart valueForKey:@"rougeCount"] objectAtIndex:i] doubleValue]]];
         }

         if ([arrForChartsDisplay containsObject:@"No of Doff"] && flagNoDoff==true) {
        [yVals6 addObject:[[BarChartDataEntry alloc]
                           initWithX:[[[getDataToLoadChart valueForKey:@"date"] objectAtIndex:i] doubleValue]
                           y:[[[getDataToLoadChart valueForKey:@"numberofDoffs"] objectAtIndex:i] doubleValue]]];
         }

         if ([arrForChartsDisplay containsObject:@"Startup Breaks"] && flagStartup==true) {
        [yVals7 addObject:[[BarChartDataEntry alloc]
                           initWithX:[[[getDataToLoadChart valueForKey:@"date"] objectAtIndex:i] doubleValue]
                           y:[[[getDataToLoadChart valueForKey:@"startupBreak"] objectAtIndex:i] doubleValue]]];
         }

         if ([arrForChartsDisplay containsObject:@"Slip Count"] && flagSlip==true) {
        [yVals8 addObject:[[BarChartDataEntry alloc]
                           initWithX:[[[getDataToLoadChart valueForKey:@"date"] objectAtIndex:i] doubleValue]
                           y:[[[getDataToLoadChart valueForKey:@"slipCount"] objectAtIndex:i] doubleValue]]];
         }

         if ([arrForChartsDisplay containsObject:@"Idle Count"] && flagIdle==true) {
        [yVals9 addObject:[[BarChartDataEntry alloc]
                           initWithX:[[[getDataToLoadChart valueForKey:@"date"] objectAtIndex:i] doubleValue]
                           y:[[[getDataToLoadChart valueForKey:@"idleCount"] objectAtIndex:i] doubleValue]]];
         }

        NSString *dateStr = [[getDataToLoadChart valueForKey:@"date"] objectAtIndex:i];

        // Convert string to date object
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"yyyyMMdd"];
        NSDate *date = [dateFormat dateFromString:dateStr];
        [xVals addObject:date];
    }

    BarChartDataSet *set1 = nil, *set2 = nil, *set3 = nil, *set4 = nil ,*set5 = nil, *set6 = nil, *set7 = nil, *set8 = nil,*set9 = nil;
    _chartView.data=nil;
    if (_chartView.data.dataSetCount > 0)
    {
        set1 = (BarChartDataSet *)_chartView.data.dataSets[0];
        set2 = (BarChartDataSet *)_chartView.data.dataSets[1];
        set3 = (BarChartDataSet *)_chartView.data.dataSets[2];
        set4 = (BarChartDataSet *)_chartView.data.dataSets[3];
        set5 = (BarChartDataSet *)_chartView.data.dataSets[4];
        set6 = (BarChartDataSet *)_chartView.data.dataSets[5];
        set7 = (BarChartDataSet *)_chartView.data.dataSets[6];
        set8 = (BarChartDataSet *)_chartView.data.dataSets[7];
        set9 = (BarChartDataSet *)_chartView.data.dataSets[8];
        set1.values = yVals1;
        set2.values = yVals2;
        set3.values = yVals3;
        set4.values = yVals4;
        set5.values = yVals5;
        set6.values = yVals6;
        set7.values = yVals7;
        set8.values = yVals8;
        set9.values = yVals9;

        BarChartData *data = _chartView.barData;

        _chartView.xAxis.axisMinimum = startYear;
        _chartView.xAxis.axisMaximum = [data groupWidthWithGroupSpace:groupSpace barSpace: barSpace] * _sliderX.value + startYear;
        [data groupBarsFromX: startYear groupSpace: groupSpace barSpace: barSpace];

        [_chartView.data notifyDataChanged];
        [_chartView notifyDataSetChanged];
    }
    else
    {
    NSMutableArray *dataSets = [[NSMutableArray alloc] init];
    if (count>0) {

    if ([arrForChartsDisplay containsObject:@"Total Production"] && flagTotal==true) {
        set1 = [[BarChartDataSet alloc] initWithValues:yVals1 label:@"Total Production"];
        [set1 setColor:[UIColor colorWithRed:104/255.f green:241/255.f blue:175/255.f alpha:1.f]];
        [dataSets addObject:set1];
    }

    if ([arrForChartsDisplay containsObject:@"eb/100sh"] && flageb==true) {
        set2 = [[BarChartDataSet alloc] initWithValues:yVals2 label:@"eb/100sh"];
        [set2 setColor:[UIColor colorWithRed:164/255.f green:228/255.f blue:251/255.f alpha:1.f]];
        [dataSets addObject:set2];
    }

    if ([arrForChartsDisplay containsObject:@"Production Efficiency"] && flagProduction==true) {
        set3 = [[BarChartDataSet alloc] initWithValues:yVals3 label:@"Production Efficiency"];
        [set3 setColor:[UIColor colorWithRed:242/255.f green:247/255.f blue:158/255.f alpha:1.f]];
        [dataSets addObject:set3];
    }

    if ([arrForChartsDisplay containsObject:@"End Break count"] && flagEnd==true) {
        set4 = [[BarChartDataSet alloc] initWithValues:yVals4 label:@"End Break count"];
        [set4 setColor:[UIColor colorWithRed:255/255.f green:102/255.f blue:0/255.f alpha:1.f]];
         [dataSets addObject:set4];
    }

    if ([arrForChartsDisplay containsObject:@"Rouge Spindle Count"] && flagRouge==true) {
        set5 = [[BarChartDataSet alloc] initWithValues:yVals5 label:@"Rouge Spindle Count"];
        [set5 setColor:[UIColor colorWithRed:255/255.f green:102/255.f blue:204/255.f alpha:1.f]];
        [dataSets addObject:set5];
    }

    if ([arrForChartsDisplay containsObject:@"No of Doff"] && flagNoDoff==true) {
        set6 = [[BarChartDataSet alloc] initWithValues:yVals6 label:@"No of Doff"];
        [set6 setColor:[UIColor colorWithRed:204/255.f green:0/255.f blue:0/255.f alpha:1.f]];
        [dataSets addObject:set6];
    }

    if ([arrForChartsDisplay containsObject:@"Startup Breaks"] && flagStartup==true) {
        set7 = [[BarChartDataSet alloc] initWithValues:yVals7 label:@"Startup Breaks"];
        [set7 setColor:[UIColor colorWithRed:0/255.f green:255/255.f blue:0/255.f alpha:1.f]];
         [dataSets addObject:set7];
    }

    if ([arrForChartsDisplay containsObject:@"Slip Count"] && flagSlip==true) {
        set8 = [[BarChartDataSet alloc] initWithValues:yVals8 label:@"Slip Count"];
        [set8 setColor:[UIColor colorWithRed:153/255.f green:153/255.f blue:102/255.f alpha:1.f]];
         [dataSets addObject:set8];
    }

    if ([arrForChartsDisplay containsObject:@"Idle Count"] && flagIdle==true) {
        set9 = [[BarChartDataSet alloc]initWithValues:yVals9 label:@"Idle Count"];
        [set9 setColor:[UIColor colorWithRed:0/255.f green:102/255.f blue:102/255.f alpha:1.f]];
        [dataSets addObject:set9];
    }

    }

     if (count>0) {

        BarChartData *data = [[BarChartData alloc]initWithDataSets:dataSets];
        [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:10.f]];
        [data setValueFormatter:[[LargeValueFormatter alloc] init]];

        // specify the width each bar should have
        data.barWidth = barWidth;

        // restrict the x-axis range
        _chartView.xAxis.axisMinimum = startYear;

        // groupWidthWithGroupSpace(...) is a helper that calculates the width each group needs based on the provided parameters
        _chartView.xAxis.axisMaximum = startYear + [data groupWidthWithGroupSpace:groupSpace barSpace: barSpace] * groupCount;

         _chartView.xAxis.valueFormatter=self;

        [data groupBarsFromX: startYear groupSpace: groupSpace barSpace: barSpace];
         //(0.2 + 0.03) * 4 + 0.08
    _chartView.data = data;
     }
    }
}
</code>```

Title: Multiple bar chart group spacing issue


问:
dynamic query on entity field name in a generic
I'm using generics because I need a lot of reusability with different types of data. my main problem is querying data. I'm looking for a way to query something like this:

```<code>public void test<T>(int id, T type) where T : class
{
    using (var ctx = myDbContext())
    {
        var myTbl = ctx.Set<T>();
        //this line gets the primary key of the table
        string key = myTbl.GetPrimaryKey(ctx);

        //this is the query I want:
        var myResult = myTbl.FirstOrDefault(x => x.key == id);

        //let's say if key = "UserId", then (x => x.UserId == id) or something that translates to this.
    }
}
</code>```

also I have implemented following method:

```<code>public object GetPropertyValue(object src, string propertyName)
</code>```

that I can use to get value of a specific property.

but my problem is that I can't use it inside the .FirstOrDefault() call because of the LINQ to query issues with methods.

I currently use this code instead:

```<code>var myResult = myTbl.ToList().FirstOrDefault(x => (int)GetPropertyValue(x, key) == id);
</code>```

which is fine with a few number of rows in database, but when data grows in future it will have a lot of performance impact.

P.S: I'm using EF power tools for reverse engineering code first

答:
Umm, your code sample is completely unclear. Please, atleast provide correct variable names, because now I don't even know where you use 'key' variable.

Also, if you want to store and query objects and it's properties of various inheritance and nestings, consider to use NoSQL databases instead of relation based SQL engines.

Body:
I'm using generics because I need a lot of reusability with different types of data. my main problem is querying data. I'm looking for a way to query something like this:

public void test<T>(int id, T type) where T : class
{
    using (var ctx = myDbContext())
    {
        var myTbl = ctx.Set<T>();
        //this line gets the primary key of the table
        string key = myTbl.GetPrimaryKey(ctx);

        //this is the query I want:
        var myResult = myTbl.FirstOrDefault(x => x.key == id);

        //let's say if key = "UserId", then (x => x.UserId == id) or something that translates to this.
    }
}

also I have implemented following method:

public object GetPropertyValue(object src, string propertyName)

that I can use to get value of a specific property.

but my problem is that I can't use it inside the .FirstOrDefault() call because of the LINQ to query issues with methods.

I currently use this code instead:

var myResult = myTbl.ToList().FirstOrDefault(x => (int)GetPropertyValue(x, key) == id);

which is fine with a few number of rows in database, but when data grows in future it will have a lot of performance impact.

P.S: I'm using EF power tools for reverse engineering code first


问:
Custom Callback never called when Google Auth on passportjs
I try to login with Google by using PassportJS. But when I use the custom callback, the Google Strategy never called the callback. What am I doing wrong? My codes are below.

endpoints:

```<code>var router = express.Router();
router.get('/',
  passport.authenticate('google', { scope: [
    'https://www.googleapis.com/auth/plus.login',
    'https://www.googleapis.com/auth/plus.profiles.read',
    'https://www.googleapis.com/auth/userinfo.email'
  ] }
));

router.get('/callback', function (req, res) {
  console.log("GOOGLE CALLBACK");
  passport.authenticate('google', function (err, profile, info) {
    console.log("PROFILE: ", profile);
  });
});

module.exports = router;
</code>```

Passport:

```<code>passport.use(new GoogleStrategy({
          clientID: config.GOOGLE.CLIENT_ID,
          clientSecret: config.GOOGLE.CLIENT_SECRET,
          callbackURL: config.redirectURL+"/auth/google/callback",
          passReqToCallback: true
          },
          function(request, accessToken, refreshToken, profile, done) {
            process.nextTick(function () {
              return done(null, profile);
            });
          }
        ));
</code>```

GOOGLE CALLBACK log is printed but PROFILE log never printed.

Thanks in advance.

答:
This is a trick situation...

The passport.authenticate method, returns a function.

And if you use in that way, you have to call it, by yourself.

Look:

```<code>router.get('/callback', function (req, res) {
  console.log("GOOGLE CALLBACK");
  passport.authenticate('google', function (err, profile, info) {
    console.log("PROFILE: ", profile);
  })(req, res); // you to call the function retuned by passport.authenticate, with is a midleware.
});
</code>```

Or, you could do this:

```<code>router.get('/callback', passport.authenticate('google', function (err, profile, info) {
    console.log("PROFILE: ", profile);
  }));
</code>```

passport.authenticate is a middleware.

Hope is helps.

Body:
I try to login with Google by using PassportJS. But when I use the custom callback, the Google Strategy never called the callback. What am I doing wrong? My codes are below.

endpoints:

var router = express.Router();
router.get('/',
  passport.authenticate('google', { scope: [
    'https://www.googleapis.com/auth/plus.login',
    'https://www.googleapis.com/auth/plus.profiles.read',
    'https://www.googleapis.com/auth/userinfo.email'
  ] }
));

router.get('/callback', function (req, res) {
  console.log("GOOGLE CALLBACK");
  passport.authenticate('google', function (err, profile, info) {
    console.log("PROFILE: ", profile);
  });
});

module.exports = router;

Passport:

passport.use(new GoogleStrategy({
          clientID: config.GOOGLE.CLIENT_ID,
          clientSecret: config.GOOGLE.CLIENT_SECRET,
          callbackURL: config.redirectURL+"/auth/google/callback",
          passReqToCallback: true
          },
          function(request, accessToken, refreshToken, profile, done) {
            process.nextTick(function () {
              return done(null, profile);
            });
          }
        ));

GOOGLE CALLBACK log is printed but PROFILE log never printed.

Thanks in advance.

Body:
This is a trick situation...

The passport.authenticate method, returns a function.

And if you use in that way, you have to call it, by yourself.

Look:

router.get('/callback', function (req, res) {
  console.log("GOOGLE CALLBACK");
  passport.authenticate('google', function (err, profile, info) {
    console.log("PROFILE: ", profile);
  })(req, res); // you to call the function retuned by passport.authenticate, with is a midleware.
});

Or, you could do this:

router.get('/callback', passport.authenticate('google', function (err, profile, info) {
    console.log("PROFILE: ", profile);
  }));

passport.authenticate is a middleware.

Hope is helps.


问:
Invoking cts through batch
I would like to run cts on windows using batch script. I want to run Android CTS 5.0 R3 version on windows 64 bit.

My script has the below command to invoke cts:

java -cp ddmlib-prebuilt.jar;tradefed-prebuilt.jar;hosttestlib.jar;cts-tradefed.jar -DCTS_ROOT=D:\cts com.android.cts.tradefed.command.CtsConsole

When I double click on my batch script,  it will enter into a shell like "cts-tf>". I then have to manually run cts using " run cts --plan CTS " command.

I would like to put "run cts --plan CTS" command also as well as part of my batch script. i.e. when command prompt has entered into shell, I need to execute run cts --plan CTS from my batch file.

答:
```<code>java -cp ddmlib-prebuilt.jar;tradefed-prebuilt.jar;hosttestlib.jar;cts-tradefed.jar -DCTS_ROOT=android-cts-6.0_r13-linux_x86-arm com.android.cts.tradefed.command.CtsConsole
</code>```

Title: Invoking cts through batch


问:
Empty space in UISplitViewController embedded in a UITabViewController
I have this view hierarchy on my storyboard:

UITabBarController -> UIView + ContainerController -> SplitViewController => [MASTER: (UINavigationController -> UITableviewController -> UITableViewController), DETAIL: (UINavigationController -> UIView)]

Here a screenshot of the storyboard:

As a result my detail view controller have a sort of offset from the bottom screen as shown in the red circle in the next screen:

I think it is a consequence of having a split view controller in a container controller that its embedded in a tab controller. It's like the detail view inherits the space of the tab bar of the root tab bar controller. I have tried to set all the options like UnderBottombar or "Under opaque bar" but nothing. I have removed any sort of custom code in my classes but there is always the same problem.
How can i fix this issue?

ps: Sorry for bad english :)

答: This can be solved by checking Under Opaque Bars from attribute inspector of your SplitViewController. refer below screenshot,

ContentLicense: CC BY-SA 4.0


问:
Get logged in user from time-stamp
I have 2 tables in my DB. One tracks when users log in: id, name, IP, & time-stamp. The other is a series of events: id, event name, IP, & time-stamp.

Is there an easy way to see which user is logged on given a specific event?.

For example, if I have

```<code>id  l_ip          l_user  l_time
0   172.16.1.10   ces77   2010-12-14 09:02:12
1   172.16.1.64   ces34   2010-12-14 10:06:43
2   172.16.1.10   ces47   2010-12-14 11:10:52
</code>```

and

```<code>id  e_name   e_ip         e_time
0   remove   172.16.1.10  2010-12-14 09:10:33
1   run      172.16.1.64  2010-12-14 10:15:10
2   change   172.16.1.64  2010-12-14 10:20:32
3   run      172.16.1.10  2010-12-14 12:55:59
</code>```

could I run a query to give me the user for each one of the events so it would produce?

```<code>id  e_name   e_ip         e_time               l_user
0   remove   172.16.1.10  2010-12-14 09:10:33  ces77
1   run      172.16.1.64  2010-12-14 10:15:10  ces34
2   change   172.16.1.64  2010-12-14 10:20:32  ces34
3   run      172.16.1.10  2010-12-14 12:55:59  ces47
</code>```

答:
UPD>

```<code>SELECT e.id, e_name, e_ip, e_time, l_user
FROM events e
  INNER JOIN loggedin l ON e.e_ip = l.l_ip AND e.e_time >= l.l_time
</code>```

Is this what you need?

Title: Get logged in user from time-stamp

Body:
I have 2 tables in my DB. One tracks when users log in: id, name, IP, & time-stamp. The other is a series of events: id, event name, IP, & time-stamp.

Is there an easy way to see which user is logged on given a specific event?.

For example, if I have

id  l_ip          l_user  l_time
0   172.16.1.10   ces77   2010-12-14 09:02:12
1   172.16.1.64   ces34   2010-12-14 10:06:43
2   172.16.1.10   ces47   2010-12-14 11:10:52

and

id  e_name   e_ip         e_time
0   remove   172.16.1.10  2010-12-14 09:10:33
1   run      172.16.1.64  2010-12-14 10:15:10
2   change   172.16.1.64  2010-12-14 10:20:32
3   run      172.16.1.10  2010-12-14 12:55:59

could I run a query to give me the user for each one of the events so it would produce?

id  e_name   e_ip         e_time               l_user
0   remove   172.16.1.10  2010-12-14 09:10:33  ces77
1   run      172.16.1.64  2010-12-14 10:15:10  ces34
2   change   172.16.1.64  2010-12-14 10:20:32  ces34
3   run      172.16.1.10  2010-12-14 12:55:59  ces47

Body:
UPD>

SELECT e.id, e_name, e_ip, e_time, l_user
FROM events e
  INNER JOIN loggedin l ON e.e_ip = l.l_ip AND e.e_time >= l.l_time

Is this what you need?


问:
Read barcode from Gallery Image in xamarin c#
I need  to read Barcode from gallery image in android application using xamarin.

答:
Zxing is powerful and how I do this too, but I would add I have encountered an occasional BarcodeReader.Decode issue with image resolution that returns a null for near-misses on the physically appearing barcode.

After messing around with some fiddles, I discovered that you can vary the height/width ratio via the following code and often get good results for where before Decode was returning a null:

```<code>int i = -20;
while (barcode == null && i < 100)
{
    Bitmap resized = new Bitmap(pageImg, new Size(pageImg.Width + i, pageImg.Height + i));
    barcode = barcodeReader.Decode(resized);
    i++;
}
</code>```

Body:
Zxing is powerful and how I do this too, but I would add I have encountered an occasional BarcodeReader.Decode issue with image resolution that returns a null for near-misses on the physically appearing barcode.

After messing around with some fiddles, I discovered that you can vary the height/width ratio via the following code and often get good results for where before Decode was returning a null:

int i = -20;
while (barcode == null && i < 100)
{
    Bitmap resized = new Bitmap(pageImg, new Size(pageImg.Width + i, pageImg.Height + i));
    barcode = barcodeReader.Decode(resized);
    i++;
}


问:
CSS not being applied in CGI script
I wrote this cgi script

```<code>#!/usr/bin/env python

import cgi

print "Content-type: text/html\n\n"
print"<html>"
print"<title>Wedmed Search engine</title>"
print"""<link type="text/css" rel="stylesheet" href="stylesheet1.css"/>
<body>

<div class="img" position="center">
    <h1>
        WebMED</h1>
    </div>

<form action="/cgi-bin/hello.py" method="POST">

    <input type="text" size="50" name="data" value=""><br>

    <input type="submit" value="Submit">
    <input type="reset" value="Reset">

</form>
</body></html>"""
</code>```

The problem is css is not working with my cgi script. It works perfectly fine with html code.
can anyone please help??

答:
I found a way that isn't the best but does the trick for me.

Put your whole style-sheet in stylesheet1.css as you already did and then write this in your python file

```<code>f = open('stylesheet1.css', 'r')
style = ''
for i in f:
    style += i
head = '''
    <head>
    <style>
    %s
    <style>
    </head>''' % (style)
print "Content-type: text/html\n\n"
print"<html>"
print head
print """<body>

<div class="img" position="center">
    <h1>
        WebMED</h1>
    </div>

<form action="/cgi-bin/hello.py" method="POST">

    <input type="text" size="50" name="data" value=""><br>

    <input type="submit" value="Submit">
    <input type="reset" value="Reset">

</form>
</body></html>"""
</code>```

Title: CSS not being applied in CGI script

Body:
I wrote this cgi script

#!/usr/bin/env python

import cgi

print "Content-type: text/html\n\n"
print""
print"<title>Wedmed Search engine</title>"
print"""<link type="text/css" rel="stylesheet" href="stylesheet1.css"/>

        WebMED

<form action="/cgi-bin/hello.py" method="POST">

    <input type="text" size="50" name="data" value="">

    <input type="submit" value="Submit">
    <input type="reset" value="Reset">

</form>
"""

The problem is css is not working with my cgi script. It works perfectly fine with html code.
can anyone please help??

Body:
I found a way that isn't the best but does the trick for me.

Put your whole style-sheet in stylesheet1.css as you already did and then write this in your python file

f = open('stylesheet1.css', 'r')
style = ''
for i in f:
    style += i
head = '''
    <head>
    <style>
    %s
    <style>
    </head>''' % (style)
print "Content-type: text/html\n\n"
print"<html>"
print head
print """<body>

<div class="img" position="center">
    <h1>
        WebMED</h1>
    </div>

<form action="/cgi-bin/hello.py" method="POST">

    <input type="text" size="50" name="data" value=""><br>

    <input type="submit" value="Submit">
    <input type="reset" value="Reset">

</form>
</body></html>"""


问:
Django: is there a way to count SQL queries from an unit test?
I am trying to find out the number of queries executed by a utility function. I have written a unit test for this function and the function is working well. What I would like to do is track the number of SQL queries executed by the function so that I can see if there is any improvement after some refactoring.

```<code>def do_something_in_the_database():
    # Does something in the database
    # return result

class DoSomethingTests(django.test.TestCase):
    def test_function_returns_correct_values(self):
        self.assertEqual(n, <number of SQL queries executed>)
</code>```

EDIT: I found out that there is a pending Django feature request for this. However the ticket is still open. In the meantime is there another way to go about this?

答:
If you are using pytest, pytest-django has django_assert_num_queries fixture for this purpose:

```<code>def test_queries(django_assert_num_queries):
    with django_assert_num_queries(3):
        Item.objects.create('foo')
        Item.objects.create('bar')
        Item.objects.create('baz')
</code>```

Body:
I am trying to find out the number of queries executed by a utility function. I have written a unit test for this function and the function is working well. What I would like to do is track the number of SQL queries executed by the function so that I can see if there is any improvement after some refactoring.

def do_something_in_the_database():
    # Does something in the database
    # return result

class DoSomethingTests(django.test.TestCase):
    def test_function_returns_correct_values(self):
        self.assertEqual(n, <number of SQL queries executed>)

EDIT: I found out that there is a pending Django feature request for this. However the ticket is still open. In the meantime is there another way to go about this?

Body:
If you are using pytest, pytest-django has django_assert_num_queries fixture for this purpose:

def test_queries(django_assert_num_queries):
    with django_assert_num_queries(3):
        Item.objects.create('foo')
        Item.objects.create('bar')
        Item.objects.create('baz')


问:
Why my feature extraction script fails?
I have used the following script , to extract features vectors of my dataset using AlexNet pretrained model.

I extract feature vectors  from fully connected layer 7  and save it on HICKLE format.

The files that are used in the code below :

-train.txt contains the path of 5000 images

-val.txt  contains the path of 1000 images

After few iterations , I got this error error == cudaSuccess (2 vs. 0)  out of memory .
I know that my gpu is out memory . Would you help me to correct this issue ?

```<code>import numpy as np
import hickle as hkl
import caffe

caffe.set_mode_gpu()

def feature_extract(img):

    model_file='/home/jaba/caffe/data/diota_model/feature_extractor/bvlc_reference_caffenet.caffemodel'
    deploy_file='/home/jaba/caffe/data/diota_model/feature_extractor/alex.deployprototxt'

    net=caffe.Net(deploy_file,model_file,caffe.TEST)

    mean_values=np.array([103.939, 116.779, 123.68])

    #setting the transformer

    transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
    transformer.set_mean('data', mean_values ) #subtract by mean
    transformer.set_transpose('data', (2,0,1)) #(H,W,C) => (C,H,W)
    transformer.set_raw_scale('data', 255.0)   #[0.0, 1.0] => [0.0, 255.0]
    transformer.set_channel_swap("data", (2,1,0)) # RGB => BGR

    #img = caffe.io.load_image(img)

    net.blobs['data'].data[...] = transformer.preprocess('data', img)

    output=net.forward()

    feat=net.blobs['fc7'].data.copy()

    return feat

def create_dataset(datalist,db_prefix):
    with open(datalist) as fr:
            lines = fr.readlines()
    lines = [line.rstrip() for line in lines]

    feats = []
    labels = []

    for line_i, line in enumerate(lines):

        a=len(line)
        label=line[a-1]
        img_path=line[0:a-2]
            img = caffe.io.load_image(img_path)
            feat = feature_extract(img)
            feats.append(feat)
            label = int(label)
            labels.append(label)
            if (line_i + 1) % 100 == 0:
                    print "processed", line_i + 1

    feats = np.asarray(feats)
    labels = np.asarray(labels)

    hkl.dump(feats, dbprefix + "_features.hkl", mode="w")
    hkl.dump(labels, dbprefix + "_labels.hkl", mode="w")

create_dataset('train.txt','vgg_fc7_train')
create_dataset('val.txt','vgg_fc7_test')
</code>```

for the deploy file :

```<code>name: "AlexNet"
layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param { shape: { dim: 1 dim: 3 dim: 227 dim: 227 } }
}
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 96
    kernel_size: 11
    stride: 4
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "conv1"
  top: "conv1"
}
layer {
  name: "norm1"
  type: "LRN"
  bottom: "conv1"
  top: "norm1"
  lrn_param {
    local_size: 5
    alpha: 0.0001
    beta: 0.75
  }
}
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "norm1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "conv2"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 256
    pad: 2
    kernel_size: 5
    group: 2
  }
}
layer {
  name: "relu2"
  type: "ReLU"
  bottom: "conv2"
  top: "conv2"
}
layer {
  name: "norm2"
  type: "LRN"
  bottom: "conv2"
  top: "norm2"
  lrn_param {
    local_size: 5
    alpha: 0.0001
    beta: 0.75
  }
}
layer {
  name: "pool2"
  type: "Pooling"
  bottom: "norm2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "conv3"
  type: "Convolution"
  bottom: "pool2"
  top: "conv3"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 384
    pad: 1
    kernel_size: 3
  }
}
layer {
  name: "relu3"
  type: "ReLU"
  bottom: "conv3"
  top: "conv3"
}
layer {
  name: "conv4"
  type: "Convolution"
  bottom: "conv3"
  top: "conv4"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 384
    pad: 1
    kernel_size: 3
    group: 2
  }
}
layer {
  name: "relu4"
  type: "ReLU"
  bottom: "conv4"
  top: "conv4"
}
layer {
  name: "conv5"
  type: "Convolution"
  bottom: "conv4"
  top: "conv5"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 256
    pad: 1
    kernel_size: 3
    group: 2
  }
}
layer {
  name: "relu5"
  type: "ReLU"
  bottom: "conv5"
  top: "conv5"
}
layer {
  name: "pool5"
  type: "Pooling"
  bottom: "conv5"
  top: "pool5"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "fc6"
  type: "InnerProduct"
  bottom: "pool5"
  top: "fc6"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 4096
  }
}
layer {
  name: "relu6"
  type: "ReLU"
  bottom: "fc6"
  top: "fc6"
}
layer {
  name: "drop6"
  type: "Dropout"
  bottom: "fc6"
  top: "fc6"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc7"
  type: "InnerProduct"
  bottom: "fc6"
  top: "fc7"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 4096
  }
}
layer {
  name: "relu7"
  type: "ReLU"
  bottom: "fc7"
  top: "fc7"
}
layer {
  name: "drop7"
  type: "Dropout"
  bottom: "fc7"
  top: "fc7"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc8"
  type: "InnerProduct"
  bottom: "fc7"
  top: "fc8"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 1000
  }
}
layer {
  name: "prob"
  type: "Softmax"
  bottom: "fc8"
  top: "prob"
}
</code>```

答: Reduce your batch size. That is the simplest fix in this condition. You may keep a minimum ```batch size`` of 1. Go on increasing it to find the limit for your GPU. You have to live with that figure with the current GPU.

Title: Why my feature extraction script fails?

Body:
I have used the following script , to extract features vectors of my dataset using AlexNet pretrained model.

I extract feature vectors  from fully connected layer 7  and save it on HICKLE format.

The files that are used in the code below :

-train.txt contains the path of 5000 images

-val.txt  contains the path of 1000 images

After few iterations , I got this error error == cudaSuccess (2 vs. 0)  out of memory .
I know that my gpu is out memory . Would you help me to correct this issue ?

import numpy as np
import hickle as hkl
import caffe

caffe.set_mode_gpu()

def feature_extract(img):

    model_file='/home/jaba/caffe/data/diota_model/feature_extractor/bvlc_reference_caffenet.caffemodel'
    deploy_file='/home/jaba/caffe/data/diota_model/feature_extractor/alex.deployprototxt'

    net=caffe.Net(deploy_file,model_file,caffe.TEST)

    mean_values=np.array([103.939, 116.779, 123.68])

    #setting the transformer

    transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})
    transformer.set_mean('data', mean_values ) #subtract by mean
    transformer.set_transpose('data', (2,0,1)) #(H,W,C) => (C,H,W)
    transformer.set_raw_scale('data', 255.0)   #[0.0, 1.0] => [0.0, 255.0]
    transformer.set_channel_swap("data", (2,1,0)) # RGB => BGR

    #img = caffe.io.load_image(img)

    net.blobs['data'].data[...] = transformer.preprocess('data', img)

    output=net.forward()

    feat=net.blobs['fc7'].data.copy()

    return feat

def create_dataset(datalist,db_prefix):
    with open(datalist) as fr:
            lines = fr.readlines()
    lines = [line.rstrip() for line in lines]

    feats = []
    labels = []

    for line_i, line in enumerate(lines):

        a=len(line)
        label=line[a-1]
        img_path=line[0:a-2]
            img = caffe.io.load_image(img_path)
            feat = feature_extract(img)
            feats.append(feat)
            label = int(label)
            labels.append(label)
            if (line_i + 1) % 100 == 0:
                    print "processed", line_i + 1

    feats = np.asarray(feats)
    labels = np.asarray(labels)

    hkl.dump(feats, dbprefix + "_features.hkl", mode="w")
    hkl.dump(labels, dbprefix + "_labels.hkl", mode="w")

create_dataset('train.txt','vgg_fc7_train')
create_dataset('val.txt','vgg_fc7_test')

for the deploy file :

name: "AlexNet"
layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param { shape: { dim: 1 dim: 3 dim: 227 dim: 227 } }
}
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 96
    kernel_size: 11
    stride: 4
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "conv1"
  top: "conv1"
}
layer {
  name: "norm1"
  type: "LRN"
  bottom: "conv1"
  top: "norm1"
  lrn_param {
    local_size: 5
    alpha: 0.0001
    beta: 0.75
  }
}
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "norm1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "conv2"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 256
    pad: 2
    kernel_size: 5
    group: 2
  }
}
layer {
  name: "relu2"
  type: "ReLU"
  bottom: "conv2"
  top: "conv2"
}
layer {
  name: "norm2"
  type: "LRN"
  bottom: "conv2"
  top: "norm2"
  lrn_param {
    local_size: 5
    alpha: 0.0001
    beta: 0.75
  }
}
layer {
  name: "pool2"
  type: "Pooling"
  bottom: "norm2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "conv3"
  type: "Convolution"
  bottom: "pool2"
  top: "conv3"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 384
    pad: 1
    kernel_size: 3
  }
}
layer {
  name: "relu3"
  type: "ReLU"
  bottom: "conv3"
  top: "conv3"
}
layer {
  name: "conv4"
  type: "Convolution"
  bottom: "conv3"
  top: "conv4"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 384
    pad: 1
    kernel_size: 3
    group: 2
  }
}
layer {
  name: "relu4"
  type: "ReLU"
  bottom: "conv4"
  top: "conv4"
}
layer {
  name: "conv5"
  type: "Convolution"
  bottom: "conv4"
  top: "conv5"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 256
    pad: 1
    kernel_size: 3
    group: 2
  }
}
layer {
  name: "relu5"
  type: "ReLU"
  bottom: "conv5"
  top: "conv5"
}
layer {
  name: "pool5"
  type: "Pooling"
  bottom: "conv5"
  top: "pool5"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "fc6"
  type: "InnerProduct"
  bottom: "pool5"
  top: "fc6"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 4096
  }
}
layer {
  name: "relu6"
  type: "ReLU"
  bottom: "fc6"
  top: "fc6"
}
layer {
  name: "drop6"
  type: "Dropout"
  bottom: "fc6"
  top: "fc6"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc7"
  type: "InnerProduct"
  bottom: "fc6"
  top: "fc7"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 4096
  }
}
layer {
  name: "relu7"
  type: "ReLU"
  bottom: "fc7"
  top: "fc7"
}
layer {
  name: "drop7"
  type: "Dropout"
  bottom: "fc7"
  top: "fc7"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc8"
  type: "InnerProduct"
  bottom: "fc7"
  top: "fc8"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  inner_product_param {
    num_output: 1000
  }
}
layer {
  name: "prob"
  type: "Softmax"
  bottom: "fc8"
  top: "prob"
}


问:
Error FrameLayout in android 6 But not library
Image for Example

ChildFragment Exmple

OneFragment.java

public class OneFragment extends Fragment  {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i("Fragment Demo", "Fragment_One onCreate()");
  }

  public OneFragment() {
    // Required empty public constructor
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_one, container, false);

    return rootView;
  }
  @Override
  public void onAttach(Context newBase) {
    super.onAttach(CalligraphyContextWrapper.wrap(newBase));
  }
}```
</div>
</div>
</p>

<p>fragment_one.xml</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context=".fragment.OneFragment">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:gravity="center"
    android:layout_margin="16dp"
    android:orientation="vertical">

    <ImageView

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:tint="@color/grey_blue_100"
        android:src="@android:drawable/ic_dialog_alert"/>
    <TextView
        android:gravity="center"
        android:textSize="16sp"
        android:textColor="@color/grey_blue_100"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="نقشه گوگل در حال حاضر در دسترس نمی باشد"/>
</LinearLayout>

</RelativeLayout></code>```

MainFragment.java

public class RegisterFragment extends Fragment implements View.OnClickListener {

  private FragmentActivity myContext;
  private Fragment fragment;
  private View rootView;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i("Fragment Demo", "Fragment_One onCreate()");
  }

  public RegisterFragment() {
    // Required empty public constructor
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {

      rootView = inflater.inflate(R.layout.fragment_register_6, container, false);

    Button btnOne = (Button) rootView.findViewById(R.id.btn_one);
    btnOne.setOnClickListener(this);
    Button btnTwo = (Button) rootView.findViewById(R.id.btn_two);
    btnTwo.setOnClickListener(this);
    Button btnFinal = (Button) rootView.findViewById(R.id.btn_three);
    btnFinal.setOnClickListener(this);

    // This is default Fragment for RegisterFragment
      setFragmentUp(new OneFragment());

    return rootView;
  }

  @Override
  public void onClick(View v) {

    fragment = null;
    switch (v.getId()) {
      case R.id.btn_one:
        fragment = new OneFragment();
        break;
      case R.id.btn_two:
        fragment = new TwoFragment();
        break;
      case R.id.btn_three:
        fragment = new FinalFragment();
        break;
      default:
        break;
    }

    if (fragment != null) {
      setFragmentUp(fragment);
    }
  }

  @Override
  public void onAttach(Activity activity) {
    myContext = (FragmentActivity) activity;
    super.onAttach(activity);
  }

  protected void setFragmentUp(Fragment fragment) {
    myContext.getSupportFragmentManager().beginTransaction()
      .replace(R.id.fragRegisterUp, fragment, fragment.getClass().getSimpleName()).addToBackStack(null).commit();
  }

  @Override
  public void onAttach(Context newBase) {
    super.onAttach(CalligraphyContextWrapper.wrap(newBase));
  }
}```
</div>
</div>
</p>

<p>fragment_main.xml</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorAccent"
    android:orientation="vertical"
    tools:context="com.fanavartech.android.ham_bar_v002.fragment.RegisterFragment">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:layout_marginTop="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginLeft="16dp"
    android:layout_marginBottom="16dp"
    android:background="@android:color/white"
    android:orientation="horizontal">

    <com.andexert.library.RippleView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        app:rv_rippleDuration="114"
        app:rv_color="@color/colorPrimaryDark"
        rv_centered="true">
    <Button
        android:id="@+id/btn_one"
        android:layout_width="match_parent"
        android:text="اطلاعات بار"
        android:textSize="16sp"
        android:textStyle="bold"
        android:background="@null"
        android:layout_height="match_parent"/>
    </com.andexert.library.RippleView>

    <com.andexert.library.RippleView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        app:rv_rippleDuration="114"
        app:rv_color="@color/colorPrimaryDark"
        rv_centered="true">
    <Button
        android:id="@+id/btn_two"
        android:text="اطلاعات مسیر"
        android:textSize="16sp"
        android:textStyle="bold"
        android:background="@null"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    </com.andexert.library.RippleView>

    <com.andexert.library.RippleView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        app:rv_rippleDuration="114"
        app:rv_color="@color/colorPrimaryDark"
        rv_centered="true">
    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/btn_three"
        android:text="پرداخت"
        android:textSize="16sp"
        android:textStyle="bold"
        android:background="@null"/>
    </com.andexert.library.RippleView>

</LinearLayout>

    <FrameLayout
        android:id="@+id/fragRegister"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_margin="16dp"/>

</LinearLayout></code>```

MainActivity.java

public class FirstActivity extends AppCompatActivity
  implements NavigationView.OnNavigationItemSelectedListener {

  private Toolbar toolbar;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_first);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
    }

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, drawer, toolbar, R.string.drawer_open , R.string.drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    Toast.makeText(FirstActivity.this, "ثبت بار", Toast.LENGTH_SHORT).show();
    toolbar.setTitle(R.string.nav_register);
    Fragment fragment = new RegisterFragment();
    getSupportFragmentManager().beginTransaction()
      .replace(R.id.container_body, fragment, fragment.getClass().getSimpleName()).addToBackStack(null).commit();
}```
</div>
</div>
</p>

<p>activity_main.xml</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/container_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar"/>

        </LinearLayout>

        <android.support.percent.PercentFrameLayout
            android:id="@+id/container_body"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"/>

    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/header"
        app:menu="@menu/activity_main_drawer"/>

</android.support.v4.widget.DrawerLayout></code>```

Error Massage

06-05 13:16:55.049 4867-4867/com.fanavartech.android.ham_bar__v002 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.ham_v002, PID: 4867
java.lang.IllegalStateException: Underflow in restore - more restores than saves
at android.graphics.Canvas.native_restore(Native Method)
at android.graphics.Canvas.restore(Canvas.java:540)
at com.andexert.library.RippleView.draw(RippleView.java:166)
at android.view.View.updateDisplayListIfDirty(View.java:15174)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2615)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2434)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2067)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)```

for Android version 6 error, but at lower Android working properly.
Where is the problem?

答:
You can try two approaches:

"Just downgrade your - targetSdkVersion to 22 It works for all
versions" - This works fine if you have not launched your app with
targetSdkVersion 23 yet.

If you already have launched your app with targetSdkVersion 23 then,
instead of adding compile 'com.github.traex.rippleeffect:library:1.3'
in dependancies, Download the project by clicking on link -
https://codeload.github.com/traex/RippleEffect/zip/master

Get library from that and use that in your app. It's probably gonna work :)

Body:
Image for Example

ChildFragment Exmple

OneFragment.java

public class OneFragment extends Fragment  {

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i("Fragment Demo", "Fragment_One onCreate()");
  }

  public OneFragment() {
    // Required empty public constructor
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_one, container, false);

    return rootView;
  }
  @Override
  public void onAttach(Context newBase) {
    super.onAttach(CalligraphyContextWrapper.wrap(newBase));
  }
}

fragment_one.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context=".fragment.OneFragment">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:gravity="center"
    android:layout_margin="16dp"
    android:orientation="vertical">

    <ImageView

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:tint="@color/grey_blue_100"
        android:src="@android:drawable/ic_dialog_alert"/>
    <TextView
        android:gravity="center"
        android:textSize="16sp"
        android:textColor="@color/grey_blue_100"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="نقشه گوگل در حال حاضر در دسترس نمی باشد"/>
</LinearLayout>

</RelativeLayout>

MainFragment.java

public class RegisterFragment extends Fragment implements View.OnClickListener {

  private FragmentActivity myContext;
  private Fragment fragment;
  private View rootView;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i("Fragment Demo", "Fragment_One onCreate()");
  }

  public RegisterFragment() {
    // Required empty public constructor
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {

      rootView = inflater.inflate(R.layout.fragment_register_6, container, false);

    Button btnOne = (Button) rootView.findViewById(R.id.btn_one);
    btnOne.setOnClickListener(this);
    Button btnTwo = (Button) rootView.findViewById(R.id.btn_two);
    btnTwo.setOnClickListener(this);
    Button btnFinal = (Button) rootView.findViewById(R.id.btn_three);
    btnFinal.setOnClickListener(this);

    // This is default Fragment for RegisterFragment
      setFragmentUp(new OneFragment());

    return rootView;
  }

  @Override
  public void onClick(View v) {

    fragment = null;
    switch (v.getId()) {
      case R.id.btn_one:
        fragment = new OneFragment();
        break;
      case R.id.btn_two:
        fragment = new TwoFragment();
        break;
      case R.id.btn_three:
        fragment = new FinalFragment();
        break;
      default:
        break;
    }

    if (fragment != null) {
      setFragmentUp(fragment);
    }
  }

  @Override
  public void onAttach(Activity activity) {
    myContext = (FragmentActivity) activity;
    super.onAttach(activity);
  }

  protected void setFragmentUp(Fragment fragment) {
    myContext.getSupportFragmentManager().beginTransaction()
      .replace(R.id.fragRegisterUp, fragment, fragment.getClass().getSimpleName()).addToBackStack(null).commit();
  }

  @Override
  public void onAttach(Context newBase) {
    super.onAttach(CalligraphyContextWrapper.wrap(newBase));
  }
}

fragment_main.xml

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorAccent"
    android:orientation="vertical"
    tools:context="com.fanavartech.android.ham_bar_v002.fragment.RegisterFragment">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:layout_marginTop="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginLeft="16dp"
    android:layout_marginBottom="16dp"
    android:background="@android:color/white"
    android:orientation="horizontal">

    <com.andexert.library.RippleView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        app:rv_rippleDuration="114"
        app:rv_color="@color/colorPrimaryDark"
        rv_centered="true">
    <Button
        android:id="@+id/btn_one"
        android:layout_width="match_parent"
        android:text="اطلاعات بار"
        android:textSize="16sp"
        android:textStyle="bold"
        android:background="@null"
        android:layout_height="match_parent"/>
    </com.andexert.library.RippleView>

    <com.andexert.library.RippleView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        app:rv_rippleDuration="114"
        app:rv_color="@color/colorPrimaryDark"
        rv_centered="true">
    <Button
        android:id="@+id/btn_two"
        android:text="اطلاعات مسیر"
        android:textSize="16sp"
        android:textStyle="bold"
        android:background="@null"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    </com.andexert.library.RippleView>

    <com.andexert.library.RippleView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        app:rv_rippleDuration="114"
        app:rv_color="@color/colorPrimaryDark"
        rv_centered="true">
    <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/btn_three"
        android:text="پرداخت"
        android:textSize="16sp"
        android:textStyle="bold"
        android:background="@null"/>
    </com.andexert.library.RippleView>

</LinearLayout>

    <FrameLayout
        android:id="@+id/fragRegister"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_margin="16dp"/>

</LinearLayout>

MainActivity.java

public class FirstActivity extends AppCompatActivity
  implements NavigationView.OnNavigationItemSelectedListener {

  private Toolbar toolbar;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_first);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
    }

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, drawer, toolbar, R.string.drawer_open , R.string.drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    Toast.makeText(FirstActivity.this, "ثبت بار", Toast.LENGTH_SHORT).show();
    toolbar.setTitle(R.string.nav_register);
    Fragment fragment = new RegisterFragment();
    getSupportFragmentManager().beginTransaction()
      .replace(R.id.container_body, fragment, fragment.getClass().getSimpleName()).addToBackStack(null).commit();
}

activity_main.xml

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:id="@+id/container_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar"/>

        </LinearLayout>

        <android.support.percent.PercentFrameLayout
            android:id="@+id/container_body"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"/>

    </LinearLayout>

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/header"
        app:menu="@menu/activity_main_drawer"/>

</android.support.v4.widget.DrawerLayout>

Error Massage

06-05 13:16:55.049 4867-4867/com.fanavartech.android.ham_bar__v002 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.android.ham_v002, PID: 4867
java.lang.IllegalStateException: Underflow in restore - more restores than saves
at android.graphics.Canvas.native_restore(Native Method)
at android.graphics.Canvas.restore(Canvas.java:540)
at com.andexert.library.RippleView.draw(RippleView.java:166)
at android.view.View.updateDisplayListIfDirty(View.java:15174)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3593)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3573)
at android.view.View.updateDisplayListIfDirty(View.java:15134)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2615)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2434)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2067)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
at android.view.Choreographer.doCallbacks(Choreographer.java:670)
at android.view.Choreographer.doFrame(Choreographer.java:606)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

for Android version 6 error, but at lower Android working properly.
Where is the problem?


问:
rails 3 test case error.on(:field) Vs. errors[:field]
I am working on the Rails 3 Test cases . While writing case i got Deprecation error like

```<code>DEPRECATION WARNING: Errors#on have been deprecated, use Errors#[] instead.
Also note that the behaviour of Errors#[] has changed. Errors#[] now always returns an Array. An empty Array is returned when there are no errors on the specified attribute. (called from on at /usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.0.0.rc/lib/active_model/deprecated_error_methods.rb:7)
</code>```

For that i used errors[:field] instead of errors.on(:field)
Now Deprecation error is gone , but cases are not working as earlier it was working . It is not testing any validation for the model

Sol

答:
After searching for examples of how to do this without finding anything I ended up doing:

```<code>errors[:field].present? /  errors[:field].blank?
</code>```

Don't know if this is the preferred way but it seems to do the job.

Body:
I am working on the Rails 3 Test cases . While writing case i got Deprecation error like

DEPRECATION WARNING: Errors#on have been deprecated, use Errors#[] instead.
Also note that the behaviour of Errors#[] has changed. Errors#[] now always returns an Array. An empty Array is returned when there are no errors on the specified attribute. (called from on at /usr/local/lib/ruby/gems/1.9.1/gems/activemodel-3.0.0.rc/lib/active_model/deprecated_error_methods.rb:7)

For that i used errors[:field] instead of errors.on(:field)
Now Deprecation error is gone , but cases are not working as earlier it was working . It is not testing any validation for the model

Sol

Body:
After searching for examples of how to do this without finding anything I ended up doing:

errors[:field].present? /  errors[:field].blank?

Don't know if this is the preferred way but it seems to do the job.


答:
You just need to use the jQuery data() method with the right selector, like this:

```<code>$('select option:selected').data('key');
</code>```

Demo:

var key = $('select option:selected').data('key');
console.log(key);```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<td class="" data-id="46" contenteditable="true">
<select class="form-control">
   <option data-key="end" selected>Opt1</option>
   <option data-key="operator_transfer">Opt2</option>
   <option data-key="process_script">Opt3</option>
</select>
</td></code>```

And you can update your code like this:

```<code>if (selectObject.length) { // if it is a select
  localobj[dataattr] = selectObject[0].getAttribute('data-key');
}
$(selectObject).find('option:selected').data('key');
</code>```

Title: Javascript get data attribute from selected option in a table

Body:
I got the following html:

<select class="form-control">
   <option data-key="end" selected>Opt1</option>
   <option data-key="operator_transfer">Opt2</option>
   <option data-key="process_script">Opt3</option>
</select>

I need to get data attribute of the selected option. I am trying to do it that way:

var cell = $row.find(':nth-child(4)');
dataattr = cell[0].getAttribute('data-id');
var selectObject = cell.find("select");
if(selectObject.length){// if it is a select
    localobj[dataattr] = selectObject[0].getAttribute('data-key');//val(); previously it was val() here but now I want data-key
}

I tried with this:

$(selectObject/*need to insert something here*/ + ' option:selected').data('key');

but it is showing me an error saying that it is an object Object. I need to insert something after selectObject. Any ideas how to fix that?

Thank you.

Body:
You just need to use the jQuery data() method with the right selector, like this:

$('select option:selected').data('key');

Demo:

var key = $('select option:selected').data('key');
console.log(key);

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<td class="" data-id="46" contenteditable="true">
<select class="form-control">
   <option data-key="end" selected>Opt1</option>
   <option data-key="operator_transfer">Opt2</option>
   <option data-key="process_script">Opt3</option>
</select>
</td>

And you can update your code like this:

if (selectObject.length) { // if it is a select
  localobj[dataattr] = selectObject[0].getAttribute('data-key');
}
$(selectObject).find('option:selected').data('key');


问:
Cannot we initialize a variable in constructor as follows? [Angular2]
I just started learning angular-2. The string "Pikolo" does not show up in the end-html, when the class appcomponent is as follows:

```<code>export class AppComponent {
    mideos:String;
    construtor(){
        this.mideos = "Pikolo";
    }
}
</code>```

I do not think there is a  problem with passing the variable thru components and/or binding with html because the value appears,  when I change the code as follows:

```<code>export class AppComponent {
    mideos:String = "Pikolo";
    construtor(){

    }
}
</code>```

I am really confused. Thanks in advance.

答:
Angular2 Component's constructor specifically for DI purposes,Initializing a property in the constructor allows you to leverage constructor parameters when you're initializing the property.

There is no difference in generated JS between the two.

EDIT:
your code has a typo error

```<code>export class AppComponent {
    mideos:String;
    constructor(){
        this.mideos = "Pikolo";
    }
}
</code>```

Body:
I just started learning angular-2. The string "Pikolo" does not show up in the end-html, when the class appcomponent is as follows:

export class AppComponent {
    mideos:String;
    construtor(){
        this.mideos = "Pikolo";
    }
}

I do not think there is a  problem with passing the variable thru components and/or binding with html because the value appears,  when I change the code as follows:

export class AppComponent {
    mideos:String = "Pikolo";
    construtor(){

    }
}

I am really confused. Thanks in advance.

Body:
Angular2 Component's constructor specifically for DI purposes,Initializing a property in the constructor allows you to leverage constructor parameters when you're initializing the property.

There is no difference in generated JS between the two.

EDIT:
your code has a typo error

export class AppComponent {
    mideos:String;
    constructor(){
        this.mideos = "Pikolo";
    }
}


问:
OSError: out of pty devices with python sh
I am running a pyinstaller binary in a chroot environment. The following code produces a traceback.

```<code>from sh import ps, grep
    grep(ps('-ef'), '[p]rovision_storage.py', _tty_in=True)

File "sh.py", line 1427, in call
File "sh.py", line 767, in init
File "sh.py", line 1780, in init
File "pty.py", line 29, in openpty
File "pty.py", line 70, in _open_terminal
OSError: out of pty devices
</code>```

_tty_in set to False also produces the same traceback.

Environment: Pyinstaller binary compiled with Python 2.7.13
Compile/Runtime chroot OS: Debian Stretch

答:
Just mount devpts device into the chroot environment:

```<code># mount --bind /dev /path/to/chroot/dev
# mount -t devpts none /path/to/chroot/dev/pts
</code>```

Body:
I am running a pyinstaller binary in a chroot environment. The following code produces a traceback.

from sh import ps, grep
    grep(ps('-ef'), '[p]rovision_storage.py', _tty_in=True)

File "sh.py", line 1427, in call
File "sh.py", line 767, in init
File "sh.py", line 1780, in init
File "pty.py", line 29, in openpty
File "pty.py", line 70, in _open_terminal
OSError: out of pty devices

_tty_in set to False also produces the same traceback.

Environment: Pyinstaller binary compiled with Python 2.7.13
Compile/Runtime chroot OS: Debian Stretch

Body:
Just mount devpts device into the chroot environment:

# mount --bind /dev /path/to/chroot/dev
# mount -t devpts none /path/to/chroot/dev/pts


问:
How do I correctly manually recreate sklearn (python) logistic regression predict_proba outcome for multiple classification
If I run a basic logistic regression with 4 classes, I can get the predict_proba array.

How can i manually calculate the probabilities using the coefficients and intercepts?   What are the exact steps to get the same answers that predict_proba generates?

There seem to be multiple questions about this online and several suggestions which are either incomplete or don't match up anyway.

For example, I can't replicate this process from my sklearn model so what is missing?

https://stats.idre.ucla.edu/stata/code/manually-generate-predicted-probabilities-from-a-multinomial-logistic-regression-in-stata/

Thanks,

答:
Replicate sklearn calcs (saw this on a different post):

```<code>V = X_train.values.dot(model.coef_.transpose())
U = V + model.intercept_
A = np.exp(U)
P=A/(1+A)
P /= P.sum(axis=1).reshape((-1, 1))
</code>```

seems slightly different than softmax calcs, or the UCLA stat example, but it works.

Body:
Replicate sklearn calcs (saw this on a different post):

V = X_train.values.dot(model.coef_.transpose())
U = V + model.intercept_
A = np.exp(U)
P=A/(1+A)
P /= P.sum(axis=1).reshape((-1, 1))

seems slightly different than softmax calcs, or the UCLA stat example, but it works.


问:
How do I Serialize object to json using json.net which contains an image property
I have an object with a number of public properties where one is of type image.  I am trying to serialise this using json.net and assume that I will need to base64 encode this and serialise the resultant string.  I have tried with the BinaryConverter against the property without success below

```<code>public class Person
{
    public string name { get; set; }

    public int age { get; set; }

    [JsonConverter(typeof(BinaryConverter))]
    public Image photo { get; set; }

    public string ToJson()
    {
        return JsonConvert.SerializeObject(this);
    }
}
</code>```

When called with this test code...

```<code>var p = new Person();
p.name = "John Doe";
p.age = 99;
p.photo = Image.FromFile(@"dea4007a-c812-41e9-b09a-c7793c6e853d.jpg");

var json = p.ToJson();
Console.WriteLine(json);
Console.ReadKey();
</code>```

I get an exception "Unexpected value type when writing binary".  Any help would be very helpful as I have been searching the web for a while now without success.

答: I would recommend in this case to convert the image to base64 and then serialize it, here an example of how to do it in C#: Convert Image to Base64 </p>

Body:
I have an object with a number of public properties where one is of type image.  I am trying to serialise this using json.net and assume that I will need to base64 encode this and serialise the resultant string.  I have tried with the BinaryConverter against the property without success below

public class Person
{
    public string name { get; set; }

    public int age { get; set; }

    [JsonConverter(typeof(BinaryConverter))]
    public Image photo { get; set; }

    public string ToJson()
    {
        return JsonConvert.SerializeObject(this);
    }
}

When called with this test code...

var p = new Person();
p.name = "John Doe";
p.age = 99;
p.photo = Image.FromFile(@"dea4007a-c812-41e9-b09a-c7793c6e853d.jpg");

var json = p.ToJson();
Console.WriteLine(json);
Console.ReadKey();

I get an exception "Unexpected value type when writing binary".  Any help would be very helpful as I have been searching the web for a while now without success.


问:
Checking if an index exists in a non-optional Array
I have this array:

```<code>var currentTouches = [UITouch]()
</code>```

At any point, it may contain 0-5 UITouches. I want to check each index and do something with the content if it exists.

But I cannot find a way to check without getting an error. The problem seems to be, that UITouch isn't an optional, so I can't just ask if it is nil.

What do I do? I tried making it an optional, but that makes much of my other code unusual. Surely there must be a simple solution.

答:
The valid indices of currentTouches are simply currentTouches.indices.  So to check if an index i is valid, you could check if currentTouches.indices.contains(i).  You could also check if i < currentTouches.count (assuming you already know that i >= 0).

An easier way of doing that would be to just loop on the valid indices and handle each in turn:

```<code>for index in currentTouches.indices {
    // handle value at index
}
</code>```

Or if you don't care about the indices:

```<code>for touch in currentTouches {
    // handle touch
}
</code>```

Even better is to use enumerated() which gives you a tuple containing the index and value:

```<code>for (index, touch) in currentTouches.enumerated() {
    // handle touch at index
}
</code>```

Body:
I have this array:

var currentTouches = [UITouch]()

At any point, it may contain 0-5 UITouches. I want to check each index and do something with the content if it exists.

But I cannot find a way to check without getting an error. The problem seems to be, that UITouch isn't an optional, so I can't just ask if it is nil.

What do I do? I tried making it an optional, but that makes much of my other code unusual. Surely there must be a simple solution.

Body:
The valid indices of currentTouches are simply currentTouches.indices.  So to check if an index i is valid, you could check if currentTouches.indices.contains(i).  You could also check if i < currentTouches.count (assuming you already know that i >= 0).

An easier way of doing that would be to just loop on the valid indices and handle each in turn:

for index in currentTouches.indices {
    // handle value at index
}

Or if you don't care about the indices:

for touch in currentTouches {
    // handle touch
}

Even better is to use enumerated() which gives you a tuple containing the index and value:

for (index, touch) in currentTouches.enumerated() {
    // handle touch at index
}


问:
Is there a JQuery plugin for displaying default text in a text field?
When I hit the page, the text box says "Search...", in gray font.

Then, I click the textbox.  Then, the "search..." disappears. And I can type.

答:
I offer my own solution to this: http://tholljos.lu/mike/files/watermark.zip

jQuery(selector).watermark('here be text...','cssClass');

'here be text' will be your watermark text.
'cssClass' is a css class that is added to the input field in order to style the watermark text.

AFAIAC this covers pretty much every edge case I have encountered so far. Of course, you can use the other plugins if you want, but I find my solution simple and effective.


问:
Casting between sequential unsafe structs
I'm trying to port some netlink socket code from C to C#. The code is the same as in the link:

First, we port sockaddr_nl structure (c source):

```<code>[StructLayout(LayoutKind.Sequential)]
public struct sockaddr_nl
{
    public ushort nl_family;
    public ushort nl_pad;
    public uint nl_pid;
    public uint nl_groups;
}
</code>```

Then, get a socket fd using

```<code>var fd = -1;
fd = UnixFiller.socket(
    (int) UnixAddressFamily.AF_NETLINK,
    (int) UnixSocketType.SOCK_RAW | 0x80000,
    0 /* NETLINK_ROUTE */
);
if(fd < 0)
    FatalError("Failed to create routing socket.");
</code>```

UnixFiller.socket is just a DLLImport from libc. This call succeeds as expected.

However, the next step would be to cast the expressive sockaddr_nl structure to the family + byte array structure sockaddr consumed by bind:

```<code>bind(fd, (struct sockaddr*)&address, sizeof(address));
</code>```

Where sockaddr is

```<code>struct sockaddr {
    sa_family_t sa_family;  /* address family, AF_xxx   */
    char        sa_data[14];    /* 14 bytes of protocol address */
};
</code>```

Which, as far as I know, would be this in C#:

```<code>[StructLayout(LayoutKind.Sequential)]
public struct sockaddr
{
    public ushort sa_familiy;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] byte[] sa_data;
}
</code>```

Question

First, how should the bind import look like?

```<code>[DllImport("libc", SetLastError = true, EntryPoint = "bind")]
public static extern int bind(int sockfd, ??? addr, int addrlen);
</code>```

??? = unknown.

Next, how can I port the cast from sockaddr_nl to sockaddr in order to pass the right format to bind?

答:
You can't cast between sockaddr_nl and sockaddr because you have a reference (sa_data) that is going to get in the way. If it was a fixed buffer instead (i.e. raw data directly in the struct), then it would probably be fine, but then you need to use unsafe throughout. However, I'm unclear what that would look like; It looks like you mean that the 14 bytes of sa_data shuld be the contents of sockaddr_nl ? (I only count 12 bytes, note)

To write a struct over a byte[], you can use unsafe code:

```<code>static unsafe void Main()
{
    var val = new sockaddr_nl
    {
        nl_family = 1, nl_pad = 2, nl_pid = 3, nl_groups = 4
    };
    byte[] data = new byte[14];
    Console.WriteLine("size of struct: " + sizeof(sockaddr_nl));
    // show value before
    Console.WriteLine(BitConverter.ToString(data));
    // thunk over the data
    fixed (byte* p = data)
    {
        *((sockaddr_nl*)p) = val;
    }
    // show value after
    Console.WriteLine(BitConverter.ToString(data));
}
</code>```

This has the output:

```<code>size of struct: 12
00-00-00-00-00-00-00-00-00-00-00-00-00-00
01-00-02-00-03-00-00-00-04-00-00-00-00-00
</code>```

Body:
I'm trying to port some netlink socket code from C to C#. The code is the same as in the link:

First, we port sockaddr_nl structure (c source):

[StructLayout(LayoutKind.Sequential)]
public struct sockaddr_nl
{
    public ushort nl_family;
    public ushort nl_pad;
    public uint nl_pid;
    public uint nl_groups;
}

Then, get a socket fd using

var fd = -1;
fd = UnixFiller.socket(
    (int) UnixAddressFamily.AF_NETLINK,
    (int) UnixSocketType.SOCK_RAW | 0x80000,
    0 /* NETLINK_ROUTE */
);
if(fd < 0)
    FatalError("Failed to create routing socket.");

UnixFiller.socket is just a DLLImport from libc. This call succeeds as expected.

However, the next step would be to cast the expressive sockaddr_nl structure to the family + byte array structure sockaddr consumed by bind:

bind(fd, (struct sockaddr*)&address, sizeof(address));

Where sockaddr is

struct sockaddr {
    sa_family_t sa_family;  /* address family, AF_xxx   */
    char        sa_data[14];    /* 14 bytes of protocol address */
};

Which, as far as I know, would be this in C#:

[StructLayout(LayoutKind.Sequential)]
public struct sockaddr
{
    public ushort sa_familiy;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 14)] byte[] sa_data;
}

Question

First, how should the bind import look like?

[DllImport("libc", SetLastError = true, EntryPoint = "bind")]
public static extern int bind(int sockfd, ??? addr, int addrlen);

??? = unknown.

Next, how can I port the cast from sockaddr_nl to sockaddr in order to pass the right format to bind?

Body:
You can't cast between sockaddr_nl and sockaddr because you have a reference (sa_data) that is going to get in the way. If it was a fixed buffer instead (i.e. raw data directly in the struct), then it would probably be fine, but then you need to use unsafe throughout. However, I'm unclear what that would look like; It looks like you mean that the 14 bytes of sa_data shuld be the contents of sockaddr_nl ? (I only count 12 bytes, note)

To write a struct over a byte[], you can use unsafe code:

static unsafe void Main()
{
    var val = new sockaddr_nl
    {
        nl_family = 1, nl_pad = 2, nl_pid = 3, nl_groups = 4
    };
    byte[] data = new byte[14];
    Console.WriteLine("size of struct: " + sizeof(sockaddr_nl));
    // show value before
    Console.WriteLine(BitConverter.ToString(data));
    // thunk over the data
    fixed (byte* p = data)
    {
        *((sockaddr_nl*)p) = val;
    }
    // show value after
    Console.WriteLine(BitConverter.ToString(data));
}

This has the output:

size of struct: 12
00-00-00-00-00-00-00-00-00-00-00-00-00-00
01-00-02-00-03-00-00-00-04-00-00-00-00-00


问:
Access in a specific position of JSON in node js
I have a xml file which I convert to JSON for simplify some operations.

I wrote this snippet:

```<code>var fs = require('fs');
var parser = require('xml2json');

var fileXML = '';
var str = '';

fs.readdirSync('C:/Users/dir/').forEach(file => {
    if(file.includes('.xml')){
        fileXML = file;
    }
});

fs.readFile( 'C:/Users/dir/'+fileXML, function(err, data) {
    var json = parser.toJson(data);
 });
</code>```

var json is a JSON representing this:

```<code>{
   "event:eventsList":{
      "xmlns:event":"info",
      "event:header":{
         "event:fileName":"info1",
         "event:creationDate":"2017-03-28T17:10:00.113+01:00",
         "event:eventsAmount":"4",
         "event:messageId":"2"
      }
   }
}
</code>```

My question is, how I can access the event:eventsList property?

I tried json.event but it gives me error.

答: Use json["event:eventsList"], you can access object key this way

Body:
I have a xml file which I convert to JSON for simplify some operations.

I wrote this snippet:

var fs = require('fs');
var parser = require('xml2json');

var fileXML = '';
var str = '';

fs.readdirSync('C:/Users/dir/').forEach(file => {
    if(file.includes('.xml')){
        fileXML = file;
    }
});

fs.readFile( 'C:/Users/dir/'+fileXML, function(err, data) {
    var json = parser.toJson(data);
 });

var json is a JSON representing this:

{
   "event:eventsList":{
      "xmlns:event":"info",
      "event:header":{
         "event:fileName":"info1",
         "event:creationDate":"2017-03-28T17:10:00.113+01:00",
         "event:eventsAmount":"4",
         "event:messageId":"2"
      }
   }
}

My question is, how I can access the event:eventsList property?

I tried json.event but it gives me error.


答:
In order to access the event:eventsList key you need to make use of the brackets notation since your key is not a valid JSON key

var json = {
       "event:eventsList":{
          "xmlns:event":"info",
          "event:header":{
             "event:fileName":"info1",
             "event:creationDate":"2017-03-28T17:10:00.113+01:00",
             "event:eventsAmount":"4",
             "event:messageId":"2"
          }
       }
    }

    console.log(json["event:eventsList"])```

Title: Access in a specific position of JSON in node js


问:
What will be the output if the argument's date type is different?
What happens  if the actual parameter and formal parameter's data types are different in overloading   ?  </p>

```<code>Class A
{
   public void m1(int i)
    {
    System.out.println("int");
     }
     public void m1(float f)
     {
     System.out.println("float");
     }
 Public static void main(String[] args)
 {
  A a=new A();
  a.m1('a');
  a.m1(10l);
  }
  }
</code>```

答: The function corresponding to the arguments types gets called, this is some the basics of OOP not only in java but in all other languages.</p>

Body:
What happens  if the actual parameter and formal parameter's data types are different in overloading   ?

Class A
{
   public void m1(int i)
    {
    System.out.println("int");
     }
     public void m1(float f)
     {
     System.out.println("float");
     }
 Public static void main(String[] args)
 {
  A a=new A();
  a.m1('a');
  a.m1(10l);
  }
  }