text:
Q: Deploy lambda function on aws-pulumi I'm trying to deploy a lambda Function on my AWS account, that zips a file that is uploaded into "lambda-bucket-in" onto a bucket "lambda-bucket-out". The example I'm trying to follow is this one, specifically the second way (the first does its job properly).
My pulumi code is the following one:
import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

const tpsReports = new aws.s3.Bucket("lambda-bucket-in");
const tpsZips = new aws.s3.Bucket("lambda-bucket-out");

// First, create some IAM machinery:
const zipFuncRole = new aws.iam.Role("zipTpsReportsFuncRole", {
    assumeRolePolicy: {
       Version: "2012-10-17",
       Statement: [{
          Action: "sts:AssumeRole",
          Principal: {
             Service: "lambda.amazonaws.com",
          },
          Effect: "Allow",
          Sid: "",
       }],
    },
 });
 new aws.iam.RolePolicyAttachment("zipTpsReportsFuncRoleAttach", {
    role: zipFuncRole,
    policyArn: aws.iam.ManagedPolicy.AWSLambdaExecute,
 });

 // Next, create the Lambda function itself:
 const zipFunc = new aws.lambda.Function("zipTpsReportsFunc", {
    environment: {
       variables: {
          "TPS_ZIP_BUCKET": tpsZips.bucket,
       },
    },
    code: new pulumi.asset.AssetArchive({
       ".": new pulumi.asset.FileArchive("app"),
    }),
    runtime: "nodejs12.x",
    role: zipFuncRole.arn,
 });

 // Finally, register the Lambda to fire when a new TPS report arrives:
 tpsReports.onObjectCreated("zipTpsReports", zipFunc);

While "app" file, with the lambda function is:
   const AdmZip = require("adm-zip");
   const s3 = new aws.sdk.S3();
   for (const rec of e.Records || []) {
      const zip = new AdmZip();
      const [ buck, key ] = [ rec.s3.bucket.name, rec.s3.object.key ];
      console.log(`Zipping ${buck}/${key} into ${tpsZips.bucket.get()}/${key}.zip`);
      const data = await s3.getObject({ Bucket: buck, Key: key }).promise);
      zip.addFile(key, data.Body);
      await s3.putObject({
         Bucket: tpsZips.bucket.get(),
         Key: `${key}.zip`,
         Body: zip.toBuffer(),
      }).promise();
   }

While running pulumi with the command pulumi up --yes, and after inserting the password, it returns:
Previewing update (my-lambda):
     Type                                  Name                         Plan       Info
 +   pulumi:pulumi:Stack                   bucket-my-lambda-my-lambda   create     1 error; 48 messages
 +   ├─ aws:s3:Bucket                      lambda-bucket-out            create
 +   ├─ aws:s3:Bucket                      lambda-bucket-in             create
 +   │  ├─ aws:s3:BucketEventSubscription  zipTpsReports                create
 +   │  └─ aws:s3:BucketNotification       zipTpsReports                create
 +   ├─ aws:iam:Role                       zipTpsReportsFuncRole        create
 +   └─ aws:iam:RolePolicyAttachment       zipTpsReportsFuncRoleAttach  create

Diagnostics:
  pulumi:pulumi:Stack (bucket-my-lambda-my-lambda):
    TypeError: Cannot read property 'split' of undefined
        at deserializeProperty (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:472:48)
        at Object.deserializeProperties (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:126:24)
        at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:524:43
        at Generator.next (<anonymous>)
        at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
        at resolveOutputs (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:519:12)
        at Object.<anonymous> (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:321:19)
        at Generator.throw (<anonymous>)
    TypeError: Cannot read property 'split' of undefined
        at deserializeProperty (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:472:48)
        at Object.deserializeProperties (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:126:24)
        at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:524:43
        at Generator.next (<anonymous>)
        at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
        at resolveOutputs (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:519:12)
        at Object.<anonymous> (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:321:19)
        at Generator.throw (<anonymous>)

    unhandled rejection: CONTEXT(1251): monitor.registerResource(resource:zipTpsReports[aws:lambda/permission:Permission])-initial
    STACK_TRACE:
    Error:
        at Object.debuggablePromise (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/debuggable.js:69:75)
        at runAsyncResourceOp (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:634:75)
        at Object.<anonymous> (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:257:9)
        at Generator.next (<anonymous>)
        at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
        at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:219:63
        at runMicrotasks (<anonymous>)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
    unhandled rejection: CONTEXT(1251): monitor.registerResource(resource:zipTpsReports[aws:lambda/permission:Permission])-initial
    STACK_TRACE:
    Error:
        at Object.debuggablePromise (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/debuggable.js:69:75)
        at runAsyncResourceOp (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:634:75)
        at Object.<anonymous> (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:257:9)
        at Generator.next (<anonymous>)
        at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
        at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:219:63
        at runMicrotasks (<anonymous>)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)

    error: Running program '/home/andrea/Piratech/pulumi/bucket-my-lambda' failed with an unhandled exception:
    TypeError: Cannot read property 'split' of undefined
        at deserializeProperty (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:472:48)
        at Object.deserializeProperties (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/rpc.js:126:24)
        at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:524:43
        at Generator.next (<anonymous>)
        at /home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:21:71
        at new Promise (<anonymous>)
        at __awaiter (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:17:12)
        at resolveOutputs (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:519:12)
        at Object.<anonymous> (/home/andrea/Piratech/pulumi/bucket-my-lambda/node_modules/@pulumi/pulumi/runtime/resource.js:321:19)
        at Generator.throw (<anonymous>)

Does anyone know how to fix this issue, and what does it stand for?
Thank you for your help.


text:
Q: comparison of infinispan and Jboss cache I am not native and am poor at English. Please understand the situation.
I have been carrying out a comparison of Infinispan and JBoss Cache.
Both products are open-source. The JBoss Cache website has at the top the statement 'Project In Maintenance Mode'. Growth of the product will not be carried
out, but it is recognized they will carry out stability based changes.
Moreover, I recognize Infinispan being a successor of kind to JBoss
Cache.
However, the point that Infinispan is better than JBoss Cache in regard to performance or
stability is unknown to me. Since it is unclear to me after an investigation from the web site,
may I have it taught?

A: As one of the Infinispan developers, and old JBoss Cache contributor, I'd suggest you have a read to the FAQS.
They explain all you need to know about the relationship between Infinispan and JBoss Cache. The point is, unless you're tied to old JBoss Cache, you should be using Infinispan.

A: On stability point of view, Red Hat have producterize Infinispan into Data Grid providing enterprise support of the product, so they think they have correct stability.
On performance, I found some local cache scenario (Infinispan is customizable enough to be not distributed) coparaison with JBoss Cache and eChache http://infinispan.blogspot.co.uk/2010/02/infinispan-as-local-cache.html
Feature wise Infinispan is more complete.
Even with these argument, actual use, ease of use and performance, depending of team experience, actual caching scenario, foreseeable future scenario can be guest.  You probably need to make some prototype to prove the fit.  (But I will start with Infinispan...)

A: I would start with infinispan too. Currently I am using Infinispan 5.1.5 in pre-production env. I have never used JBoss Cache.
Infinispan 5.1.5 is used in RedHat JDG and you could buy support if needed.

redpajama_set_name: RedPajamaStackExchange


text:
Q: pyautogui "move" and "press" function does not run for some unknown reason I am building a client which receives commands from a server. (A "TeamViewer" type program)
The server sends keypress events and mouse coordinates and the client runs them.
although currently debugging is running on the same computer, I expect to see some mouse movement when I use pyautogui.move(x,y) or pyautogui.press(char). No movement is seen and no keyboard press is happening.
The function exe() is running on a thread and is working properly (printing the coordinates works fine).
Why does pyautogui.move(x,y) or pyautogui.press(char) work is this code?

def exe():
        while True:
            if executeQ:
                command = executeQ.get()
                commandlist = command.split('\n')

                char = commandlist[0]
                x = commandlist[1]           #getting command
                y = commandlist[2]

                try:
                    print(f'Typing - {char}')
                    pyautogui.press(char)
                except:
                    pass

                try:
                    print(f'Moving to - {x},{y}')
                    pyautogui.move(x,y)
                except:
                    print("OUT OF BOUNDS / SAME POSOTION")

A: Try to convert x and y to integers.
x = int(commandlist[1])
y = int(commandlist[2])


text:
Q: Confusion on assessing the linearity assumption This is for assignment. But i am not asking for hold my finger and guide me. Just asking something that is confusing me.
I am reading a chapter in which we are using gg_resX(mydata) from lindia package.  The value of mydata was calculated from mydata <- with(my_centered_data, lm(y ~ x)).
The output of this is following graph

The author of the tutorial then went on to say that there is no non-linear pattern here. Even though, to me, it appears that there is kind of a sin wave ..
Now, here is another graph

Should i consider that there is no pattern here as well? Or should i call it out that there are outliers at the bottom of the graph?
I mean, I am not sure why author said in first graph that it is linear and because of that i am confuse at second one

A: The plots appear to be for residuals vs fitted values, or perhaps against a predictor. This is a fairly standard approach to assessing linearity.
Basically we don't want to see any non-linear pattern in the plots.
The problem we have here is that the sample size is quite small. It looks like around 30. With this sample size it would be easy for a nonlinearity to be masked, or indeed to see a spurious nonlinear association.
I think you are justified in considering both plots to not show any clear evidence of nonlinearity.
Also, I would not pay too worry too much about apparent "outliers". Extreme data points occur naturally, it is only when something is clearly an error, such as a hieght of a human being 10cm, or 10m, that it should be removed.


text:
Q: Android android.permission.BLUETOOTH_CONNECT error I'm new to android studio and y have a problem that I can't solve.
I'm trying to enable Bluetooth, so I have done this :
AndroidManifest.xml :
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

MainActivity.java :
private void enableBLT(){

    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    if (adapter == null) {
        dialogNoBlt();
    }
    if (!adapter.isEnabled()) {

    if (ContextCompat.checkSelfPermission(
            MainActivity.this, Manifest.permission.BLUETOOTH_CONNECT) ==
            PackageManager.PERMISSION_GRANTED) {

            Intent enableBltIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableBltIntent, REQUEST_ENABLE_BT);

        } else {
            Log.d("blt-", "no permission");
        }
    } else {
        Log.d("blt-", "Not enabled");

    }
}

But I still have an error "requires android.permission.BLUETOOTH_CONNECT", and my app just crash.
Can you help me please ?

