text:
Q: How to specify multiple resources in a single entry in serverless.yml? I would like to be able to specify multiple resources using a single entry in serverless.yml.
My use case is as follows:
reportFatalError:
    handler: "handler.reportFatalError"
    events:
    - cloudwatchLog:
        # "*" implies wish to insert wildcard
        logGroup: "/aws/lambda/*-${opt:stage}-*"
        filter: "\"FATAL\""

Naturally, I would like the Fatal Error Reporter to report the Fatal Error from any logGroup, and explicitly specifying all of them is a recipe for poorly maintained serverless.yml in the future.
Is there some way to specify a wildcard or loop over the logGroups as serverless deploys?

A: Unfortunately there isn't a way to do this with wildcards. This is a limitation of AWS, not Serverless.
You could write a script that loaded a list of all your CloudWatch logGroups and then applied those events to your reportFatalError function on deployment.
See here: https://serverless.com/framework/docs/providers/aws/guide/variables/#reference-variables-in-javascript-files

A: I also faced that issue recently and after researching the topic I ultimately decided to go with the implementation leveraging JavaScript based on what @Jeremy suggested. Frankly, it seems there is no alternative apart from having a long, long serverless.yml configuration file. I'll be more than happy to learn about other options if there are any.
So as a follow-up, I decided to share a minimal working example in case someone else needs to provide the same capability in the project and wonders how to actually achieve that.
Minimal example
Project structure
.
├── _serverless
│   └── cloudwatch_log_events.js
├── handler.py
└── serverless.yml

_serverless/cloudwatch_log_events.js
The _serverless directory is meant to store all Serverless Framework-related configuration files.
module.exports = async ({ options, resolveVariable }) => {
  const stage = await resolveVariable('sls:stage');
  const logGroups = [
    `/aws/lambda/foo-${stage}`,
    `/aws/lambda/bar-${stage}`,
  ];
  const logGroupFilter = '{ $.level = "error" }';

  return logGroups.map(function (logGroup) {
    return {
      cloudwatchLog: {
          logGroup: logGroup,
          filter: logGroupFilter
      }
    }
  });
}

handler.py
def foobar(event, context):
    return {
        "foo": "bar"
    }

serverless.yml
service: FoobarService

frameworkVersion: '3'

provider:
  name: aws
  runtime: python3.8
  stage: ${opt:stage, 'local'}

functions:
  foobar:
    name: foobar-${self:provider.stage}
    handler: handler.foobar
    events:
      ${file(_serverless/cloudwatch_log_events.js)}

The output serverless.yml
Generated using the $ sls print command.
service: FoobarService
frameworkVersion: '3'
provider:
  name: aws
  runtime: python3.8
  stage: local
  region: us-east-1
  versionFunctions: true
functions:
  foobar:
    name: foobar-local
    handler: handler.foobar
    events:
      - cloudwatchLog:
          logGroup: /aws/lambda/foo-local
          filter: '{ $.level = "error" }'
      - cloudwatchLog:
          logGroup: /aws/lambda/bar-local
          filter: '{ $.level = "error" }'

Testing
Setup
The following tests involve Localstack, therefore it needs to be added as a dependency in the plugins. Updated config:
serverless.yml
service: FoobarService

frameworkVersion: '3'

provider:
  name: aws
  runtime: python3.8
  stage: ${opt:stage, 'local'}

plugins:
  - serverless-localstack

custom:
  defaultStage: local
  profile: default
  localstack:
    debug: true
    stages:
      - local
    host: http://localhost
    edgePort: 4566
    autostart: true
    lambda:
      mountCode: false
    docker:
      sudo: false

functions:
  # Note:
  # `foo` and `bar` functions were added here only for demo purposes, just to assign
  # existing CloudWatch groups as the `foobar` lambda's event source mappings.
  # Providing unexisting groups would result in a deployment failure.
  foo:
    name: foo-${self:provider.stage}
    handler: handler.foobar
  bar:
    name: bar-${self:provider.stage}
    handler: handler.foobar
  foobar:
    name: foobar-${self:provider.stage}
    handler: handler.foobar
    events:
      ${file(_serverless/cloudwatch_log_events.js)}

docker-compose.yml
It's a minimal Localstack config file needed for the demo. Just run it with $ docker-compose up.
version: '2.1'

services:
  localstack:
    container_name: "localstack"
    image: localstack/localstack:latest
    ports:
      - "4566-4599:4566-4599"
    environment:
      - SERVICES=iam,cloudformation,s3,lambda,sts
      - DEBUG=1
      - LAMBDA_EXECUTOR=local
      - DOCKER_HOST=unix:///var/run/docker.sock
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"

Outcome
$ sls print --stage local
Running "serverless" from node_modules
config.options_stage: local
serverless.service.custom.stage: undefined
serverless.service.provider.stage: local
config.stage: local
Using serverless-localstack
Reconfiguring service acm to use http://localhost:4566
Reconfiguring service amplify to use http://localhost:4566
Reconfiguring service apigateway to use http://localhost:4566
Reconfiguring service apigatewayv2 to use http://localhost:4566
Reconfiguring service application-autoscaling to use http://localhost:4566
Reconfiguring service appsync to use http://localhost:4566
Reconfiguring service athena to use http://localhost:4566
Reconfiguring service autoscaling to use http://localhost:4566
Reconfiguring service batch to use http://localhost:4566
Reconfiguring service cloudformation to use http://localhost:4566
Reconfiguring service cloudfront to use http://localhost:4566
Reconfiguring service cloudsearch to use http://localhost:4566
Reconfiguring service cloudtrail to use http://localhost:4566
Reconfiguring service cloudwatch to use http://localhost:4566
Reconfiguring service cloudwatchlogs to use http://localhost:4566
Reconfiguring service codecommit to use http://localhost:4566
Reconfiguring service cognito-idp to use http://localhost:4566
Reconfiguring service cognito-identity to use http://localhost:4566
Reconfiguring service docdb to use http://localhost:4566
Reconfiguring service dynamodb to use http://localhost:4566
Reconfiguring service dynamodbstreams to use http://localhost:4566
Reconfiguring service ec2 to use http://localhost:4566
Reconfiguring service ecr to use http://localhost:4566
Reconfiguring service ecs to use http://localhost:4566
Reconfiguring service eks to use http://localhost:4566
Reconfiguring service elasticache to use http://localhost:4566
Reconfiguring service elasticbeanstalk to use http://localhost:4566
Reconfiguring service elb to use http://localhost:4566
Reconfiguring service elbv2 to use http://localhost:4566
Reconfiguring service emr to use http://localhost:4566
Reconfiguring service es to use http://localhost:4566
Reconfiguring service events to use http://localhost:4566
Reconfiguring service firehose to use http://localhost:4566
Reconfiguring service glacier to use http://localhost:4566
Reconfiguring service glue to use http://localhost:4566
Reconfiguring service iam to use http://localhost:4566
Reconfiguring service iot to use http://localhost:4566
Reconfiguring service iotanalytics to use http://localhost:4566
Reconfiguring service iotevents to use http://localhost:4566
Reconfiguring service iot-data to use http://localhost:4566
Reconfiguring service iot-jobs-data to use http://localhost:4566
Reconfiguring service kafka to use http://localhost:4566
Reconfiguring service kinesis to use http://localhost:4566
Reconfiguring service kinesisanalytics to use http://localhost:4566
Reconfiguring service kms to use http://localhost:4566
Reconfiguring service lambda to use http://localhost:4566
Reconfiguring service logs to use http://localhost:4566
Reconfiguring service mediastore to use http://localhost:4566
Reconfiguring service neptune to use http://localhost:4566
Reconfiguring service organizations to use http://localhost:4566
Reconfiguring service qldb to use http://localhost:4566
Reconfiguring service rds to use http://localhost:4566
Reconfiguring service redshift to use http://localhost:4566
Reconfiguring service route53 to use http://localhost:4566
Reconfiguring service s3 to use http://localhost:4566
Reconfiguring service s3control to use http://localhost:4566
Reconfiguring service sagemaker to use http://localhost:4566
Reconfiguring service sagemaker-runtime to use http://localhost:4566
Reconfiguring service secretsmanager to use http://localhost:4566
Reconfiguring service ses to use http://localhost:4566
Reconfiguring service sns to use http://localhost:4566
Reconfiguring service sqs to use http://localhost:4566
Reconfiguring service ssm to use http://localhost:4566
Reconfiguring service stepfunctions to use http://localhost:4566
Reconfiguring service sts to use http://localhost:4566
Reconfiguring service timestream to use http://localhost:4566
Reconfiguring service transfer to use http://localhost:4566
Reconfiguring service xray to use http://localhost:4566
service: FoobarService
frameworkVersion: '3'
provider:
  name: aws
  runtime: python3.8
  stage: local
  region: us-east-1
  versionFunctions: true
plugins:
  - serverless-localstack
custom:
  defaultStage: local
  profile: default
  localstack:
    debug: true
    stages:
      - local
    host: http://localhost
    edgePort: 4566
    autostart: true
    lambda:
      mountCode: false
    docker:
      sudo: false
functions:
  foo:
    name: foo-local
    handler: handler.foobar
    events: []
  bar:
    name: bar-local
    handler: handler.foobar
    events: []
  foobar:
    name: foobar-local
    handler: handler.foobar
    events:
      - cloudwatchLog:
          logGroup: /aws/lambda/foo-local
          filter: '{ $.level = "error" }'
      - cloudwatchLog:
          logGroup: /aws/lambda/bar-local
          filter: '{ $.level = "error" }'
