text:
Q: What causes my SAM template to generate that many errors I've been trying to get my SAM template working. I get the General idea of having a SAM template but i dont understand the logic behind the errors i keep getting from CloudFormation
Are my outputs correct? I only use the API's (not the functions?). I am able to do GET requests, but CORS is preventing me from doing the PUT and POST requests.
What is redundant and what am i missing?
The error: "Status reason
Unresolved resource dependencies [ServerlessRestApi] in the Outputs block of the template"
I've been getting the following error alot too: "The REST API doesn't contain any methods (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: abad588e-02ee-4fc6-a668-43b30bec6aaf; Proxy: null)"
Template.yaml:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  SAM Template

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 10

Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      Name: ApiGatewayApi
      StageName: Prod
      Cors:
        AllowMethods: "'OPTIONS,POST,GET,PUT,PATCH,DELETE'"
        AllowHeaders: "'Content-Type'"
        AllowOrigin: "'*'"
  DeclineSituationFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: DeclineSituation
      CodeUri: decline-situation/
      Handler: app.lambda_handler
      Runtime: python3.8
      Events:
        DeclineSituationAPI:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /decline-situation
            Method: put
            RestApiId: !Ref ApiGatewayApi
  AcceptSituationFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: AcceptSituation
      CodeUri: accept-situation/
      Handler: app.lambda_handler
      Runtime: python3.8
      Events:
        AcceptSituationAPI:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /accept-situation
            Method: post
            RestApiId: !Ref ApiGatewayApi
  GetIncidentsFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: GetIncidents
      CodeUri: get-incidents/
      Handler: app.lambda_handler
      Runtime: python3.8
      Events:
        GetIncidentsAPI:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /incidents
            Method: get
            RestApiId: !Ref ApiGatewayApi
  GetSituationsFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: GetSituations
      CodeUri: get-situations/
      Handler: app.lambda_handler
      Runtime: python3.8
      Policies: AWSLambdaDynamoDBExecutionRole
      Events:
        GetSituationsAPI:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /situations
            Method: get
            RestApiId: !Ref ApiGatewayApi
  GetRecoveriesFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      FunctionName: GetRecoveries
      CodeUri: get-recoveries/
      Handler: app.lambda_handler
      Runtime: python3.8
      Policies: AWSLambdaDynamoDBExecutionRole
      Events:
        GetRecoveriesAPI:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /recoveries
            Method: get
            RestApiId: !Ref ApiGatewayApi
  ReadNotificationFunction:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: ReadNotification
      CodeUri: read-notification/
      Handler: app.lambda_handler
      Runtime: python3.8
      Policies:
        - DynamoDBCrudPolicy:
            TableName: Situations
  Incidents:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: AIMAS-Incidents
      AttributeDefinitions:
        - AttributeName: incidentId
          AttributeType: S
        - AttributeName: situationId
          AttributeType: S
      KeySchema:
        - AttributeName: incidentId
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 5
        WriteCapacityUnits: 5
  Situations:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: AIMAS-Situations
      AttributeDefinitions:
        - AttributeName: situationId
          AttributeType: S
      KeySchema:
        - AttributeName: situationId
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 5
        WriteCapacityUnits: 5
  Recoveries:
    Type: AWS::DynamoDB::Table
    Properties:
      TableName: AIMAS-Recoveries
      AttributeDefinitions:
        - AttributeName: recoveryId
          AttributeType: S
        - AttributeName: situationId
          AttributeType: S
        - AttributeName: incidentId
          AttributeType: S
      KeySchema:
        - AttributeName: recoveryId
          KeyType: HASH
      ProvisionedThroughput:
        ReadCapacityUnits: 5
        WriteCapacityUnits: 5
Outputs:
  # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
  # Find out more about other implicit resources you can reference within SAM
  # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
  #Incidents
  GetIncidentsAPI:
    Description: "API Gateway endpoint URL for Prod stage for GetIncidentsAPI"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/incidents/"
  GetIncidentsFunction:
    Description: "GetIncidents Lambda Function ARN"
    Value: !GetAtt GetIncidentsFunction.Arn
  #Recoveries
  GetRecoveriesAPI:
    Description: "API Gateway endpoint URL for Prod stage for GetRecoveriesAPI"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/recoveries/"
  GetRecoveriesFunction:
    Description: "GetRecoveries Lambda Function ARN"
    Value: !GetAtt GetRecoveriesFunction.Arn
  #Situations
  AcceptSituationFunction:
    Description: "AcceptSituationFunction Lambda Function ARN"
    Value: !GetAtt AcceptSituationFunction.Arn
  AcceptSituationAPI:
    Description: "API Gateway endpoint URL for GetSituationsAPI"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/accept-situation/"
  DeclineSituationFunction:
    Description: "DeclineSituationFunction Lambda Function ARN"
    Value: !GetAtt DeclineSituationFunction.Arn
  DeclineSituationAPI:
    Description: "API Gateway endpoint URL for GetSituationsAPI"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/decline-situation/"
  GetSituationsAPI:
    Description: "API Gateway endpoint URL for GetSituationsAPI"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/situations/"
  GetSituationsFunction:
    Description: "GetSituations Lambda Function ARN"
    Value: !GetAtt GetSituationsFunction.Arn
  #Read Notifications
  ReadNotificationFunction:
    Description: "ReadNotification Lambda Function ARN"
    Value: !GetAtt ReadNotificationFunction.Arn

A: There are multiple errors in your template.
    E3039 The set of Attributes in AttributeDefinitions: ['incidentId', 'situationId'] and KeySchemas: ['incidentId'] must match at Resources/Incidents/Properties

    E3039 The set of Attributes in AttributeDefinitions: ['incidentId', 'recoveryId', 'situationId'] and KeySchemas: ['recoveryId'] must match at Resources/Recoveries/Properties

    E1019 Parameter ServerlessRestApi for Fn::Sub not found at Outputs/GetIncidentsAPI/Value/Fn::Sub
    x.yml:156:5

    E1019 Parameter ServerlessRestApi for Fn::Sub not found at Outputs/GetRecoveriesAPI/Value/Fn::Sub
    x.yml:163:5

    E1019 Parameter ServerlessRestApi for Fn::Sub not found at Outputs/AcceptSituationAPI/Value/Fn::Sub
    x.yml:173:5

    E1019 Parameter ServerlessRestApi for Fn::Sub not found at Outputs/DeclineSituationAPI/Value/Fn::Sub
    x.yml:179:5

    E1019 Parameter ServerlessRestApi for Fn::Sub not found at Outputs/GetSituationsAPI/Value/Fn::Sub
    x.yml:182:5

Use cfn-linter and the documentation for generating the template, there are plenty of good examples in the documentation as well.


text:
Q: Xamarin WebView is not showing content of specific URL (localhost that is redirecting to CAS server) I have been working on Xamarin for Android and I have a problem accessing localhost from WebView. Yes, I know that on emulators and devices one can not access localhost so I installed Conveyor by Keyoti which gives me access to my localhost through MYIP:PORT. Localhost is setup to redirect to CAS server login that my application needs as initial login. The main problem is that webview is not showing anything but if I try to access for e.g google.com it will show main page of google. Also, I am using Navigated and Navigating properties and I always get to Navigated property which outputs Loaded.. on the screen. Furthermore, if I try to access this "https://myip:45456" through google chrome on my device or through new incognito window it works like a charm but refuses to work inside of a webview.
Here is some xaml code that I tried because there is not much going on in the code-behind:
<WebView VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
                 Navigated="WebView_Navigated" Navigating="WebView_Navigating"
                 Source = "myip:45456">
        </WebView>

I'm really not getting what the problem is, so if anybody has experience in this area, help would be much appreciated.
EDIT:
After losing my head around this I've found out the problem lays in certificates and I'm getting this output message: Failed to validate the certificate chain, error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
I have tried couple of other solutions such as:
Xamarin Android issue connecting via HTTPS to site with self-signed certificate: "Trust anchor for certification path not found."
and workaround with ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true in MainActivity but it's still showing the same error.
Maybe it is something in configuration, but I can't find what it is?! :(

redpajama_set_name: RedPajamaStackExchange