A: You have to request Manifest.permission.BLUETOOTH_CONNECT and Manifest.permission.BLUETOOTH_SCAN permissions at runtime as well. Just declaring in manifest is not sufficient because they are under dangerous permissions category.
docs for requesting permission
Refer the following link of answer for a direct code sample
requesting multiple permissions at runtime


text:
Q: Android Opengl 2d side scrolling game design decision I'm currently playing around with a 2D side scrolling platform game but I am unable to get the background to scroll. I've looked around the internet and have found a couple of tutorials, but I want to do it by drawing within OpenGL itself that make up the background.  There are obstacles on the background and a player which moves diagonally along a road. The background appears to move in diagonal direction.
I have also seen a few android game engines like andEngine and an open source project like http://code.google.com/p/replicaisland/
but unable to decide which one should be used as a starting point. I read in a few blogs for andEngine that it does not allow vertical scrolling so not sure if I should move ahead with it.

A: Get Corona SDK from anscomobile.com.

A: Side scrolling using OpenGL isn't very hard to do, but if you're just beginning with OpenGL, you do have something of a learning curve ahead of you. One library that might help you is Cocos2d for Android, which is free and open source, based on the excellent Cocos2d for iPhone library. The iPhone version of the library is mature, stable, and robust. I have no idea what the state of the Android library is, but it's worth looking into.
Good luck!


text:
Q: jqgrid editable x number formating is inconsisent with format on grid I've built a grid as the code bellow:
colModel: [
            { name: 'price',
              label: 'price',
              index: 'price',
              jsonmap: 'price',
              formatter: 'number',
              formatoptions: {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, defaultValue: '0,00'},
              editable: true
            }
          ]

The format of field is correctly on grid, for instance: 10,32, but the form created to edit the field fills one with 10.32 instead of 10,32.
Someone knows why this is going on? Do I need to use properties as edittype and editoptions (this one using formmater and formatoptions) as well? if yes, How I need set up these properties?

A: I've fixed the problem using the the function afterShowForm to handle the formating of field on form generated from grid.
In fact, I was expecting that jQGrid could do that automatically, i.e, using the configuration provided to column to apply on field generated, or if i could apply the configurion on JSON message, for instance:
editoptons: { formatter = "number", formatteroptions = { .... } ...

anyway, it's working now.


text:
Q: Media Upload URL or URL-loop -Wordpress I have created a custom gallery slider that I would like to connect to the Media Upload gallery function that's inside the post and pages creator.
The problem is that I cant seem to understand how to get raw URL-loop from the media upload gallery, because if I for now add images with the media upload function, it gives me an output that looks like this.

And i would like to have something like

Is this even possible ? I don't really want to use plugins

A: to get the url - run a query
$query_images_args = array(
    'post_type' => 'attachment', 'post_mime_type' =>'image', 'post_status' => 'inherit', 'posts_per_page' => -1,
);

$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image) {
    $images[]= wp_get_attachment_url( $image->ID );
}


text:
Q: How to get data from all rxjs streams where one of them are not emitted? I have some Rxjs streams that indicates changes:
reportChanges$
objectPropChanges$
textPropsChanges$

The first two have default values, the latest is not.
I tried to collect all changes and store them:
   this.changes$ = combineLatest([
            this.reportChanges$,
            this.objectPropChanges$,
            this.textPropsChanges$,
        ]).pipe(
            debounceTime(this.debouncetime),
            map(([reportProperties, reportObjectsProperties, textProperties]) => {
                return { reportObjectsProperties, reportProperties, textProperties };
            }),
        );

Then to store it:
   this.changes$
            .pipe(
                skip(1),
                switchMap((properties: ReportPropertiesRequest) => this.save(this.registryId, properties)),
            )
            .subscribe();
    }

Issue is that combineLatest works only when all streams have the latest value. In my case textPropsChanges$ has no.
How to collect all changes and store them?
My purpose is to collect all changes that happens asynchronously and store them imidiatly in storage.
Possible solution is set start value for all stremas with startWith or to use BehSubject. But in my case I can not use this, because user should make chnages himself.

A: You can ignore some default token. So here I've used null as an example:
this.changes$ = combineLatest([
  this.reportChanges$,
  this.objectPropChanges$,
  this.textPropsChanges$.pipe(startWith(null)),
]).pipe(
  debounceTime(this.debouncetime),
  map(([reportProperties, reportObjectsProperties, textProperties]) =>
      textProperties != null ? // Only include if not null
      { reportObjectsProperties, reportProperties, textProperties } :
      { reportObjectsProperties, reportProperties }
  ),
);