$ sls deploy --stage local
Running "serverless" from node_modules
config.options_stage: local
serverless.service.custom.stage: undefined
serverless.service.provider.stage: local
config.stage: local
Using serverless-localstack
Reconfiguring service acm to use http://localhost:4566
Reconfiguring service amplify to use http://localhost:4566
Reconfiguring service apigateway to use http://localhost:4566
Reconfiguring service apigatewayv2 to use http://localhost:4566
Reconfiguring service application-autoscaling to use http://localhost:4566
Reconfiguring service appsync to use http://localhost:4566
Reconfiguring service athena to use http://localhost:4566
Reconfiguring service autoscaling to use http://localhost:4566
Reconfiguring service batch to use http://localhost:4566
Reconfiguring service cloudformation to use http://localhost:4566
Reconfiguring service cloudfront to use http://localhost:4566
Reconfiguring service cloudsearch to use http://localhost:4566
Reconfiguring service cloudtrail to use http://localhost:4566
Reconfiguring service cloudwatch to use http://localhost:4566
Reconfiguring service cloudwatchlogs to use http://localhost:4566
Reconfiguring service codecommit to use http://localhost:4566
Reconfiguring service cognito-idp to use http://localhost:4566
Reconfiguring service cognito-identity to use http://localhost:4566
Reconfiguring service docdb to use http://localhost:4566
Reconfiguring service dynamodb to use http://localhost:4566
Reconfiguring service dynamodbstreams to use http://localhost:4566
Reconfiguring service ec2 to use http://localhost:4566
Reconfiguring service ecr to use http://localhost:4566
Reconfiguring service ecs to use http://localhost:4566
Reconfiguring service eks to use http://localhost:4566
Reconfiguring service elasticache to use http://localhost:4566
Reconfiguring service elasticbeanstalk to use http://localhost:4566
Reconfiguring service elb to use http://localhost:4566
Reconfiguring service elbv2 to use http://localhost:4566
Reconfiguring service emr to use http://localhost:4566
Reconfiguring service es to use http://localhost:4566
Reconfiguring service events to use http://localhost:4566
Reconfiguring service firehose to use http://localhost:4566
Reconfiguring service glacier to use http://localhost:4566
Reconfiguring service glue to use http://localhost:4566
Reconfiguring service iam to use http://localhost:4566
Reconfiguring service iot to use http://localhost:4566
Reconfiguring service iotanalytics to use http://localhost:4566
Reconfiguring service iotevents to use http://localhost:4566
Reconfiguring service iot-data to use http://localhost:4566
Reconfiguring service iot-jobs-data to use http://localhost:4566
Reconfiguring service kafka to use http://localhost:4566
Reconfiguring service kinesis to use http://localhost:4566
Reconfiguring service kinesisanalytics to use http://localhost:4566
Reconfiguring service kms to use http://localhost:4566
Reconfiguring service lambda to use http://localhost:4566
Reconfiguring service logs to use http://localhost:4566
Reconfiguring service mediastore to use http://localhost:4566
Reconfiguring service neptune to use http://localhost:4566
Reconfiguring service organizations to use http://localhost:4566
Reconfiguring service qldb to use http://localhost:4566
Reconfiguring service rds to use http://localhost:4566
Reconfiguring service redshift to use http://localhost:4566
Reconfiguring service route53 to use http://localhost:4566
Reconfiguring service s3 to use http://localhost:4566
Reconfiguring service s3control to use http://localhost:4566
Reconfiguring service sagemaker to use http://localhost:4566
Reconfiguring service sagemaker-runtime to use http://localhost:4566
Reconfiguring service secretsmanager to use http://localhost:4566
Reconfiguring service ses to use http://localhost:4566
Reconfiguring service sns to use http://localhost:4566
Reconfiguring service sqs to use http://localhost:4566
Reconfiguring service ssm to use http://localhost:4566
Reconfiguring service stepfunctions to use http://localhost:4566
Reconfiguring service sts to use http://localhost:4566
Reconfiguring service timestream to use http://localhost:4566
Reconfiguring service transfer to use http://localhost:4566
Reconfiguring service xray to use http://localhost:4566

Deploying FoobarService to stage local (us-east-1)
config.options_stage: local
serverless.service.custom.stage: undefined
serverless.service.provider.stage: local
config.stage: local
config.options_stage: local
serverless.service.custom.stage: undefined
serverless.service.provider.stage: local
config.stage: local
Using custom endpoint for STS: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for S3: http://localhost:4566
Using custom endpoint for S3: http://localhost:4566
Using custom endpoint for Lambda: http://localhost:4566
Using custom endpoint for Lambda: http://localhost:4566
Using custom endpoint for Lambda: http://localhost:4566
Using custom endpoint for CloudWatchLogs: http://localhost:4566
Using custom endpoint for CloudWatchLogs: http://localhost:4566
Using custom endpoint for S3: http://localhost:4566
Using custom endpoint for S3: http://localhost:4566
Using custom endpoint for S3: http://localhost:4566
Skipping template validation: Unsupported in Localstack
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Overriding S3 templateUrl to http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for CloudFormation: http://localhost:4566
Using custom endpoint for S3: http://localhost:4566

✔ Service deployed to stack FoobarService-local (14s)

functions:
  foo: foo-local (926 B)
  bar: bar-local (926 B)
  foobar: foobar-local (926 B)
$ sls invoke -f foobar --stage local
Running "serverless" from node_modules
config.options_stage: local
serverless.service.custom.stage: undefined
serverless.service.provider.stage: local
config.stage: local
Using serverless-localstack
Reconfiguring service acm to use http://localhost:4566
Reconfiguring service amplify to use http://localhost:4566
Reconfiguring service apigateway to use http://localhost:4566
Reconfiguring service apigatewayv2 to use http://localhost:4566
Reconfiguring service application-autoscaling to use http://localhost:4566
Reconfiguring service appsync to use http://localhost:4566
Reconfiguring service athena to use http://localhost:4566
Reconfiguring service autoscaling to use http://localhost:4566
Reconfiguring service batch to use http://localhost:4566
Reconfiguring service cloudformation to use http://localhost:4566
Reconfiguring service cloudfront to use http://localhost:4566
Reconfiguring service cloudsearch to use http://localhost:4566
Reconfiguring service cloudtrail to use http://localhost:4566
Reconfiguring service cloudwatch to use http://localhost:4566
Reconfiguring service cloudwatchlogs to use http://localhost:4566
Reconfiguring service codecommit to use http://localhost:4566
Reconfiguring service cognito-idp to use http://localhost:4566
Reconfiguring service cognito-identity to use http://localhost:4566
Reconfiguring service docdb to use http://localhost:4566
Reconfiguring service dynamodb to use http://localhost:4566
Reconfiguring service dynamodbstreams to use http://localhost:4566
Reconfiguring service ec2 to use http://localhost:4566
Reconfiguring service ecr to use http://localhost:4566
Reconfiguring service ecs to use http://localhost:4566
Reconfiguring service eks to use http://localhost:4566
Reconfiguring service elasticache to use http://localhost:4566
Reconfiguring service elasticbeanstalk to use http://localhost:4566
Reconfiguring service elb to use http://localhost:4566
Reconfiguring service elbv2 to use http://localhost:4566
Reconfiguring service emr to use http://localhost:4566
Reconfiguring service es to use http://localhost:4566
Reconfiguring service events to use http://localhost:4566
Reconfiguring service firehose to use http://localhost:4566
Reconfiguring service glacier to use http://localhost:4566
Reconfiguring service glue to use http://localhost:4566
Reconfiguring service iam to use http://localhost:4566
Reconfiguring service iot to use http://localhost:4566
Reconfiguring service iotanalytics to use http://localhost:4566
Reconfiguring service iotevents to use http://localhost:4566
Reconfiguring service iot-data to use http://localhost:4566
Reconfiguring service iot-jobs-data to use http://localhost:4566
Reconfiguring service kafka to use http://localhost:4566
Reconfiguring service kinesis to use http://localhost:4566
Reconfiguring service kinesisanalytics to use http://localhost:4566
Reconfiguring service kms to use http://localhost:4566
Reconfiguring service lambda to use http://localhost:4566
Reconfiguring service logs to use http://localhost:4566
Reconfiguring service mediastore to use http://localhost:4566
Reconfiguring service neptune to use http://localhost:4566
Reconfiguring service organizations to use http://localhost:4566
Reconfiguring service qldb to use http://localhost:4566
Reconfiguring service rds to use http://localhost:4566
Reconfiguring service redshift to use http://localhost:4566
Reconfiguring service route53 to use http://localhost:4566
Reconfiguring service s3 to use http://localhost:4566
Reconfiguring service s3control to use http://localhost:4566
Reconfiguring service sagemaker to use http://localhost:4566
Reconfiguring service sagemaker-runtime to use http://localhost:4566
Reconfiguring service secretsmanager to use http://localhost:4566
Reconfiguring service ses to use http://localhost:4566
Reconfiguring service sns to use http://localhost:4566
Reconfiguring service sqs to use http://localhost:4566
Reconfiguring service ssm to use http://localhost:4566
Reconfiguring service stepfunctions to use http://localhost:4566
Reconfiguring service sts to use http://localhost:4566
Reconfiguring service timestream to use http://localhost:4566
Reconfiguring service transfer to use http://localhost:4566
Reconfiguring service xray to use http://localhost:4566
config.options_stage: local
serverless.service.custom.stage: undefined
serverless.service.provider.stage: local
config.stage: local
config.options_stage: local
serverless.service.custom.stage: undefined
serverless.service.provider.stage: local
config.stage: local
Using custom endpoint for Lambda: http://localhost:4566
{
    "foo": "bar"
}

Limitations
Be aware that following this solution means that defining other events using the YAML syntax won't work. The reason is that YAML does not fully support merging arrays at the moment (related threads: 1, 2).
For instance, the following code
...

cloudwatch_log_events: &cloudwatch_log_events
  ${file(_serverless/cloudwatch_log_events.js)}

...

     events:
       - *cloudwatch_log_events
       - cloudwatchLog:
           ...

would produce the config as follows
     events:
       - - cloudwatchLog:
             ...
       - cloudwatchLog:

Notice the nested list (- -). In order for the config to be valid, there would need to be an option to extend the cloudwatch_log_events array, which is not possible today.
However, to handle different categories of CloudWatch log events (e.g. per service), you can go ahead with granularity on the JavaScript level. Following the above example:
(New) Project structure
.
├── _serverless
│   ├── cloudwatch_log_events.js
│   └── services
│       ├── bar.js
│       └── foo.js
├── handler.py
└── serverless.yml

_serverless/services/foo.js
const getConfig = async (resolveVariable) => {
  const stage = await resolveVariable('sls:stage');
  const logGroups = [
    `/aws/lambda/foo-${stage}-1`,
    `/aws/lambda/foo-${stage}-2`,
  ];
  const logGroupFilter = '{ $.level = "error" }';

  return logGroups.map(function (logGroup) {
    return {
      cloudwatchLog: {
          logGroup: logGroup,
          filter: logGroupFilter
      }
    }
  });
}

module.exports = {
    getConfig: getConfig
}

_serverless/services/bar.js
const getConfig = async (resolveVariable) => {
  const stage = await resolveVariable('sls:stage');
  const logGroups = [
    `/aws/lambda/bar-${stage}-1`,
    `/aws/lambda/bar-${stage}-2`,
  ];
  const logGroupFilter = '{ $.level = "error" }';

  return logGroups.map(function (logGroup) {
    return {
      cloudwatchLog: {
          logGroup: logGroup,
          filter: logGroupFilter
      }
    }
  });
}

module.exports = {
    getConfig: getConfig
}

_serverless/cloudwatch_log_events.js
const foo = require('./services/foo.js');
const bar = require('./services/bar.js');

module.exports = async ({ options, resolveVariable }) => {
    const fooConfig = await foo.getConfig(resolveVariable);
    const barConfig = await bar.getConfig(resolveVariable);

    return [
        ...fooConfig,
        ...barConfig,
    ];
}

The rest of the files remain untouched.


text:
Q: How to top encode without allocating I am trying to read the content of the input from a TopDecode, but erdpy contract report reports has-allocator equals true.
Below is my current snippet.
impl<M: ManagedTypeApi> TopDecode for PenguinAttributes<M> {
    fn top_decode<I: elrond_codec::TopDecodeInput>(input: I) -> Result<Self, DecodeError> {
        let boxed_bytes = input.into_boxed_slice_u8();

        return Result::Ok(PenguinAttributes::empty());
    }
}