text:
Q: C# Excel interop merge cells in fast way I want to merge cells and to do it multiple times...
The reason I'm using this merge its because I want more the one table.
and a different number of columns for each table and different size of a column on the another...
The number and the places of the merges are unknown
    using Microsoft.Office.Interop.Excel;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp111
{
    class Program
    {
        static void Main(string[] args)
        {
            string x = @"C:\Users\hed-b\source\repos\TESTUserFormFromExcel\ConsoleApp111\bin\Debug\TEST.xltm";

            Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application
            {
                DisplayAlerts = false,
                Visible = false,
                ScreenUpdating = false,
            };

            Workbook wb = xlApp.Workbooks.Open(x);
            Worksheet ws = (Worksheet)wb.Worksheets[1];
            if (ws == null)
            {
                Console.WriteLine("Worksheet could not be created. Check that your office installation and project references are correct.");
                return;
            }
            Stopwatch stopWatch = Stopwatch.StartNew();

            for (int i = 2; i <= 10; i++)
            {
                ws.get_Range("A"+i, "B"+i).Merge();

            }
            for (int i = 2; i <= 10; i++)
            {
                ws.get_Range("C" + i, "D" + i).Merge();
            }
            for (int i = 2; i <= 10; i++)
            {
                ws.get_Range("E" + i, "H" + i).Merge();
            }
            Console.WriteLine(stopWatch.ElapsedMilliseconds);

            stopWatch = Stopwatch.StartNew();
            ws.get_Range("A" + 2, "H" + 10).Value2 = new string[10, 5]{
                { "aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
                { "aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
                { "aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
                { "aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
                { "aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
                { "aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
                { "aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
                { "aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
                { "aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
                { "aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaa","","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},
            };

            ws.get_Range("A" + 11, "H" + 15).Value2 = new string[5, 8]{
                { "bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb"},
                { "bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb"},
                { "bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb"},
                { "bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb"},
                { "bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb","bbbbb"}
            };

            Console.WriteLine(stopWatch.ElapsedMilliseconds);

            xlApp.ScreenUpdating = true;
            xlApp.Visible = true;
        }
    }
}

I just looking for better way to do it faster
All these example program merges take about 1724 ms. in my actual program I have much more merges and take more than 5000 ms.
This merges its what take the most of the time...

A: It'll probably perform better if you execute the merge at once and let Excel handle the multiple ranges you need to merge.
I.e. define a range object which holds the multiple areas and call the Merge on it. It won't merge everything into one big fat cell, but will merge the multiple areas as defined:
var ranges = String.Empty();

for (int i = 2; i <= 10; i++)
{
    ranges += $"A{i}:B{i},C{i}:D{i},E{i}:H{i},";
}

ws.get_Range(ranges.TrimEnd(',')).Merge();


text:
Q: Can't download reviewed Firefox add-on Received the message below from Mozilla AddOn editors with regards to our new version of our add on:
"Your add-on, iGive Button 5.0.0.9, has been reviewed and is now signed and ready for you to download at https://addons.mozilla.org/en-US/developers/addon/igive-button-1/versions."
When I go to that link, I'm supposed to be able to download the reviewed and now signed add on.  To try to do that, I clicked on the link which lets me manage the add on.  At the top of the Manade Add On screen there is a link to the file (igive_button-5.0.0.9-fx.xpi):  https://addons.mozilla.org/firefox/downloads/file/352648/igive_button-5.0.0.9-fx.xpi?src=devhub
However, when I click that link I get a "404 Not Found" error.
How do I get the signed add-on so we can distribute it from our web site?

A: Try for the sources in
about:config
and search for browser.dictionaries.download.url
verify the sources of the apps is correct

A: Did Mozilla send you a link to your preliminarily approved addon?  When you click that link it takes you to developer hub.  Under current versions there should be a link to your reviewed addon.  Click that link to go to the management page for your addon.  Near the top of this page you should see an element called "files" with your extension file shown as a link.  You should be able to click that link to download your file.


text:
Q: mapping over lists and selecting columns (to create new lists) I am trying to map over some data and select some columns. I try to run the folling:
map(dat$splits, ~ analysis(.x) %>%
      as_tibble(., .name_repair = "universal") %>%
            map(., ~select(X1, X2, X3, X4, X5, X6, X7, X8, X9)))

But get given an error, however I can see the tibbles by using:
map(dat$splits, ~ analysis(.x))

Which gives:
[[1]]
# A tibble: 20 x 17
   date       ID     var1     var2     Y Y_plus_1    X1    X2    X3    X4     X5      X6     X7      X8
   <date>     <chr> <dbl>    <dbl> <dbl>    <dbl> <dbl> <dbl> <dbl> <dbl>  <dbl>   <dbl>  <dbl>   <dbl>
 1 2016-10-21 CAT1   799.  3.01e-3     1        0  4.14    18     0     1 0.0770 4.29e-4  0.652 -0.976
 2 2016-10-24 CAT1   813.  1.72e-2     1        1  4.14    17     0     1 0.0793 4.24e-4  0.634 -0.861
 3 2016-10-25 CAT1   808. -6.69e-3     0        1  4.16    16     0     1 0.0804 4.04e-4  0.780 -0.478
 4 2016-10-26 CAT1   799. -1.06e-2     0        0  4.16    15     0     1 0.0626 4.26e-4  0.378 -0.332
 5 2016-10-27 CAT1   795. -4.66e-3     0        0  4.16    14     0     1 0.0587 4.42e-4 -0.253 -0.647
 6 2016-10-28 CAT1   795.  2.52e-5     0        0  4.11    13     0     1 0.0610 4.40e-4 -0.523 -0.753
 7 2016-10-31 CAT1   785. -1.36e-2     0        0  4.14    12     0     1 0.0704 4.25e-4 -0.125 -0.620
 8 2016-11-01 CAT1   784. -1.19e-3     1        0  3.98    11     0     1 0.0867 4.17e-4 -0.933 -1.30
 9 2016-11-02 CAT1   769. -1.90e-2     0        1  6.00    10     0     1 0.0673 4.53e-4 -0.958 -0.793
10 2016-11-03 CAT1   762. -8.55e-3     0        0  8.42    10     0     1 0.0877 4.29e-4 -1.51  -1.17
11 2016-11-04 CAT1   762. -1.44e-4     1        0  7.95    10     0     1 0.0924 4.26e-4 -1.67  -1.21
12 2016-11-07 CAT1   783.  2.69e-2     1        1  7.89    10     0     1 0.0821 4.24e-4 -1.64  -1.06
13 2016-11-08 CAT1   791.  1.02e-2     1        1  7.64    10     0     1 0.0361 4.51e-4 -0.963  0.0116
14 2016-11-09 CAT1   785. -6.58e-3     1        1  4.51    10     0     1 0.0634 4.87e-4 -0.762  1.15
15 2016-11-10 CAT1   763. -2.90e-2     0        1  4.53    10     0     1 0.0290 5.26e-4 -1.32   0.560
16 2016-11-11 CAT1   754. -1.12e-2     0        0  4.40    10     0     1 0.0404 4.94e-4 -1.74   0.142
17 2016-11-14 CAT1   736. -2.38e-2     0        0  4.19    10     0     1 0.0587 4.93e-4 -2.32  -0.504
18 2016-11-15 CAT1   758.  3.04e-2     1        0  4.27    10     0     1 0.125  4.17e-4 -2.74  -1.19
19 2016-11-16 CAT1   764.  7.90e-3     1        1  2.31    29     0     1 0.0637 3.30e-4 -2.16   0.593
20 2016-11-17 CAT1   771.  8.83e-3     1        1  2.31    28

That is I want to map over and select the X1... X8 columns.
Data:
dat <- structure(list(splits = list(structure(list(data = structure(list(
    date = structure(c(17095, 17098, 17099, 17100, 17101, 17102,
    17105, 17106, 17107, 17108, 17109, 17112, 17113, 17114, 17115,
    17116, 17119, 17120, 17121, 17122, 17123, 17126, 17127, 17128,
    17130, 17133, 17134, 17135, 17136, 17137, 17140, 17141, 17142,
    17143, 17144, 17147, 17148, 17149, 17150, 17151, 17154, 17155,
    17156, 17157, 17158, 17162, 17163, 17164, 17165), class = "Date"),
    ID = c("CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
    "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
    "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
    "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
    "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
    "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
    "CAT1", "CAT1"), var1 = c(799.369995, 813.109985, 807.669983,
    799.070007, 795.349976, 795.369995, 784.539978, 783.609985,
    768.700012, 762.130005, 762.02002, 782.52002, 790.51001,
    785.309998, 762.559998, 754.02002, 736.080017, 758.48999,
    764.47998, 771.22998, 760.539978, 769.200012, 768.27002,
    760.98999, 761.679993, 768.23999, 770.840027, 758.039978,
    747.919983, 750.5, 762.52002, 759.109985, 771.190002, 776.419983,
    789.289978, 789.27002, 796.099976, 797.070007, 797.849976,
    790.799988, 794.200012, 796.419983, 794.559998, 791.26001,
    789.909973, 791.549988, 785.049988, 782.789978, 771.820007
    ), var2 = c(0.00301143592272179, 0.0171885235697395, -0.00669036428079295,
    -0.0106478836418512, -0.00465545067066953, 0.0000251700516804565,
    -0.0136163258207899, -0.00118539912060411, -0.0190272881732103,
    -0.00854690633203736, -0.000144312649125955, 0.0269021803390415,
    0.0102105886057713, -0.00657804700031572, -0.0289694516279417,
    -0.0111990899370517, -0.0237924756958046, 0.0304450229355975,
    0.00789725649510542, 0.0088295314155904, -0.0138609782778413,
    0.0113866913646978, -0.0012090379426567, -0.00947587412040363,
    0.00090671757719174, 0.00861253683999563, 0.00338440726054889,
    -0.016605324777718, -0.0133502127773003, 0.00344958960669994,
    0.0160160159893405, -0.00447205963195563, 0.0159133949476373,
    0.00678170228664343, 0.0165760738798502, -0.0000252860172512692,
    0.00865350998635406, 0.00121847887105075, 0.000978545163097477,
    -0.00883623264030775, 0.00429947401567232, 0.00279522911918573,
    -0.00233543235943645, -0.00415322695366804, -0.00170618631415476,
    0.00207620495506755, -0.00821173659091756, -0.00287881031086645,
    -0.0140139389980795), Y = c(1, 1, 0, 0, 0, 0, 0, 1, 0, 0,
    1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0,
    1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0,
    0), Y_plus_1 = c(0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1,
    1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0,
    1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0), X1 = c(4.13858526513854,
    4.13858526513855, 4.16341131085939, 4.16341131085937, 4.16341131085937,
    4.11423119297315, 4.13858526513857, 3.97599968560627, 5.99758130881283,
    8.41953801047614, 7.95231443679086, 7.88558780320248, 7.6408950559188,
    4.51370117323327, 4.52868963859669, 4.39998987943623, 4.18852747359839,
    4.27042958796773, 2.30720560360487, 2.3083029424251, 2.3083029424251,
    2.30720560360488, 2.30720560360486, 2.33467572807035, 2.33467572807036,
    2.33467572807036, 2.30720560360486, 2.33467572807035, 2.31545097851707,
    2.3399413414153, 2.40685890963718, 2.40309440701756, 2.33633188340289,
    2.3363318834029, 2.23996107961566, 2.23996107961567, 2.23996107961566,
    3.14644299189703, 3.1910343925295, 3.4393907031427, 3.30413087760388,
    3.33080017630688, 2.63827508869038, 2.99443088216722, 2.99443088216723,
    2.99443088216722, 2.99443088216722, 3.14542139469794, 3.14542139469794
    ), X2 = c(18, 17, 16, 15, 14, 13, 12, 11, 10, 10, 10, 10,
    10, 10, 10, 10, 10, 10, 29, 28, 27, 26, 25, 24, 23, 22, 21,
    20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 10, 10, 10, 10,
    87, 86, 85, 84, 83, 82, 81), X3 = c(0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0), X4 = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), X5 = c(0.0769944316144198,
    0.0793311568823971, 0.0803743155230278, 0.0625789438826206,
    0.0586506192715035, 0.0610303101083243, 0.0703939970975855,
    0.0867098273608016, 0.0673120522212106, 0.0877296725069155,
    0.0923742675361241, 0.0821050363880187, 0.0360531976099817,
    0.063410467337928, 0.0289807505667197, 0.0403890038946993,
    0.0587200889534704, 0.124855015077667, 0.0636602113103218,
    0.0748772236055617, 0.0828248414842617, 0.0588561607897347,
    0.0437146614571738, 0.0399432627968126, 0.0535895503558405,
    0.0538598239712004, 0.0600971764378981, 0.0543532803438423,
    0.0412119504402689, 0.0445593481900316, 0.0471324573693227,
    0.0366910541674913, 0.0412784111781792, 0.0338162772274317,
    0.0391189676384125, 0.051151724195942, 0.0442197922283997,
    0.0458769828703159, 0.0392536462039503, 0.0397989336000519,
    0.0293505218180493, 0.0229058449521028, 0.0154019371887762,
    0.0102366640366435, 0.00783792657548366, 0.014037818210456,
    0.00900392496961011, 0.0148108452415051, 0.0159871581537364
    ), X6 = c(0.000428660536007568, 0.000424348382531349, 0.000403672086504106,
    0.000425772306880377, 0.000441567036819891, 0.000440420473928468,
    0.000424616565866307, 0.000417156794102717, 0.000453102696396517,
    0.000429420158272163, 0.000426339236438714, 0.000424204011080916,
    0.000450812884669126, 0.00048728803860348, 0.000526461561504051,
    0.000494106517096305, 0.000493488610269819, 0.00041740609044358,
    0.000329604373072286, 0.000321981688032803, 0.000313820182149535,
    0.000324018084037671, 0.000321928021838835, 0.000325886279909115,
    0.000324905583026473, 0.000323263064904554, 0.000315582726878559,
    0.00033115144688, 0.000326176783596685, 0.000320421043513733,
    0.000317459171547033, 0.000306378296724892, 0.000304230982248009,
    0.00031578316067723, 0.000315783239223671, 0.000308443856342272,
    0.000302387474982801, 0.000302702247056619, 0.000300580888361005,
    0.000298662388842681, 0.000295031270763261, 0.000300955138678924,
    0.000308009865186193, 0.00031004060452567, 0.000308580481883199,
    0.000309081734643359, 0.000309347430761987, 0.00031610525741575,
    0.000316030523318374), X7 = c(0.652246323794644, 0.633658121909502,
    0.779640005424855, 0.37849713571782, -0.25338461752528, -0.522937755983531,
    -0.124971717359712, -0.93339126000489, -0.957987757878853,
    -1.50800507959919, -1.67334654587184, -1.6438607078889, -0.962881285608565,
    -0.761952591493898, -1.31627449065341, -1.73806924167703,
    -2.31894300820554, -2.73548173635386, -2.16326733735933,
    -2.18976199245069, -1.70174528306041, -2.05934220840334,
    -1.83997395786783, -1.66507504806585, -1.90235222119862,
    -1.84142082212644, -1.77786289146221, -1.23082082088862,
    -1.53821065097434, -1.56812844617651, -1.59984630224514,
    -1.15906488048868, -1.18713323505712, -0.57100200805735,
    -0.228511848060405, 0.253315947225092, 0.0532312338057499,
    0.223428854601438, -0.00144862031236322, -0.0398092612664749,
    -0.0588761129681466, -0.0771471433941018, 0.117493259867833,
    0.459197464971977, 0.292335416896516, 0.114242276938583,
    0.202233666501737, 0.331679162319782, 0.175470525372577),
    X8 = c(-0.975973892452776, -0.861258722930479, -0.477565916680931,
    -0.33185021650311, -0.647129621511124, -0.752564004048953,
    -0.620377457915967, -1.30234931058582, -0.793283548875438,
    -1.16602371553076, -1.20919980603818, -1.06429334017641,
    0.0115994967476536, 1.15288649261686, 0.559547871095353,
    0.142148842103466, -0.504045772338972, -1.18889934824633,
    0.593184249578906, 0.999978721521271, 1.3874173248314, 0.798117587221041,
    0.799993914873595, 0.748516271275043, 0.617354487136954,
    0.66965220108721, 0.886228797393692, 1.10466660545966, 0.37553937583687,
    0.113225726134138, 0.35930466268218, 0.588184742745078, 0.536929080120224,
    0.875533406569582, 1.29869394121533, 1.3954069386108, 1.2896602501424,
    1.28952719595234, 1.04620293691641, 1.04835604946992, 0.944659231862545,
    0.658278997146449, 0.530493113505759, 0.386873773618166,
    0.412971784704427, 0.116661980563476, 0.274658721324867,
    -0.231454627137936, -0.0490920485204462), X9 = c(-0.0145637619761308,
    -0.0147930666936059, -0.0147662947883565, -0.0325177535962596,
    -0.0128572105783758, -0.0126204141222343, -0.0193506283734377,
    -0.0204879399440294, -0.015817519858536, -0.0171950326442131,
    -0.0146419066547099, -0.0104033279055883, -0.00702994914474458,
    0.012163515055523, 0.0311052843018782, 0.0466972362285693,
    0.0638538376999092, 0.0587189119891982, -0.0382761719744182,
    0.017369814913167, 0.00894072522957917, 0.0159165549773805,
    -0.00278974160229076, 0.00087423648615031, -0.000799924570855513,
    -0.00720654828839435, 0.00144205696290743, -0.00744120420924264,
    -0.00623238593684327, 0.0140296542021987, 0.0078581351311665,
    0.0194264610155223, 0.0214019946797077, 0.0135050903487779,
    0.0136275994696147, 0.0191532733906993, 0.0145192162284441,
    0.0180836191687308, 0.0211148970828572, 0.0228082176297255,
    0.0282007760760499, 0.0246107996585935, 0.0169675399817873,
    0.0207974225382235, 0.0246684486060467, 0.0216975706632474,
    0.0291883466992148, 0.0253376536386199, 0.0262304363854249
    ), X10 = c(0.225525775667678, 0.218320938251066, 0.205736199627003,
    0.18430441198689, 0.171653942908123, 0.169720213220954, 0.169160112065287,
    0.162051896119269, 0.158642308835919, 0.163696353319601,
    0.162160340961121, 0.160663336867733, 0.116728767616044,
    0.0744707092081847, 0.0816373143043771, 0.120472162777503,
    0.120923040165681, 0.10545848677116, 0.172548378854213, 0.184998553367414,
    0.181410472295269, 0.248454355918383, 0.218320516349615,
    0.216853385184294, 0.180488106442423, 0.177799948562715,
    0.186118707334448, 0.177473777344988, 0.161807804965392,
    0.167723342514708, 0.158568160654393, 0.16773089626074, 0.16307716529608,
    0.162099891399657, 0.15812964617053, 0.149690169923917, 0.164750142363451,
    0.163460075128328, 0.155183021202297, 0.14616757689419, 0.154376710865108,
    0.147389439599357, 0.183009449087266, 0.175519602867033,
    0.177732643891337, 0.17814584046646, 0.175149718955584, 0.176134687816332,
    0.175399285149764), X11 = c(0.510204081632653, 0.520408163265306,
    0.520408163265306, 0.530612244897959, 0.530612244897959,
    0.520408163265306, 0.520408163265306, 0.520408163265306,
    0.530612244897959, 0.520408163265306, 0.530612244897959,
    0.530612244897959, 0.540816326530612, 0.530612244897959,
    0.520408163265306, 0.530612244897959, 0.530612244897959,
    0.530612244897959, 0.536082474226804, 0.536082474226804,
    0.536082474226804, 0.530612244897959, 0.525773195876289,
    0.536082474226804, 0.510204081632653, 0.520408163265306,
    0.520408163265306, 0.530612244897959, 0.530612244897959,
    0.520408163265306, 0.510204081632653, 0.510204081632653,
    0.510204081632653, 0.510204081632653, 0.510204081632653,
    0.5, 0.5, 0.489795918367347, 0.489795918367347, 0.489795918367347,
    0.5, 0.5, 0.510204081632653, 0.5, 0.5, 0.510204081632653,
    0.510204081632653, 0.520408163265306, 0.520408163265306)), row.names = c(NA,
-49L), class = c("tbl_df", "tbl", "data.frame")), in_id = 1:20,
    out_id = 21L, id = structure(list(id = "Slice01"), row.names = c(NA,
    -1L), class = c("tbl_df", "tbl", "data.frame"))), class = c("rsplit",
"rof_split")), structure(list(data = structure(list(date = structure(c(17095,
17098, 17099, 17100, 17101, 17102, 17105, 17106, 17107, 17108,
17109, 17112, 17113, 17114, 17115, 17116, 17119, 17120, 17121,
17122, 17123, 17126, 17127, 17128, 17130, 17133, 17134, 17135,
17136, 17137, 17140, 17141, 17142, 17143, 17144, 17147, 17148,
17149, 17150, 17151, 17154, 17155, 17156, 17157, 17158, 17162,
17163, 17164, 17165), class = "Date"), ID = c("CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1",
"CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1", "CAT1"), var1 = c(799.369995,
813.109985, 807.669983, 799.070007, 795.349976, 795.369995, 784.539978,
783.609985, 768.700012, 762.130005, 762.02002, 782.52002, 790.51001,
785.309998, 762.559998, 754.02002, 736.080017, 758.48999, 764.47998,
771.22998, 760.539978, 769.200012, 768.27002, 760.98999, 761.679993,
768.23999, 770.840027, 758.039978, 747.919983, 750.5, 762.52002,
759.109985, 771.190002, 776.419983, 789.289978, 789.27002, 796.099976,
797.070007, 797.849976, 790.799988, 794.200012, 796.419983, 794.559998,
791.26001, 789.909973, 791.549988, 785.049988, 782.789978, 771.820007
), var2 = c(0.00301143592272179, 0.0171885235697395, -0.00669036428079295,
-0.0106478836418512, -0.00465545067066953, 0.0000251700516804565,
-0.0136163258207899, -0.00118539912060411, -0.0190272881732103,
-0.00854690633203736, -0.000144312649125955, 0.0269021803390415,
0.0102105886057713, -0.00657804700031572, -0.0289694516279417,
-0.0111990899370517, -0.0237924756958046, 0.0304450229355975,
0.00789725649510542, 0.0088295314155904, -0.0138609782778413,
0.0113866913646978, -0.0012090379426567, -0.00947587412040363,
0.00090671757719174, 0.00861253683999563, 0.00338440726054889,
-0.016605324777718, -0.0133502127773003, 0.00344958960669994,
0.0160160159893405, -0.00447205963195563, 0.0159133949476373,
0.00678170228664343, 0.0165760738798502, -0.0000252860172512692,
0.00865350998635406, 0.00121847887105075, 0.000978545163097477,
-0.00883623264030775, 0.00429947401567232, 0.00279522911918573,
-0.00233543235943645, -0.00415322695366804, -0.00170618631415476,
0.00207620495506755, -0.00821173659091756, -0.00287881031086645,
-0.0140139389980795), Y = c(1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1,
1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0,
1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0), Y_plus_1 = c(0,
1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0,
1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0,
0, 0, 0, 1, 0, 0), X1 = c(4.13858526513854, 4.13858526513855,
4.16341131085939, 4.16341131085937, 4.16341131085937, 4.11423119297315,
4.13858526513857, 3.97599968560627, 5.99758130881283, 8.41953801047614,
7.95231443679086, 7.88558780320248, 7.6408950559188, 4.51370117323327,
4.52868963859669, 4.39998987943623, 4.18852747359839, 4.27042958796773,
2.30720560360487, 2.3083029424251, 2.3083029424251, 2.30720560360488,
2.30720560360486, 2.33467572807035, 2.33467572807036, 2.33467572807036,
2.30720560360486, 2.33467572807035, 2.31545097851707, 2.3399413414153,
2.40685890963718, 2.40309440701756, 2.33633188340289, 2.3363318834029,
2.23996107961566, 2.23996107961567, 2.23996107961566, 3.14644299189703,
3.1910343925295, 3.4393907031427, 3.30413087760388, 3.33080017630688,
2.63827508869038, 2.99443088216722, 2.99443088216723, 2.99443088216722,
2.99443088216722, 3.14542139469794, 3.14542139469794), X2 = c(18,
17, 16, 15, 14, 13, 12, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15,
14, 13, 12, 11, 10, 10, 10, 10, 10, 87, 86, 85, 84, 83, 82, 81
), X3 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), X4 = c(1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
), X5 = c(0.0769944316144198, 0.0793311568823971, 0.0803743155230278,
0.0625789438826206, 0.0586506192715035, 0.0610303101083243, 0.0703939970975855,
0.0867098273608016, 0.0673120522212106, 0.0877296725069155, 0.0923742675361241,
0.0821050363880187, 0.0360531976099817, 0.063410467337928, 0.0289807505667197,
0.0403890038946993, 0.0587200889534704, 0.124855015077667, 0.0636602113103218,
0.0748772236055617, 0.0828248414842617, 0.0588561607897347, 0.0437146614571738,
0.0399432627968126, 0.0535895503558405, 0.0538598239712004, 0.0600971764378981,
0.0543532803438423, 0.0412119504402689, 0.0445593481900316, 0.0471324573693227,
0.0366910541674913, 0.0412784111781792, 0.0338162772274317, 0.0391189676384125,
0.051151724195942, 0.0442197922283997, 0.0458769828703159, 0.0392536462039503,
0.0397989336000519, 0.0293505218180493, 0.0229058449521028, 0.0154019371887762,
0.0102366640366435, 0.00783792657548366, 0.014037818210456, 0.00900392496961011,
0.0148108452415051, 0.0159871581537364), X6 = c(0.000428660536007568,
0.000424348382531349, 0.000403672086504106, 0.000425772306880377,
0.000441567036819891, 0.000440420473928468, 0.000424616565866307,
0.000417156794102717, 0.000453102696396517, 0.000429420158272163,
0.000426339236438714, 0.000424204011080916, 0.000450812884669126,
0.00048728803860348, 0.000526461561504051, 0.000494106517096305,
0.000493488610269819, 0.00041740609044358, 0.000329604373072286,
0.000321981688032803, 0.000313820182149535, 0.000324018084037671,
0.000321928021838835, 0.000325886279909115, 0.000324905583026473,
0.000323263064904554, 0.000315582726878559, 0.00033115144688,
0.000326176783596685, 0.000320421043513733, 0.000317459171547033,
0.000306378296724892, 0.000304230982248009, 0.00031578316067723,
0.000315783239223671, 0.000308443856342272, 0.000302387474982801,
0.000302702247056619, 0.000300580888361005, 0.000298662388842681,
0.000295031270763261, 0.000300955138678924, 0.000308009865186193,
0.00031004060452567, 0.000308580481883199, 0.000309081734643359,
0.000309347430761987, 0.00031610525741575, 0.000316030523318374
), X7 = c(0.652246323794644, 0.633658121909502, 0.779640005424855,
0.37849713571782, -0.25338461752528, -0.522937755983531, -0.124971717359712,
-0.93339126000489, -0.957987757878853, -1.50800507959919, -1.67334654587184,
-1.6438607078889, -0.962881285608565, -0.761952591493898, -1.31627449065341,
-1.73806924167703, -2.31894300820554, -2.73548173635386, -2.16326733735933,
-2.18976199245069, -1.70174528306041, -2.05934220840334, -1.83997395786783,
-1.66507504806585, -1.90235222119862, -1.84142082212644, -1.77786289146221,
-1.23082082088862, -1.53821065097434, -1.56812844617651, -1.59984630224514,
-1.15906488048868, -1.18713323505712, -0.57100200805735, -0.228511848060405,
0.253315947225092, 0.0532312338057499, 0.223428854601438, -0.00144862031236322,
-0.0398092612664749, -0.0588761129681466, -0.0771471433941018,
0.117493259867833, 0.459197464971977, 0.292335416896516, 0.114242276938583,
0.202233666501737, 0.331679162319782, 0.175470525372577), X8 = c(-0.975973892452776,
-0.861258722930479, -0.477565916680931, -0.33185021650311, -0.647129621511124,
-0.752564004048953, -0.620377457915967, -1.30234931058582, -0.793283548875438,
-1.16602371553076, -1.20919980603818, -1.06429334017641, 0.0115994967476536,
1.15288649261686, 0.559547871095353, 0.142148842103466, -0.504045772338972,
-1.18889934824633, 0.593184249578906, 0.999978721521271, 1.3874173248314,
0.798117587221041, 0.799993914873595, 0.748516271275043, 0.617354487136954,
0.66965220108721, 0.886228797393692, 1.10466660545966, 0.37553937583687,
0.113225726134138, 0.35930466268218, 0.588184742745078, 0.536929080120224,
0.875533406569582, 1.29869394121533, 1.3954069386108, 1.2896602501424,
1.28952719595234, 1.04620293691641, 1.04835604946992, 0.944659231862545,
0.658278997146449, 0.530493113505759, 0.386873773618166, 0.412971784704427,
0.116661980563476, 0.274658721324867, -0.231454627137936, -0.0490920485204462
), X9 = c(-0.0145637619761308, -0.0147930666936059, -0.0147662947883565,
-0.0325177535962596, -0.0128572105783758, -0.0126204141222343,
-0.0193506283734377, -0.0204879399440294, -0.015817519858536,
-0.0171950326442131, -0.0146419066547099, -0.0104033279055883,
-0.00702994914474458, 0.012163515055523, 0.0311052843018782,
0.0466972362285693, 0.0638538376999092, 0.0587189119891982, -0.0382761719744182,
0.017369814913167, 0.00894072522957917, 0.0159165549773805, -0.00278974160229076,
0.00087423648615031, -0.000799924570855513, -0.00720654828839435,
0.00144205696290743, -0.00744120420924264, -0.00623238593684327,
0.0140296542021987, 0.0078581351311665, 0.0194264610155223, 0.0214019946797077,
0.0135050903487779, 0.0136275994696147, 0.0191532733906993, 0.0145192162284441,
0.0180836191687308, 0.0211148970828572, 0.0228082176297255, 0.0282007760760499,
0.0246107996585935, 0.0169675399817873, 0.0207974225382235, 0.0246684486060467,
0.0216975706632474, 0.0291883466992148, 0.0253376536386199, 0.0262304363854249
), X10 = c(0.225525775667678, 0.218320938251066, 0.205736199627003,
0.18430441198689, 0.171653942908123, 0.169720213220954, 0.169160112065287,
0.162051896119269, 0.158642308835919, 0.163696353319601, 0.162160340961121,
0.160663336867733, 0.116728767616044, 0.0744707092081847, 0.0816373143043771,
0.120472162777503, 0.120923040165681, 0.10545848677116, 0.172548378854213,
0.184998553367414, 0.181410472295269, 0.248454355918383, 0.218320516349615,
0.216853385184294, 0.180488106442423, 0.177799948562715, 0.186118707334448,
0.177473777344988, 0.161807804965392, 0.167723342514708, 0.158568160654393,
0.16773089626074, 0.16307716529608, 0.162099891399657, 0.15812964617053,
0.149690169923917, 0.164750142363451, 0.163460075128328, 0.155183021202297,
0.14616757689419, 0.154376710865108, 0.147389439599357, 0.183009449087266,
0.175519602867033, 0.177732643891337, 0.17814584046646, 0.175149718955584,
0.176134687816332, 0.175399285149764), X11 = c(0.510204081632653,
0.520408163265306, 0.520408163265306, 0.530612244897959, 0.530612244897959,
0.520408163265306, 0.520408163265306, 0.520408163265306, 0.530612244897959,
0.520408163265306, 0.530612244897959, 0.530612244897959, 0.540816326530612,
0.530612244897959, 0.520408163265306, 0.530612244897959, 0.530612244897959,
0.530612244897959, 0.536082474226804, 0.536082474226804, 0.536082474226804,
0.530612244897959, 0.525773195876289, 0.536082474226804, 0.510204081632653,
0.520408163265306, 0.520408163265306, 0.530612244897959, 0.530612244897959,
0.520408163265306, 0.510204081632653, 0.510204081632653, 0.510204081632653,
0.510204081632653, 0.510204081632653, 0.5, 0.5, 0.489795918367347,
0.489795918367347, 0.489795918367347, 0.5, 0.5, 0.510204081632653,
0.5, 0.5, 0.510204081632653, 0.510204081632653, 0.520408163265306,
0.520408163265306)), row.names = c(NA, -49L), class = c("tbl_df",
"tbl", "data.frame")), in_id = 2:21, out_id = 22L, id = structure(list(
    id = "Slice02"), row.names = c(NA, -1L), class = c("tbl_df",
"tbl", "data.frame"))), class = c("rsplit", "rof_split"))), id = c("Slice01",
"Slice02")), row.names = 1:2, class = c("rset", "tbl_df", "tbl",
"data.frame"), initial = 20, assess = 1, cumulative = FALSE, skip = 0)

A: We don't need the . and map.  After the select, it can be converted to list with as.list (if it is required), otherwise, just keep it as the tibble
library(purrr)
library(dplyr)
map(dat$splits, ~ analysis(.x) %>%
  as_tibble(., .name_repair = "universal") %>%
          select(X1:X9) %>%
          as.list)


text:
Q: GCP alerting policies based on percentage I am trying to create some alerting policies in GCP for my application hosted in Kubernetes cluster.
We have a Cloud load balancer serving the traffic and I can see the HTTP status codes like 2XX, 5XX etc.
I need to create some alerting policies based on the error percentage rather than the absolute value like ((NumberOfFailures/Total) * 100) so that if my error percentage goes above say 50% then trigger an alert.
I couldn't find anything on the google documentation. It just tells you to use counter which is like using an absolute value. I am looking for something like if the failure rate goes beyond 50% in a rolling window of 15 minutes then trigger the alert.
Is that even possible to do that natively in GCP?

A: Yes, I think this is possible with MQL. I have recently created something similar to your use case.
fetch api
    | metric 'serviceruntime.googleapis.com/api/request_count'
    | filter
        (resource.service == 'my-service.com')
    | group_by 10m, [value_request_count_aggregate: aggregate(value.request_count)]
    | every 10m
    | { group_by [metric.response_code_class],
        [response_code_count_aggregate: aggregate(value_request_count_aggregate)]
    | filter (metric.response_code_class = '5xx')
        ; group_by [],
    [value_request_count_aggregate_aggregate:
        aggregate(value_request_count_aggregate)] }
    | join
    | value [response_code_ratio: val(0) / val(1)]
    | condition gt(val(), 0.1)

In this example, I am using the request count for a service my-service.com. I am aggregating the request count over the last 10 minutes and responses with response code 5xx. Additionally, I am aggregating the request count over the same time period, but all response codes. Then in the last two lines, I am computing the ratio of the number of 5xx status codes with the number of all response codes. Finally, I create a boolean value that is true when the ratio is above 0.1 and that I can use to trigger an alert.
I hope this gives you a rough idea of how you can create your own alerting policy based on percentages.


text:
Q: Parametrization of a circle at (-1,-8) with Radius 9 Question:
The circle centered at $(−1,−8)$ with radius $9$ can be parametrized in many ways, this still happens even if we impose the extra constraint that the circle must be traversed in the counter-clockwise direction. This problem asks you to work with two of those counter-clockwise parametrizations.
a). If $x = -1 + 9 \cos(t)$
b). If $x = -1 + 9 \sin(t)$
So this is what i have so far,
i know that equation of a circle is $x^2+y^2=r^2$
I put the points into the equation $(x+1)^2+(y+8)^2=9^2$
Then I solved for $y$ and plugged in a). as a substitute to get the answer, which I believe is: $y=1-9\cos(t)$
But i get a wrong answer, I am not to sure where to I am messing up, I think I am missing a couple of steps, but i just don't know how to get there.

A: Hint: Recall for a circle $(x-a)^2 + (y-b)^2 = r^2$, we can convert it into the parameterized equation $$\begin {matrix} x = a + r \cos t \\ y = b + r \sin t \end {matrix}$$  What is the equation given your points $(-1, -8)$ and radius $9$?


text:
Q: angularjs weird error loading controllers I've being developing angularjs for the last months and I have an app with some controllers, directives and services. Until now all have gone all right, but with the last controller I'm getting a weird error that it's making me go mad. Because the app its a bigger enough to put here all code I will put the important parts.
In my index.html
<!DOCTYPE html>
<html ng-app="my_app">
<head>
    <meta charset="encoding">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <meta name="viewport"  content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link rel="stylesheet" href="lib/ionic/css/ionic.css">
    <link rel="stylesheet" href="css/style.css">

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="lib/angular-translate/angular-translate.min.js"></script>
    <script src="lib/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <!--<script src=""-->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <!--SERVICES-->
    <script src="js/services/services.js"></script>
    <script src="js/services/s_configDB.js"></script>
    <script src="js/services/s_clinicDB.js"></script>
    <!-- CONTROLLERS -->
    <script src="js/controllers/controllers.js"></script>
    <script src="js/controllers/c_splash.js"></script>
    <script src="js/controllers/c_communications.js"></script>
    <!--<script src="js/controllers/c_communicationsB.js"></script> 
    <script src="js/controllers/c_clock.js"></script>
    <script src="js/controllers/c_menu.js"></script>
    <script src="js/controllers/c_language.js"></script>
    <!--DIRECTIVES-->
    <script src="js/directives/directives.js"></script>
    <script src="js/directives/d_menu.js"></script>

</head>

<body ng-controller="AppComms">
    <ion-nav-view ></ion-nav-view>
</body>
</html>

At my app.js:

var SDv4 = angular.module('my_app', [
    'ionic',
    'my_app.services',
    'my_app.controllers',
    'my_app.directives'
]);

At controllers.js
var app = angular.module('my_app.controllers',[
    //'ionic',
    'my_app.c_splash',
    'my_app.c_clock',
    'my_app.c_language',
    'my_app.c_comms',
    //'my_app.c_commsb',
    'pascalprecht.translate',
    'my_app.c_menu'
]);

And for example the c_communications.js
var comms = angular.module('my_app.c_comms',[])

comms.controller('AppComms',['$scope',function($scope){

    …

}])

This code is working ok, but if I add another controller (c_communicationsB.js) :
var commsb = angular.module('my_app.c_commsb',[])

and add the my_app.commsb to the controllers.js
It gives me the error:
ionic.bundle.js:8895 Uncaught Error: [$injector:modulerr] Failed to instantiate module MY_APP due to:
Error: [$injector:modulerr] Failed to instantiate module my_app.controllers due to:
Error: [$injector:modulerr] Failed to instantiate module my_app.c_commsb due to:
Error: [$injector:nomod] Module 'my_app.c_commsb' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.4.3/$injector/nomod?p0=MY_APP.c_commsb
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:8895:12
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:10785:17
    at ensure (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:10709:38)
    at module (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:10783:14)
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13189:22
    at forEach (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:9163:20)
    at loadModules (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13173:5)
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13190:40
    at forEach (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:9163:20)
    at loadModules (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13173:5)
http://errors.angularjs.org/1.4.3/$injector/modulerr?p0=MY_APP.c_commsb&…3A63342%2FSD4v040t2%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13173%3A5)
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:8895:12
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13212:15
    at forEach (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:9163:20)
    at loadModules (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13173:5)
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13190:40
    at forEach (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:9163:20)
    at loadModules (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13173:5)
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13190:40
    at forEach (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:9163:20)
    at loadModules (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13173:5)
http://errors.angularjs.org/1.4.3/$injector/modulerr?p0=MY_APP.controlle…3A63342%2FSD4v040t2%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A13173%3A5)
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:8895:12
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13212:15
    at forEach (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:9163:20)
    at loadModules (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13173:5)
    at http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13190:40
    at forEach (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:9163:20)
    at loadModules (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13173:5)
    at createInjector (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:13099:11)
    at doBootstrap (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:10457:20)
    at bootstrap (http://localhost:63342/SD4v040t2/www/lib/ionic/js/ionic.bundle.js:10478:12)
http://errors.angularjs.org/1.4.3/$injector/modulerr?p0=MY_APP&p1=Error%…A63342%2FSD4v040t2%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A10478%3A12)

What is happening here?!

A: you have commented out the line <!--<script src="js/controllers/c_communicationsB.js"></script>
in your code sample, but have said that the method is in here.

A: It seems like your app is not getting called. Try wrapping your app in an IFFY.
(function () {
    var comms = angular.module('my_app.c_comms',[]);

    comms.controller('AppComms',['$scope',function($scope){
        //controller magic here
    }])

}());

This is a self calling function so your app will get called by itself.

A: //At controllers.js
angular.module('my_app',[
    //'ionic',
    'my_app.c_splash',
    'my_app.c_clock',
    'my_app.c_language',
    'my_app.c_comms',
    //'my_app.c_commsb',
    'pascalprecht.translate',
    'my_app.c_menu'
]);

A: Solved,
a week ago I used a script to prevent loading page from cache in browser in order to no need to refresh the site when i was debugging on chrome and force always to read from source.
I don't know who or why it was preventing of loading new controllers or new css in a new html  page I've added, this is what has made me think about this script.


text:
Q: iOS 15.3 has broken SwiftUI layout I just upgraded my phone from 15.x (I think 15.2) to 15.3, and my SwiftUI layout is broken, seems to be a List border issue.
Here is the code, followed by a screen shot of normal behavior (13.x to 15.x) and then what I see in 15.3
struct SessionView: View {
    var title: String
    var panel: Int
    var index: Int
    var range: [Int] = [0,2,3,4]

    @EnvironmentObject var state: MainViewModel
    @EnvironmentObject var content: ContentViewModel

    @ViewBuilder
    var body: some View {
        VStack() {
            // -- Header
            HStack() {
                Text(" ")
                Image(self.state.panelIcon(panel: panel)).resizable().frame(width: 12.0, height: 12.0)
                Text(title)
                Spacer()
            }.padding(EdgeInsets(top: 8, leading: 0, bottom: 8, trailing: 0))
            .background(Color(red: 0.9, green: 0.9, blue: 0.9))
            .onTapGesture {
                showDetailDialog()
            }

            // -- Rows
            List {
                ForEach(0..<5) { i in
                    if i != 1 { // Skip IP address
                        HStack(alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/, spacing: -4, content: {
                            Text("\(state.keyValues[i+index]!.key)").frame(minWidth: 120, maxHeight: 20, alignment: .leading)
                                .font(Font.system(size: 15, design: .default)).padding(0)
                            Text("\(state.keyValues[i+index]!.value)").frame(maxHeight: 20, alignment: .leading)
                                .font(Font.system(size: 15, design: .default)).padding(0)
                        }).frame(height: 10)
                    }
                }
            }.environment(\.defaultMinListRowHeight, 10)
            .frame(height: 4*20+20)
            .listStyle(DefaultListStyle()).environment(\.defaultMinListRowHeight, 8).onAppear {
                UITableView.appearance().isScrollEnabled = false
            }.layoutPriority(1)
        }.overlay(
            RoundedRectangle(cornerRadius: 10)
                .stroke(Color(red: 0.8, green: 0.8, blue: 0.8), lineWidth: 1.25)
        ).background(Color.white)

    }
    .
    .
    .
}

A: I had this problem too. However, it is not a border issue. When you updated your iPhone, the default list style for SwiftUI changed. The old default style is now called PlainListStyle(). Use that instead to get the old look back.
List {

}.listStyle(PlainListStyle())


text:
Q: iOS: Google Maps API - markerInfoWindow vs markerInfoContents I looked through the Google Maps docs and the description does not seem to help much.
I'm following an old tutorial that made use of markerInfoContents however, when I used the delegate it didn't return what I expected.
With markerInfoContents: My custom view seems to override the default view

When I used markerInfoWindow, the results were what I expected:

I am simply pulling in a custom UIView from a xib file like so:
func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
    let placeMarker = marker as! PlaceMarker
    print(placeMarker.name)

    if let infoView = UIView.viewFromNibName(name: "MarkerInfoView") as? MarkerInfoView {
        infoView.nameLabel.text = placeMarker.name

        return infoView
    } else {
        return nil
    }
}

(Replace markerInfoWindow with markerInfoContents for the first image results)
With markerInfoContents it created the anchor and the shadow effect of the box. When using markerInfoWindow it does not create that anchor or shadow effect like in the tutorial.
Any help would be great!

A: As mentioned in the documentation link posted, when using markerInfoContents: "If this method returns a view, it will be placed within the default info window frame.", so your view is constrained within the default window (that's why it shows the anchor and shadow). It looks like the default infowindow is smaller than the UIView form your xib, so it truncates it.
The use of markerInfoWindow shows the view you pass directly, so if it does not have the anchor or shadow, it will not appear.

A: If you want to use the default shadow effect and the anchor with markerInfoContents then you have to do it like this:
func mapView(_ mapView: GMSMapView, markerInfoContents marker: GMSMarker) -> UIView?
{
    let placeMarker = marker as! PlaceMarker
    let view = UIView(frame: CGRect.init(x: 0, y: 0, width: 150, height: 150))
    if let infoView = UIView.viewFromNibName(name: "MarkerInfoView") as? MarkerInfoView
    {
        infoView.nameLabel.text = placeMarker.name
        view.addSubview(infoView!)
        return view
    } else {
        return nil
    }
}


text:
Q: Is there a way to collapse rows that belong to the same Table in Antd 2.x? I'm trying to make a row show more information that belong to the same table using antd and react (the data nested still belongs to the table, but it is collapsed) as is shown on image below. Searching on antd table documentation, I found a example to nest another table in the main table. Howerver, the second table also needs to have a Header besides it does not fallow the alignment of the first one. Could someone please explain me how I reach there?
example
antd table example


text:
Q: Div saindo do lado direito da pagina na animação Eu tenho uma div que é um celular e quando vou descendo a pagina executa a animação porem antes de executar a animação essa div ta ficando fora da pagina quebrando todo o layuout
minha div

ela fica com essa faixa branca e em smartphones é bem maior

conforme a animação é executada a faixa some pq a imagem fica na sua posição correta colocando overflow: hidden eu consegui limitar o erro mas ai é como se ela saísse do meio da pagina fica feio

A: Acredito que colocar um overflow no eixo X no HTML e no body deve resolver o seu problema.
    html,
    body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow-x: hidden;
    }


text:
Q: Trouble checking if url param exists I'm having a bit of trouble trying to find if my url parameters exist or not.
I have tried the following:
 // doesn't work
(Request.QueryString["showTop"] != "" && Request.QueryString["showTop"] != null)
 // doesn't work
(Request.Params["showTop"] != "" && Request.Params["showTop"] != null)

I am trying to find the correct value. The full statement looks like:
showTop = (Request.QueryString["showTop"] != "" &&
           Request.QueryString["showTop"] != null) ?
                     Request.QueryString["showTop"]  : (10).ToString();

Which works fine, if showTop exists with a value.
This is being done within the view.

A: Try the following:
showTop = string.IsNullOrEmpty(Request["showTop"]) ? "10" : Request["showTop"];

Assuming you want "showTop"to default to "10".

A: First check whether QueryString has keys or not by calling this method.
bool qKeys = Request.QueryString.HasKeys();


text:
Q: Difference between feedback RNN and LSTM/GRU I am trying to understand different Recurrent Neural Network (RNN) architectures to be applied to time series data and I am getting a bit confused with the different names that are frequently used when describing RNNs. Is the structure of Long Short-Term Memory (LSTM) and Gated Recurrent Unit (GRU) essentially an RNN with a feedback loop?

A: All RNNs have feedback loops in the recurrent layer. This lets them maintain information in 'memory' over time. But, it can be difficult to train standard RNNs to solve problems that require learning long-term temporal dependencies. This is because the gradient of the loss function decays exponentially with time (called the vanishing gradient problem). LSTM networks are a type of RNN that uses special units in addition to standard units. LSTM units include a 'memory cell' that can maintain information in memory for long periods of time. A set of gates is used to control when information enters the memory, when it's output, and when it's forgotten. This architecture lets them learn longer-term dependencies. GRUs are similar to LSTMs, but use a simplified structure. They also use a set of gates to control the flow of information, but they don't use separate memory cells, and they use fewer gates.
This paper gives a good overview:

Chung et al. (2014).  Empirical Evaluation of Gated Recurrent Neural Networks on Sequence Modeling.

A: LSTMs are often referred to as fancy RNNs. Vanilla RNNs do not have a cell state. They only have hidden states and those hidden states serve as the memory for RNNs.
Meanwhile, LSTM has both cell states and a hidden states. The cell state has the ability to remove or add information to the cell, regulated by "gates". And because of this "cell", in theory, LSTM should be able to handle the long-term dependency (in practice, it's difficult to do so.)

A: TL;DR

We can say that, when we move from RNN to LSTM (Long Short-Term Memory), we are introducing
more & more controlling knobs, which control the flow and mixing of
Inputs as per trained Weights. And thus, bringing in more flexibility
in controlling the outputs. So, LSTM gives us the most Control-ability
and thus, Better Results. But also comes with more Complexity and
Operating Cost.
Reference

[NOTE]:
GRU is better than LSTM as it is easy to modify and doesn't need memory units, therefore, faster to train than LSTM and give as per performance. Actually, the key difference comes out to be more than that: Long-short term (LSTM) perceptrons are made up using the momentum and gradient descent algorithms.

This image demonstrates the difference between them:

A: Standard RNNs (Recurrent Neural Networks) suffer from vanishing and exploding gradient problems. LSTMs  (Long Short Term Memory) deal with these problems by introducing new gates, such as input and forget gates, which allow for a better control over the gradient flow and enable better preservation of "long-range dependencies". The long range dependency in RNN is resolved by increasing the number of repeating layer in LSTM.
RNN

LSTM
For Further Details :Understanding LSTM

A: I think the difference between regular RNNs and the so-called "gated RNNs" is well explained in the existing answers to this question. However, I would like to add my two cents by pointing out the exact differences and similarities between LSTM and GRU.
The original definitions mostly come in the following form (I omitted bias terms, as well as time indices where not needed, in order to reduce some noise in the formulas):
$$\begin{align}
  & \text{GRU} & & \text{LSTM} \\ \\
  \boldsymbol{z} &= \mathrm{gate}(\boldsymbol{x}, \boldsymbol{h}) &
  \boldsymbol{i} &= \mathrm{gate}(\boldsymbol{x}, \boldsymbol{h}) \\
  \boldsymbol{r} &= \mathrm{gate}(\boldsymbol{x}, \boldsymbol{h}) &
  \boldsymbol{o} &= \mathrm{gate}(\boldsymbol{x}, \boldsymbol{h}) \\
  &&
  \boldsymbol{f} &= \mathrm{gate}(\boldsymbol{x}, \boldsymbol{h}) \\
  \hat{\boldsymbol{h}}[t] &= \phi(\boldsymbol{W} \boldsymbol{x} + \boldsymbol{U} (\boldsymbol{r} \odot \boldsymbol{h}[t-1])) &
  \boldsymbol{c}[t] &= \boldsymbol{f} \odot \boldsymbol{c}[t-1] + \boldsymbol{i} \odot \phi_1(\boldsymbol{W} \boldsymbol{x} + \boldsymbol{U} \boldsymbol{h}[t-1]) \\
  \boldsymbol{h}[t] &= (\boldsymbol{1} - \boldsymbol{z}) \odot \boldsymbol{h}[t-1] + \boldsymbol{z} \odot \hat{\boldsymbol{h}}[t] &
  \boldsymbol{h}[t] &= \boldsymbol{o} \odot \phi_2(\boldsymbol{c}[t]).
\end{align}$$
Note that the GRU has only 2 gates, whereas the LSTM has 3. Also, the LSTM has two activation functions, $\phi_1$ and $\phi_2$, whereas the GRU has only 1, $\phi$. This immediately gives the idea that GRU is slightly less complex than the LSTM.
Now, if we rewrite the recurrences of both models so that they fit on a single line (instead of spreading over two lines), we would end up with the following equations:
\begin{align*}
  \boldsymbol{h}[t] &= (\boldsymbol{1} - \boldsymbol{z}) \odot \boldsymbol{h}[t-1] + \boldsymbol{z} \odot \phi(\boldsymbol{W} \boldsymbol{x} + \boldsymbol{U} (\boldsymbol{r} \odot \boldsymbol{h}[t-1])) \tag{GRU} \\
  \boldsymbol{c}[t] &= \boldsymbol{f} \odot \boldsymbol{c}[t-1] + \boldsymbol{i} \odot \phi_1(\boldsymbol{W} \boldsymbol{x} + \boldsymbol{U} (\boldsymbol{o}\odot \phi_2(\boldsymbol{c}[t-1]))) \tag{LSTM}
\end{align*}
By putting the recurrences next to each other like this, it should become clear that if all of the follwing equalities hold
$$\begin{align}
  \boldsymbol{f} & = \boldsymbol{1} - \boldsymbol{z} &
  \boldsymbol{i} & = \boldsymbol{z} &
  \boldsymbol{o} & = \boldsymbol{r} &
  \phi_2(\boldsymbol{x}) & = \boldsymbol{x},
\end{align}$$
the GRU and LSTM models implement the same recurrence. The only difference that remains, is that, in the LSTM, the gates are computed from $\boldsymbol{c}[t-1]$, whereas the GRU directly uses the result of the recurrence, $\boldsymbol{h}[t-1]$.
In this sense, the GRU is a strictly simplified version of the LSTM.


text:
Q: How do I fix the 'int' object has no attribute 'move' error when trying to allow the user to press the arrow keys to move an image? There is a part in my program where the user needs to move an image resembling their character by pressing the arrow keys or the 'wasd' keys. I have tried many ways to fix my code but it still produces the AttributeError: 'int' object has no attribute 'move'.
This is a section of my code:
#functions to move the player image
def left(event):
    level1.move(playerImage, -10, 0)

def right(event):
    level1.move(playerImage, 10, 0)

def up(event):
    level1.move(playerImage, 0, -10)

def down(event):
    level1.move(playerImage, 0, 10)

#function to open the level 1 page
def level1():

    #close levelSelection page and open level1 page
    root3.destroy()
    root4 = Tk()

    root4.bind("<a>", left)
    root4.bind("<d>", right)
    root4.bind("<w>", up)
    root4.bind("<s>", down)
    root4.bind('<Left>', left)
    root4.bind('<Right>', right)
    root4.bind('<Up>', up)
    root4.bind('<Down>', down)

    #create a canvas for the level1 and put it into the root
    level1 = Canvas(root4, height = 1500, width = 2000, bg = 'LightBlue3')
    level1.pack()

    #bring player image onto canvas
    player = PhotoImage(file = 'Player.png')
    playerImage = level1.create_image(425, 1200, image = player)

    mainloop()#end level1 page

A: You don't move canvas objects by calling move on the object id, you do it by calling move on the canvas and passing in the object id.
level1.move(playerImage, 10, 0)

Though in your case it won't work either since level1 is a function and also a local variable, and playerImage is also a local variable. You need to save the identifiers of the objects you move in a global variable (or use classes, or canvas tags), and you shouldn't be using the same name for both a function and a variable.
For example:
def left(event):
    level1_canvas.move(playerImage_id, -10, 0)

def level1():
    global level1_canvas, player1_id
    ...
    level1_canvas = Canvas(root4, height = 1500, width = 2000, bg = 'LightBlue3')
    ...
    player1_id = level1_canvas.create_image(...)

Though, if you are going to be creating multiple levels and/or multiple players it would be much better to use classes rather than global variables. Regardless, the root of your problem is that you're not using the move method properly.


text:
Q: Display property overridden by User Agent Stylesheet As must be obvious, I am no CSS expert. I have a class
.hidden{
 display:hidden
}

and a div
<div class="hidden">
</div>

But the div is not hidden when the page is rendered. When I look at the Computed styles in Chrome, it says the display property was overridden by the user agent stylesheet. Why?

A: Css:
.hidden {
    display: none
}

is the correct syntax.

A: If you want the element to not be visible AND not take in any space you should do:
.hidden { display: none; }

However if you want to hide the element, but let it take in space you should do:
.hidden { visibility: hidden; }

See this simple demo for an example.
The fact that you think the style is overwritten by the user-agent is that the user-agent doesn't recognize the style you are trying to use (because it is invalid).

A: Use display:none instead
Alternatively use visibility: hidden or opacity: 0 but please not browser support is sketchy


text:
Q: updating a variable in an ASP.NET MVC view I have this string variable call "status" which is updated by a serial port connection I've made. the "status" show's if u are connected to the serial port or not.
I've made a simple 2 buttons view. one opens the connection and the other close it.
i want to be able to auto update the status of the connection inside the view.
i guess i need to use some kind of timer which shows the string inside "status" every given time, but i have no clue on how to do it..
This is my HomeController:
public class HomeController : Controller
{
   public ActionResult Index()
    {
      return View();
    }

    [HttpPost]
    public JsonResult CheckStatus()
    {
    return Json(new { status = "active" });
    }
}

and this is my view:
<script type="text/javascript">
$(function() {
    // poll every 5 seconds
    setInterval('checkStatus()', 5000);
}

function checkStatus() {
    $.ajax({
        url: 'Home/CheckStatus',
        type: 'POST',
        dataType: 'json',
        success: function(xhr_data) {
            if(xhr_data.status == 'active') {
                // this would just disable the "Open" button
                $('#btnOpen').attr('disabled', 'disabled');
            }
        }
    });
}

A: I'm going to assume you can use jQuery, and that you have a Controller action that looks like this:
[HttpPost]
public class StatusController : Controller
{
    public JsonResult CheckStatus()
    {
        return Json(new { status = "active" });
    }
}

Then, in your view add the following script
<script type="text/javascript">
    $(function() {
        // poll every 5 seconds
        setInterval('checkStatus()', 5000);
    }

    function checkStatus() {
        $.ajax({
            url: 'Status/CheckStatus',
            type: 'POST',
            dataType: 'json',
            success: function(xhr_data) {
                if(xhr_data.status == 'active') {
                    // this would just disable the "Open" button
                    $('#btnOpen').attr('disabled', 'disabled');
                }
            }
        });
    }
</script>


text:
Q: When I hit play, my Sprite character rotates. Why? I am making a top down game on Unity, so I am using the x and z axis as my plane. I have my character rotated x 90, y 0, z 0 so that it is flat on the plane. As soon as I hit play the character is rotated vertical?! I think it has something to do with my script to face the mouse position.
What it should look like:

When I hit play:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{
    public static float moveSpeed = 10f;

    private Rigidbody rb;

    private Vector3 moveInput;
    private Vector3 moveVelocity;

    // Update is called once per frame

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        mainCamera = FindObjectOfType<Camera>();
    }

    void Update()
    {
        // Setting up movement along x and z axis. (Top Down Shooter)
        moveInput = new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical"));
        moveVelocity = moveInput * moveSpeed;

        //Make character look at mouse.
        var dir = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
        var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.AngleAxis(angle, Vector3.up);
    }

    void FixedUpdate()
    {
        // Allows character to move.
        rb.velocity = moveVelocity;
    }
}

A: Figured it out: I am answering my own question to help others.
Vector3 difference = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(90f, 0f, rotZ -90);

This does EXACTLY what I wanted!


text:
Q: Total orbital angular momentum of closed orbital Can anyone please help me in understanding why total orbital angular momentum of a closed orbital is zero? I can understand that the z th component $L_z$ = $m_l$h/2π will be zero on summing over all indexes but not why total L will be zero.
Total orbital and spin angular momentum for a closed shell
This is the link of a very much similar question but it doesn't answer my doubt as it goes through z-th component of L only and not x and y components. Any help will be appreciated.

A: Closed shells have spherical symmetry so if one component of $L$ is zero they all are zero.


text:
Q: Error Msg 10314, Level 16, State 11 with SAFE assembly after upgrade to SQL Server 2017 I have a pre-SQL Server 2017 database that I restored into / upgraded to SQL Server 2017. In this database I have a SQLCLR Assembly. The Assembly is marked as SAFE since it doesn't do anything requiring a higher level of permissions, and the database has TRUSTWORTHY disabled / OFF. The SQLCLR functions and stored procedures worked as expected before moving to SQL Server 2017, but now when I try to execute any of them I get the following error:

Msg 10314, Level 16, State 11, Server XXXXXXXXXXX, Line YYYYYY
        An error occurred in the Microsoft .NET Framework while trying to load assembly id ZZZZZ. The server may be running out of resources, or the assembly may not be trusted. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:
        System.IO.FileLoadException: Could not load file or assembly '{assembly_name}, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An error relating to security occurred. (Exception from HRESULT: 0x8013150A)

I have confirmed that CLR Integration / SQLCLR has been enabled on the server / instance.

A: The error is a result of the new clr strict security server-level configuration option in SQL Server 2017. This new security setting disallows any Assembly, even those marked as SAFE, from being either created or loaded into memory for execution, unless:

*

*the Database property of TRUSTWORTHY is ON (don't do this as it is an unnecessary security risk) and the Login that is the database owner (i.e. same SID used by the [dbo] User) needs to have the UNSAFE ASSEMBLY permission (which it might already have if the owner is sa or a member of the sysadmin fixed server role or maybe has the CONTROL SERVER permission).

*the Server-level configuration option of clr strict security is disabled / 0 (don't do this as it is an unnecessary security risk)

*the Assembly is signed and you have a corresponding signature-based Login that has been granted the UNSAFE ASSEMBLY permission (please do this)

*the SHA-512 hash of the Assembly is registered as a "Trusted Assembly" (absolutely never do this as there are numerous problems with it, not to mention that it was never needed in the first place)

All you need to do in order to fix this situation are the following steps (which are not difficult and provide the highest level of security):

*

*Create a Certificate in the Database where the Assembly resides

*Back up the Certificate (both Public and Private Keys) to files (optional)

*Sign the Assembly (or Assemblies) with the Certificate

*Remove the Private Key (it can be restored later from the backup file) (optional)

*For each additional Database that has unsigned, SAFE Assemblies:

*

*Either skip this sub-step (i.e. skip to Step 6), complete the steps, and repeat the whole process (this will result in one Certificate per each Database needing one), OR

*Do the following (this will result in one Certificate total, which will be used for all Databases):

*

*Create the same Certificate from the backup files (including the Private Key!)

*Sign the Assembly (or Assemblies) with the Certificate

*Remove the Private Key (it can be restored later from the backup file)

*Copy Certificate to [master] (Public Key only!)

*Create Login from Certificate

*Grant the Certificate-based Login the UNSAFE ASSEMBLY permission

A simple example of this (minus the optional backup and Private Key removal) would be:
USE [{database_containing_unsigned_safe_assembly}];

CREATE CERTIFICATE [{certificate_name}]
  ENCRYPTION BY PASSWORD = '{some password}'
  WITH SUBJECT = '{simple description}',
  EXPIRY_DATE = '2099-12-31';

ADD SIGNATURE
  TO Assembly::[{assembly_name}]
  BY CERTIFICATE [{certificate_name}]
  WITH PASSWORD = '{some password}';

DECLARE @PublicKey VARBINARY(MAX),
        @SQL NVARCHAR(MAX);

SET @PublicKey = CERTENCODED(CERT_ID(N'{certificate_name}'));

SET @SQL = N'
CREATE CERTIFICATE [{certificate_name}]
  FROM BINARY = ' + CONVERT(NVARCHAR(MAX), @PublicKey, 1) + N';';
PRINT @SQL; -- DEBUG

EXEC [master].[sys].[sp_executesql] @SQL;

EXEC [master].[sys].[sp_executesql] N'
CREATE LOGIN [{login_name}]
  FROM CERTIFICATE [{certificate_name}];

GRANT UNSAFE ASSEMBLY TO [{login_name}]; -- REQUIRED!!!!
';

A fully working example of this (minus the backup and Private Key removal) can be found on PasteBin:
Avoiding "Trusted Assemblies" - Demo
A detailed explanation of why you should use Certificates, and why you should not use "Trusted Assemblies", to fix this problem is provided in my blog post:
SQLCLR vs. SQL Server 2017, Part 4: "Trusted Assemblies" – The Disappointment
Also, please consider supporting my request to have Microsoft remove the new "Trusted Assemblies" feature given the numerous problems surrounding it (including security concerns), and the overall lack of benefits for having it:
Trusted Assemblies are more problematic yet less functional than Certificates - Please Remove


text:
Q: Activeform field hidden on create and shown on update in Yii2 I have an activeform field.
<?= $form->field($model, 'featured_listings')->dropDownList([1=>'Yes',0=>'No']); ?>

I need this field hidden on create and shown on update.

A: Add if() statement which uses $model->isNewRecord:
if($model->isNewRecord) {
    //do your stuff here
}

Or if you want to have just HTML hidden, add proper class by $model->isNewRecord ? 'hidden' : ''


text:
Q: Continuity of a supremum function over compact sets I'm unsure how to formally prove or disprove the following claim. It came up in trying to prove convergence of a gradient descent-style algorithm. I've tried using different definitions of continuity including the topological and epsilon-delta ones, but haven't quite got it.
Assume $f : \mathbb{R}^d \to \mathbb{R}^d$ is continuous, $U \subset \mathbb{R}^d$ is compact and define
$$ U_a=\{x+atf(x)∣t∈[0,1],x∈U\}$$ for any $a \in \mathbb{R}^{\geq0}$.
Notice that $U_a$ is just a compact expansion of $U$ with $U_a \subset U_{a'}$ for all $a < a'$. Is the function $L(a)=\sup_{x∈U_a}g(x)$ continuous for any continuous function $g : \mathbb{R}^d \to \mathbb{R}$?

A: The answer is yes.
Let $g: \mathbb R^d \to \mathbb R$ be a continuous function and $a \in [0,+\infty[$, $\epsilon >0$.
Since $U$ is compact (remark : $U$ is usually used to denote open sets rather than compacts), there is $M>0$ such that $\|f(x) \| \leq M$ for any $x\in U$. Since $U_{a+1}$ is compact, $g$ is uniformly continuous on it. Let $\eta$ be such that for all $x,y\in U_{a+1}$, $\|x-y\|\leq \eta$ implies $\|g(x) -g(y)\|\leq \epsilon$.
Then, if $x \in U_{a + \eta /M}$, there is $y\in U_{a}$ such that $\|x -y\| \leq \eta$. Therefore :
$$g(x) \leq g(y) + \epsilon \leq L(a) +\epsilon$$
and by taking the supremum of $x \in U_{a+\eta/M}$ you get :
$$L(a) \leq L(a+\eta/M)\leq L(a) +\epsilon $$
The same argument with $a$ replaced by $a-\eta/M$ shows that :
$$L(a) - \epsilon \leq L(a-\eta/M) \le L(a)$$
Since $L$ is increasing, this shows that $L$ is continuous.


text:
Q: Как запустить run в IntelliJ, если есть ошибки в коде? Как запустить такой код? Допустим, есть два класса, один с error`ами, другой нормальный. Класс с ошибками вообще не участвует в работе программы, но из-за него не получается протестить класс без ошибок. Вроде в IntelliJ можно поменять параметры запуска кода?
P.S. Писал тесты, но идея все равно выбрасывает исключения и не дает запустить тест.
UPD: Этот вопрос не решает проблему, там про подсветку в IntelliJ, а у меня про IntelliJ, которая не дает скомпилировать код если там есть ошибки.
UPD2: Вот JUnit тест:
@Test
public void test() {
    Board board = new Board();
    //initialization of the playing field (Board), checkers, etc.
    InitializeBoard initBoard = new InitializeBoard(board);
    initBoard.initialize();

    //start game
    CheckersGame game = new CheckersGame(board);
    game.start();
}

А если в edit configurations к тесту стaвлю Build, no errors check, то выходит такое исключение:
java.lang.Exception: No runnable methods

    at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:191)
    at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128)
    at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
    at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
    at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

A: В настройках запуска в Edit Configurations есть поле Before launch: Build, Activate tool window со списком действий, которые совершает IntelliJ перед запуском. По умолчанию там присутствует одно единственное действие Build. Замените его на Build, no error check и вы сможете запускать классы без ошибок, несмотря на наличие других классов с ошибками компиляции.
1)

2)

3)

4)

A: Закомментировать проблемные участки.


text:
Q: AngularJS $scope issues in tabset I have a problem trying to watch in my controller a collection generated by a filter in the view.
I store the filtered data in a variable :

and I would like to subscribe to changes of 'filteredCollection ' in my controller :
$scope.$watchCollection('filteredCollection', function() {
    if (typeof($scope.filteredCollection) != 'undefined')
        console.log('Results changed : ' + $scope.filteredCollection.length);
});

I have set up this JSFiddle to show you my issue : my watch function is never called.
Fun Fact, it works when I remove all the <tabset> <tab> tags in my HTML. I think I messed up with the $scope, but I don't get why. Maybe the tabset create a new $scope child or something.
I hope you guys will find out what is going on here,
Cheers

A: Try to put filteredCollection in an object, so the it will change the correct scope property:
$scope.obj = { filteredCollection : [] };
$scope.$watchCollection('obj.filteredCollection', function(newVal) {
    if (typeof($scope.obj.filteredCollection) != 'undefined')
        console.log('Results changed : ' + $scope.obj.filteredCollection.length);
});

In the HTML:

See this fiddle.

A: You are correct in your thought that tabset and tab create new scopes. Because of that you are losing the context of filteredCollection since this is now being created in the context of the tab directives scope.
Angular fairly recently added controllerAs syntax that helps to avoid situations like this. It allows us to determine better which scope something is being executed in.
I have updated your jsFiddle with controllerAs syntax to show how this helps. The watch now fires as expected.
http://jsfiddle.net/hezwyjx1/2/
Here is a resource for some help with controller as syntax:
http://toddmotto.com/digging-into-angulars-controller-as-syntax/

A: This is an another post with the solution for this:
https://github.com/angular-ui/bootstrap/issues/1553


text:
Q: Calculate time difference using Python I am wondering if there is a way or builtin library available to find the difference in time from two string input.
What I mean is, if I have 2 input strings:

*

*'2013-10-05T01:21:07Z'

*'2013-10-05T01:21:16Z'

how can I can calculate the difference in time and print it as output.
I know it sounds a bit silly but any help on this is appreciated.

A: Parsing your strings using strptime():
a = time.strptime('2013-10-05T01:21:07Z', '%Y-%m-%dT%H:%M:%SZ')
b = time.strptime('2013-10-05T01:21:16Z', '%Y-%m-%dT%H:%M:%SZ')

This will parse the given time strings as local times (setting daylight savings (DST) to automatic), and the results are time structs.  These still reflect whether DST was explicitly off (0), on (1), or implicitly automatic (-1).  Convert these to a float (seconds since 1970-01-01):
a = time.mktime(a)
b = time.mktime(b)

Then compute the difference (in seconds):
d = b - a

And convert them to days/hours/minutes/seconds:
days = int(d) / 86400
hours = int(d) / 3600 % 24
minutes = int(d) / 60 % 60
seconds = int(d) % 60

The last block only works properly for positive differences, so be careful not to swap the a and b ;-)
But @J.F.Sebastian correctly pointed out that this might not be what you intended.  It seems from the notation that your strings describe a UTC time, not a local time.  For mere time differences this is relevant in case your time spans over a DST switch.  In this case it would of course result in a time difference one hour too great or one hour too small (because UTC is always without DST).
To avoid this, you can set the DST flag from automatic (-1) to a fixed value (e. g. 0 for off) and use these values:
a = time.mktime(a[:-1] + (0,))  # switch DST to off
b = time.mktime(b[:-1] + (0,))

Or, also as @J.F.Sebastian pointed out, you could forget about the time module and instead use datetime.datetime which is unaware of the DST aspect:
a = datetime.datetime.strptime('2013-10-05T01:21:07Z', '%Y-%m-%dT%H:%M:%SZ')
b = datetime.datetime.strptime('2013-10-05T01:21:16Z', '%Y-%m-%dT%H:%M:%SZ')

Then the results are datetime objects which can be subtracted directly to get a timedelta object which represents such a time difference as you want it.  Printing it will result in sth like 0:00:05 which might well be exactly what you are looking for.

A: You seem to be using an ISO 8601 formatted dateTime. This format is used in many places, including the GPS eXchange Format.
[-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]

Using datetime:
import datetime
a = datetime.datetime.strptime("2013-10-05T01:21:07Z", "%Y-%m-%dT%H:%M:%SZ")
b = datetime.datetime.strptime("2013-10-05T01:21:16Z", "%Y-%m-%dT%H:%M:%SZ")
c = b - a
print(c)

Advantages:

*

*Built-in to Python Standard Library

*Object-oriented interface

Disadvantages:

*

*Need to manually handle other valid ISO 8601 representations such as '2013-10-05T01:21:16+00:00'

*Throws exception for leap seconds such as '2012-06-30T23:59:60Z'

Using python-dateutil:
import dateutil.parser
a = dateutil.parser.parse("2013-10-05T01:21:07Z")
b = dateutil.parser.parse("2013-10-05T01:21:16Z")
c = b - a
print(c)

Advantages:

*

*Automagically handles pretty much any time format

Disadvantages:

*

*Needs python-dateutil library (pip install python-dateutil)

*Throws exception for leap seconds such as '2012-06-30T23:59:60Z'

Using time.strptime and time.mktime as suggested by Alfe
Advantages:

*

*Built-in to Python Standard Library

*Can parse leap seconds such as '2012-06-30T23:59:60Z'

Disadvantages:

*

*Need to manually handle other valid ISO 8601 representations such as '2013-10-05T01:21:16+00:00'

*Loss of one leap second between '2012-06-30T23:59:60Z' and '2012-07-01T00:00:00Z' (unavoidable without knowing when leap seconds will next occur)

A: import datetime
a = datetime.datetime.now()
b = datetime.datetime.now()
c = b - a
datetime.timedelta(0, 8, 562000)
divmod(c.days * 86400 + c.seconds, 60)

Original Answer  here


text:
Q: Writing Data to Internal File - ContextWrapper NullPointerException I'm creating a file for internal storage, and I'm running into a problem when the data is written. I know that it retrieves the right data when it's called (I used a Logcat tag to check that it was), but as soon as it tries to open the FileOutputStream, it says that there is a NullPointerException on the second line:
static ContextWrapper wrap = new ContextWrapper(context);
FileOutputStream gamesave = wrap.openFileOutput (FILENAME, Context.MODE_PRIVATE);
gamesave.write(DATA.getBytes());
gamesave.close();

I've looked at other questions and I can't figure out why the NullPointerException is there, it seems to be following the right procedure.

A: I think you have the wrong Context in your context var (i.e. ApplicationContext). Try using the context directly - without the Wrapper.

A: Why are you creating a ContextWrapper?  There is no reason to do that.  Just use the Context you have at hand -- the Activity if you are an Activity, or one passed in to your code if not.
Note that it is perfectly fine to use the Application as a Context for this.


text:
Q: How to check overlap date time with specific time SQL I using postgresSql and i want check overlap date in specific datetime, not range date time.
Example :
I have booking room two time  and it booking every saturday :
StartTime                EndTime
2019-08-10 00:00:00      2019-08-20 03:00:00

I only want check datetime every saturday(startTime + 7 days) every week. If I put time look like :
StartTime                EndTime
2019-08-17 00:00:00      2019-08-17 03:00:00

it overlaps . If i put time :
StartTime                EndTime
2019-08-16 00:00:00      2019-08-16 03:00:00

it not overlaps.
If i using command sql look like :
SELECT (TIMESTAMP '2019-08-10 00:00:00', TIMESTAMP '2019-08-10 03:00:00') OVERLAPS (TIMESTAMP '2019-08-10 01:00:00',TIMESTAMP '2019-08-20 01:00:00')

It check all date in range time: 2019-08-10 -> 2019-08-20 and throw overlaps . I only want check 2019-08-10 an 2019-08-17 and throw overlaps. If date 2019-08-11,2019-08-12,2019-08-13,2019-08-14,2019-08-15,2019-08-16,2019-08-18,2019-08-19,2019-08-20 it not overlaps. How to do that.
It same question it monthly. Please help ?

A: You may add an additional condition If at least one Saturday falls in the given range
SELECT
(TIMESTAMP '2019-08-10 00:00:00', TIMESTAMP '2019-08-10 03:00:00')
  OVERLAPS
(TIMESTAMP '2019-08-10 01:00:00', TIMESTAMP '2019-08-20 01:00:00') AND
EXISTS (
 select 1 from generate_series(
         TIMESTAMP '2019-08-10 00:00:00',
         TIMESTAMP '2019-08-10 03:00:00',
         INTERVAL '1 DAY'
         ) as dt  where extract(isodow from dt ) = 6
   )                            --ISO day of the week


text:
Q: Android regular expression to get first possibility Hi I am using following code to get the double value from string.
if (content!=null){
            Pattern p = Pattern.compile("[0-9]+([.][0-9]+)?$");
            Matcher m = p.matcher(content);
            if(m.find()){
                textView2.setText(m.group(0));
            }
        }

But my problem is,it always shows the last occurrence of double value.For example I am having a string "34.56 is greater than 24.67".In this I want to return 34.56,but the above code always return 24.67. Can any one show me the right way to get the first occurrence. Any help would be appreciated and thanks in advance.

A: Don't use $. It's for the end of the string. So it should be:
[0-9]+([.][0-9]+)?


text:
Q: RecyclerView don't work I have created RecyclerView inside RecyclerView, but for some reason my pictures are not displayed in the internal. Help please!
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

    switch (holder.getItemViewType()) {

        case TYPE_SUBSKRIBE_LIKE_AS:

            SubscribeLikeAsHolder subscribeLikeAs = (SubscribeLikeAsHolder) holder;

            subscribeLikeAs.recyclerViewImagines.setLayoutManager(new LinearLayoutManager(ctx, LinearLayoutManager.HORIZONTAL, false));

            subscribeLikeAs.recyclerViewImagines.setAdapter(imageRecyclerViewAdapter);

            break;
    }
}

public class ImageRecyclerViewAdapter extends RecyclerView.Adapter<ImageRecyclerViewAdapter.ImagesViewHolder>{

private Context ctx;
private LayoutInflater lInflater;
private ArrayList<ItemsImage> images;

public  void InForEntries (Context context, ArrayList<ItemsImage>  items) {

    ctx =  context;
    images = items;
    lInflater = (LayoutInflater) ctx
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

}

public static class ImagesViewHolder extends RecyclerView.ViewHolder {

    ImageView image;

    ImagesViewHolder(View itemView) {
        super(itemView);
        image = (ImageView) itemView.findViewById(R.id.imageViewSmall);
    }
}

@Override
public ImagesViewHolder onCreateViewHolder(ViewGroup viewGroup, int typeView) {
    View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.adapter_for_images, viewGroup, false);
    return new ImagesViewHolder(view);
}

@Override
public void onBindViewHolder(ImageRecyclerViewAdapter.ImagesViewHolder holder, int position) {

   // holder.image.setBackground(images.get(position).getDrawable());

    holder.image.setBackground(ctx.getResources().getDrawable(R.drawable.image_1));

}

@Override
public int getItemCount() {
    return images.size();
}

@Override
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
    super.onAttachedToRecyclerView(recyclerView);
}

}

A: A common mistake I make is forgetting to set a LinearLayoutManager to the RecyclerView.
    private LinearLayoutManager mLayoutManager;
    RecyclerView mRecyclerView;

    mLinearLayoutManager = new LinearLayoutManager(context);
    mLinearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mLayoutManager);


text:
Q: Get polygons close to a lat,long in MySQL Does anyone know of a way to fetch all polygons in a MySQL db within a given distance from a point? The actual distance is not that important since it's calculated for each found polygon later, but it would be a huge optimization to just do that calculation for the polygons that are "close".
I've looked at the MBR and contains functions but the problem is that some of the polygons are not contained within a bounding box drawn around the point since they are very big, but some of their vertices are still close.
Any suggestions?

A: A slow version (without spatial indexes):
SELECT  *
FROM    mytable
WHERE   MBRIntersects(mypolygon, LineString(Point(@X - @distance, @Y - @distance), Point(@X + @distance, @Y + @distance))

To make use of the spatial indexes, you need to denormalize your table so that each polygon vertex is stored in its own record.
Then create the SPATIAL INDEX on the field which contains the coordinates of the vertices and just issue this query:
SELECT  DISTINCT polygon_id
FROM    vertices
WHERE   MBRContains(vertex, LineString(Point(@X - @distance, @Y - @distance), Point(@X + @distance, @Y + @distance))

The things will be much more easy if you store UTM coordinates in your database rather than latitude and longitude.

A: I don't think there's a single answer to this. It's generally a question of how to organize your data so that it makes use of the spacial locality inherent to your problem.
The first idea that pops into my head would be to use a grid, assign each point to a square, and check select the square the point is in, and those around it. If we're talking infinite grids, then use a hash-value of the square, this would give you more points than needed (where you have collisions), but will still reduce the amount by a bunch. Of course this isn't immediately applicable to polygons, it's just a brainstorm. A possible approach that might yield too many collisions would be to OR all hashed values together and select all entries where the hashes ANDed with that value is non-zero (not sure if this is possible in MySQL), you might want to use a large amount of bits though.
The problem with this approach is, assuming we're talking spherical coordinates (lat, long generally does) are the singularities, as the grid 'squares' grow narrower as you approach the poles. The easy approach to this is... don't put any points close to the poles... :)

A: Create a bounding box for all of the polygons and (optionally storing these results in the database will make this a lot faster for complex polygons).  You can then compare the bounding box for each polygon with the one round the point at the desired size.  Select all the polygons which have intersecting bounding boxes.