A: Probably you can have local object changes = {}. Then listen each stream separately and set chnages to this object:
this.reportChanges$.subscribe((data) => this.changes.report = data;
this.objectPropChanges$.subscribe((data) => this.changes.objectProp = data;


text:
Q: kubernetes nginx ingress controller return 404 Following this guide, I created an ingress controller on my local kubernetes server, the only difference is that it is created as a NodePort.
I have done some test deployments, with respective services and everything works, here the file
Deploy1:
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: helloworld1
spec:
  selector:
    matchLabels:
      app: helloworld1
  replicas: 1
  template:
    metadata:
      labels:
        app: helloworld1
    spec:
      containers:
      - name: hello
        image: gcr.io/google-samples/hello-app:1.0
        ports:
        - containerPort: 8080

Deploy2:
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: helloworld2
spec:
  selector:
    matchLabels:
      app: helloworld2
  replicas: 1
  template:
    metadata:
      labels:
        app: helloworld2
    spec:
      containers:
      - name: hello
        image: gcr.io/google-samples/hello-app:2.0
        ports:
        - containerPort: 8080

Deploy3:
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: geojson-example
spec:
  selector:
    matchLabels:
      app: geojson-example
  replicas: 1
  template:
    metadata:
      labels:
        app: geojson-example
    spec:
      containers:
        - name: geojson-container
          image: "nmex87/geojsonexample:latest"
          ports:
            - containerPort: 8080

Service1:
apiVersion: v1
kind: Service
metadata:
  name: helloworld1
spec:
#  type: NodePort
  ports:
  - port: 8080
  selector:
    app: helloworld1

Service2:
apiVersion: v1
kind: Service
metadata:
  name: helloworld2
spec:
#  type: NodePort
  ports:
  - port: 8080
  selector:
    app: helloworld2

Service3:
apiVersion: v1
kind: Service
metadata:
  name: geojson-example
spec:
  ports:
    - port: 8080
  selector:
    app: geojson-example

This is the ingress controller:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/default-backend: geojson-example
spec:
  rules:
    - http:
        paths:
          - path: /geo
            pathType: Prefix
            backend:
              service:
                name: geojson-example
                port:
                  number: 8080
          - path: /test1
            pathType: Prefix
            backend:
              service:
                name: helloworld1
                port:
                  number: 8080
          - path: /test2
            pathType: Prefix
            backend:
              service:
                name: helloworld2
                port:
                  number: 8080

When I do a GET on myServer:myPort/test1 or /test2 everything works, on /geo i get the following answer
{
    "timestamp": "2021-03-09T17:02:36.606+00:00",
    "status": 404,
    "error": "Not Found",
    "message": "",
    "path": "/geo"
}

Why??
if I create a pod, and from inside the pod, i do a curl on geojson-example it works, but from the external, i obtain a 404 (i think by nginx ingress controller)
This is the log of nginx pod:
x.x.x.x - - [09/Mar/2021:17:02:21 +0000] "GET /test1 HTTP/1.1" 200 68 "-" "PostmanRuntime/7.26.8" 234 0.006 [default-helloworld1-8080] [] 192.168.168.92:8080 68 0.008 200

x.x.x.x - - [09/Mar/2021:17:02:36 +0000] "GET /geo HTTP/1.1" 404 116 "-" "PostmanRuntime/7.26.8" 232 0.013 [default-geojson-example-8080] [] 192.168.168.109:8080 116 0.012 404

What can I do?

A: As far the doc: This annotation is of the form nginx.ingress.kubernetes.io/default-backend: <svc name> to specify a custom default backend. This <svc name> is a reference to a service inside of the same namespace in which you are applying this annotation. This annotation overrides the global default backend.
This service will be handle the response when the service in the Ingress rule does not have active endpoints.
You cannot use same service as default backend and also for a path. When you do this the path /geo became invalid. As we know default backend serves only the inactive endpoints. Now If you tell that you want geojson-example as default backend(for inactive endpoints) again in the paths if you tell that use geojson-example for a valid path /geo then it became invalid as you are creating a deadlock type situation here.
You actually do not need to give this nginx.ingress.kubernetes.io/default-backend annotation.
Your ingress should be like below without the default annotation, or you can use the annotation but in that case you need to remove geojson-example from using for any valid path in the paths, or need to use another service for the path /geo. Options that you can use are given below:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
    - http:
        paths:
          - path: /geo
            pathType: Prefix
            backend:
              service:
                name: geojson-example
                port:
                  number: 8080
          - path: /test1
            pathType: Prefix
            backend:
              service:
                name: helloworld1
                port:
                  number: 8080
          - path: /test2
            pathType: Prefix
            backend:
              service:
                name: helloworld2
                port:
                  number: 8080

Or:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/default-backend: geojson-example
spec:
  rules:
    - http:
        paths:
          - path: /geo
            pathType: Prefix
            backend:
              service:
                name: <any_other_service>    # here use another service except `geojson-example`
                port:
                  number: 8080
          - path: /test1
            pathType: Prefix
            backend:
              service:
                name: helloworld1
                port:
                  number: 8080
          - path: /test2
            pathType: Prefix
            backend:
              service:
                name: helloworld2
                port:
                  number: 8080

Or:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/default-backend: geojson-example
spec:
  rules:
    - http:
        paths:
          - path: /test1
            pathType: Prefix
            backend:
              service:
                name: helloworld1
                port:
                  number: 8080
          - path: /test2
            pathType: Prefix
            backend:
              service:
                name: helloworld2
                port:
                  number: 8080

A: This is for your default backend. You set the geojson-example service as a default backend.
The default backend is a service which handles all URL paths and hosts the nginx controller doesn't understand (i.e., all the requests that are not mapped with an Ingress).

Basically a default backend exposes two URLs:

/healthz that returns 200
/ that returns 404

So , if you want geojson-example service as a default backend then you don't need /geo path specification. Then your manifest file will be:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/default-backend: geojson-example
spec:
  rules:
    - http:
        paths:
          - path: /test1
            pathType: Prefix
            backend:
              service:
                name: helloworld1
                port:
                  number: 8080
          - path: /test2
            pathType: Prefix
            backend:
              service:
                name: helloworld2
                port:
                  number: 8080

Or if you want geojson-example as a ingress valid path then you have to remove default backend annotation. Then your manifest file will be:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
    - http:
        paths:
          - path: /geo
            pathType: Prefix
            backend:
              service:
                name: geojson-example
                port:
                  number: 8080
          - path: /test1
            pathType: Prefix
            backend:
              service:
                name: helloworld1
                port:
                  number: 8080
          - path: /test2
            pathType: Prefix
            backend:
              service:
                name: helloworld2
                port:
                  number: 8080


text:
Q: Reduce the number of non-empty switch cases Is there a way to Reduce the number of non-empty switch cases as SonarQube tells? In the reducer file a have 37 cases in a switch, but SonarQube allow just 30.
Maybe it is possible to write my code differently, because it works perfectly, the problem is just that SonarQube returns it like a CodeSmell. I post my reducer code below.
export function equipmentReducer(
  lastState: IEquipmentState = new EquipmentState(),
  action: GenericAction<EquipmentActionTypes, any>
): IEquipmentState {
    switch (action.type) {
        case EquipmentActionTypes.REQUEST_EQUIPMENT:
          return reducerUtils.requestListData<IEquipmentState, IEquipment[]>(lastState, ['equipmentList']);

    case EquipmentActionTypes.RECEIVE_EQUIPMENT:
      return reducerUtils.receiveListData<IEquipmentState, IEquipment[]>(lastState, ['equipmentList'], action.payload);

    case EquipmentActionTypes.ERROR_RECEIVE_EQUIPMENT:
      return reducerUtils.errorListData<IEquipmentState, IEquipment[]>(lastState, ['equipmentList'], action.payload);

    case EquipmentActionTypes.REQUEST_EQUIPMENT_BY_ID:
      return reducerUtils.requestItemData<IEquipmentState, IEquipment>(lastState, ['selectedEquipment']);

    case EquipmentActionTypes.RECEIVE_EQUIPMENT_BY_ID:
      return reducerUtils.receiveItemData<IEquipmentState, IEquipment>(
        lastState,
        ['selectedEquipment'],
        action.payload as IEquipment
      );

    case EquipmentActionTypes.ERROR_RECEIVE_EQUIPMENT_BY_ID:
      return reducerUtils.errorItemData<IEquipmentState, IEquipment>(lastState, ['selectedEquipment'], action.payload);

    case EquipmentActionTypes.REQUEST_ADD_EQUIPMENT:
    case EquipmentActionTypes.REQUEST_UPDATE_EQUIPMENT:
      return reducerUtils.requestPostPutItemData<IEquipmentState, IEquipment>(
        lastState,
        ['selectedEquipment'],
        action.payload
      );

    case EquipmentActionTypes.RECEIVE_ADD_EQUIPMENT:
    case EquipmentActionTypes.RECEIVE_UPDATE_EQUIPMENT:
      return reducerUtils.receivePostPutItemData<IEquipmentState, IEquipment>(
        lastState,
        ['selectedEquipment'],
        action.payload
      );

    case EquipmentActionTypes.ERROR_ADD_EQUIPMENT:
    case EquipmentActionTypes.ERROR_UPDATE_EQUIPMENT:
      return reducerUtils.errorPostPutItemData<IEquipmentState, IEquipment>(
        lastState,
        ['selectedEquipment'],
        action.payload
      );

    case EquipmentActionTypes.REQUEST_INITIAL_SPECIFICATION:
      return reducerUtils.requestListData<IEquipmentState, IEquipmentInitialSpecification[]>(lastState, [
        'equipmentInitialSpecification',
      ]);

    case EquipmentActionTypes.RECEIVE_INITIAL_SPECIFICATION:
      return reducerUtils.receiveListData<IEquipmentState, IEquipmentInitialSpecification[]>(
        lastState,
        ['equipmentInitialSpecification'],
        action.payload
      );

    case EquipmentActionTypes.ERROR_INITIAL_SPECIFICATION:
      return reducerUtils.errorListData<IEquipmentState, IEquipmentInitialSpecification[]>(
        lastState,
        ['equipmentInitialSpecification'],
        action.payload
      );

    case EquipmentActionTypes.REQUEST_MANUFACTURERS:
      return reducerUtils.requestListData<IEquipmentState, IManufacturersListItem[]>(lastState, [
        'manufacturers',
        'manufacturerList',
      ]);

    case EquipmentActionTypes.RECEIVE_MANUFACTURERS:
      return reducerUtils.receiveListData<IEquipmentState, IManufacturersListItem[]>(
        lastState,
        ['manufacturers', 'manufacturerList'],
        action.payload
      );

    case EquipmentActionTypes.ERROR_RECEIVE_MANUFACTURERS:
      return reducerUtils.errorListData<IEquipmentState, IManufacturersListItem[]>(
        lastState,
        ['manufacturers', 'manufacturerList'],
        action.payload
      );

    case EquipmentActionTypes.REQUEST_SUPPLIERS:
      return reducerUtils.requestListData<IEquipmentState, ISuppliersListItem[]>(lastState, [
        'suppliers',
        'supplierList',
      ]);

    case EquipmentActionTypes.RECEIVE_SUPPLIERS:
      return reducerUtils.receiveListData<IEquipmentState, ISuppliersListItem[]>(
        lastState,
        ['suppliers', 'supplierList'],
        action.payload
      );

    case EquipmentActionTypes.ERROR_RECEIVE_SUPPLIERS:
      return reducerUtils.errorListData<IEquipmentState, ISuppliersListItem[]>(
        lastState,
        ['suppliers', 'supplierList'],
        action.payload
      );

    case EquipmentActionTypes.REQUEST_ADD_MANUFACTURER:
      return reducerUtils.requestPostPutItemData<IEquipmentState, IManufacturer>(
        lastState,
        ['manufacturers', 'selectedManufacturer', 'manufacturerInfo'],
        action.payload
      );

    case EquipmentActionTypes.RECEIVE_ADD_MANUFACTURER:
      return reducerUtils.receivePostPutItemData<IEquipmentState, IManufacturer>(
        lastState,
        ['manufacturers', 'selectedManufacturer', 'manufacturerInfo'],
        action.payload
      );

    case EquipmentActionTypes.ERROR_ADD_MANUFACTURER:
      return reducerUtils.errorPostPutItemData<IEquipmentState, IManufacturer>(
        lastState,
        ['manufacturers', 'selectedManufacturer', 'manufacturerInfo'],
        action.payload
      );

    case EquipmentActionTypes.REQUEST_ADD_SUPPLIER:
      return reducerUtils.requestPostPutItemData<IEquipmentState, ISupplier>(
        lastState,
        ['suppliers', 'selectedSupplier', 'supplierInfo'],
        action.payload
      );

    case EquipmentActionTypes.RECEIVE_ADD_SUPPLIER:
      return reducerUtils.receivePostPutItemData<IEquipmentState, ISupplier>(
        lastState,
        ['suppliers', 'selectedSupplier', 'supplierInfo'],
        action.payload
      );

    case EquipmentActionTypes.ERROR_ADD_SUPPLIER:
      return reducerUtils.errorPostPutItemData<IEquipmentState, ISupplier>(
        lastState,
        ['suppliers', 'selectedSupplier', 'supplierInfo'],
        action.payload
      );

    case EquipmentActionTypes.REQUEST_ADD_MANUFACTURER_CONTACT:
      return reducerUtils.requestPostPutItemData<IEquipmentState, IContact>(
        lastState,
        ['manufacturers', 'selectedManufacturer', 'selectedContact'],
        action.payload
      );

    case EquipmentActionTypes.RECEIVE_ADD_MANUFACTURER_CONTACT:
      return reducerUtils.receivePostPutItemData<IEquipmentState, IContact>(
        lastState,
        ['manufacturers', 'selectedManufacturer', 'selectedContact'],
        action.payload
      );

    case EquipmentActionTypes.ERROR_ADD_MANUFACTURER_CONTACT:
      return reducerUtils.errorPostPutItemData<IEquipmentState, IContact>(
        lastState,
        ['manufacturers', 'selectedManufacturer', 'selectedContact'],
        action.payload
      );

    case EquipmentActionTypes.REQUEST_ADD_SUPPLIER_CONTACT:
      return reducerUtils.requestPostPutItemData<IEquipmentState, IContact>(
        lastState,
        ['suppliers', 'selectedSupplier', 'selectedContact'],
        action.payload
      );

    case EquipmentActionTypes.RECEIVE_ADD_SUPPLIER_CONTACT:
      return reducerUtils.receivePostPutItemData<IEquipmentState, IContact>(
        lastState,
        ['suppliers', 'selectedSupplier', 'selectedContact'],
        action.payload
      );

    case EquipmentActionTypes.ERROR_ADD_SUPPLIER_CONTACT:
      return reducerUtils.errorPostPutItemData<IEquipmentState, IContact>(
        lastState,
        ['suppliers', 'selectedSupplier', 'selectedContact'],
        action.payload
      );

    case EquipmentActionTypes.REQUEST_EQUIPMENT_DELETE:
      return reducerUtils.requestPostPutItemData<IEquipmentState, IEquipment>(lastState, ['deletedEquipment'], action.payload);

    case EquipmentActionTypes.RECEIVE_EQUIPMENT_DELETE:
      return reducerUtils.receivePostPutItemData<IEquipmentState, IEquipment>(lastState, ['deletedEquipment'], action.payload);

    case EquipmentActionTypes.ERROR_RECEIVE_EQUIPMENT_DELETE:
      return reducerUtils.errorPostPutItemData<IEquipmentState, IEquipment>(lastState, ['deletedEquipment'], action.payload);

    case EquipmentActionTypes.REQUEST_EQUIPMENT_IS_DELETED:
      return requestItemData<IEquipmentState, boolean>(lastState, ['equipmentIsDeleted']);

    case EquipmentActionTypes.RECEIVE_EQUIPMENT_IS_DELETED:
      return receiveItemData<IEquipmentState, boolean>(lastState, ['equipmentIsDeleted'], action.payload);

    case EquipmentActionTypes.ERROR_RECEIVE_EQUIPMENT_IS_DELETED:
      return errorItemData<IEquipmentState, boolean>(lastState, ['equipmentIsDeleted'], action.payload);

    case EquipmentActionTypes.RESET_STATE:
      return resetSelectedEquipmentState(lastState);

    default:
      return lastState;
  }
}

A: I believe you can reduce it by finding common returns and creating a map. For example reducerUtils.requestListData is called 5 times, by creating a map for the differences you should be able to get rid of 4 switch cases.
Initial thought is to turn action.types that share return functions, into a new map (myMap) keys and list the specific different parameters here (I use option1 and option2 as I don't know the rest of your code). An alternative to using option1 is to change it to unknown or a list of possibilities with | (IEquipment[] | IEq....) inside <>
const myMap = {
    [EquipmentActionTypes.REQUEST_EQUIPMENT]: {
      option1: IEquipment[],
      option2: ['equipmentList']
    },
    [EquipmentActionTypes.REQUEST_INITIAL_SPECIFICATION]: {
      option1: IEquipmentInitialSpecification[],
      option2: ['equipmentInitialSpecification']
    },
    [EquipmentActionTypes.REQUEST_INITIAL_SPECIFICATION]: {
      option1: IEquipmentInitialSpecification[],
      option2: [
        'equipmentInitialSpecification',
      ]
    },
    [EquipmentActionTypes.REQUEST_MANUFACTURERS]: {
      option1: IManufacturersListItem[],
      option2: [
        'manufacturers',
        'manufacturerList',
      ]
    },
    [EquipmentActionTypes.REQUEST_SUPPLIERS]: {
      option1: ISuppliersListItem[],
      option2: [
        'suppliers',
        'supplierList',
      ]
    }
  }
  switch (action.type) {

    case EquipmentActionTypes.REQUEST_INITIAL_SPECIFICATION:
    case EquipmentActionTypes.REQUEST_MANUFACTURERS:
    case EquipmentActionTypes.REQUEST_SUPPLIERS:
    case EquipmentActionTypes.REQUEST_INITIAL_SPECIFICATION:
    case EquipmentActionTypes.REQUEST_EQUIPMENT:
      // alternatively instead of option1            ..... , unknown >
      // alternatively instead of option1            ..... , IEquipment[] | IEq.... >
      return reducerUtils.requestListData < IEquipmentState, myMap[action.type].option1 > (lastState, myMap[action.type].option2);

Continuing the above thought it should be possible to move the function into option1 and remove switch case entirely. Related article or this one
const myMap = {
    [EquipmentActionTypes.REQUEST_EQUIPMENT]:{
        option1: reducerUtils.requestListData<IEquipmentState, IEquipment[] >(),
        option2: ['equipmentList']
    },
    ...
}
myMap[action.type].option1(lastState, myMap[action.type].option2, actionPayload)


text:
Q: Maven using local spark library Due to a recent EKS update on AWS I was not anymore able to run spark jobs on AWS (kubernetes client version had to be upgraded).
Therefore, I have been building the last Spark snapshot version (2.4.5-SNAPSHOT, it contains the bugfix I need) successfully.
Now I want to add it to my project, replacing the old 2.3.3 version.
Unfortunately I get some compilation error (see below).
I am probably doing something wrong with my pom.xml file. The final goal is to fetch jar files from remote and from local (the repo)
Ideas?
Thanks!
P.s.
Ubuntu 18.04 + intellij
        The relevant part of the pom.xml file are the following:

        <?xml version="1.0" encoding="UTF-8"?>
        <project xmlns="http://maven.apache.org/POM/4.0.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>

    I add my local repo...

         <!-- My local repo where the jar file has been placed -->
            <repositories>
                <repository>
                    <id>Local</id>
                    <name>Repository Spark</name>
                    <url>/home/cristian/repository/sparkyspark/spark</url>
                </repository>
            </repositories>

        <groupId>sparkjob</groupId>
        <artifactId>sparkjob</artifactId>
        <version>1.0-SNAPSHOT</version>

        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.test.skip>true</maven.test.skip>
        </properties>

        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>entry.Main</mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>

                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <!-- bind to the packaging phase -->
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>1.4.1</version>
                    <configuration>
                        <rules><dependencyConvergence/></rules>
                    </configuration>
                </plugin>
            </plugins>
        </build>

        ...

        <dependencies>
        ....
        ....
    here it is, the jar file I need
         <!-- The last Spark jar file -->
            <dependency>
                <groupId>org.apache.spark</groupId>
                <artifactId>spark-core_2.11</artifactId>
                <version>2.4.5-SNAPSHOT</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-core</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        ...
        ....
         </dependencies>

This is the error message, the path is correct...the file is there.
Ideas? :)

ERROR:
Could not resolve dependencies for project sparkjob:sparkjob:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.apache.spark:spark-core_2.11:jar:2.4.5-SNAPSHOT: Failed to read artifact descriptor for org.apache.spark:spark-core_2.11:jar:2.4.5-SNAPSHOT: Could not transfer artifact org.apache.spark:spark-core_2.11:pom:2.4.5-SNAPSHOT from/to Local (/home/cristian/repository/sparkyspark/spark): Cannot access /home/cristian/repository/sparkyspark/spark with type default using the available connector factories.....

UPDATE: hard wiring the path seems to be a good work-around...
<dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-core_2.11</artifactId>
        <version>2.4.5-SNAPSHOT</version>
        <scope>system</scope>
        <systemPath>/home/cristian/repository/sparkyspark/spark/spark-core_2.11-2.4.5-SNAPSHOT.jar</systemPath>
        <exclusions>
            <exclusion>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

A: If you want to use a folder as a repository you have to use file:// protocol.
So you repository config should be.
<repositories>
    <repository>
       <id>Local</id>
       <name>Repository Spark</name>
       <url>file:///home/cristian/repository/sparkyspark/spark</url>
    </repository>
</repositories>


text:
Q: Reactjs ajax Uncaught (in promise) ReferenceError: $ is undefined I am new to React and probably doing something wrong here but I keep getting a $ is undefined when making an ajax request.  Here is the class I am making the request from:
import React from 'react';
import './Projects.scss';
import Link from '../Link';
import Overlay from '../Overlay';

var Project = React.createClass({
  // Project detail class, commented out because it is big.
});

var Projects = React.createClass({
  getInitialState: function() {
    return { data: [] };
  },
  componentDidMount: function() {
    $.get('http://localhost:3000/api/posts').done(function(data) {
      this.setState({data: data});
    }.bind(this));
  },
  render: function() {
    return (
      <div>
        <Project data={this.state.data} />
      </div>
    );
  }

});

export default Projects;

It's returning:
Uncaught (in promise) ReferenceError: $ is not defined from componentDidMount()

A: $.get implies that you are trying to use jQuery, you probably haven't actually loaded it.


text:
Q: Getting 960.gs to work in IE6 - Please assist I'm using the 960.gs grid system to style a website. It appears fine in all the major browsers, except in IE6, I see other sites using the 960.gs perfectly well and it displaying fine in IE6 and wanted to know what I need to tweak to appear correctly.
Here's more info on the 960.gs system: http://960.gs
I've used the class="grid_6 omega" to try and force my last div to float to the right. Which it does in all browsers except IE6. Does anyone know what I need to do to make it work in IE6, do I need to clear something?
Any advice greatly appreciated!

A: I figured out the problem this morning for anyone wanting to know. I'm using 960.gs and Thematic because I think they're both brilliant in their own ways.
The solution that worked for me was to add the following CSS styling to the containing div before the div that floats to the right, in my case this DIV happens to be called leftloopcontainer, but obviously adjust it to whatever you need it to be:
#leftloopcontainer {overflow: hidden; zoom: 1;}

After I did this IE6 behaved (well, as much as that troublesome browser can!) and displayed my content just fine!


text:
Q: How to get clipboard as input file name to Vim on bash? I install xclip to access system clipboard, my setting and some operations as below:
➜  ~ cat .zshrc | grep xclip
alias c="xclip -selection c"
alias v="xclip -selection c -o"
➜  ~ which dict | c
➜  ~ v
/usr/bin/dict
➜  ~ sudo vim ??

/usr/bin/dict is a python script. And what I want to know is what can substitute ?? on my last command can use vim open file /usr/bin/dict?

A: Given your current setup
sudo vim "$(v)"

will use command substitution to run your alias v and insert its output into the command line to be run before executing it, so it would run sudo vim /usr/bin/dict in the end. The quotes make sure it comes out as a single argument, and $(...) handles running the command and capturing its output.
This will only work from your interactive shell, since aliases aren't used elsewhere. If you want to access it from a script, you could make a small script somewhere in your PATH variable with the same command inside it.

You've tagged this bash but then shown an extract from .zshrc, so note also that zsh has "global aliases" that expand anywhere:
alias -g v='"$(xclip -selection c -o)"'

and then just run sudo vim v and have that happen for free. Global aliases are almost always more trouble than they're worth, so I don't recommend that, but depending on your usage patterns some global alias might be convenient (I'd recommend a longer and more unusual name if you do: putting some odd punctuation in can help avoid running it by mistake, so alias -g v# ... or @v or ^v or something).


text:
Q: Using Excel Conditional formatting on a range, "applies to" a variable number of rows I want to have the value (X) in a cell $A:$A conditionally format cells on (X) number of rows down.
E.g. "Applies to" $B1:$B( ROW() + (X) )
This is what I'm hoping to get;


text:
Q: isdigit() function pass a Chinese parameter When I try using the isdigit() function with a Chinese character, it reports an assert in Visual Studio 2013 in Debug mode, but there is no problem in Release mode.
I think if this function is to determine whether the parameter is a digit, why does it not return 0 if the Chinese is wrong?
This is my code:
string testString = "abcdefg12345中文";
int count = 0;
for (const auto &c : testString) {
    if (isdigit(c)) {
        ++count;
    }
}

and this is the assert :

A: You broke the contract of isdigit(int), which expects only ASCII characters in the range stated.

The behavior is undefined if the value of ch is not representable as unsigned char and is not equal to EOF.

Your standard library implementation is being kind and asserting, rather than going on to blow stuff up.
There is an alternative, locale-aware isdigit(charT ch, const locale&) that you may be able to use here.
I suggest performing some further research on how "characters" work in computers, particularly with regards to encoding more "exotic"1 character sets.
1 From the perspective of computer history. Of course, to you, it is the less exotic alternative!

A: The isdigit() and related functions / macros in <ctypes.h> expect an int converted from an unsigned char, or EOF, which on most systems means a value in the range 0-255 (or -1 for EOF).  So any value not in the range -1…255 is incorrect.
Problem 1: You are passing in a char, which on your system has range -128…+127.  Solution to this problem is simple:
if (isdigit(static_cast<unsigned char>(c)))

This won't crash, however, it's not quite correct for Chinese characters.
Problem 2: Non-ASCII characters should probably use iswdigit() instead.  This will correctly handle Chinese characters:
wstring testString = L"abcdefg12345中文";
int count = 0;
for (const auto &c : testString) {
    if (iswdigit(c)) {
        ++count;
    }
}


text:
Q: GetFileAttributes Function #include "stdafx.h"
#include <Windows.h>
#include <conio.h>

int _tmain(int argc, _TCHAR* argv[])
{
    DWORD d = GetFileAttributes(argv[0]);
    _TCHAR* temp;
    printf("%d\n", d);
    switch(d)
    {
        case 2048: temp = L"Compressed"; break;
        case 32: temp = L"Archive"; break;
        case 16: temp = L"Directory"; break;
        case 16384: temp = L"Encrypted"; break;
        case 2: temp = L"Hidden"; break;
        case 128: temp = L"Normal"; break;
        case 1: temp = L"Readonly"; break;
        case 4: temp = L"System"; break;
        case 256: temp = L"Temporary"; break;
        default: temp = L"Error or unsupported attribute"; break;
    }
    _tprintf(temp);
    getch();

    return 0;
}

what's wrong with this code? I always get 32 in d, even when I launch it with no attributes?
I'm using visual studio 2010.
Thank you!

A: argv[0] is the name of your executable program.  Simply set the index to 1 (ensure it exists).  You may also want to use a bitwise AND operation to determine if a flag is set.


text:
Q: pressing back button make fragment does not work nav component I am using nav component, just Activity Frag1,Frag2 , however moving from Frag1 to Frag2 is working, but When phone back button is pressed, Frag1 is appearing But nothing works, Clicklistner is nothing, init code does working
 class CarActivity : AppCompatActivity() {
       fun getLayoutId(): Int = R.layout.activity_car

      private lateinit var appBarConfiguration: AppBarConfiguration

      override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())
        setSupportActionBar(toolbar_details)

        val navController = findNavController(R.id.nav_host_fragment_content_main)
        appBarConfiguration = AppBarConfiguration(navController.graph)
        setupActionBarWithNavController(navController, appBarConfiguration)

    }
    }

Activity
  <fragment
        android:id="@+id/nav_host_booking_fragment_content_main"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:defaultNavHost="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph="@navigation/nav_graph" />

nav_graph.xml
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/nav_graph_cars"
    app:startDestination="@id/carFragment">

    <fragment
        android:id="@+id/Frag1"

        android:label=" ">

in activity
  override fun onSupportNavigateUp(): Boolean {
    val navController = findNavController(R.id.nav_host_fragment_content_main)
    return navController.navigateUp(appBarConfiguration)
            || super.onSupportNavigateUp()
  }

is seems like a new view is created, or a view is disconnected from fragment
using ViewBinding solve everything but ?


text:
Q: Android Available Ram How much RAM is available for use by each app?
I read somewhere that each app could only use a max of 16 mb, but the total system memory is much higher.

A: Each application is limited to 16MB of Java heap space, at least for devices with "normal" class screens. That limit has apparently been bumped to 24MB for devices with "large" class screens -- in part because of larger bitmaps such screens might manipulate, and probably in a trade-off for the minimum amount of device RAM such devices will need to have.


text:
Q: Netboot a machine, automatically rsync internal HDD to network master and continue booting from internal HDD I have a server which stores the master image for a set of client computers.
As of now the clients netboot from the server and use an overlayfs, so any changes do not affect the master image.
Changes to the master image, can now result in undefined behavior, which is only fixed by a reboot of the clients. Also the clients are 100% dependent on the server, which means they are no usable if the server goes down for maintenance.
I would therefore like the clients to have a local copy of the master image, which is updated regularly e.g. upon boot.
What I envision is the following

*

*The client boot over the network and get the kernel and initramfs from the server

*It then synchronizes its internal HDD with a master image on the server

*It continues booting with an overlayfs (so the copy of the master images does not change)

If possible i would like to avoid to much manual work. Much like I use the overlayroot package to take care of all the overlayfs stuff.


text:
Q: What is Failed requests ratio in Soap UI Please see my image, the err is: 146 and the rat is: 200. I understand that there are 146 errors of my assertion, Could you please explain for me the value "200" rat, what and why it is ?

A: The rat column is the percentage of assertion errors to the number of requests. If you have 73 requests and 146 errors, it looks like you're getting multiple errors per request so your rat is 200%.


text:
Q: How to access .dll file via CAPL? I have tried the following code.
int CAPLEXPORT far CAPLPASCAL capl_visa_init(double arg)
{
    return visa_init(arg);
}

CAPL_DLL_INFO CAPL_DLL_INFO_LIST[] =
{
    {"my_visa_init", (CAPL_FARCALL)capl_visa_init, 'D', 1, "F", "\000"},
    ....
    {0,0}
};

For this code, I get 'Parse error'. How can I resolve it? Do I need to include an header file?

A: In order for the CAPL compiler and CAPL browser to recognize the DLL, you must link it to the CAPL program.
To do this, you can enter the DLL in the Options dialog in CANoe. In this case, the DLL will be available to all CAPL programs that you have. On the other hand you can enter the DLL in the includes section of a CAPL program using the #pragma library command. In this case, it will only be available to this program.

A: It appears that you are missing three elements here (Function category, Text, Parameter name) as defined in the CAPL DLL export table

Functions that have been created can be exported into CAPL code with the aid of a table function (CAPL_DLL_INFO_LIST).
The first row of the table contains version information. This row must be defined in the following manner:
{CDLL_VERSION_NAME, (CAPL_FARCALL)CDLL_VERSION, "", "", CAPL_DLL_CDECL, 0xabcd, CDLL_EXPORT },

Example: Using the Export Table
void CAPLEXPORT far CAPLPASCAL appPut(unsigned long x)
{
  data = x;
}

CAPL_DLL_INFO4 table[] = {
{CDLL_VERSION_NAME, (CAPL_FARCALL)CDLL_VERSION, "", "", CAPL_DLL_CDECL, 0xabcd, CDLL_EXPORT },

  {"dllPut", (CAPL_FARCALL)appPut, "CAPL_DLL","This function will save data from CAPL to DLL memory",'V', 1, "D", "\000", {"x"}},
  {0, 0}
};
CAPLEXPORT CAPL_DLL_INFO4 far * caplDllTable4 = table;


text:
Q: Android call method but don't work on wifi but work on gprs we work with xamarin android and visual studio 2015.
we have an app who works since several months fine :)
This app when it starts call a webservice for to retrieve some data in json format.
All work fine, but last week we have a problem and we are COMPLETY lost about it !
Since last week, for one device when it call the web service we receive this error in the catch exception :
unable to read data from the transport connection Connection reset by peer  ...

Here is it the method on the device who call the WS:
 public override HttpResult ExecuteGet(Uri target)
{
    var client = new HttpClient();
    client.MaxResponseContentBufferSize = 25600000;

    try
    {
        var response = client.GetAsync(target).Result;
        if (response.IsSuccessStatusCode)
        {
            var content = response.Content.ReadAsStringAsync().Result;
            return new HttpResult(content, null, null);
        }

        return new HttpResult(null, " ERROR MESSAGE ", response.StatusCode.ToString());
    }
    catch (Exception e)
    {
        return new HttpResult(null, " ERROR MESSAGE", e.Message);
    }
}

well, now with the same device if we stop the wifi and call the webservice in GPRS that work.
Also we have two wifi, we also have noticed if the device connect on the second wifi and try to call the web service => that's work !
After talk with some colleague, they tell me to look to update my android version of the device , or wifi app on the device but for me the first thing we need to do will be to compare wifi 1 and wifi 2.
My question is, how i can compare two wifi ?
All suggestion are welcome because we search and we find nothing ...
Thanks for all guys that's really great to share your knowledge ...


text:
Q: Cambiar el título de un item de la barra de menú Quiero cambiar el título de los items de la barra de menú.
He intentado lo siguiente:

*

*Creo un IBOutlet del MenuItem que quiero cambiar

*Cambio el título

*Lanzo una notificación

El código es:
class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet weak var formato: NSMenuItem!

    func applicationDidFinishLaunching(_ aNotification: Notification) {

        let barraMenu = NSApp.mainMenu

        self.formato.title = "Formato"

        // Lanza una notificación
        let centroDeNotificaciones = NotificationCenter.default
        //centroDeNotificaciones.post(name: NSMenu.didChangeItemNotification, object: formato)
        centroDeNotificaciones.post(name: NSMenu.didChangeItemNotification, object: barraMenu!, userInfo: ["NSMenuItemIndex":NSNumber(value: 3)])
        }
}