I have commented the boxed_bytes method, and has-allocator now equals false.
But how can I read the content of input withouting using allocator please ?
I am using elrond-wasm 0.29.3 and erdpy 1.2.3.
Thank you
An example of my input Hat:unequipped;Beak:Golden Beak (BEAK-a1a1a1-05).

A: I achieve this by loading my bytes in an array of 512. Then, I read the array from 0 to managed_buffer.length.
impl<M: ManagedTypeApi> TopDecode for PenguinAttributes<M> {
    fn top_decode<I: elrond_codec::TopDecodeInput>(input: I) -> Result<Self, DecodeError> {
        let mut bytes: [u8; 512] = [0; 512];
        managed_buffer.load_to_byte_array(&mut bytes);

        return Result::Ok(PenguinAttributes::empty());
    }
}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Design Pattern to add columns in database table dynamically The user wants to add new fields in UI dynamically. This new field should get stored in database and they should be allowed to perform CRUD on it.
Now I can do this by specifying a XML but I wanted a better way where these new columns are searchable. Also the idea of firing ALTER statement and adding a new column seems wrong.
Can anyone help me with a design pattern on database server side of how to solve this problem?

A: This can be approached using a key value system.  You create a table with the primary key column(s) of the table you want to annotate, a column for the name of the attribute, and a column for its value.  When you user wants to add an attribute (say height) to the record of person 123 you add a row to the new table with the values (123, 'HEIGHT', '140.5').
In general you cast the values to TEXT for storage but if you know all the attributes will be numeric you can choose a different type for the value column.  You can also (not recommended) use several different value columns depending on the type of the data.
This technique has the advantage that you don't need to modify the database structure to add new attributes and attributes are only stored for those records that have them.  The disadvantage is that querying is not as straightforward as if the columns were all in the main data table.

A: There is no reason why a qualified business user should not be allowed to add a column to a table.  It is less likely to cause a problem than just about anything else you can imagine including adding a new row to a table or changing. the value of a data element.
Using either of the methods described above do not avoid any risk; they are simply throwbacks to COBOL filler fields or unnecessary embellishments of the database function.  The result can still be unnormalized and inaccurate.
These same business persons add columns to spreadsheets and tables to Word documents without DBAs getting in their way.
Of course, just adding the column is the smallest part of getting an information system to work, but it is often the case that it is perceived to be an almost insurmountable barrier.  It is in fact 5 min worth of work assuming you know where to put it.  Adding a column to the proper table with the proper datatype is easy to do, easy to use, and has the best chance of encouraging data quality.

A: Find out what the maximum number of user-added fields will be and add them before hand.  For example 'User1', 'User2', 'User3', 'User4'...etc.  You can then enable the fields on the UI based on some configurable settings.


text:
Q: Getting different position values using Analyzer API in ES 1.4 and ES 2.3 I am upgrading from ES 1.4 to ES 2.3 and while testing the scoring of the documents I noticed a difference between the outputs from the Explain API for the same query:
{
    "query": {
        "match": {
            "article_content": "news"
        }
    }
}

From ES 2.3.0 I get:
{
  "value": 0.9890914,
  "description": "fieldWeight in 3931, product of:",
  "details": [
    {
      "value": 5.8309517,
      "description": "tf(freq=34.0), with freq of:",
      "details": [
        {
          "value": 34,
          "description": "termFreq=34.0",
          "details": []
        }
      ]
    },
    {
      "value": 5.428089,
      "description": "idf(docFreq=117, maxDocs=9885)",
      "details": []
    },
    {
      "value": 0.03125,
      "description": "fieldNorm(doc=3931)",
      "details": []
    }
  ]
}

and from ES 1.4.2 I get:
{
  "value": 0.9319723,
  "description": "fieldWeight in 403, product of:",
  "details": [
    {
      "value": 5.8309517,
      "description": "tf(freq=34.0), with freq of:",
      "details": [
        {
          "value": 34,
          "description": "termFreq=34.0"
        }
      ]
    },
    {
      "value": 5.114622,
      "description": "idf(docFreq=226, maxDocs=13899)"
    },
    {
      "value": 0.03125,
      "description": "fieldNorm(doc=403)"
    }
  ]
}

I thought that there might be something wrong with my custom_analyzer, so checked even that using the Analyze API:
For ES 2.3 I used:
curl -XGET 'localhost:9200/new_index/_analyze' -d '{
  "analyzer" : "custom_text_analyzer",
  "text" : "...."
}'

and for ES 1.4.2 I used
curl -XGET 'localhost:9210/new_index2/_analyze?analyzer=custom_text_analyzer' -d '...'