Parece que el título se ha cambiado pero no se muestra cuando se lanza la aplicación.
¿Alguna sugerencia?

A: ¡Gracias por contestar!
El IBOutlet se hace desde el menú de la ventana del mainstoryboard a AppDelegate; y los cambios en el método applicationDidFinishLaunching.
Ya he resuelto el problema: lo que yo cambiaba era el título del NSMenuItem del mainMenu, mientras que lo que se muestra en la barra de menús es el título del submenú de cada item del mainMenu. Lo que hay que hacer es:
self.formato.submenu!.title = "Formato"
Saludos de Víctor.-


text:
Q: Is the set $SL(2, \mathbb F)$ an Abelian group? For the set $SL(2,\mathbb F)$, where $\mathbb F$ are entries from either $$\mathbb{Q},\mathbb{R},\mathbb{C} \text{ or } \mathbb{Z}_p \text{  (p is prime)}$$
How should I start by checking this matrix group is an Abelian group?
First off, what is modulo $p$ prime? (modulo integer n is the set of integers in the set smaller than n and relative prime to n so does modulo p prime implies the set of integers which are prime, smaller than n and relative prime to n? Doesn't make much sense to me)

A: The set $SL(2,\mathbb F)$ is not an abelian group, because
$$\begin{pmatrix}
1 & 1\\
0 & 1
\end{pmatrix}
\begin{pmatrix}
1 & 0\\
1 & 1
\end{pmatrix}=
\begin{pmatrix}
2 & 1\\
1 & 1
\end{pmatrix}\ne
\begin{pmatrix}
1 & 1\\
1 & 2
\end{pmatrix}=
\begin{pmatrix}
1 & 0\\
1 & 1
\end{pmatrix}
\begin{pmatrix}
1 & 1\\
0 & 1
\end{pmatrix}.$$

A: $\Bbb Z_p$ is a shorthand for $\Bbb Z/p\Bbb Z$. When $p$ is prime this defines a quotient ring, since $\Bbb Z$ is a ring and $p\Bbb Z$ defines an ideal of $\Bbb Z$. It turns out that $p\Bbb Z$ is a maximal ideal in $\Bbb Z$ and hence the quotient ring $\Bbb Z_p$ is a field, e.g. $\Bbb F_p$ the field of $p$ elements.
Now what does $\Bbb Z/p\Bbb Z$ mean in terms of how you will be dealing with it? Let $p=3$. Here you are dealing with modulo three arithmetic, e.g.
$$=2\pmod 3 + 4\pmod 3\equiv2\pmod3+1\pmod3$$$$2+4=6=0\pmod3$$
Now $\Bbb Z_p$ is an abelian group under addition regardless of whether we have $p$ prime or not, but when $p$ is not prime we don't have all of our multiplicative inverses. It is in this case that we have a monoid under multiplication. This monoid with our abelian group addition gives a ring.
So taking entries from $\Bbb Z_p$ $p$ prime, means to take entries from $\Bbb F_p$, here your matrices will be filled with values from $\{0,1,2,3,\cdots,p-1\}$.


text:
Q: Unable to use p:overlaypanel inside composite component Am trying to create a composite component that will display the values as overlaypanel.  But it returns the below error;
Cannot find component 'j_idt58:reviewDataTable:0:overrideCol' in view
overrideVersionDetails.xhtml:(composite component)
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:cc="http://java.sun.com/jsf/composite"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:c="http://java.sun.com/jsp/jstl/core">

    <cc:interface>
        <cc:attribute name="forId" type="java.lang.String" required="true" />
        <cc:attribute name="forValue" type="java.lang.Object" />
    </cc:interface>

    <cc:implementation>
        <p:overlayPanel for="#{cc.attrs.forId}" my="left bottom">
            #{cc.attrs.forValue}
        </p:overlayPanel>
    </cc:implementation>
</ui:composition>

Its used in another page:
<h:form>
....
...
<p:dataTable .....>
....
    <p:column sortBy="#{dto.isSameCycleOverride}" width="100">
      <f:facet name="header">
          Override
      </f:facet>
      <h:commandLink id="overrideCol" binding="#{overrideCol}"
        value="#{(dto.isSameCycleOverride) ? 'Yes' : 'No'}" />
     <comp:overrideVersionDetails forId="#{overrideCol.clientId}"
     forValue="#{dto.message}" />
    </p:column>
....
</p:dataTable>
</h:form>

Any help is really appreciated.

A: I don't work with Primefaces, but with RichFaces I would use :
<comp:overrideVersionDetails forId="#{rich:clientId('overrideCol')}"
                             forValue="#{dto.message}" />

to do what you want.
With a little Help from SO :
Rich Faces rich:clientId in Primefaces?
it seems you can do this :
...
 <h:commandLink id="overrideCol" value="#{(dto.isSameCycleOverride) ? 'Yes' : 'No'}" />
 <comp:overrideVersionDetails forId="#{p:component('overrideCol')}"
 forValue="#{dto.message}" />
...

Now to see if this works better than the use of binding in a dataTable...


text:
Q: FTX API get response I tried to use the FTX API, but somehow I can't manage to print the response:
import time
import hmac
from requests import Request

ts = int(time.time() * 1000)
request = Request('GET', 'https://ftx.com/api/wallet/balances')
prepared = request.prepare()
signature_payload = f'{ts}{prepared.method}{prepared.path_url}'.encode()
signature = hmac.new('MY_API_SECRET'.encode(), signature_payload, 'sha256').hexdigest()

request.headers[f'FTXUS-KEY'] = 'MY_API_KEY'
request.headers[f'FTXUS-SIGN'] = signature
request.headers[f'FTXUS-TS'] = str(ts)

print(request)

The output is <Request [GET]>, but I want to get my wallet balances. The whole code is from FTX API documentation, except the print line.

A: from requests import Request, Session
s = Session()
response = s.send(prepared)
print(response)

A: you need to rename request.headers as prepared.headers as per the documentation provided by Olvin Roght


text:
Q: Symmetry in gravitational time dilation In special relativity, when two observers move in respect to each other, each observes the other's clock tick slower.
An observer floating in space far from gravitational fields, observes earth clock ticking slower; at what rate is the clock of the floating observer ticking as observed from earth?

A: Assuming that the Schwarzschild metric is a good representation of the spacetime geometry round the Earth, the ratio of Earth time to space time is:
$$ \frac{t_E}{t_S} = \sqrt{1 - \frac{2GM}{c^2r_E}} $$
where $r_E$ is the radius of the Earth. So the clock on Earth runs slow as observed from space.
The ratio of space time to Earth time is simply the inverse of this:
$$ \frac{t_S}{t_E} = \frac{1}{\sqrt{1 - \frac{2GM}{c^2r_E}}} $$
so the clock in space runs fast as observed from Earth.


text:
Q: Parent & Child field syncing I want to write custom code to support the behavior below:
Parent A has a field called "ABC" Each Child task of Parent A has this field "ABC" as Read-only "ABC" edited in the Parent should filter down to each child every time its updated. Obviously this wouldn't be a true live sync but should call the same value as soon as the end user refreshes the page to see the updated value.
I really, want a Scripted Function that reads custom fields on a parent-task for change, and if changed carries that value over to the child-task. I am using "Script Runner" but I cannot figure out how to do this. Could you please provide the script that can be used in script runner and also i want to automate the job for all the issue's & sub-task in our instances.
I know this can be done through custom script listener but i need a script that can accomplish this task.

A: You can easily do this with a Scripted Field. The documentation is quite good.
Basically you first have to get your parent issue. The issue object has a method getParentObject() that does this:

Issue getParentObject()
If this issue is a subtask, return its parent.
Returns:
The parent Issue, or null if the issue is not a subtask.

And then you can get the value of your parent issue's custom field. Assuming this is a simple Text field, it would look something like this:
String customFieldName = "My fancy custom field"

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
Collection<CustomField> customFields = customFieldManager.getCustomFieldObjectsByName(customFieldName)

parentIssue.getCustomFieldValue(customFields.first()) as String


text:
Q: printing pieces of a multidimentional array I am configuring a job board API and have got it to where I can print the full array but I would like to echo only specific parts.
Here is the array and I have stopped after 2 entries to keep it compact.
Array
(
[search_settings] => Array
    (
        [query] => Information Technology
        [location] => chicago
        [miles] => 15
        [sort] => dd
        [window_size] => 50
        [publisher_id] => 22222
        [search_style] => 2
        [configuration_flag] => r
        [auth] => 123456
        [client_ip] => 111.111.111.111
    )

[request_url] => http://api.simplyhired.com/a/jobs-api/xml_v2/q-Information+Technology/l-chicago/mi-15/ws-50/sb-dd
[request_title] => Information Technology Jobs - Chicago, IL
[request_time] => 2014-10-22 16:44:30 EDT
[start_index] => 0
[num_results] => 50
[total_results] => 20724
[total_viewable_results] => 778
[jobs_collection] => Array
    (
        [0] => Array
            (
                [job_key] => 7055.x0146017d3fd5
                [title] => Senior Information Security Manager
                [company_name] => Teambradley
                [company_url] =>
                [source] => JobServe Ltd
                [url] => http://api.simplyhired.com/a/job-details/view/jobkey-7055.x0146017d3fd5/rid-yvujgjnejabmuqwgjvmogcpatdfjkhue/cjp-0/hits-20724?icsrc=xml&rfr=partner
                [type] => organic
                [is_paid] =>
                [is_sponsored] =>
                [is_organic] => 1
                [location] => Chicago, IL
                [city] => Chicago
                [state] => IL
                [postcode] => 60624
                [county] => Cook County
                [region] =>
                [country] => US
                [date_last_seen] => 2014-10-22 13:11:50 EDT
                [date_that_posted] => 2014-10-22 13:11:50 EDT
                [description] => technical security control design, architecture, security technology implementation, information security solution engineering, etc. If you are interested in this job opportunity, contact TeamBradley today to learn more! WHEN RESPONDING TO...>
            )

        [1] => Array
            (
                [job_key] => 43374f83d8ee563c1f5d17128063425db4bc1052
                [title] => Instructor II
                [company_name] => General Dynamics Information Technology
                [company_url] =>
                [source] => General Dynamics Information Technology, Inc
                [url] => http://api.simplyhired.com/a/job-details/view/jobkey-43374f83d8ee563c1f5d17128063425db4bc1052/rid-yvujgjnejabmuqwgjvmogcpatdfjkhue/cjp-1/hits-20724?icsrc=xml&rfr=partner
                [type] => organic
                [is_paid] =>
                [is_sponsored] =>
                [is_organic] => 1
                [location] => Chicago, IL
                [city] => Chicago
                [state] => IL
                [postcode] => 60624
                [county] => Cook County
                [region] =>
                [country] => US
                [date_last_seen] => 2014-10-22 11:37:11 EDT
                [date_that_posted] => 2014-10-22 11:37:11 EDT
                [description] => Dynamics Information Technology provides information technology (IT), systems engineering, professional services ... been at a like-type and like-level facility. Additional Information Relocation No Security Clearance Level Background...>
            )

I would like to echo the title, url and city from all entries from the job_collection array.
I am able to echo parts from the first part of the array using
echo $myArray[search_settings]['publisher_id'];

I can also echo a single value from the jobs_collection array with the below
echo $jobs22[jobs_collection][0]['city'];

I assume I can use a for or while loop but I can't get anything to work.

A: foreach ($jobs22[jobs_collection] as $job) {
  echo $job['title'] . ' in ' . $job['city'] . " @ " . $job['url'];
}

Adjust to what you need


text:
Q: Driver IC for 3-4v, 5A Tamiya motors I have some tamiya motors and would like to use them on a project, the problem is when i looked up the data sheet of my motor (Tamiya plasma dash 4WD). the motors are at 3volts , 4-5amps. this is quite difficult since common drivers (L293d) only drives motor above 4.5 volts at 1A. I have read that MOSFETS are good, but i don't have a lot of experience using MOSFETS. But i think i can learn, question is there a MOSFET that can carry it though.
Does anyone know a common IC that does the Job?
If there is none, a workaround to drive the motors is also greatly appreciated.
PS. i will be an arduino Microcontroller , with either a LiPo or Eneloops batteries.
EDIT : I would like for it to be bi directional, Electronic Braking would be great.
Thank you.

A: For bidirectional control with braking you can use 4 MOSFETs wired in 'H-Bridge' configuration, like this:-

simulate this circuit – Schematic created using CircuitLab
M1 and M4 are turned on to run the motor one direction, and M2 and M3 are turned on for the other direction. For braking you turn on either both upper FETs or both lower FETs, which puts a short across the motor.
PWM can be applied (using digitalWrite or a custom PWM routine) to the lower N-channel FETs to control motor speed. The upper P-channel FETs are turned on by negative voltage, so you make the digital outputs LOW to turn them on and HIGH to turn them off.
Resistors R1-R4 ensure that all FETs are turned off when the Arduino starts up. They prevent the I/O pins from 'floating' before being initialized.
Note that you must never turn on both upper and lower FETs on one side at the same time, or current will 'shoot through' both FETs and short out the battery. When testing you should wire a current limiting device (eg. a light bulb) in series with the battery, until you are sure that the firmware is reliable.
Most H-bridge designs include level converter circuits to boost the Gate voltage on the upper FETs. You don't need this because the battery voltage is lower than the Arduino's logic voltage, so it can directly drive the FETs with sufficient voltage. However if you power the motor with a 2 cell NiMH battery then the upper FETs must be rated to turn on fully with 2.4V, or if you use a single cell Lipo 3.7V. The lower FETs get 5V on the Gate so they only have to be 'logic-level' types.
The FETs should be rated for much higher current than the motor, both to prevent overheating and to reduce voltage drop (at this low voltage even fractions of a volt may noticeably reduce motor power). Finding P-channel FETs with appropriate ratings may be difficult. Here's one example:- NDP6020P P-Channel FET, -2.5V gate, -20V, 24A max. If you cannot obtain suitable P-channel FETs in your country then you could use all NMOS devices with level converters to drive the upper FETs. 'Logic-level' FETs would need at least 4.5V more than the battery voltage, ie. >7V.
The Dash Plasma is a high performance motor designed to produce maximum possible power at low voltage. Since the Arduino needs at least 5V, you might consider using a motor designed to draw lower current at higher voltage - then you might be able to use a single battery to power both.


text:
Q: Latent variable estimation with fixed effects I have survey data on political beliefs that I'd like to estimate latent ideology with. Survey questions are binary agree/disagree responses. However, respondents can repeat the survey and skip any questions they want. As a result, I have variation across individuals in how many responses I have and which questions were answered. Some answered all questions once or twice, others answered the same few questions dozens of times.
If everyone had the same propensity to answer questions I might do some sort of SEM/factor analysis:
$$
y_i = v + \lambda\theta_i + \epsilon_i
$$
Where $y_i$ is the observed responses from person $i$, $v$ is the intercept, $\lambda$ is the factor loading, and $\theta$ is the latent ideology variable.
However, people have different participation rates for the survey and response rates for specific questions. I don't want to transform responses to a binary and use IRT because that sacrifices a lot of information. How do I incorporate these different response propensities into my latent variable estimation?
Is it something like a fixed/random effect to shift the intercept for each participant? I haven't seen any similar applications in latent variable software like Stan and Lavaan, is this possible?


text:
Q: Prevent downloading app to iPod I'm developing an app which I want that can be download-able by just iPhone not via iPod Touches like Whatsapp.
On Whatsapp example, you can see Whatsapp in the market but when you push to download it blocks you so you can't download it.
I have find a way to determine device and shutdown app but it still in iPod device.
What are you suggestions ?
Thanks in advance.


text:
Q: How to detect Mock location in Flutter using Geolocator Plugin I am trying to detect Mock Location. I have installed Fake location app and enabled Mock Locations in Settings (Under Developer Options). But when I try to detect Mock location using Geolocator, it doesn't work at all.
Future<Position> _determinePosition() async {
bool serviceEnabled;
LocationPermission permission;

serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
  return Future.error('Location services are disabled.');
}

permission = await Geolocator.checkPermission();
if (permission == LocationPermission.deniedForever) {
  return Future.error(
      'Location permissions are permanently denied, we cannot request permissions.');
}

if (permission == LocationPermission.denied) {
  permission = await Geolocator.requestPermission();
  if (permission != LocationPermission.whileInUse &&
      permission != LocationPermission.always) {
    return Future.error(
        'Location permissions are denied (actual value: $permission).');
  }
}
return await Geolocator.getCurrentPosition(
    desiredAccuracy: LocationAccuracy.high);
}

And then I call this function as:
_determinePosition().then((position) {
  if (position.isMocked) {
    //.. Show error message
    return;
  }

And this if block is never reached and there is no error log either.


text:
Q: find the number of string including white-space that can be inserted inside a div of fixed width with a fixed font-size I am trying to know if I could predict the number of strings including white-space that can be inserted inside a div of fixed width and fixed font-size programatically.. I have a divs of diferent width in to which I add names dynamically.. so the width varies based on the some density measures of that name..
I know I can use the css methods like
        "white-space", "nowrap"
        "overflow", "hidden"
        "text-overflow", "ellipsis"

but I wanna know if I do it using javascript or jquery?

A: Yes you can do it programmatically. Check this
var wid = $("div").width();
var allowedChars = parseInt(wid/getCharWidth('Courier New', '10px'));

var div = $("div");
for(var i = allowedChars; i > 0; i--) {
   $(div).append("a");
}

function getCharWidth(fontFamily, fontSize) {
 var div = document.createElement("div");
 div.style.position = "absolute";
 div.style.visibility = "hidden";
 div.style.fontFamily = fontFamily;
 div.style.fontSize = fontSize;
 div.innerHTML = "S";
 document.body.appendChild(div);
 var width = div.offsetWidth;
 document.body.removeChild(div);
 return(width);
}

Also check this link for more information.
Cheers!!!


text:
Q: AWS RDS Track incoming connections and where they were initiated I understand that there are means of auditing database connections in posgresql. I have studied the below articles:
https://aws.amazon.com/premiumsupport/knowledge-center/rds-postgresql-query-logging/
https://aws.amazon.com/premiumsupport/knowledge-center/track-failed-login-rds-postgresql/
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.LoggingAndMonitoring.html
However none of these seem to indicate that there is an "out of the box" way to, for example, see if a connection came in at 4am last Tuesday to your database and then disconnected.
Audit is there, but some statement has to be made to be tracked, and logging failed connections seems possible but again, that doesn't help in this instance.
So, specifically with AWS RDS Postgresql, does anyone know if there is a historic view of connections available anywhere? Thanks!


text:
Q: How to resolve 'Error occurred during initialization of VM' java? I've connected to a linux-based server using ssh. Recently, I've installed JDK using following command:
sudo yum install java-1.6.0-openjdk-devel
And jdk installed successfully, but whenever I run command java or javac I get following error:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

Even, running command java -version, will bring that error. When I try to give java more space using java -Xmx512m -Xms256m -version, I'll get following error:
*** glibc detected *** java: double free or corruption (!prev): 0x00007fc84400e270 ***
*** glibc detected *** java: double free or corruption (fasttop): 0x00007fc8440089f0 ***
#
Aborted (core dumped)

How can I resolve this?
Thanks in advance

A: I have never seen this sort of exception, so it is my best guess: did you try to limit stack size by using -Xss JVM parameter (i.e. -Xms8m -Xmx16m -Xss4m)? Also quick googling suggest that export MALLOC_CHECK_=0 could possibly let you get over, but I am not sure if JVM will function well.

A: A virtual Linux server?
What do you get when run:
java -Xmx1m -version
and
ulimit -a
Looks like a memory allocating problem. You can try to increase swap space if possible.

A: To me it looks like there is not enough memory to run the virtual machine (maybe physical memory, virtual memory or ulimit) - you should try decreasing the memory allocated to the VM (I think the default in 64Mb) and not increasing it.

A: Lower your -Xms   (not xmx).Use -Xms40m for example.If it starts as it is stated in other answers, you may be too low on memory to reclaim 256m for the vm at start.

A: Looks like you are using JDK 32-bit version. If so, you cannnot assign a Heap size more than 1.2GB or something.
Either use a 64 bit JDK or try with 1.2G as the max heap size.


text:
Q: How to implement tabulation in internet explorer browser using angular? I have fields in a form that i want to navigate from a field to an other using tab button on my keyboard.
i tried tabindex but it's working on chrome but not on internet explorer
    <form [formGroup]="parentForm">

      du

au

    </form>

i expect that tapping on tabs makes me navigate from calendar to an other but that does not work on internet explorer.


text:
Q: Getting Object in Nested Loop I have Nested Loop Object every object contains Id and Name if pass the id as a param needs to get required  name based on Id without using any looping
if any possible to get like that can you please help me

A: var name =yourList.Where(x=>x.Id=="myId").Name;


text:
Q: Cannot import neo4j in python Neo4j driver v1.5.3 has been installed, Neo4j is running. After that I've tried to run example:
from neo4j.v1 import GraphDatabase

uri = "bolt://localhost:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "password"))

def print_friends_of(tx, name):
    for record in tx.run("MATCH (a:Person)-[:KNOWS]->(f) "
                         "WHERE a.name = {name} "
                         "RETURN f.name", name=name):
        print(record["f.name"])

with driver.session() as session:
    session.read_transaction(print_friends_of, "Alice")

But I'm getting:

Traceback (most recent call last):
    File "C:/experiment/Cypher.py", line 1, in
      from neo4j.v1 import GraphDatabase
  ModuleNotFoundError: No module named 'neo4j'
  Process finished with exit code 1

Additional info using: (venv) >pip freeze

aiohttp==3.1.2 appdirs==1.4.3 async-timeout==2.0.1 attrs==17.4.0
  beautifulsoup4==4.6.0 certifi==2018.1.18 chardet==3.0.4 idna==2.6
  idna-ssl==1.0.1 lxml==4.2.1 multidict==4.1.0 neo4j-driver==1.5.3
  packaging==17.1 py2neo==3.1.2 pyparsing==2.2.0 PyQt5==5.10.1
  pyqt5-tools==5.9.0.1.2 python-dateutil==2.7.2 requests==2.18.4
  selenium==3.11.0 sip==4.19.8 six==1.11.0 urllib3==1.22 yarl==1.1.1

So, what I do wrong?
UPDATE
I'm using PyCharm 2018.1.3 (pro) and python 3.6.1. All modules were installed using pip. The strange thing is that I just successfully ran this script directly using Windows PowerShell command string "python c:\experiment.cypher.py". So, the problem is in PyCharm, or I have something to do to make this work inside PyCharm?


text:
Q: What bonuses does testing with a convoy have? When I finish a regular test, I get the option to run a convoy on my bridge. So far I succeeded with all convoys too, but I was wondering what it does.
Does it have any gameplay or "story" effect?


text:
Q: explode function in hive I have the following sample data and I am trying to explode it in hive.. I used split but I know I am missing something..
["[[-80.742426,35.23248],[-80.740424,35.23184],[-80.739583,35.231562],[-80.735935,35.23041],[-80.728624,35.228069],[-80.727753,35.227836],[-80.727294,35.227741],[-80.726762,35.227647],[-80.726321,35.227594],[-80.725687,35.227544],[-80.725134,35.227535],[-80.721502,35.227615],[-80.691298,35.216202],[-80.688009,35.215396],[-80.686516,35.215016],[-80.598433,35.234307]]"]

I used the below query
select explode(split(col, ',')) from sample2;
and the result is this
        ["[[-80.742426
        35.23248]
        [-80.740424
        35.23184]
        [-80.739583
        35.231562]
        [-80.735935
        35.23041]
        [-80.728624
        35.228069]
        [-80.727753
        35.227836]
        [-80.71143
        35.227831]
        [-80.711007
        35.227795]
        [-80.710638
        35.227741]
        [-80.673884
        35.21014]
        [-80.672358
        35.209481]
        [-80.672036
        35.209356]
        [-80.671686
        35.209234]
        [-80.67124
        35.209099]
        [-80.670815
        35.209006]
        [-80.670267
        35.208906]
        [-80.669612
        35.208833]
        [-80.668924
        35.208806]
        [-80.598433
        35.234307]]"]

I need it in below format
    [-80.742426,35.23248]
    [-80.740424,35.23184]
    [-80.739583,35.231562]
    [-80.735935,35.23041]
    [-80.728624,35.228069]
    [-80.727753,35.227836]
    [-80.727294,35.227741]
    [-80.726762,35.227647]
    [-80.726321,35.227594]
    [-80.725687,35.227544]
    [-80.725134,35.227535]
    [-80.721502,35.227615]
    [-80.691298,35.216202]
    [-80.688009,35.215396]
    [-80.686516,35.215016]
    [-80.684281,35.214466]
    [-80.68396,35.214395]
    [-80.683375,35.214231]
    [-80.682908,35.214079]
    [-80.682444,35.213905]
    [-80.682045,35.213733]
    [-80.68062,35.213112]
    [-80.678078,35.211983]
    [-80.676836,35.211447]
    [-80.598433,35.234307]

Any help over here..?

A: You have your data set as arrays of array and you want to explode your data at first level only, so use LATERAL VIEW explode(colname) to explode at the first level.
Below is the SELECT query with explode():
SELECT col1 FROM sample2 LATERAL VIEW EXPLODE(col) explodeVal AS col1;

output generated from your input data set as below:
[-80.742426,35.23248]
[-80.740424,35.23184]
[-80.739583,35.231562]
[-80.735935,35.23041]
[-80.728624,35.228069]
[-80.727753,35.227836]
[-80.727294,35.227741]
[-80.726762,35.227647]
[-80.726321,35.227594]
[-80.725687,35.227544]
[-80.725134,35.227535]
[-80.721502,35.227615]
[-80.691298,35.216202]
[-80.688009,35.215396]
[-80.686516,35.215016]
[-80.684281,35.214466]
[-80.68396,35.214395]
[-80.683375,35.214231]
[-80.682908,35.214079]
[-80.682444,35.213905]
[-80.682045,35.213733]
[-80.68062,35.213112]
[-80.678078,35.211983]
[-80.676836,35.211447]
[-80.598433,35.234307]


text:
Q: Deployment of Hexo Application into Modulus.io I'm trying to create a blog post using Hexo. It's working fine on local deployment. I'm using Modulus as my nodejs hosting. The problem here is that hexo application starts with hexo server command unlike node app.js command. Also the main file of application _config.yml unlike app.js or server.js of nodejs. Modulus deployment starts application with node main-file.js command rather than hexo server command. So, my application unable to start when deployed to Modulus server. Please suggest something on how to host Hexo in Modulus.

A: 1. Hexo can generate static pages
you can just run:
$ hexo generate

And the generated static pages will locate in public/.
Check the doc for more details: http://hexo.io/docs/generating.html
2. You can run hexo from .js
If you really want to run hexo server, and have to load it from .js file, it's ok. Just add a single line code file app.js with following content:
require('hexo').init({command: 'server'});

So, you can just run it with whatever method you want.
For more details, please check: http://hexo.io/docs/server.html#Forever_/_PM2


text:
Q: Oracle - Filter results between modified working week Using Oracle, I am currently filtering data using AND schedstart BETWEEN (TRUNC(SYSDATE - (TO_CHAR(SYSDATE,'D')+6))) AND (TRUNC(SYSDATE - (TO_CHAR(SYSDATE,'D')-1)))) which isn't what I want.
My working week starts on a Wednesday and finishes on a Tuesday so I want my results to be filtered on my current working week. Any help would be very much appreciated.

A: To find the beginning of the next week you would use Next_Day():
Next_Day(Trunc(SysDate),'WED')

Therefore to find the beginning of "this" week, use:
Next_Day(Trunc(SysDate),'WED') - 7

So to limit schedstart to the current working week (assuming schedstart has no time component):
schedstart between Next_Day(Trunc(SysDate),'WED') - 7
               and Next_Day(Trunc(SysDate),'WED') - 1


text:
Q: How to prevent updated data in Child component from updating Parent's data in VueJS [2.6.14] I am using vuejs 2.6.14 and am running into the following issue :
Modified data from child component updates data in parent component aswell, without any use of $emit in code.
This is the opposite of the usual "how to update data in child from parent / how to update in parent from child"
Here is my code in greater details:
I have a parent component named Testing.vue, passing a JSON object ("userData") to a child,
GeneralData.vue.
This is what the code looks like for the parent :
<template>

          Account settings for :

    Populate fake user

    <GeneralData :userData="user" />

</template>

A very simple testing component that calls userServices.getFakeUser(), which asynchronously returns a JSON object.
For the child :
<template>

      Age

      Language(s)

        **This form is set to read only, for display purposes only**

        Remove

        **This button removes a language from the userLangs array by calling removeLang(langKey)**

        <datalist id="langlist-id">
          <option>Manual Option</option>
          <option v-for="lang in langList" :key="lang.name">
            {{ lang.name }}
          </option>
        </datalist>
        Add

</template>

Here is what the data looks in the vuejs dev tool inside the browser after having updated this.user in Testing.vue:
Data in Testing.vue :
user : {
 general:{"age":22,"langs":["French"]}
}

Data in GeneralData.vue :
userData : {
  general:{"age":22,"langs":["French"]}
}

userAge : 22

userLangs : ["French"]

userGeneral :
{
  general:{"age":22,"langs":["French"]}
}

So far so good right?
Well here is  where the issues happen, if I change the age field in my form, userAge gets incremented, userGeneral.age gets update, but userData.general.age doesnt. Which is expected as userGeneral.age is computed out of this.userAge, and userData is a prop so it shouldn't be mutated as a good practice (and not method sets userData.general.age = xxx anyways).
HOWEVER, if i hit the Remove button next to French in the language list, this.userLangs gets updated as it should and is now [], this.userGeneral.langs gets updated to [] aswell as it is computed directly from the former. And userData.general.langs ... gets updated to [] aswell which really makes no sense to me.
Worse, in the parent, Testing.vue, user.general.langs is now set to [] aswell.
So somehow, this.userLangs updated the prop this.userData, AND this prop has updated it's original sender user in the parent component, although no $emit of any kind has been involved.
I do not want this to happen as I dont think it's supposed to happen this way and is therefore an hasard, but also because i want to setup a 'save' button later on allowing the user to modify his values all at once.
What i've tried : setting all kinds of .prevent, .stop on the @click element on the Remove / Add buttons, in the method called itself, adding e.preventDefault (modifying addLang and removeLang to send the $event element aswell), none of those attemps have solved anything.
Hopefully I didnt implement the .prevent part correctly, and someone can help me block this reverse-flow annoying issue.

A: Solution to the problem here is that lang is an array that is passed as a reference thus a mutation is bubbled up to the parent.
Instead of assigning the original array we can just assign a copy of that
userData: function () {       this.userLangs = [...this.userData.general.langs];       this.userAge = this.userData.general.age     }


text:
Q: How derivatives of SeqView (like SeqViewRMS) appear? In "Programming in Scala" (Section 24.15, Views), I saw next code:
scala> val v = Vector(1 to 10: _*)
v: scala.collection.immutable.Vector[Int] = Vector(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

v.view map (_ + 1)
res69: scala.collection.SeqView[Int,Seq[_]] = SeqViewM(...)

It's said

... is in essence a wrapper that records the fact that a map with
  function (_ + 1) needs to be applied on the vector v.

But I can't figure out where those SeqViewR*M*S* are. Are there any already created classes, like Function1..22 (what I didn't find, and it's a bit impossible to create all combinations), or these are created dynamically?

A: SeqViewR, SeqViewRMS, etc. are not in fact classes, but only text descriptions for views. The same class will use a different description depending on how much transformation it represents, e.g. SeqViewR and SeqViewRR are usually the same class.
The relevant code is the viewToString method in TraversableViewLike:
protected[this] def viewIdString: String = ""
protected[this] def viewIdentifier: String = ""
def viewToString = stringPrefix + viewIdString + "(...)"

stringPrefix is the original type of the view, e.g. SeqView. viewIdString is the R/RMS/ whatever part. When you invoke a method like map or take or reverse, you obtain a class that implements TraversableViewLike.Transformed, which has the following definition:
final override protected[this] def viewIdString = self.viewIdString + viewIdentifier

and then in each implementation something like:
final override protected[this] def viewIdentifier = "R"

This viewIdString method takes the viewIdString of the original view and attaches the appropriate letter. This works recursively, so the result of view.reverse.reverse.reverse is a class with a viewIdString of "RRR". Note that no classes are being dynamically generated, only their descriptions.


text:
Q: How can I INSERT multiple rows by adding same value to ID's from other table thus creating new pairs? I have 3 tables:

*

*product

*brand

*brand_product

I want to INSERT pair of brand_id(which is say 35) and product_id in brand_product for all products that are LIKE '%chosen brand%'.
So far I got this, but it won't work:
INSERT INTO brand_product(brand_id, product_id)
VALUES ('426', (SELECT entity_id FROM catalog_product_entity WHERE sku LIKE '%NIKE%'))

A: You can use insert . . . select if you want to insert multiple rows:
INSERT INTO brand_product(brand_id, product_id)
    SELECT 426, entity_id
    FROM catalog_product_entity
    WHERE sku LIKE '%NIKE%';

A: You can use following query.
Insert into brand_product(brand_id, product_id)
VALUES ( select 426,entity_id FROM catalog_product_entity WHERE sku LIKE '%NIKE% ) ;