Both calls resulted in the same number of tokens, the only difference was values of "position":
For ES 2.3.0
{
  "tokens": [
    {
      "token": "show",
      "start_offset": 0,
      "end_offset": 4,
      "type": "<ALPHANUM>",
      "position": 0
    }, ....

For ES 1.4.2
{
  "tokens": [
    {
      "token": "show",
      "start_offset": 0,
      "end_offset": 4,
      "type": "<ALPHANUM>",
      "position": 1
    }, ....

NOTE:

*

*Both the indices have same documents in count and content.

*The document that I tested had 289 tokens

*The custom analyzer is same for both indices. (I checked twice)
I just wanted some insight into what could be the issue?

A: The difference in scoring is here:
2.3.0:
{
  "value": 5.428089,
  "description": "idf(docFreq=117, maxDocs=9885)",
  "details": []
}

1.4.2:
{
  "value": 5.114622,
  "description": "idf(docFreq=226, maxDocs=13899)"
}

So the IDF is different because you seem to have a different number of documents and different number of frequency of terms in those documents. You say you have equal number of documents, but maxDocs takes into consideration all documents in a Lucene shard. All includes the marked-as-deleted documents.
My assumption is that your 1.4.x index also has some deleted documents in it (which weren't yet physically deleted from disk from merging segments) and these ones influence a bit the scoring calculations. You can check the deleted documents count with curl -XGET "http://localhost:9200/_cat/indices?v" and you can force a merge by using the _optimize API (curl -XPOST "http://localhost:9200/my_index/_optimize?max_num_segments=1"). Be careful, though, that the optimization does use a bit of resources so you'd want to do this when the cluster is not busy.


text:
Q: iOS App Update - Restricting new version to single platform My application is currently present in Appstore for both iPad and iPhone platforms. Now, i want to update the appstore app but restricted to only iPhone platform (will later release the iPad version).
1) During Appstore submission, Xcode throws validation error that "this version doesn't compatible with previous version (not supporting iPad version)". Should i need to support iPad version also?
2) Ignoring that error, i tried proceeding with the appstore distribution. Its never get uploaded. waited for around more than 2 hrs. It showed "Your application is being uploaded"

Any help appreciated. Thanks.

A: Unfortunately, once you've submitted an app that supports both platforms, from that point on each update also needs to support both platforms (as you've found).
The only way around this is to create a new app with a different bundle id.
In your case, as you will support both eventually you may have to delay release until the iPad version is complete.


text:
Q: Any way of adding member variable for specific template value? I have this math vector struct:
template <size_t _Size, typename _NumType>
struct Vector {
    _NumType elements[_Size];

    //... Other stuff ...
};

And I want to add variables depending on how many elements the vector has.
Something like this:
_NumType& x = elements[0]; // Only if _Size >= 1
_NumType& y = elements[1]; // Only if _Size >= 2
_NumType& z = elements[2]; // Only if _Size >= 3

Making a base class/struct and then extending would be a solution but due to other code I can't do that (it would only make more problems).
Another solution I found is doing something I believe is called partial template specialization:
template <typename _NumType>
struct Vector<2U, _NumType> {
    _NumType& x = elements[0];
    _NumType& y = elements[1];

    //... Other stuff ...
};

The problem with this solution is that I would have to copy "other stuff" for each specialization which is something I'd rather avoid ("other stuff" is around 70 lines of code).
In case there is no solution I can elaborate on the problem with extending a base class but I hope it won't be necessary.

A: partial template specialization can do the job, and to avoid code duplication you have to split the class, something like
template <size_t Size, typename T>
struct VectorData {
    T elements[Size];
};

template <typename T>
struct VectorData<2, T> {
    T elements[2];
    T& x = elements[0];
    T& y = elements[1];
};

template <typename T>
struct VectorData<3, T> {
    T elements[3];
    T& x = elements[0];
    T& y = elements[1];
    T& z = elements[2];
};

template <size_t Size, typename T>
struct Vector : VectorData<Size, T> {
    //... Other stuff ...
};

If you change reference to function, you might use SFINAE and since C++20, you might even discard some methods:
template <size_t Size, typename T>
struct Vector : VectorData<Size, T> {
    T elements[Size];

    T& x() requires (size == 2 || size == 3) { return elements[0]; }
    T& y() requires (size == 2 || size == 3) { return elements[0]; }
    T& z() requires (size == 3) { return elements[0]; }
    //... Other stuff ...
};

A: Not sure why you want this, however, if you don't need it to be members, you can do something like this: (C++17)
auto getCoordinates()
 {
      if constexpr (TSize == 1)
           return std::tuple<TNumType&>(elements[0]);
       else if constexpr (TSize == 2)
           return std::tuple<TNumType&, TNumType &>(elements[0], elements[1]);
       else if constexpr (TSize == 3)
           return std::tuple<TNumType&, TNumType &, TNumType&>(elements[0], elements[1], elements[2]);
}

With usage:
 auto [x, y, z] = v.getCoordinates(); // Assuming 3

A: In the case you don't have a compiler capable of supporting constraints, or choose not to use them, an effect similar (albeit clunkier) to the second part of Jarod42's answer can be achieved with the use of static_assert.
template<size_t Size_, typename NumType_>
struct Vector {
    NumType_ elements[Size_];

    // ...

    NumType_& x() {
        static_assert(Size_ > 0, "Must contain a minimum of 1 element for x.");
        return elements[0];
    }

    NumType_& y() {
        static_assert(Size_ > 1, "Must contain a minimum of 2 elements for y.");
        return elements[1];
    }

    NumType_& z() {
        static_assert(Size_ > 2, "Must contain a minimum of 3 elements for z.");
        return elements[2];
    }
};

This relies on the rules of implicit template instantiation, which state that:

*

*When a class template is implicitly instantiated, the declarations of its member functions are also implicitly instantiated... but the definitions aren't.

*If a function template isn't explicitly instantiated, and isn't explicitly specialised, it will be implicitly specialised when it needs to be.

Combined, these two rules mean that the functions will always be visible for any Vector, but they'll break the moment you call them if Size_ isn't large enough.
Vector<1, int> v1i;

v1i.x() = 3; // Instantiates Vector<1, int>::x().  1 > 0, so we're good.
v1i.y() = 6; // Instantiates Vector<1, int>::y().  !(1 > 1), so static_assert emits an error.
v1i.z() = 9; // Instantiates Vector<1, int>::y().  !(1 > 2), so static_assert emits an error.

This will function as desired... provided nobody thinks to stat explicitly instantiate things to speed up compilation!
Note that I changed the underscores in your template parameters' names from prefix to postfix, to comply with language rules regarding underscores followed by capitals.


text:
Q: Making a button transparent then opaque again in android I have a game where I am using 12 buttons with no text on to display lives. Every time they lose a life, this code is run
public void guessesRemainingDisplay(int numberOfGuesses) {

    int guessesRemaining;

    guessesRemaining = maximumGuesses + 1 - numberOfGuesses;

    switch(guessesRemaining) {

    case 1:

        findViewById(R.id.Guess1).setBackgroundColor(color.transparent);
        break;

    case 2:
        findViewById(R.id.Guess2).setBackgroundColor(color.transparent);
        break;

    case 3:
        findViewById(R.id.Guess3).setBackgroundColor(color.transparent);
        break;

    case 4:
        findViewById(R.id.Guess4).setBackgroundColor(color.transparent);
        break;

    case 5:
        findViewById(R.id.Guess5).setBackgroundColor(color.transparent);
        break;

    case 6:
        findViewById(R.id.Guess6).setBackgroundColor(color.transparent);
        break;

    case 7:
        findViewById(R.id.Guess7).setBackgroundColor(color.transparent);
        break;

    case 8:
        findViewById(R.id.Guess8).setBackgroundColor(color.transparent);
        break;

    case 9:
        findViewById(R.id.Guess9).setBackgroundColor(color.transparent);
        break;

    case 10:
        findViewById(R.id.Guess10).setBackgroundColor(color.transparent);
        break;

    case 11:
        findViewById(R.id.Guess11).setBackgroundColor(color.transparent);
        break;

    case 12:
        findViewById(R.id.Guess12).setBackgroundColor(color.transparent);
        break;

    }

}

And the furthest most right button disappears (they are in a line, 1 on left 12 on right).
However, when I start a new game, or when the activity first opens, this code is run
findViewById(R.id.Guess1).setBackgroundColor(color.X);

Repeated for every single id. X being literally any color (I've tried it with loads of different ones). For some reason, if this code is ever run, the button disappears. Why? If its not run, the 12 buttons appear, but whenever I start a new game obviously the buttons that have disappeared due to losing lives dont come back.

A: For you task it's better to use findViewById(R.id.id).setVisibility(View.Invisible) for disappearing and 'findViewById(R.id.id).setVisibility(View.Visible)' for returning view back.


text:
Q: Rotate an image on iPhone only? How would one rotate an image using the following line of code but for iPhone only?
PhotoView.transform=CGAffineTransformMakeRotation(M_PI*0.5);

My app uses a UIScrollView. In the scrollView are thumbnail images. When a thumbnail is tapped, a segue is triggered to load an image in a new view controller, but for some reason, the image loads on its side on iPhone 4 (it loads perfectly straight on iPad mini)
I used the following if statement format to no avail...
 if ([[UIScreen mainScreen] bounds].size.height == 480)
    {
        // iPhone, iPod Touch
     ...
    }

My question: Is there another way to explicitly rotate the image on iPhone devices only? The following line successfully rotates the image correctly for iPhone uses, but conversely erroneously loads it for the iPad.
PhotoView.transform=CGAffineTransformMakeRotation(M_PI*0.5);

How can one programmatically rotate an image for iPhone 4 only? Additional info: this is technically an iPhone app under build settings.

A: Try this
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){
}
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
}


text:
Q: can roles and tasks exist in the same playbook? ---
# file: main.yml

- hosts: fotk
  remote_user: fakesudo
  tasks:
  - name: create a developer user
    user: name={{ user }}
          password={{ password }}
          shell=/bin/bash
          generate_ssh_key=yes
          state=present
  roles:
  - { role: create_developer_environment, sudo_user: "{{ user }}" }
  - { role: vim, sudo_user: "{{ user }}" }

For some reason the create user task is not running.  I have searched every key phrase I can think of on Google to find an answer without success.
The roles are running which is odd.
Is it possible for a playbook to contain both tasks and roles?

A: You can also do pre_tasks:  and post_tasks: if you need to do things before or after.  From the Docs https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html
- hosts: localhost

  pre_tasks:
    - shell: echo 'hello in pre'

  roles:
    - { role: some_role }

  tasks:
    - shell: echo 'in tasks'

  post_tasks:
    - shell: echo 'goodbye in post'

Gives the output: PLAY [localhost]

GATHERING FACTS
***************************************************************  ok: [localhost]
TASK: [shell echo 'hello in pre']
*********************************************  changed: [localhost]
TASK: [some_role | shell echo 'hello from the role']
**************************  changed: [localhost]
TASK: [shell echo 'in tasks']
*************************************************  changed: [localhost]
TASK: [shell echo 'goodbye in post']
******************************************  changed: [localhost]
PLAY RECAP
********************************************************************  localhost                  : ok=5    changed=4    unreachable=0
failed=0

This is with ansible 1.9.1

A: Actually this should be possible and I remember I did this a few times during testing. Might be something with your version - or the order does matter, so that the tasks will be executed after the roles.
I would have posted this as a comment, rather than an answer, but I wouldn't be able to give the following example in a comment:
Whatever might be the reason why your task is not executed, you can always separate your playbook into several plays, like so:
---
# file: main.yml

- hosts: fotk
  remote_user: fakesudo
  tasks:
  - name: create a developer user
    user: name={{ user }}
          password={{ password }}
          shell=/bin/bash
          generate_ssh_key=yes
          state=present

- hosts: fotk
  remote_user: fakesudo
  roles:
  - { role: create_developer_environment, sudo_user: "{{ user }}" }
  - { role: vim, sudo_user: "{{ user }}" }

A: https://docs.ansible.com/playbooks_roles.html#roles

If the play still has a 'tasks' section, those tasks are executed
  after roles are applied.

If you wish to run tasks before or after roles are executed, you need to list these under pre_tasks and post_tasks. Thus, there is no way to run "loose" tasks between two roles. You might want to create a dedicated role for these tasks.

A: Short follow up to the already mentioned options by quoting the latest Ansible docs docs.ansible.com/latest/playbooks_reuse_roles:

As of Ansible 2.4, you can now use roles inline with any other tasks using import_role or include_role:

---
- hosts: webservers
  tasks:
    - debug:
      msg: "before we run our role"
    - import_role:
      name: example
    - include_role:
      name: example
    - debug:
      msg: "after we ran our role"`

Code snippet is also from Ansible docs.
Be aware of the difference between static (import*) & dynamic (include*) usage.


text:
Q: text align center not working for inline-block I have a parent div in which there are three child div, all the child divs are display:inline-block, so that all the three child div comes in single line.
Now the problem is, I want first and last div to float:right & float:left, receptively and the center div should be center aligned. I am trying to do this but not able to achieve.
The first div is already at the left corner so not issues.
The last div is float:right, which also works fine.
The center div is not working as expected text-align:center
Can someone please help me with this?

#wave {
  color: white;
  font-size: 24px;
  /* text-align:left; */
  line-height: 65px;
  display: inline-block;
  /* float:left; */
  padding-left: 10px;
  font-family: Exo-Regular;
  font-weight: bolder;
  letter-spacing: 1.5px;
  padding-right: 22px;
  text-align: center;
  /* border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
  -webkit-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75); */
}

#score-card {
  color: white;
  font-size: 26px;
  /* text-align:right; */
  line-height: 65px;
  display: inline-block;
  float: right;
  padding-right: 10px;
  font-family: Exo-Regular;
  font-weight: bolder;
  letter-spacing: 1.5px;
  padding-left: 22px;
  /* border-top-left-radius: 50px;
  border-bottom-left-radius: 50px;
  -webkit-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75); */
}

#life {
  display: inline-block;
  line-height: 65px;
  color: white;
  font-size: 26px;
}

    Wave

    Life

    0

A: I added text-align:center to the parent, and added float:left & right to the first and last child;
This cannot properly center it, due to unequal width of the first and last child,
So I added position:absolute to center the second element and by making the parent relative position,
This method will ensure, that the second element will always be at the center, irrespective of the length of first and last child.
But it can get overlapped on small screens

#wave {
  color: white;
  font-size: 24px;
  /* text-align:left; */
  line-height: 65px;
  /*display: inline-block;*/
  float:left;
  padding-left: 10px;
  font-family: Exo-Regular;
  font-weight: bolder;
  letter-spacing: 1.5px;
  padding-right: 22px;
  text-align: center;
  /* border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
  -webkit-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75); */
}

#score-card {
  color: white;
  font-size: 26px;
  /* text-align:right; */
  line-height: 65px;
  /*display: inline-block;*/
  float: right;
  padding-right: 10px;
  font-family: Exo-Regular;
  font-weight: bolder;
  letter-spacing: 1.5px;
  padding-left: 22px;
  /* border-top-left-radius: 50px;
  border-bottom-left-radius: 50px;
  -webkit-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75); */
}

#life {
  display: inline-block;
  line-height: 65px;
  color: white;
  font-size: 26px;
}
#stat-board{text-align:center}

.type2{position:relative;}

.type2 #life{
  position:absolute;
  left:0;
  width:100%;
  text-align:center;
}

    Wave

    Life

    0

    Wave

    Life

    0

A: How about...

*

*add relative positioning to the container div

*absolutely position the middle div

#stat-board {
  width: 100%;
  position: relative;
}

#wave {
  color: white;
  font-size: 24px;
  /* text-align:left; */
  line-height: 65px;
  display: inline-block;
  /* float:left; */
  padding-left: 10px;
  font-family: Exo-Regular;
  font-weight: bolder;
  letter-spacing: 1.5px;
  padding-right: 22px;
  text-align: center;
  /* border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
  -webkit-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75); */
}

#score-card {
  color: white;
  font-size: 26px;
  /* text-align:right; */
  line-height: 65px;
  display: inline-block;
  float: right;
  padding-right: 10px;
  font-family: Exo-Regular;
  font-weight: bolder;
  letter-spacing: 1.5px;
  padding-left: 22px;
  /* border-top-left-radius: 50px;
  border-bottom-left-radius: 50px;
  -webkit-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  -moz-box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75);
  box-shadow: 0px 2px 78px -8px rgba(0,0,0,0.75); */
}

#life {
  position: absolute;
  display: inline-block;
  line-height: 65px;
  color: white;
  font-size: 26px;
  left: 50%;
  right: 50%;
}

    Wave

    Life

    0


text:
Q: Remote command execution using perl client-server (socket) My client.pl
#!/usr/bin/perl
use IO::Socket::INET;
use strict;

my $name = '172.20.10.189'; #Server IP
my $port = '7890';

my $socket = IO::Socket::INET->new('PeerAddr' => $name,
                                   'PeerPort' => $port,
                                'Proto' => 'tcp') or die "Can't create socket ($!)\n";

print "Client sending\n";
while (1) {
    my $msg = <STDIN>;
    print $socket $msg;
    print scalar <$socket>;
}
close $socket
    or die "Can't close socket ($!)\n";

My server.pl
#!/usr/bin/perl
use IO::Socket::INET;
use strict;

my $port = "7890";

my $socket = IO::Socket::INET->new('LocalPort' => $port,
                                   'Proto' => 'tcp',
                                   'Listen' => SOMAXCONN)
    or die "Can't create socket ($!)\n";

while (my $client = $socket->accept) {
    my $name = gethostbyaddr($client->peeraddr, AF_INET);
    my $port = $client->peerport;
    while (<$client>) {
        print "[$name $port] $_";
        my @out = `$_`;
        print @out;
        print $client "$.: @out";
    }
    close $client
        or die "Can't close ($!)\n";
}

die "Can't accept socket ($!)\n";

My client is sending a command (ls -lrt /) to the server and Server is supposed to run that command and send output to the client back.
Problem:-
The command is executed successfully on the server but it sends only first line to the client. If I press any key from client again the next line of output is sent to the client.
Or tell me how to send multiple line output to back to client.
Any help would be appreciated.
Thanks
Abhishek

A: The Server sends all lines to the client, the client however chooses to read only one line:
print scalar <$socket>;

If you remove the scalar, it should work. However, your architecture is still a security nightmare.

*

*All servers should run in taint mode (-T switch).

*Never blindly execute commands that a clients sends you. Only execute commands that pass a very strict validation test, do not run commands that just don't look malicious.

*Perhaps you are trying to duplicate SSH, you might want to look at that program instead.

*Your server doesn't do any kind of authentication. At least it logs all inputs.

A: It was a silly mistake... and I have fixed the first issue as follows and got multi-line output on the client side...
Client.pl
#!/usr/bin/perl
use IO::Socket::INET;
use strict;

my $name = '172.20.10.189'; #Server IP
my $port = '7890';

my $socket = IO::Socket::INET->new('PeerAddr' => $name,
                                   'PeerPort' => $port,
                                   'Proto' => 'tcp')
    or die "Can't create socket ($!)\n";
print "Client sending\n";

while (1) {
        my $msg = <STDIN>;
        print $socket $msg;
        while (<$socket>)
        {
                print "\n$_";
        }
}

close $socket
    or die "Can't close socket ($!)\n";
BUT there is one more issue -
I want my client to keep sending few other commands one after another until I close the client manually and receive output.
The problem is - It receives output of the first command only..
Can anyone now help me on this?


text:
Q: Normal subgroup generated by $D_8$ Let $D_8 = <a,b : a^4 = b^2 = 1, bab^{-1} = a^{-1}>$ be the dihedral group.
I'm trying to show that the subgroup generated by $a^2$ is normal. But, isn't $<a^2> ={\{1, a^2}\}$? So the index isn't $2$, so it can't be normal?
What am I missing here? Is my $<a^2>$ right or am I getting this bit wrong? Is it not just powers of $a^2$?
Thank you for any help.

A: Theorem: Let $G$ be a group and $H\le G$ be a subgroup of $G$. If $[G:H]=2$, Then $H \vartriangleleft G$ is a normal subgroup of $G$.
The converse of the above theorem is not always true. (An obvious example would be $G\vartriangleleft G$.)
Another example is $\langle a^2 \rangle \vartriangleleft D_8$. First, verify that $Z(D_8) = \{1,a^2\}$. And then, in particular, you can conclude that $\langle a^2 \rangle=\{1,a^2\}$ is a normal subgroup of $D_8$.


text:
Q: Exporting part of a circuit from a circuit defined as structural netlist in verilog I have a gate-level structual netlist of a design with 40,000 gates and 5000 flipflops in verilog. It is a flattened netlist with no sub-circuits inside. I would like to extract another netlist from this large netlist by deleting a few flip-flops and logic gates. The exported netlist should also be in verilog. I would like to know if an existing tool can do it.

A: You may use synthesis tools like Design Compiler (from Synopsys) or RTL compiler (from Cadence) to import the netlist, delete gates (e.g. from a tcl-script) and write out the modified netlist.
I'm sure that there are also lots of other tools that can be used for this purpose, so it also depends on your availability of these tools, and of course preferences in terms of which tools you know how to use.

A: Once the netlist is imported by Design Compiler, it's possible to delete any flip-flop or gate. Here is a simple example.
remove_cell {U1/reg1}

The following command helps to search for cells in the netlist.
get_cells "U1/reg*"


text:
Q: React Dropdown Value My intention is to get several values from API by using Dropdown component.
Here is my code examples:
<GridContainer>
   <GridItem xs={12} sm={2}>
      <FormLabel className={classes.labelHorizontal}>Package</FormLabel>
   </GridItem>

   <GridItem xs={12} sm={4}>
      <FormControl fullWidth className={classes.selectFormControl}>

       <InputLabel htmlFor="simple-select" className={classes.selectLabel}>
           Please Choose
       </InputLabel>

       <Select
         MenuProps={{
           className: classes.selectMenu
          }}
           classes={{
             select: classes.select
            }}
         inputProps={{
        value: state.memberLoginInformation.package,
        onChange: event => {
          const { memberLoginInformation } = state;
           setState({
            ...state,
           memberLoginInformation: {
           ...memberLoginInformation,
           package: event.target.value
            }
          });
        }
        >
         {
            packageList.data &&
            packageList.data.package.content.map(({ id, name, active, price }) => {

            if (active)
            {
               return (
                    <MenuItem
                        classes={{
                          root: classes.selectMenuItem,
                          selected: classes.selectMenuItemSelected
                        }}
                          value={id}
                    >
                          {name}
                    </MenuItem>
                );
            }
            })
        }
     </Select>
     </FormControl>
   </GridItem>

On my API I have something like this:
{
  "id": 1,
  "name": "Premium",
  "price": 100,
  "point": 100,
  "term": 2,
  "active": true,
  "supplementRenewal": null,
  "termUnit": "YEAR"
}

Now my goal is, how can I get the values for (name, price and point) when the component is selected.
Anyone here can help me out because Im only able to get one value.
Thanks!!!

A: you are storing the id value in the attribute 'value' using
value={id}

can you try adding another attributes and storing the values of (name, price and point), like so:
<MenuItem
                        classes={{
                          root: classes.selectMenuItem,
                          selected: classes.selectMenuItemSelected
                        }}
                           valueID={id}
                           valueName={name}
                           valuePrice={price}
                           valuePoint={point}
                    >
                          {name}
                    </MenuItem>


text:
Q: Existence of special system of values. There is a graph $G=(V,E)$, where $|V|=n$.
Let's consider every induced subgraph of $G$ with $k$ vertices. I denote cardinality of $l$-th induced subgraph (its edges) as $a_{l}$ and i call it a $l$-th value of a graph.

There is given a system of values $(a_{1},...,a_{{n\choose k}})$. Find the a way to decide whether this system is set of values of some graph.

I even don't know how to approach this problem.
Regards.


text:
Q: How to post a twit using C# with username and password? I used tweetsharp API to post a twit using access token it is working fine. Now I need to implement with username and password to post the twit. Is it possible to post a twit using username and password?.
If yes which API is good option to twit using user credentials?
Thanks in advance

A: The Twitter API requires that you use OAuth (an authenticated access token) to use the statuses/update endpoint. So, no, it is not possible to post a Tweet using just the username and password.


text:
Q: Uploading an android camera shoot through a web service I'm writting an android app which has to upload an picture throught a web service.
My web service part is working (test with console application).
So I guess my error is in the android part.
Android Code use to take the picture :
public void TakePicture(){
    i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    //outputFileUri = Uri.fromFile( new File(Environment.getExternalStorageDirectory(), "appicture.jpeg"));
    //Log.i("URI", outputFileUri.toString());
    i.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
    startActivityForResult(i, cameraData);
}

The activity result :
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    try{
        super.onActivityResult(requestCode, resultCode, data);
        //if I got information from Activity result
        if(resultCode == RESULT_OK){

            Bundle extras = data.getExtras();
            _bmp = (Bitmap) extras.get("data");

        }else{
            //log
            Log.v("Phone", "Error picture");
        }
    }
    catch (Exception e) {
        Log.i("Cam error", e.toString());
    }
}

And now the sending part :
public void SendReport(){
    File img;
    try {
        //Web service URL
        String url = "http://10.0.2.2:51136/API/picture";

        //Convert the picture
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        _bmp.compress(Bitmap.CompressFormat.JPEG, 100, bao);
        byte[] data = bao.toByteArray();

        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(url);
        MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);

        //Add the picture
        entity.addPart("image",new ByteArrayBody(data, "image/jpeg", "image"));
        httppost.setEntity(entity);

        //Call
        HttpResponse response = httpclient.execute(httppost);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

A: Try like this:
    entity.addPart("image",new ByteArrayBody(data, "image.jpg"));


text:
Q: Cannot save shipment Unfortunately My Magento Backend Shows error While Ship order in
Cannot save shipment.

I don't know what is the problem recently only it happend
My exception.log
016-02-29T13:44:58+00:00 ERR (3):
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '100000257' for key 'UNQ_SALES_FLAT_SHIPMENT_INCREMENT_ID'' in /home/domain/public_html/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /home/domain/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /home/domain/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /home/domain/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /home/domain/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#4 /home/domain/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `sa...', Array)
#5 /home/domain/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `sa...', Array)
#6 /home/domain/public_html/lib/Zend/Db/Adapter/Abstract.php(576): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `sa...', Array)
#7 /home/domain/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert('sales_flat_ship...', Array)
#8 /home/domain/public_html/app/code/core/Mage/Sales/Model/Resource/Order/Abstract.php(425): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Sales_Model_Order_Shipment))
#9 /home/domain/public_html/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Sales_Model_Resource_Order_Abstract->save(Object(Mage_Sales_Model_Order_Shipment))
#10 /home/domain/public_html/app/code/core/Mage/Core/Model/Resource/Transaction.php(151): Mage_Core_Model_Abstract->save()
#11 /home/domain/public_html/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php(120): Mage_Core_Model_Resource_Transaction->save()
#12 /home/domain/public_html/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php(220): Mage_Adminhtml_Sales_Order_ShipmentController->_saveShipment(Object(Mage_Sales_Model_Order_Shipment))
#13 /home/domain/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Sales_Order_ShipmentController->saveAction()
#14 /home/domain/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('save')
#15 /home/domain/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#16 /home/domain/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#17 /home/domain/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#18 /home/domain/public_html/index.php(83): Mage::run('', 'store')
#19 {main}

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '100000257' for key 'UNQ_SALES_FLAT_SHIPMENT_INCREMENT_ID', query was: INSERT INTO `sales_flat_shipment` (`store_id`, `total_qty`, `email_sent`, `order_id`, `customer_id`, `shipping_address_id`, `billing_address_id`, `increment_id`, `created_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, '2016-02-29 13:44:58', '2016-02-29 13:44:58')' in /home/domain/public_html/lib/Zend/Db/Statement/Pdo.php:235
Stack trace:
#0 /home/domain/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/domain/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/domain/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /home/domain/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `sa...', Array)
#4 /home/domain/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `sa...', Array)
#5 /home/domain/public_html/lib/Zend/Db/Adapter/Abstract.php(576): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `sa...', Array)
#6 /home/domain/public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert('sales_flat_ship...', Array)
#7 /home/domain/public_html/app/code/core/Mage/Sales/Model/Resource/Order/Abstract.php(425): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Sales_Model_Order_Shipment))
#8 /home/domain/public_html/app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Sales_Model_Resource_Order_Abstract->save(Object(Mage_Sales_Model_Order_Shipment))
#9 /home/domain/public_html/app/code/core/Mage/Core/Model/Resource/Transaction.php(151): Mage_Core_Model_Abstract->save()
#10 /home/domain/public_html/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php(120): Mage_Core_Model_Resource_Transaction->save()
#11 /home/domain/public_html/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php(220): Mage_Adminhtml_Sales_Order_ShipmentController->_saveShipment(Object(Mage_Sales_Model_Order_Shipment))
#12 /home/domain/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Sales_Order_ShipmentController->saveAction()
#13 /home/domain/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('save')
#14 /home/domain/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#15 /home/domain/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#16 /home/domain/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#17 /home/domain/public_html/index.php(83): Mage::run('', 'store')
#18 {main}

A: Try this i followed this it's working fine
UPDATE eav_entity_store
INNER JOIN eav_entity_type ON eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
SET eav_entity_store.increment_last_id='XXXXXXXXXX'
WHERE eav_entity_type.entity_type_code='shipment';

This Means
    xxxxxx **Your last Shipment order id **

A: To fix this issue. You need to change your increment_last_id of your shipment entity type.
By default in magento shipment entity type is 8. Which you can find in eav_entity_type table.
You need to change this value for store. The increment_last_id is in eav_entity_store table. You can run following query to update your shipment increment_last_id. Where X is your new increment_last_id and STORE_ID_HERE is your store id to whom you changing shipment increment_last_id.
UPDATE eav_entity_store
       INNER JOIN eav_entity_type
         ON eav_entity_type.entity_type_id = eav_entity_store.entity_type_id
SET    eav_entity_store.increment_last_id = 'X'
WHERE  eav_entity_type.entity_type_code = 'shipment'
       AND eav_entity_store.store_id = {STORE_ID_HERE};

OR
UPDATE `eav_entity_store` SET `increment_last_id` = 'X' WHERE `entity_type_id` = '8';

Notice that the value for increment_last_id already contains the increment_prefix. Use your entity_type increment_prefix
For more details check here : https://www.warpconduit.net/2012/04/18/how-to-change-the-order-increment-id-and-prefix-in-magento/
Hope this helps.

A: INSERT INTO db_name.eav_entity_store (entity_store_id, entity_type_id, store_id, increment_prefix, increment_last_id) VALUES ('{last_id_of_eav_entity_store}', '{entity_type_id_from_eav_entity_type_for_SHIPMENT}', '{store_id}', '1', '{copy_from_admin_sales_shipment_last#}');


text:
Q: Need to execute cordoba.exec synchronously in phonegap I'm modifying an app in Ionic and I need to make a function that returns the remaining storage space in the device. Problem I've is that cordoba.exec executes asynchronous and returns the value after the function that contains it already returned the value. How can I make the process to wait for the result.
var getFreeSpace = function() {
    var value = -1;

    cordova.exec(function(result) {
        value = result;
        console.log("Free Disk Space: " + result);
    }, function(e) {
        console.log("Error getFreeDiskSpace: " + e.error);
    }, "File", "getFreeDiskSpace", []);

    return value;
}

console.log('getFreeSpace',getFreeSpace());

This consoles like this:
getFreeSpace -1
Free Disk Space: 500000

Thanks

A: You can try out this.
var getFreeSpace = function() {
    var value = -1;

    cordova.exec(function(result) {
        value = result;
        console.log("Free Disk Space: " + result);
        setTimeout(getFreeSpace, 0)// this will call after you get the result only.You can set delay if u want.
    }, function(e) {
        console.log("Error getFreeDiskSpace: " + e.error);
    }, "File", "getFreeDiskSpace", []);

    return value;
}

console.log('getFreeSpace',getFreeSpace());


text:
Q: Swift constraint autosize label width This is my code to make UILabel autosize:
        gmatesLabel.topAnchor.constraint(equalTo: homeButton.bottomAnchor, constant: 5).isActive = true
        gmatesLabel.trailingAnchor.constraint(equalTo: gmatesUniversitySeparatorView.leadingAnchor, constant: -20).isActive = true
        gmatesLabel.heightAnchor.constraint(equalToConstant: 40).isActive = true
//        gmatesLabel.widthAnchor.constraint(equalTo: gmatesLabel.widthAnchor, multiplier: 0.5)
        gmatesLabel.setContentCompressionResistancePriority(UILayoutPriorityRequired, for: .horizontal)

Also I've tried this code :
gmatesLabel.widthAnchor.constraint(equalTo: gmatesLabel.widthAnchor, multiplier: 0.5, constant: 150).isActive = true

But the problem the labels always shrinked, what did I missed here ?
Update
I've added the leadingAnchor
gmatesLabel.heightAnchor.constraint(equalToConstant: 40).isActive = true

And this the function to set my label :
fileprivate func setCommonGmatesText(_ count: Int ) {

    let commonGmatesString   =  NSMutableAttributedString(string: "\(count)", attributes: [NSFontAttributeName : Font.boldFont22, NSForegroundColorAttributeName: Color.lightGray])
    commonGmatesString.append(NSAttributedString(string: "\(NSLocalizedString("commonGmates", comment: "How much common gmates we got"))", attributes: [NSFontAttributeName : Font.regularFont14, NSForegroundColorAttributeName: Color.lightGray]))
    gmatesLabel.attributedText = commonGmatesString
    gmatesLabel.sizeToFit()
}

A: You should set a leadingAnchor to your label (greater or equal to 8pt for instance) so that the label doesn't grow bigger that it's superview.
You should also set the lineBreakMode:
yourLabel.lineBreakMode = .byWordWrapping


text:
Q: group_by list of dataframes grouping by wildcarded columns in R A stackoverflow member (Gregor Thomas) helped me, in my previous post, to learn about pivot_longer in order to transform my dataset to do operations on them.
This works great if there is a constant grouping column(s).
However I found that I have many index columns TS_Wafer(n) resulting in many dataframes.
I combined the dataframes into a list and was able to use the lapply function to perform the pivot_longer on the list of dataframes, however I am stuck when trying to perform the group_by operration.
The grouping needs to be grouped such that the n in TS_Wafer(n) matches the Wafer number.
So for example if the dataset is:
TS_Wafer1                           TS_Wafer2               Wafer           value
2022-06-29T03:43:53.767582                                  1           418.274905
2022-06-29T03:43:53.767582                                  1           449.370044
2022-06-29T03:43:53.767582                                  1           412.800065
2022-06-29T03:43:53.767582                                  1           429.350565
                            2022-06-29T02:11:52.485032      2           439.345743
                            2022-06-29T02:11:52.485032      2           415.363545
                            2022-06-29T02:11:52.485032      2           427.456437
                            2022-06-29T02:11:52.485032      2           438.357252

I want to find the max and min where the dataset is grouped with TS_Wafer1 and Wafer=1
Here is the code I have so far:
dflist <- lapply(ls(pattern="df[0-9]+"), function(x) get(x)) # combine dataframes into list
apply_long_func <- function(df) {
    df %>%
        pivot_longer(
                cols= -starts_with("TS"),
                names_pattern = "([0-9]+).*([0-9]+)",
                names_to = c("Wafer", "Radius"),
                values_to = "Temperature"
                ) %>%
                as.data.frame
}
dflong <- lapply(dflist, apply_long_func) #Gives the dataset shown in the example above

#This is where Im not sure
apply_group_func <- function(df){
    df %>%
        group_by(TS,Wafer) %>%
        summarize(
                max=max(value),
                min = min(value),
                .groups = "drop"
                ) %>%
                as.data.frame
}

I would then use the same lapply function for the group_by but how do I specify TS_Wafer(i)?
Should I use a for loop?
Any help would be greatly appreciated


text:
Q: Getting stderr from mbuffer to a variable When mbuffer finishes on the receiving side it prints the time and speed, which I would like to get into $time and $speed.
Trying to implement this answer
#!/bin/bash
exec 3>&1 4>&2 #set up extra file descriptors
error=$( { mbuffer -v 0 -4 -s 128k -m 1G -I 8023 3>&1 4>&2 > /tank3/fs5/tst; } )
exec 3>&- 4>&- # release the extra file descriptors
echo "The message is \"${error}\""

Executing this and in another terminal
echo secret | mbuffer -4 -s 128k -m 1G -O localhost:8023

I get
# ./fff

summary:  0.0 KiByte in  0.1 sec - average of  0.0 KiB/s
The message is ""
secret

where I was hoping to see the summary message between the "".
Question
I assume that the summary message must be printed to STDERR, as I pipe STDOUT to a file, and its content is correct.
Can anyone see what I am doing wrong?

A: try this:
#!/bin/bash
exec 3>&1
error=$({ mbuffer options >&3 ; } 2>&1)
exec 3>&-
echo "The message is \"${error}\"" >&2

This will pipe stdin through mbuffer to stdout, and write the processed stderr to stderr.

A: I think you may have tried to apply the wrong solution. The one you referenced dealt with a somewhat more complicated problem. If your goal is to direct stdout to a file and capture stderr, this should do it (yes, it's counterintuitive to map stderr to stdout THEN stdout to a file, but that's how redirection works, you're sending stream 2 to where stream 1 points to at that moment, which is stdout)
error=$(mbuffer -v 0 -4 -s 128k -m 1G -I 8023 2>&1 > /tank3/fs5/tst)
echo "The message is \"${error}\""


text:
Q: Copy cell data from MS Word table to Excel based on value of cell I have a rather large Word questionnaire. It has several similar irregular (meaning some rows have merged cells and some do not) tables in it. I need to read each table for 3 specific values and take the response in the next cell and move it to a new excel spreadsheet so I can import that data into Access.
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
objWord.DisplayAlerts = False
objWord.Documents.Open "C:\Users\TheRev\Desktop\AllObj.docx", False, True
Set objDoc = objWord.ActiveDocument

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False
objExcel.Workbooks.Add
Set objSheet = objExcel.ActiveSheet

dstRow = 0
For Each tbl In objDoc.Tables
    For srcRow = 1 To tbl.Rows.Count
        col = 0
        For Each cell In tbl.Rows(srcRow).Cells
            If cell = "Family number" then
            wscript.echo "Found it"
        Else
        col = col + 1
                objSheet.Cells(dstRow+srcRow, col).Value = Left(cell.Range.Text, Len(cell.Range.Text)-1)
        End If
        Next
    Next
    dstRow = dstRow + SrcRow
Next
objExcel.ActiveWorkbook.SaveAs "C:\Users\TheRev\Desktop\SurveyResults.xlsx"
objExcel.Quit

Transforms all of my tables into the excel workbook. Not what I need.
What I need to do:
If the cell value is "Objective number", copy the next cell over's data (3.9.1) into the Excel spreadsheet's column A, then the data from 2 cells down (Technologies go here) into Excel's column B, and then the next cell down (Questions go here) into Excel Column C. Repeat until the end of the Word doc.
How would I do that?

Screenshot of complete questionnaire
Test file for download. Right Click Save As.


text:
Q: Im trying to add two foreign keys on the same table and it doesn't work I have noticed that when I use I on a column the problems go away but when i click on go, the only errors that comes is a "Cannot add foreign key constraint" message.
error messages :

A: It appears that you you have misspelled LOCATION in the first statement.

A: You have misspelled Location once and both of your foreign keys are referencing the same primary key.


text:
Q: How to get particular part of string in java? I want to get the particular part of String from a complete word.
For example:
I have the following String.
# STRING_VALUES #

and a sentence is as follows

# STRING_VALUE #
# CMESSAGE #
# CUSTOMERADDRESS #

From the above, I want to get the string as follows:
STRING_VALUES
CMESSAGE
CUSTOMERADDRESS

How to do to get the above string? I am stuck with this.

A: Use split:
String ss ="# STRING_VALUES #";
String[] parts = ss.split("#");
System.out.println(parts[1].trim()); // STRING_VALUES

DEMO.

A: For your specific case following code will work:
String str = "# STRING_VALUES #";
String result = str.substring(2,str.length()-2);

UPDATE: (Following code will work for you modified input string)
String str = "
# STRING_VALUE #
# CMESSAGE #
# CUSTOMERADDRESS #

";

String[] tokens = str.substring(3, str.length()-4).split("
");
// tokens will contain [0] = "# STRING_VALUE #"
//                     [1] = "# CMESSAGE #"
//                     [2] = "# CUSTOMERADDRESS #"
//                     [3] = ""

ArrayList<String> results = new ArrayList<String>();

for(String  token : tokens)
{
    if(token.length() != 0)
    {
        results.add(token.substring(2,str.length()-2));
    }
}

// results has required strings
for(String  result : results)
{
    System.out.println(result);
}

A: You could do that with regular expressions. See the classes Pattern and Matcher. The regular expression to find the STRING_VALUE string in your example would be:
#\s(\w*)\s#

This would return a chain of word-characters (letters, numbers and underscores) after "#" and a whitespace and before a whitespace and "#". The chain of word characters would be returned as a sub-match you can extract separately.
Alternatively, you could use String.indexOf to search for the positions of delimeters in your string and String.substring to extract parts between the delimeter position you found.

A: Look at http://docs.oracle.com/javase/6/docs/api/java/lang/String.html
They will tell you:
Here are some more examples of how strings can be used:
     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);

A: You use the String[] split(String regex) method of the String class as documented here.

A: If your string  would be of this format i.e., space seperated you could use String.split()
String ss ="# STRING_VALUES #";
    System.out.println(ss.split("\\s")[1]);

the above code return STRING_VALUES as output

A: You could use substring:
http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#substring(int, int)
Or you could use regex:
Need regexp to find substring between two tokens


text:
Q: How to prove this inequality about primes? Let $p_n$ be the $n$-th prime. How to prove
$$2\prod_{i=2}^{n}\binom{p_i}{2}<\left(\frac{\prod_\limits{i=1}^{n}p_i}{\prod_\limits{i=1}^{n}p_i-\prod_\limits{i=2}^{n}(p_i-2)}\right)^{p_n^2}$$
for large n.

A: (this is not an answer yet)
Taking the logarithm :
$$\ln 2\prod_{i=1}^n {p_i \choose 2}= -(n-1)\ln 2+\sum_{i=1}^n \ln p_i+\ln (p_i-1)$$
$$=(1-n)\ln 2+2\sum_{i=1}^n \ln p_i+\sum_{i=1}^n \ln(1-\frac{1}{p_i})$$
$$\sim
(1-n)\ln 2+2\sum_{i=1}^n \ln p_i-\sum_{i=1}^n \frac{1}{p_i}\sim (1-n)\ln 2+ 2p_n- \ln \ln p_n$$
where I used that $\sum_{p < x} \ln p \sim x$ and $\sum_{p < x} \frac{1}{p} \sim \ln \ln x$ that is the prime number theorem and the Mertens theorem
what do you get following the same lines for the RHS ?


text:
Q: How do i write an applescript application from terminal? I want to write an applescript application from terminal. So far I have been able to write an .scpt file but that is not enough. I need to convert it to an applescript application that can then be opened and run. I know how to do this using the GUI but for various reasons I need to do it from terminal. Any ideas on any way to do this?

A: To make apple scripts executable from terminal, you may define osascript in shebang, for example:
#!/usr/bin/env osascript
say "Hello World!"

Make it executable, and just run it:
./AppleScriptTest.applescript


text:
Q: Linear dependence of three functions: $f(x) = \sin(x)$, $g(x) = \cos(x)$ and $h(x)=x$
Let $\mathbb{R}^\mathbb{R} $ be a vector-space of functions $f:\mathbb{R}→\mathbb{R}$.
  The following functions in the vector space are defined as follows:
  $$f(x) = \sin(x),\qquad g(x) = \cos(x),\qquad h(x) = x.$$
  Is the triple $(f,g,h)$ linearly dependent?

I have a feeling it is, because $h(x)$ is the identity function, so $h(\sin(x)) = \sin(x)$, and I know the definitions, I can't figure out how to put my explanation (if it is correct) properly.
Thanks in advance.

A: Your feeling is not correct. Recall that, by definition, if such functions are linearly dependent then there are real numbers $A,B,C$ not all zero such that
$$A\sin(x)+B\cos(x)+Cx=0 \quad \forall x\in \mathbb{R}.$$
Now by letting $x=0,\pi/2,\pi$, we have three linear equations
$$\begin{cases}
A\cdot 0+B\cdot 1+C\cdot 0=0\qquad &(x=0)\\
A\cdot 1+B\cdot 0+C\cdot \frac{\pi}{2}=0\qquad &(x=\frac{\pi}{2})\\
A\cdot 0+B\cdot (-1)+C\cdot \pi=0\qquad &(x=\pi)\\
\end{cases}$$
What may we conclude about $A,B,C$? Can you take it from here?

A: Asserting that $\{f,g,h\}$ is linearly independent means that$$(\forall a,b,c\in\mathbb{R}):af+bg+ch=0\implies a=b=c=0.$$If $af+bg+ch=0$, then $af(0)+bg(0)+ch(0)=0$, which means that $b=0$. You still have $af+ch=0$. But then $af\left(\frac\pi2\right)+c\frac\pi2=0$, which means that $a+c\frac\pi2=0$, and $af(\pi)+ch(\pi)=0$, which means that $c\pi=0$. So, $a=c=0$ too.


text:
Q: configure dnsmasq to give out addresses in different ranges I'd like to give unknown clients an ip address in one range and known clients in another (that is a static one).
I tried quite a lot now and don't seem to get it working. All I get is an "no address available" error.
My network is 10.1.0.0/22 (<-!!!)
Guests should be assigned an address in the range 10.1.3.1-10.1.3.254
Static addresses are in range 10.1.2.1-10.1.2.254
so this is my config:
iface eth0 inet static
    address 10.1.0.2/22
    gateway 10.1.0.1

eth0@if17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.1.0.2/22 brd 10.1.3.255 scope global eth0
        valid_lft forever preferred_lft forever

and
dhcp-range=tag:guests,10.1.3.1,10.1.3.254,255.255.252.0,12h
dhcp-range=tag:known,10.1.2.0,static,24h
dhcp-option=option:router,10.1.0.1
dhcp-option=option:dns-server,10.1.0.3
dhcp-option=option:ntp-server,10.1.0.1

dhcp-host=aa:bb:cc:dd:ee:ff,10.1.2.1
dhcp-host=11:22:33:44:55:66,10.1.3.2

Known hosts are given their addresses (regardless if its a .2. or .3. address) but unknown dont get anything.

A: You're not giving a netmask for the tag:known range, so dnsmasq will assume it's the entire /22, completely covering the tag:guests range.

A: Seems the problematic part was: tag:known. For some reason dnsmasq doesn't show something different in startup log messages when I remove it but now seems to work. (I cant tell if it works with /22 because I stoped using it.)

A: To use a tag, it needs to be set somewhere. I do this for requests relayed from another subnet:
dhcp-range=set:wifi,192.168.4.0,static,255.255.255.0,24h
dhcp-option=tag:wifi,option:router,192.168.4.1

In the OP's case the dhcp-host entry would be the place to set the known tag, like this:
dhcp-host=aa:bb:cc:dd:ee:ff,10.1.2.1,set:known

However (from the dnsmasq manpage): When a host matches any --dhcp-host directive (or one implied by /etc/ethers) then the special tag "known" is set.
So that set:known is implicit. Using ! to negate that tag, we can apply a different range to 'unknown' hosts:
dhcp-range=tag:!known,10.1.3.1,10.1.3.254,255.255.252.0,12h
dhcp-range=tag:known,10.1.2.0,static,255.255.252.0,24h
dhcp-option=option:router,10.1.0.1
dhcp-option=option:dns-server,10.1.0.3
dhcp-option=option:ntp-server,10.1.0.1

dhcp-host=aa:bb:cc:dd:ee:ff,10.1.2.1
dhcp-host=11:22:33:44:55:66,10.1.3.2


text:
Q: How do I use Xamarin.Android to open a certain file type with my app? I'm working on an app and I want to open my own custom file type (.bzk) with my app. The way I create it is described here. I am using Xamarin.Forms to create this app and I am stuck right now. I have found this Github Gist which should help but I have no idea how it works. I can't really find a lot of documentation about it, either.
I want my app to appear in this list.
Does anyone have any samples or some other information which could help me out with this problem?


text:
Q: Show Customer's Birthday Reminder in Popup to Admin I have a custom input field where customer is asked to add his/her birth date. That data will be saved along with customer account information.
What I need to develop is, to show admin a popup when he logs in backend. That popup will show list of customer(s) having birthday's. The Birthday list will be based on following criteria

*

*If a customer has birthday today or in next 4 days.

For example if current date is 30th July it will show like:
Birthday(s) Today:
Customr 1, Customer 2

1st July:
Customer 3

2nd July:
Customer 4

I am not able to figure out,

*

*How to list birthdays of customers and show in popup when admin logs
in backend

*Do not show the birthday notification popup if admin explicitly
closes it.

This is for boosting the sales of our store. The customers having birthday will be given a special promo code.
Thanks

A: I would look for an usable event to hook into: admin_session_user_login_success.
In the observer you simply call a collection of customers and add the birthdate attribute to filter with the appropriate parameters to reduce the collection to those who you need displayed. Something like
$customer_collection()->addAttributeToFilter('birth_date', array('gteq' => $today, 'lteq' => $today_plus_4days))

On how to utilize a popup, this Inchoo blog article might be a good place to start looking.
p.s. Again, lacking reputation to make this a comment it turned out as answer.
Edit (explicitely closing the popup, too long for comment):
I am not completely sure what you are asking. If you want to automatically close the popup after certain time passes this surely is easier to simply hard code. OR if you want the admin to be able to configure that time, create a field in the system->configuration. That is a convenient place for such kind of configurations as all it needs to add fields is some xml. The Magento Wiki - XML for admin configuration covers most of that.
If you want Magento to remember whether or not a user has closed a popup to remind him in later sessions, you need your user model to save a date. Either when the popup was closed, or when the next popup shall appear. You can either add an attribute in the User model like I suggested in comment, or you create your own table, whatever suits you more. You just need a date to check whether or not to fire your popup from the observer.


text:
Q: How can i import the pico pi into python3 and execute micropython code safed on the pico from python3? Ive got a Pico PI and i want to program a GUI for it.
Since micropython doesnt support any GUI's like tkinter I was wondering if there is a way to Call and execute programms saved on the pico from python3.
thanks for your help in advance.


text:
Q: Sort 2 unsorted arrays in a single sorted array in c++ Sort 2 unsorted arrays in one sorted array for best time complexity of O(n+m) in c++ language. How can we modify this code to make it for O(m+n) time complexity? The 2 array sizes should be different. Here the time complexity is O((m+n)log(m+n)). How to make it O(m+n) complexity?
#include <bits/stdc++.h>
using namespace std;

// Function to merge array in sorted order
void sortedMerge(int a[], int b[], int res[],
                                int n, int m)
{
    // Concatenate two arrays
    int i = 0, j = 0, k = 0;
    while (i < n) {
        res[k] = a[i];
        i += 1;
        k += 1;
    }
    while (j < m) {
        res[k] = b[j];
        j += 1;
        k += 1;
    }

    // sorting the res array
    sort(res, res + n + m);
}

// Driver code
int main()
{
    int a[] = { 10, 5, 15 };
    int b[] = { 20, 3, 2, 12 };
    int n = sizeof(a) / sizeof(a[0]);
    int m = sizeof(b) / sizeof(b[0]);

    // Final merge list
    int res[n + m];
    sortedMerge(a, b, res, n, m);

    cout << "Sorted merged list :";
    for (int i = 0; i < n + m; i++)
        cout << " " << res[i];
    cout << "n";

    return 0;
}

A: Looking at your problem I think you forgot one little detail: is your arrays always guaranteed to contain postive integers?? If so, use a third array and store the two arrays values inside it. Then use radix sort to sort it, or if you know the range, use counting sort. I attached the link instead of explaining since explaining such complex sorting algorithms here would take way to long.
Counting sort: https://www.geeksforgeeks.org/counting-sort/#:~:text=Counting%20Sort,object%20in%20the%20output%20sequence.
Radix Sort: https://www.geeksforgeeks.org/radix-sort/


text:
Q: Can't import saved logins in Firefox Quantum I installed FF Quantum (58.0b4) and imported a previous backup created with Mozbackup.
Bookmarks and history were imported correctly while passwords and saved logins were not.
I copied key3.db and logins.json containing passwords from my laptop and pasted them in my PC with the new FF Quantum, but this didn't solved.
How can I import saved passwords?
Thanks

A: Well, I forgot to write that I installed the developer version. As the classic Firefox seems to have the same functions the developer edition has, I uninstalled the dev edition and went back to classic. In this way I solved the problem.

A: Sync the passwords to a Firefox account using the old version.
Then sync them into a new profile within the new version of Firefox Quantum.
It worked for me using v53.0 b4 (regular) to v58.0 b4 (developer edition).
Firefox account / Sync can be found under "Menu/Tools > Options > etc..."

A: For those of us who cringe at the thought of syncing passwords online:

*

*Update the source Firefox to the latest version

*Install the target Firefox, enable password storage with same master password as the source Firefox then close Firefox

*Copy and overwrite these files: cert8.db, cert9.db, key3.db, key4.db, secmod.db, handlers.json, logins.json

*Start Firefox and check saved logins


text:
Q: How to remove the Added widget within that widget? how can I remove the added widget from within that widget. am i making any sense? hopefully yes, hehehe...
anyway the simple code consist of buttons and label only.
My aim is if I click the add button it will show the widget which is a label & button. If i want to remove the widget i'll just click the close button in that widget.
but its not closing, its been two days already and i cant find whats the problem and its not giving me any error.
Thanks guys.
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.widget import Widget
from kivy.app import App
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder

kv_file = Builder.load_string('''
<Screen1>:
    BoxLayout:
        Button:
            on_release: root.add_button(True)
            text: 'ADD'
            size_hint: .2,.2

<Layout1>:
    BoxLayout:
        pos: self.x,300
        size_hint: .5,.3
        Label:
            text: 'THIS IS A ADDED WIDGET'
        Button:
            text: 'Close'
            on_release: root.closeBTN()
    ''')

class Layout1(FloatLayout):
    def closeBTN(self):
        AddWidget_Layout1().addEmps(True)

class AddWidget_Layout1(Widget):
    def __init__(self, **kwargs):
        super(AddWidget_Layout1,self).__init__(**kwargs)
        self.count = 0
        self.layout1 = Layout1()

    def addEmps(self,xadd):
        if xadd == 1:
            self.add_widget(self.layout1)
        elif xadd == True:
            self.remove_widget(self.layout1)

class Screen1(Screen,AddWidget_Layout1):
    def add_button(self,*args):
        self.count += 1
        print
        if self.count == 1:
            self.addEmps(1)

class projectApps(App):
    def build(self):
        return SM

SM = ScreenManager()
SM.add_widget(Screen1())

if __name__ == "__main__":
    projectApps().run()

A: You have a few bugs in your code, first, you are testing xadd for 1 and True which is kinda the same thing:
def addEmps(self,xadd):
    if xadd:
        self.add_widget(self.layout1)
    else: #was elif xadd == True which cannot happen...
        self.remove_widget(self.layout1)

I would also change:
def closeBTN(self):
    #AddWidget_Layout1().addEmps(True) #BAD! will create a new instance
    self.parent.addEmps(False) # this looks better

Finally, I'm not sure why are you doing this since you are already using ScreenManager, so you can just switch to a different screen whenever you need instead of doing this weird widget removal thing ...
I hope this clears most of the issues


text:
Q: How to include files that changed but have the same version number into MSP using WiX Pyro? I created an MSP patch file using WiX Pyro(using purely WiX toolset). But it seems that created MSP file doesn't include files changed in content but not changed in version number. As I think, most of those files are not actually changed in main content but just rebuilt by Visual Studio. So, it may be desirable behavior that Pyro does.
But my customer asked me why files installed by the latest MSI and files updated by MSP patch are different. So, I want to know there is any way to include those files into MSP patch, or can I tell my customer that those two file sets(the latest MSI, old MSI + MSP) are the same so you can use the product safely? (Of course, I think my file version management is pretty poor and not systematic, but MSI's version rules feel too strict and somewhat inflexible to me.)

A: The Windows Installer file update rules are what they are, and I don't think you're going to get them changed. The standard rule is that you tell Windows the file is updated by incrementing the version, and then at install time a higher version will replace a lower version. That's the reason tools that generate patches also use the version rule - why should they include files that haven't got a higher version? Service packs, patches, hotfixes etc all work based on file versions.
If you want to use whatever file versions you like, then stop using patches and do a major upgrade that does a RemoveExistingProducts early so you get the equivalent of an uninstall of all the old files followed by an install of all the new ones.
By the way, if these are managed code files and you believe that incremnting the file version means incrementing the assemblyversion, then use AssemblyFileVersion to increment the file version and leave assembly version alone.


text:
Q: Which of the following are vector subspaces of $\mathbb{R}^2$? Which of the following are vector subspaces of $\mathbb{R}^2$?

*

*$W = \left\{ \begin{pmatrix} x \\ y \end{pmatrix}\, \middle|\, x \ge 0\right\}$

*$W = \left\{ \begin{pmatrix} x \\ y \end{pmatrix}\, \middle|\, x \ge 0, y \ge 0\right\}$

*$W = \left\{ \begin{pmatrix} x \\ y \end{pmatrix}\, \middle|\, x = 0\right\}$
I know that $W$ is a subspace of a vector space $V$ if $W$ is a vector space under the operations of addition and scalar multiplication defined in $V$. So what do I do? In each example shall I choose two matrices for example in each one that are in $W$ and check if their sum is in $\mathbb{R}^2$? And take a particular scalar and prove that scalar multiplication is also in $\mathbb{R}^2$? But what exactly is $\mathbb{R}^2$? I read in the book that is the set of all ordered pairs. How exactly does that work with matrices?
Explain each one please!
Thanks for the help!

A: The first two are not vector subspaces. Consider the vector $(1,1)$. It is contained in each of the two sets, but its additive inverse is not, so neither set is a subspace. The third set is a subspace. Given two vectors in $W$, they are of the form $(0,y_1)$, $(0,y_2)$ and their sum is $(0,y_1 + y_2)$ which is again in $W$, and given any scalar $r$ it follows that $r(0,y_1) = (0,ry_1)$ is again in $W$. Therefore $W$ is closed under addition and scalar multiplication, so it is a vector subspace.


text:
Q: How to make a menu stay in specific location. (Beginner) I am making a website for my family and I am stuck on how to make the menu stay at a specific place. I want it under the picture so it looks better. Also when I am resizing the browser the menu appears in a different place and the picture resizes also, I don't know how to fix that. Here is my code so far.
<!DOCTYPE html>

    <title>King Buffet</title>
    <link rel="stylesheet" type="text/css" href="main.css"/>

Menu

Map

Contact

Order Now

body {
background: #db2811;
margin: 0 auto;
padding: 2em 2em 4em;
max-width: 500px;
box-shadow: 0 0 2px rgba(0,0)
}

img {
width: 50%;
height: auto;
position: fixed;
top: 15%;
left: 25%;
}

ul {
color: #fff200;
font-size: 20px;
font-weight: 600;
display: inline-block;

}

A: Try this code

body {
background: #db2811;
margin: 0 auto;
padding: 2em 2em 4em;
max-width: 500px;
box-shadow: 0 0 2px rgba(0,0)
}

img {
  width: 100%;
}

div.wrapper {
  width: 50%;
 height: auto;
 position: fixed;
 top: 15%;
 left: 25%;
}
ul {
  display: block;
  position: absolute;
  bottom: 0;
}

ul li {
color: #fff200;
font-size: 20px;
font-weight: 600;
display: inline-block;
list-style: none;
}

Menu

Map

Contact

Order Now