text:
Q: Parse Error: Adjacent JSX elements must be wrapped in an enclosing tag I am trying to set up my React.js app so that it only renders if a variable I have set is true.
The way my render function is set up looks like:
render: function() {
    var text = this.state.submitted ? 'Thank you!  Expect a follow up at '+email+' soon!' : 'Enter your email to request early access:';
    var style = this.state.submitted ? {"backgroundColor": "rgba(26, 188, 156, 0.4)"} : {};
    return (

if(this.state.submitted==false)
{

      <input type="email" className="input_field" onChange={this._updateInputValue} ref="email" value={this.state.email} />

      <ReactCSSTransitionGroup transitionName="example" transitionAppear={true}>

         Request Invite

     </ReactCSSTransitionGroup>
}

    )
  },

Basically, the important portion here is the if(this.state.submitted==false) portion (I want these div elements to show up when the submitted variable is set to false).
But when running this, I get the error in the question:

Uncaught Error: Parse Error: Line 38: Adjacent JSX elements must be wrapped in an enclosing tag

What is the issue here?  And what can I use to make this work?

A: You should put your component between an enclosing tag, Which means:
// WRONG!

return (
    <Comp1 />
    <Comp2 />
)

Instead:
// Correct

return (

       <Comp1 />
       <Comp2 />

)

Edit: Per Joe Clay's comment about the Fragments API
// More Correct

return (
    <React.Fragment>
       <Comp1 />
       <Comp2 />
    </React.Fragment>
)

// Short syntax

return (
    <>
       <Comp1 />
       <Comp2 />
    </>
)

A: If you do not wrap your component then you can write it as mentioned below method.
Instead of:
return(
  <Comp1 />
  <Comp2 />
     );

you can write this:
return[(
 <Comp1 />
),
(
<Comp2 />
) ];

A: it's very simple we can use a parent element div to wrap all the element
or we can use the Higher Order Component( HOC's ) concept i.e very useful for
react js applications
render() {
  return (

foo

bar

  );
}

or another best way is HOC its very simple not very complicated
just add a file hoc.js in your project and simply add these codes
const aux = (props) => props.children;
export default aux;

now import hoc.js file where you want to use, now instead of wrapping with div
element we can wrap with hoc.
import React, { Component } from 'react';
import Hoc from '../../../hoc';

    render() {
      return (
    <Hoc>

foo

bar

    </Hoc>
      );
    }

A: The problem

Parse Error: Adjacent JSX elements must be wrapped in an enclosing tag

This means that you are trying to return multiple sibling JSX elements in an incorrect manner. Remember that you are not writing HTML, but JSX! Your code is transpiled from JSX into JavaScript. For example:
render() {
  return (
foo bar
);
}

will be transpiled into:
render() {
  return React.createElement("p", null, "foo bar");
}

Unless you are new to programming in general, you already know that functions/methods (of any language) take any number of parameters but always only return one value. Given that, you can probably see that a problem arises when trying to return multiple sibling components based on how createElement() works; it only takes parameters for one element and returns that. Hence we cannot return multiple elements from one function call.

So if you've ever wondered why this works...
render() {
  return (

foo

bar

baz

  );
}

but not this...
render() {
  return (

foo

bar

baz

  );
}

it's because in the first snippet, both
-elements are part of children of the
-element. When they are part of children then we can express an unlimited number of sibling elements. Take a look how this would transpile:
render() {
  return React.createElement(
    "div",
    null,
    React.createElement("p", null, "foo"),
    React.createElement("p", null, "bar"),
    React.createElement("p", null, "baz"),
  );
}

Solutions
Depending on which version of React you are running, you do have a few options to address this:

*

*Use fragments (React v16.2+ only!)
As of React v16.2, React has support for Fragments which is a node-less component that returns its children directly.
Returning the children in an array (see below) has some drawbacks:

*

*Children in an array must be separated by commas.

*Children in an array must have a key to prevent React's key warning.

*Strings must be wrapped in quotes.

These are eliminated from the use of fragments. Here's an example of children wrapped in a fragment:
render() {
  return (
    <>
      <ChildA />
      <ChildB />
      <ChildC />
    </>
  );
}

which de-sugars into:
render() {
  return (
    <React.Fragment>
      <ChildA />
      <ChildB />
      <ChildC />
    </React.Fragment>
  );
}

Note that the first snippet requires Babel v7.0 or above.

*Return an array (React v16.0+ only!)
As of React v16, React Components can return arrays. This is unlike earlier versions of React where you were forced to wrap all sibling components in a parent component.
In other words, you can now do:
render() {
  return [
foo
,
bar
];
}

this transpiles into:
return [React.createElement("p", {key: 0}, "foo"), React.createElement("p", {key: 1}, "bar")];

Note that the above returns an array. Arrays are valid React Elements since React version 16 and later. For earlier versions of React, arrays are not valid return objects!
Also note that the following is invalid (you must return an array):
render() {
  return (
foo

bar
);
}

*Wrap the elements in a parent element
The other solution involves creating a parent component which wraps the sibling components in its children. This is by far the most common way to address this issue, and works in all versions of React.
render() {
  return (

foo

bar

  );
}

Note: Take a look again at the top of this answer for more details and how this transpiles.

A: There is a rule in react that a JSX expression must have exactly one outermost element.
wrong
const para = (

);

correct
const para = (

);

A: It is late to answer this question but I thought It will add to the explanation.
It is happening because any where in your code you are returning two elements simultaneously.
e.g
return(

  )

It should be wrapped in a parent element. e.g
 return(

      )

More Detailed Explanation
Your below jsx code get transformed
class App extends React.Component {
  render(){
    return (

Welcome to React

    );
  }
}

into this
_createClass(App, [{
    key: 'render',
    value: function render() {
      return React.createElement(
        'div',
        null,
        React.createElement(
          'h1',
          null,
          'Welcome to React'
        )
      );
    }
  }]);

But if you do this
class App extends React.Component {
  render(){
    return (

Welcome to React

Hi

    );
  }
}

this gets converted into this (Just for illustration purpose, actually you will get error : Adjacent JSX elements must be wrapped in an enclosing tag)
_createClass(App, [{
    key: 'render',
    value: function render() {
      return React.createElement(
        'div',
        null,
       'Hi'
      );
    return React.createElement(
          'h1',
          null,
          'Welcome to React'
        )
    }
  }]);

In the above code you can see that you are trying to return twice from a method call, which is obviously wrong.
Edit- Latest changes in React 16 and own-wards:
If you do not want to add extra div to wrap around and want to return more than one child components you can go with React.Fragments.
React.Fragments (<React.Fragments>)are little bit faster and has less memory usage (no need to create an extra DOM node, less cluttered DOM tree).
e.g (In React 16.2.0)
render() {
  return (
    <>
       React fragments.

A heading

      More React fragments.

Another heading

      Even more React fragments.
    </>
  );
}

or
render() {
  return (
    <React.Fragments>
       React fragments.

A heading

      More React fragments.

Another heading

      Even more React fragments.
    </React.Fragments>
  );
}

or
render() {
 return [
  "Some text.",

A heading
,
  "More text.",

Another heading
,
  "Even more text."
 ];
}

A: React 16.0.0 we can return multiple components from render as an array.
return ([
    <Comp1 />,
    <Comp2 />
]);

React 16.2.0 > we can return multiple components from render in a Fragment tag. Fragment
return (
<React.Fragment>
    <Comp1 />
    <Comp2 />
</React.Fragment>);

React 16.2.0 > you can use this shorthand syntax. (some older tooling versions don't support it so you might want to explicitly write <Fragment> until the tooling catches up.)
return (
<>
    <Comp1 />
    <Comp2 />
</>)

A: React element has to return only one element. You'll have to wrap both of your tags with another element tag.
I can also see that your render function is not returning anything. This is how your component should look like:
var app = React.createClass({
    render () {
        /*React element can only return one element*/
        return (

        )
    }
})

Also note that you can't use if statements inside of a returned element:
render: function() {
var text = this.state.submitted ? 'Thank you!  Expect a follow up at '+email+' soon!' : 'Enter your email to request early access:';
var style = this.state.submitted ? {"backgroundColor": "rgba(26, 188, 156, 0.4)"} : {};
    if(this.state.submitted==false) {
        return <YourJSX />
    } else {
        return <YourOtherJSX />
    }
},

A: If you don't want to wrap it in another div as other answers have suggested, you can also wrap it in an array and it will work.
// Wrong!
return (
   <Comp1 />
   <Comp2 />
)

It can be written as:
// Correct!
return (
    [<Comp1 />,
    <Comp2 />]
)

Please note that the above will generate a warning: Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of 'YourComponent'.
This can be fixed by adding a key attribute to the components, if manually adding these add it like:
return (
    [<Comp1 key="0" />,
    <Comp2 key="1" />]
)

Here is some more information on keys:Composition vs Inheritance

A: React 16 gets your return as an array so it should be wrapped by one element like div.
Wrong Approach
render(){
    return(
    <input type="text" value="" onChange={this.handleChange} />

     <button className="btn btn-primary" onClick=   {()=>this.addTodo(this.state.value)}>Submit</button>

    );
}

Right Approach (All elements in one div or other element you are using)
render(){
    return(

            <input type="text" value="" onChange={this.handleChange} />

            <button className="btn btn-primary" onClick={()=>this.addTodo(this.state.value)}>Submit</button>

    );
}

A: React components must wrapperd in single container,that may be any tag
e.g. "
..
"
You can check render method of ReactCSSTransitionGroup

A: Import view and wrap in View. Wrapping in a div did not work for me.
import { View } from 'react-native';
...
    render() {
      return (
        <View>

foo

bar

        </View>
      );
    }

A: Invalid: Not only child elements
render(){
        return(

Responsive Form

Adjacent JSX elements must be wrapped in an enclosing tag

                <form id="contact-form" onSubmit={this.handleSubmit.bind(this)} method="POST">

                        Name
                        <input type="text" className="form-control" id="name" />

                        Email address
                        <input type="email" className="form-control" id="email" aria-describedby="emailHelp" />

                        Message
                        <textarea className="form-control" rows="5" id="message"></textarea>

                    <button type="submit" className="btn btn-primary">Submit</button>
                </form>

        )
    }

Valid: Root element under child elements
render(){
        return(

Responsive Form

Adjacent JSX elements must be wrapped in an enclosing tag

                <form id="contact-form" onSubmit={this.handleSubmit.bind(this)} method="POST">

                        Name
                        <input type="text" className="form-control" id="name" />

                        Email address
                        <input type="email" className="form-control" id="email" aria-describedby="emailHelp" />

                        Message
                        <textarea className="form-control" rows="5" id="message"></textarea>

                    <button type="submit" className="btn btn-primary">Submit</button>
                </form>

        )
    }

A: Just add
<>
  // code ....
</>

A: For Rect-Native developers. I encounter this error while renderingItem in FlatList. I had two Text components. I was using them like below
renderItem = { ({item}) =>
     <Text style = {styles.item}>{item.key}</Text>
     <Text style = {styles.item}>{item.user}</Text>
}

But after I put these tow Inside View Components it worked for me.
renderItem = { ({item}) =>
   <View style={styles.flatview}>
      <Text style = {styles.item}>{item.key}</Text>
      <Text style = {styles.item}>{item.user}</Text>
   </View>
 }

You might be using other components but putting them into View may be worked for you.

A: I think the complication may also occur when trying to nest multiple Divs within the return statement. You may wish to do this to ensure your components render as block elements.
Here's an example of correctly rendering a couple of components, using multiple divs.
return (

Data Information

      <Button type="primary">Create Data</Button>

)


text:
Q: Using a Variable Number of WHERE Clauses to Match an Arbitrary Number of Keywords pysqlite I'm using pysqlite to build and search through a database of keywords + sets of URLs which correspond to each keyword. My strategy for searching the database works fine with 1 keyword, since it only requires 1 WHERE clause in the SQL statement. Something like:
  ... WHERE lexicon.word=?", keyword)

However, I would like to match an arbitrary number of keywords to my database, which I believe would be equivalent to having several WHERE clauses with OR statements between them. Since I don't know how many keywords I'll be given, I can't assume a particular number of WHERE clauses and fill them in using the API's replacement ability.
I believe I could use Python's string insertion operation to mangle the WHERE statement with an OR statement for each keyword I find. I'm pretty sure this is quite hacky though, as it could lead to injection attack vulnerability.
I've also considered using the .executemany() function but it would run many separate selects instead of one which encompasses all WHERE clauses needed.
Is there a better way to do it than the method I mentioned with string replacement? I'm very new to SQL so please bear with me and my ignorance. Thanks.

A: An SQL query can have only a single WHERE clause, but you could concatenate multiple comparions with OR, or just use a single IN expression:
db.execute("SELECT ... WHERE lexicon.word IN (?,?,?)",
           ['Hello', 'world', 'meow'])

To construct such a statement, you need just a little bit of string handling:
keywords = ['Hello', 'world', 'meow']
sql = "SELECT ... WHERE lexicon.word IN (" + ",".join(["?"] * len(keywords)) + ")"
db.execute(sql, keywords)

redpajama_set_name: RedPajamaStackExchange


text: Q: откуда $_POST и $_GET в php читают входные данные? Я пишу свой небольшй HTTP-сервер на с++. В нем мне нужно обрабатывать динамические запросы. Я открываю дочерний процесс, запускаю в нем скрипт и отдаю std::out(которым является html текст) отработавшего скрипта клиенту. Вопрос состоит в том, как мне передать входные данные в этот скрипт? В моем случае входными данными является get или post зопросы, из которых php-скрипт по средствам $_POST и $_GET может брать информацию о переменных. Я пытался сделать это, положив запросы в std::in, но у меня ничего не вышло, методы  $_POST и $_GET не видят запрос.


text:
Q: How to copy images in assets to application document directory in Flutter? My flutter app has the following assets.
assets:
 - "images/01.png"
 - "images/02.png"
 - "images/03.png"
 ...

I'd like to copy these image files to the local path I can get by the following.
 Directory docDir = await getApplicattionDocumentsDirectory();
 String localPath = docDir.path;

A: Create a file in your application directory and copy your asset image byte by byte to that file. That's it! You copied your file.
final Directory docDir = await getApplicationDocumentsDirectory();
final String localPath = docDir.path;
File file = File('$localPath/${path.split('/').last}');
final imageBytes = await rootBundle.load(path);
final buffer = imageBytes.buffer;
await file.writeAsBytes(
    buffer.asUint8List(imageBytes.offsetInBytes, imageBytes.lengthInBytes));

A: getApplicationDocumentsDirectory you need path_provider package.
Suppose you want to copy an m4a file to your application document directory
pubspec.yaml
 assets:
    - assets/audio/no_sound_3n.m4a

Your code
import 'package:path_provider/path_provider.dart';

final Directory docDir = await getApplicationDocumentsDirectory();
final String localPath = docDir.path;
File file = File(localPath);
final asset = await rootBundle.load("assets/audio/no_sound_3n.m4a");
final buffer = asset.buffer;
await file.writeAsBytes(
    buffer.asUint8List(asset.offsetInBytes, asset.lengthInBytes));

You asset folder

A: I too couldn't find a way yet. A way to mitigate this is following the assets guide, by specifying
flutter:
  assets:
    - assets/

And load arbitrary files via rootBundle
import 'dart:async' show Future;
import 'package:flutter/services.dart' show rootBundle;

Future<String> loadAsset() async {
  return await rootBundle.loadString('assets/index.html');
}

or in your case using AssetImage
Widget build(BuildContext context) {
  // ...
  return DecoratedBox(
    decoration: BoxDecoration(
      image: DecorationImage(
        image: AssetImage('graphics/background.png'),
        // ...
      ),
  // ...
    ),
  );
  // ...
}

A: This thread is pretty old, but in case anyone is still looking for an answer, this is how I did it :)
  rootBundle.load('assets/test.jpg').then((content) {
    File newFile = File('${dir.path}/img.jpg');
    newFile.writeAsBytesSync(content.buffer.asUint8List());
    visionImage = FirebaseVisionImage.fromFile(newFile);
    _runAnalysis();
  });


text:
Q: Showing relation for raising and lowering operator I found this task in an older exam of quantum mechanics and it was about the harmonic oscillator and thought it would be a good practice for myself. The task goes as:
$\text{The normed eigenstates}\ |n\rangle \ \text{can be calculated from the zero state as:}$
$$|n\rangle= \frac{1}{\sqrt{n!}} (a^{\dagger})^n|0\rangle$$
$\text{Use this relation to show the following:}$
$$a^{\dagger}|n\rangle=\sqrt{n+1}|n+1\rangle \quad , \quad a|n\rangle=\sqrt{n}|n-1\rangle $$
I think I showed the first one:
$\sqrt{n+1}|n+1\rangle=\sqrt{n+1}\frac{1}{\sqrt{n+1}}(a^{\dagger})^{n+1}|0\rangle=\frac{1}{\sqrt{n}}(a^{\dagger})^{n+1}|0\rangle=\frac{1}{\sqrt{n}}a^{\dagger}(a^{\dagger})^{n}|0\rangle=a^{\dagger}\frac{1}{\sqrt{n}}(a^{\dagger})^{n}|0\rangle=a^{\dagger}|n\rangle$
But I don't know how to show the second relation. Any advice tip/solution is appreciated.

A: Hint:
Take the conjugate of the first equation:
$$
\langle n \mid\ =\frac{1}{\sqrt{n!}}\langle 0 \mid\ a^n
$$
and use the same logic as with the first part.


text:
Q: A loop that prints even numbers? I was supposed to write a code that asks for a name, asks for a number between 1 and 10, and then prints the numbers from 1 to the number the user entered except every third number should be the user's name that was entered at the beginning of the program. My code fulfills that purpose. The next step is to use a loop that prints all the even numbers from 2 to the user's number. I'm not sure how to include this in my code or even what kind of loop I should use. Can someone explain how to include this correctly? Here is the code so far.
import java.util.Scanner;

public class NewClass1 {
    public static void main(String[] args) {

        int number;

        Scanner scan = new Scanner(System.in);
        System.out.print("Enter your name: ");
        String name = scan.nextLine();

        System.out.print("Please enter a number between 1 and 10: ");
        number = scan.nextInt();

        //asks for a number between one and ten until I get number within that range,
        while (number < 1 || number > 10) {
            System.out.print("No, between 1 and 10: ");
            number = scan.nextInt();
        }

        for (int i = 1; i <= number; i++) {
            if (i % 3 == 0) {
                System.out.print(name + " ");
            } else {
                System.out.print(i + " ");
            }
        }
    }
}

A: Running a loop that prints on every even number is no different then running a loop that prints on every third number. Simply use % 2 instead of % 3:
for (int i = 2; i <= number; i++) {
    if (i % 2 = 0) {
        System.out.print(i + " ");
    }
}

Which can be re-written without using % at all:
for (int i = 2; i <= number; i += 2) {
    System.out.print(i + " ");
}

A: Below code for your reference:
 public class NewClass1 {
     public static void main(String[] args) {
       int number;
       Scanner scan = new Scanner(System.in);
       System.out.print("Enter your name: ");
       String name = scan.nextLine();

       System.out.print("Please enter a number between 1 and 10: ");
       number = scan.nextInt();

    //asks for a number between one and ten until I get number within that range,
      while (number < 1 || number > 10) {
          System.out.print("No, between 1 and 10: ");
          number = scan.nextInt();
      }

     for (int i = 1; i <= number; i++) {
         if (i % 3 == 0) {
             System.out.print(name + " ");
         }else {
             System.out.print(i + " ");
         }
     }
     System.out.println();
     for(int i =2; i<=number; i+=2)
         System.out.print(i + " ");
    }
 }

A: public static void main(String[]p){
   int limit=20;
   for(int i=2; i<=limit; i+=2)
   {
      System.out.println(i);
   }
}

A: for (int i = 2; i <= number; i++) {
    if (i % 2 == 0) {
        System.out.print(i + " ");
    }
}

A: for (int i = 2; i <= number; i++) {
    if (i % 2 = 0) {
        System.out.print(i + " ");
    }
}

The above is the code.

A: This is an example where you can print all the even numbers up to 100.
int number = 0;
while (number <= 100) {
  number += 1;

  if (number % 2 == 0) {
    System.out.println(number);
  }
}

A: Here is the solution with java 8 stream api and range function:
    System.out.print("Please enter a number between 1 and 10: ");
    Scanner scan = new Scanner(System.in);
    int number = scan.nextInt();
    IntStream stream = IntStream.rangeClosed(2, number);
    stream.filter( i -> i % 2 ==0).forEach( i -> System.out.format("%d\t",i));


text:
Q: Getting the frequency and the amplitude of a wav I'm wanting to get the frequency and the amplitude of a wav or ogg file in C langage and I want to save them on a list (maybe of each measure at each step of time)
Thank you.
I've firstly tried to record my microphone the instantly get theses datas but it seems impossible
I'm wanting a function where I put an sound file and that return a list composed of [f1,A1,f2,A2,....,fn,An] with f1 the frequency during [0,step]
f2 during [step, 2*step] et caetera.


text:
Q: Java FXML dynamically load content onto multiple different tabs I have multiple lists which I would like to loop through and return all their items in their respective tabs as buttons, each having an action.
I have tried the following:
@FXML
private Tab aTab;

And then on button press:
StackPane tab = new StackPane();
    tab.setStyle("-fx-background-color: Green");
    Label text = new Label("titleLabel");
    text.setStyle("-fx-font-size: 25px;");
    tab.getChildren().add(text);

    aTab.setContent(tab);

The immediate problem is that I get the exception
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException...
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
... 52 more
Caused by: java.lang.NullPointerException
at (the method I'm calling aTab.setContent(tab) in
...

And the slightly more insidious problem is that, as the amount of tabs grow, my code is going to get increasingly bloated.
Ideally, there would be a way to display the content on each tab using a general tab xml file but I have been unable to put something like this together.
How can this be done? Can this be done?


text:
Q: Load dynamic data in Jquery Data Tables  var tablerows = '';
var dataSet = [];
if (response.hasOwnProperty('records') && response.metadata.record_count > 0) {
    _.each(response.records, function (record) {
        var sku_data = get_api_data(urls.sku.list + "/" + record.skuid, api.access_token);

        if (sku_data != undefined) {
            sku_data.done(function (sku) {

                dataSet.push(sku.records[0].name);

                console.log(dataSet);
            })

        }

    })

    $('#demo').html('

');

    $('#example').dataTable({
        "data": dataSet,
        "columns": [
            { "title": "Product" }
        ],
        "aoColumns": [
                null
        ]
    });

How do i dynamically add all the dataSet values to the Datatable.
Please help right now i am getting a blank array.

A: It is not about jQuery DataTable, you need to use promise to solve your problem
    var tablerows = '';
    var dataSet = [];
    var dataSetPromise = [];
    if (response.hasOwnProperty('records') && response.metadata.record_count > 0) {
        _.each(response.records, function (record) {
            var sku_data = get_api_data(urls.sku.list + "/" + record.skuid, api.access_token);

            if (sku_data != undefined) {
                dataSetPromise.push(sku_data.done(function (sku) {

                    dataSet.push(sku.records[0].name);

                    console.log(dataSet);
                }));

            }

        })

    $.when.apply(null, dataSetPromise).done(function () {
        $('#demo').html('

');

        $('#example').dataTable({
            "data": dataSet,
            "columns": [
                { "title": "Product" }
            ],
            "aoColumns": [
                    null
            ]
        });
});


text:
Q: How to setup an EnvironmentObject in SwiftUI without SceneDelegate? I want to set up an EnvironmentObject in SwiftUI with the new App Protocol @main --> NO Scene or AppDelegate. Am I allowed to setup EnvironmentsObjects in my Content View, not my @main .swift ? And if yes? Why can't I pass in the environment Object in my NavigationLink (as you can see) and Swift wants me to put the data in manually,  I want to pass to the LoadingPage().
Thank you a lot !
import SwiftUI

struct ContentView: View {
    //MARK: Properties

    var body: some View {
        let user = UserData()
        //MARK: BODY
        TextPage().environmentObject(user)

On the TextPage() where I want to call the LoadingPage() within a NavLink
import SwiftUI
import Combine

struct TextPage: View {

    //MARK: Properties
    @EnvironmentObject var user : UserData

    @ObservedObject var post = Anfrage()

    @State var checkData = false // checkInput Var

    var body: some View {

        //MARK: Body
        NavigationView{

            VStack (alignment: .center, spacing: 30) {

            //NAV LINK
            NavigationLink(
                destination: LoadingPage().environmentObject(user), isActive: $checkData) { EmptyView() }

```
And this is what Swift suggests me to correct:
LoadingPage(user: <#Environment<UserData>#>).environmentObject(user)

A: Use a StateObject in your ContentView and then pass it as an EnvironmentObject
@StateObject var user : UserData = UserData()

BTW if you init variables in the body they will get re-initialized ever time the body gets reloaded by any of the properties with wrappers.


text:
Q: Transform one Bessel function integral representation into another I want to transform one integral representations of the Besselfunction of first kind of zeroth order into another
$$
J_0(x) = \frac 2 \pi \int_1^\infty \frac{\sin(xt)}{\sqrt{t^2-1}}\,\mathrm dt = \frac 1\pi \int_0^\pi \cos\big(x\sin(\varphi)\big)\,\mathrm d\varphi
$$
I want to do it with integration techniques (substitution, partial integration, ...) and not just show the equivalence via series representation of the Bessel function or the Bessel's differential equation.
I tried a substitution of
$$
t = \tan\big(\frac \varphi 2\big) + 1\\
\mathrm dt = \frac{1}{2\cos\big(\frac \varphi 2\big)^2} \mathrm d\varphi\\
\varphi = 2\arctan(t-1)\\
$$
to transform the limits from $1 ... \infty$ to $0 ... \pi$. It follows
$$
J_0(x) = \frac 2 \pi \int_0^\pi \frac{\sin\big[x\big(\tan\big(\frac \varphi 2\big)+1\big)\big]}{2\cos\big(\frac \varphi 2\big)^2\sqrt{\big(\tan\big(\frac \varphi 2\big) + 1\big)^2 -1}}\,\mathrm d\varphi\\
= \frac 1 \pi \int_0^\pi \frac{\sin\big[x\big(\tan\big(\frac \varphi 2\big)+1\big)\big]}{\cos\big(\frac \varphi 2\big)^2\sqrt{\tan\big(\frac \varphi 2\big)^2 + 2\tan\big(\frac \varphi 2\big)}}\,\mathrm d\varphi
$$
With this, the integrals run over the same range, however the integrands are still completely different (plotting the integrands shows completely different curves but integration gives valid results according to mathematica).
How can I transform this complicated integrand into the simpler one? Or is there a better possibility for a substitution, ...?

A: We can transform the first representation
\begin{align}
 I_1&=\frac 2 \pi \int_1^\infty \frac{\sin(xt)}{\sqrt{t^2-1}}\,\mathrm dt\\
 &=\frac 2 \pi \int_0^\infty \sin x\cosh u\,du \\
 &=\frac 2 \pi\Im \int_0^\infty \exp(ix\cosh u)\,du
\end{align}
In the complex plane, introducing the rectangular contour made by a vertical segment $u=iz, 0<z<\tfrac{\pi}{2}$ and an horizontal part $u=i\pi/2+s, 0<s<\tfrac{\pi}{2}$, the residue theorem shows that
\begin{align}
\int_0^\infty \exp(ix\cosh u)\,du &=i\int_0^{\tfrac{\pi}{2}}\exp\left( ix\cosh iz \right)\,dz+\int_0^\infty\exp\left( ix\cosh(s+\tfrac{\pi}{2}) \right)\,ds\\
&=i\int_0^{\tfrac{\pi}{2}}\exp\left( ix\cos z \right)\,dz+\int_0^\infty\exp\left( -x\sinh(s) \right)\,ds
\end{align}
As the second integral of the last expression is real,
\begin{align}
I_1&=\frac 2 \pi \Im\left[i\int_0^{\tfrac{\pi}{2}}\exp\left( ix\cos z \right)\,dz\right]\\
&=\frac 2 \pi\int_0^{\tfrac{\pi}{2}}\cos\left( x\cos z \right)\,dz\\
&=\frac 2 \pi\int_0^{\tfrac{\pi}{2}}\cos\left( x\sin z \right)\,dz\\
&=\frac 1 \pi\int_0^{\pi}\cos\left( x\sin z \right)\,dz
\end{align}
In the last two expressions, we have changed $z\to \pi/2-z$ and have used the symmetry $\sin z=\sin(\pi-z)$.


text:
Q: jQuery - Looping through elements with specific Attribute I know how to loop through the inputs below, searching for the ones with a specific class of "testers"
And here's how I do that:
<input type='text' name='firstname' class="testing" value='John'>
<input type='text' name='lastname' class="testing" value='Smith'>

<script type="text/javascript">
$(document).ready(function(){

 $.each($('.testing'), function() {
   console.log($(this).val());
 });

});
</script>

It outputs the "John", "Smith" as expected.
I want to not use the class="testing" and use a custom attribute: testdata="John".
So this is what I'd be doing:
<input type='text' name='firstname' testdata='John'>
<input type='text' name='lastname' testdata='Smith'>

My goal is to auto-populate the values of each input with whatever is inside testdata, but only those detected to have the testdata attribute.
This was my failed attempt at using the $.each loop:
$.each($('input').attr('testdata'), function() {
  var testdata = $(this).attr('testdata');
  $(this).val(testdata);
});

I get this response: Uncaught TypeError: Cannot read property 'length' of undefined
Can anyone see what I'm doing wrong?

A: $("input[testdata]").each(function(){
  alert($(this).attr('testdata'));
 // do your stuff
});

working demo

A: Here it is using the HTML5 data-* attribute:
HTML:
<input type='text' name='firstname' data-test='John'>
<input type='text' name='lastname' data-test='Smith'>

JS:
$("input[data-test]").each(function(){
    var testdata = $(this).data('test');
    $(this).val(testdata);
});

Here it is working: http://jsfiddle.net/SFVYw/
An even shorter way of doing it would be using this JS:
$("input[data-test]").val(function(){
    return $(this).data('test');
});

Internally it's doing the same as the other JS code but it's just a little more concise.

A: if you want to select inputs with specific attribute name and you have these html inputs:
<input type='text' name='user1' fieldname="user" class="testing" value='John1'>
<input type='text' name='user2' fieldname="user" class="testing" value='Smith1'>
<input type='text' name='admin1' fieldname="admin" class="testing" value='John2'>
<input type='text' name='admin2' fieldname="admin" class="testing" value='Smith2'>

you can loop on admins only like this:
$("input[fieldname='admin']").each(function(){
    alert($(this).val());
});

by the same way, you can loop for users only:
$("input[fieldname='user']").each(function(){
    alert($(this).val());
});

A: For iterating over all elements with testdata attribute and assigning form fields with what their attribute holds try
$("[testdata]").each(function(){
    $(this).val($(this).attr('testdata'))
})

[works with all elements i guess]


text:
Q: jQuery .each problem Brain squeeze and need help,
I have a table with 6 rows that are that can be hidden or visible depending on if a check box is checked. This .each routine works great with one small problem - when the last check box (val="5") is checked and you hit the refresh button the row 6 (with class="hide5") is hidden. This only occurs on the last check box - any other checkbox that is checked stays visible.
$(document).ready(function($) {
    $('input:checkbox').each(
        function(rowIndex){
            if($('#view'+rowIndex).is(':checked') == true){
                $('.hide'+rowIndex).show();
            }
            else if($('#view'+rowIndex).is(':checked') == false){
                $('.hide'+rowIndex).hide();
            }
        }
    );
    $('input:checkbox').click(function () {
        var row = this.value;
        $('.hide' + row).toggle();
    });
});

The HTML source for the 6th row is:

    Total

    <input class="auto" type="text" id="bwPound" size="18" alt="p8c3pvS" />

    <input class="auto" type="text" id="bwPound" size="18" alt="p8c3pvS" />

Thanks in advance for your help
Bob Knothe

A: Try this out:
$(document).ready(function($) {
    $('input:checkbox').each(function(rowIndex){
        var $row = $(this);
        if ($row.is(':checked')){
            $('.hide'+rowIndex).show();
        } else {
            $('.hide'+rowIndex).hide();
        }
    });
    $('input:checkbox').click(function () {
        var row = this.value;
        $('.hide' + row).toggle();
    });
});

A: The checkbox has id "View5", but the JS references 'view'+rowIndex. IDs are case sensitive.


text:
Q: Numpy import throws AttributeError: 'module' object has no attribute 'core' import numpy as np
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module>
    from . import add_newdocs
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 57, in <module>
    from numpy.testing import Tester
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 14, in <module>
    from .utils import *
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 15, in <module>
    from tempfile import mkdtemp
  File "/usr/lib/python2.7/tempfile.py", line 35, in <module>
    from random import Random as _Random
  File "/home/anirrudh/OMSCS/Courses/ML4T/ml4t/mc3_p2/random.py", line 5, in <module>
    import matplotlib.pyplot as plt
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 122, in <module>
    from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/matplotlib/cbook.py", line 33, in <module>
    import numpy.ma as ma
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/ma/__init__.py", line 44, in <module>
    from . import core
  File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/ma/core.py", line 30, in <module>
    import numpy.core.umath as umath
AttributeError: 'module' object has no attribute 'core'

I am working on Ubuntu 14.04. I tried reinstalling numpy, created a new virtualenv, but it isn't helping. I get the same error outside the virtualenv as well. It stopped working suddenly. It was fine until a little while ago.

A: (Answer posted on behalf of the OP).
Update: Resolved.
I had created a python file for one of my projects name random.py and when numpy is imported, it was calling this file instead of it's own library file hence resulting in the error. I had to delete/rename random.py which I created and that fixed the issue.

A: Try running it in Python 2 instead of Python 3 - you may have the older version of Spark

A: This happened to me in Windows with Anaconda. I fixed it by removing the python3 path from the environment variable PATH.

A: Another common problem here (which I had)...check to make sure you dont have a PYTHONPATH env var pointing to a different version of python site-packages (this happened because I updated my python version and didn't change this...it loads from PYTHONPATH first).

A: It happened to me in a specific ipynb, once I crated a copy of the notebook with a different name I was able to import numpy.


text:
Q: How to solve "Conversion failed when converting from a character string to uniqueidentifier"? I am creating application where I need to call SQL procedure.
The parameter where I get the error is last , that is fifteenth parameter, contactID .. First five parameters are also unique identifiers but they set properly..only the last one that is, contactID throws exception while trying to set it as procedure parameter.
Here is my Java code :
@SuppressWarnings({ "unchecked", "null" })
    @Override
    public JSONObject saveProductData(ProductsDataToSaveDTO ProductsDataToSaveDTO) throws SQLException {
        String output = "";
        Connection conn = null;
        Statement sta = null;
        String errorClassAndMethod = getErrorContainingClassAndMethod();
        JSONObject jsonOutput = new JSONObject();
        try {
            Gson gson = new GsonBuilder().create();
            String json = gson.toJson(ProductsDataToSaveDTO);
            org.json.JSONObject jsonInput = new org.json.JSONObject(json);
            conn = createConnection(jsonInput);
            sta = conn.createStatement();

            String SPsql = "{call SP_InsertUpdateAdvisoryBoxProductDetails (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
            PreparedStatement ps = conn.prepareStatement(SPsql);
            System.out.println(jsonInput);
            org.json.JSONArray productsList = (org.json.JSONArray) jsonInput.get("productsList");

                ps.setString(1, ProductsDataToSaveDTO.getClientId());
                ps.setString(2, ProductsDataToSaveDTO.getDivisionId());
                ps.setString(3, ProductsDataToSaveDTO.getClientRoleId());
                ps.setString(4, ProductsDataToSaveDTO.getUserID());
                ps.setString(5, ProductsDataToSaveDTO.getUserLoginDetailId());

                for (ProductsList productsListBO : ProductsDataToSaveDTO.getProductsList()) {

                    if (productsListBO.getProductCategory().equalsIgnoreCase("AOV")) {

                    ps.setString(6, productsListBO.getProductSituation());
                    String output2 = productsListBO.getProductSituation();
                    ps.setString(7, productsListBO.getProductCategory());
                    ps.setString(8, productsListBO.getProductSubcategory());
                    ps.setString(9, productsListBO.getProviderName());
                    ps.setString(10, productsListBO.getProductName());
                    ps.setString(11, productsListBO.getServiceProvider());
                    ps.setString(12, productsListBO.getPolicyNumber());
                    ps.setString(13,productsListBO.getProductClosed());
                    ps.setString(14, productsListBO.getNameFirstInsured());
                    ps.setString(15, productsListBO.getContactID());
                    }
                    ResultSet rs = ps.executeQuery();
                    while (rs.next()) {
                        output = rs.getString(1);
                        jsonOutput.put("status", output);
                    }
                }
        } catch (Exception e) {
            output = e.toString();
            e.printStackTrace();
            String errorMessageAndClassWithMethod = getErrorContainingClassAndMethod();
            throw new SpringAppRuntimeException(errorMessageAndClassWithMethod + e.toString());
        } finally {
            if (sta != null) {
                conn.close();
            }
            if (conn != null) {
                conn.close();
            }
        }
        return jsonOutput;
    }

when I run my service, I get the error as ,
"Application runtime exception occurred. [Error in ClassName.saveProductData : com.microsoft.sqlserver.jdbc.SQLServerException: Conversion failed when converting from a character string to uniqueidentifier.]"
What changes I should make in the code to run it successfully?

A: So based on your comment, I am adding it as answer
1) ps.setString(15, productsListBO.getContactID());"
2) Check 15th argument of your procedure SP_InsertUpdateAdvisoryBoxProductDetails is @ProductSituation NVARCHAR(10)
3) Is that really an identifier field and does the varchar matches the length of contactID? change that 10 to say 100 and test.
4) I also think your order of setting values in parameter (based on method names) and the order in which your procedure takes parameter is different. Go through it and correct that as well


text:
Q: OpenSSL Missing Ciphers I have two instances of RHEL (6.2 and 6.5) both using the same versions of OpenSSL and OpenSSH (albeit different versions).
Red Hat Enterprise Linux Server release 6.2
# yum info openssl
Installed Packages
Name        : openssl
Arch        : x86_64
Version     : 1.0.1e
Release     : 48.el6_8.1

# yum info openssh
Installed Packages
Name        : openssh
Arch        : x86_64
Version     : 5.3p1
Release     : 118.1.el6_8

# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013

# telnet 0 22
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.3

Red Hat Enterprise Linux Server release 6.5
# yum info openssl
Installed Packages
Name        : openssl
Arch        : x86_64
Version     : 1.0.1e
Release     : 15.el6

# yum info openssh
Installed Packages
Name        : openssh
Arch        : x86_64
Version     : 5.3p1
Release     : 94.el6

# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013

# telnet 0 22
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
SSH-2.0-OpenSSH_5.3

However the output from:
# openssl ciphers

Seems to be different on both servers.  The server running 6.5 seems to have more ciphers.  I'm not sure whether this is the expected result or if I should see identical output from both.
Red Hat Enterprise Linux Server release 6.2
# openssl ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-DSS-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-DSS-CAMELLIA256-SHA:ECDH-RSA-AES256-GCM-SHA384:ECDH-ECDSA-AES256-GCM-SHA384:ECDH-RSA-AES256-SHA384:ECDH-ECDSA-AES256-SHA384:ECDH-RSA-AES256-SHA:ECDH-ECDSA-AES256-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA:PSK-AES256-CBC-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-DSS-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:DHE-RSA-SEED-SHA:DHE-DSS-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:DHE-DSS-CAMELLIA128-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:ECDH-RSA-AES128-GCM-SHA256:ECDH-ECDSA-AES128-GCM-SHA256:ECDH-RSA-AES128-SHA256:ECDH-ECDSA-AES128-SHA256:ECDH-RSA-AES128-SHA:ECDH-ECDSA-AES128-SHA:ECDH-RSA-DES-CBC3-SHA:ECDH-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:SEED-SHA:CAMELLIA128-SHA:DES-CBC3-SHA:IDEA-CBC-SHA:PSK-AES128-CBC-SHA:PSK-3DES-EDE-CBC-SHA:KRB5-IDEA-CBC-SHA:KRB5-DES-CBC3-SHA:KRB5-IDEA-CBC-MD5:KRB5-DES-CBC3-MD5:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:ECDH-RSA-RC4-SHA:ECDH-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:PSK-RC4-SHA:KRB5-RC4-SHA:KRB5-RC4-MD5

Red Hat Enterprise Linux Server release 6.5
# openssl ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-DSS-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-DSS-CAMELLIA256-SHA:ECDH-RSA-AES256-GCM-SHA384:ECDH-ECDSA-AES256-GCM-SHA384:ECDH-RSA-AES256-SHA384:ECDH-ECDSA-AES256-SHA384:ECDH-RSA-AES256-SHA:ECDH-ECDSA-AES256-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA:PSK-AES256-CBC-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:ECDH-RSA-DES-CBC3-SHA:ECDH-ECDSA-DES-CBC3-SHA:DES-CBC3-SHA:PSK-3DES-EDE-CBC-SHA:KRB5-DES-CBC3-SHA:KRB5-DES-CBC3-MD5:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-DSS-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:DHE-RSA-SEED-SHA:DHE-DSS-SEED-SHA:DHE-RSA-CAMELLIA128-SHA:DHE-DSS-CAMELLIA128-SHA:ECDH-RSA-AES128-GCM-SHA256:ECDH-ECDSA-AES128-GCM-SHA256:ECDH-RSA-AES128-SHA256:ECDH-ECDSA-AES128-SHA256:ECDH-RSA-AES128-SHA:ECDH-ECDSA-AES128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:SEED-SHA:CAMELLIA128-SHA:IDEA-CBC-SHA:PSK-AES128-CBC-SHA:KRB5-IDEA-CBC-SHA:KRB5-IDEA-CBC-MD5:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:ECDH-RSA-RC4-SHA:ECDH-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:PSK-RC4-SHA:KRB5-RC4-SHA:KRB5-RC4-MD5:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:KRB5-DES-CBC-SHA:KRB5-DES-CBC-MD5:EXP-EDH-RSA-DES-CBC-SHA:EXP-EDH-DSS-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-KRB5-RC2-CBC-SHA:EXP-KRB5-DES-CBC-SHA:EXP-KRB5-RC2-CBC-MD5:EXP-KRB5-DES-CBC-MD5:EXP-RC4-MD5:EXP-KRB5-RC4-SHA:EXP-KRB5-RC4-MD5


text:
Q: All balls fall into 1 bin We distribute the 10 balls into 6 bins.
If we randomly distribute the balls into the bins, what is the probability that all of the balls end up in the same bin?
Is it just: (${10 \choose 1}*6)/ 6^{10}$

A: The first ball can go in any of the bins ... but after that all other 9 need to go in the same bin, so the chances of that are $(\frac{1}{6})^9$
The fact that you have 10 balls does not multiply this by 10.


text:
Q: toolStripBox1.Items.Add(toolStripTextBox.Text); Error at items I know the title might be confusing but I will give a better-detailed explanation.
I am currently trying to make a web browser. I am stuck with this issue and still can't find a fix for it.
And my error is at toolStripTextBox.Items<--- HERE it turns red squiggly underline
It gives me...

"'ToolStripTextBox' does not contain a definition for 'Items' and no accessible extension method 'Items' accepting a first argument of type 'ToolStripTextBox' could be found (are you missing a using directive or an assembly reference?)"

help is appreciated
private void goToolStripMenuItem_Click(object sender, EventArgs e) {
  ((WebBrowser)tabControl1.SelectedTab.Controls[0]).Navigate(toolStripTextBox1.Text);
  if (!toolStripTextBox1.Items.Contains(toolStripTextBox1.Text))
  {
    toolStripTextBox1.Items.Add(toolStripTextBox1.Text);
  }
}

A: Looking at your description:
 toolStripTextBox1 is a textbox and thus you cannot add items like a list or collection .
toolStripTextBox1.Items.Add(toolStripTextBox1.Text);

For this code to work,toolStripTextBox1 should be toolstrip  .You can add items
like this
toolStrip1.Items.Add(toolStripTextBox1.Text);

A: I fixed the problem by changing my toolStripTextBox1 to a ComboBox.


text:
Q: Problem in concatenating 3 strings in bash script I want to concatenate 3 strings in a bash script file.
#!/bin/sh
v1="aaaaaa"
v2="bbbb"$v1
v3=$v2"cc"
echo $v2
echo $v3

Result:
bbbbaaaaaa
ccbbaaaaaa

As you can see, 3rd string appears at the beginning and replace some characters of the main string.
What can I do for this problem?

A: The script has  been edited in windows format (with a CRLF end of line by the editor). Apart the fact that's a /bin/sh and not /bin/bash, you can use
echo -E $v3

in order to suppress the \r (carriage return), as per any other escape char.


text:
Q: how to map reg values to the ports of other module i am an amateur in verilog. i am trying to call module divider. but i get errors like "Reference to vector reg 'qtnt' is not a legal net lvalue" in synthesis. i have tried using wires as inputs but when i tried to assign values to them an error message was recieved. please help
module euclid_mul(
  input[9:0] p0,p1,q0,
  input[19:0] tot,
  input clk,
  output reg [20:0] p2,
  output reg out_en,o1,o2
);
reg[20:0] dvr,dvd,qtnt,rem;
reg[9:0] ph;
reg[20:0] mul,res;
reg enable,f1;

initial f1=0;
initial enable=0;

divider div2(dvd,dvr,enable,qtnt,rem,f1);

always @ (negedge clk)
  begin
    if(f1==0) begin
      mul=q0*p1;
      ph=p0;
      res={11'b00000000000,ph[9:0]}-mul;
      if(res[20])
        begin
          o1=1;
          dvd=-res;
        end
      else
        dvd=res;
        o2=1;
        dvr=tot;
        enable=1;
      end
    end

    always @(posedge f1)
      begin
        if(res[20])
          begin
            p2=tot-rem;
            out_en=1;
          end
        else
          begin
            p2=rem;
            out_en=1;
          end
        end
      endmodule

A: You may get more response if you formatted the code so that it was easier to read. Something like the following:
I have also pointed out a section where I think you are missing a begin and end statement.
Also inside clocked sections you often want to use nonblocking assignments <=.
Since you have not provided the divider module, I would prefer to see ports named rather than specified in order, it might help us to know what it is likely to do, even better label it with its direction and width.
module euclid_mul(
  input       [9:0] p0,p1,q0,
  input      [19:0] tot,
  input             clk,
  output reg [20:0] p2,
  output reg        out_en,o1,o2
);
reg [20:0] dvr,dvd,qtnt,rem;
reg  [9:0] ph;
reg [20:0] mul,res;
reg        enable,f1;

initial begin
  f1     = 0;
  enable = 0;
end

divider div2(dvd,dvr,enable,qtnt,rem,f1);
// My prefered style to help us understand conectivity.
//divider
//  divider_i0(
//    .divisor( dvd ), //input  [20:0]
//    .result ( res )  //output [20:0]
//);

always @ (negedge clk) begin
  if(f1==0) begin
    mul = q0*p1;
    ph  = p0;
    res = {11'b00000000000,ph[9:0]}-mul;
    if ( res[20] ) begin
      o1  = 1;
      dvd = -res;
    end
    else begin //There was a missing begin
      dvd   = res;
      o2    = 1;
      dvr   = tot;
     enable = 1;
    end //Missing End
  end
end

always @(posedge f1) begin
  if(res[20]) begin
    p2     = tot-rem;
    out_en = 1;
  end
  else begin
    p2     = rem;
    out_en = 1;
  end
end
endmodule

Inputs can be regs and driven from inside always or initial blocks, or wires driven from a single assign or another modules output.
Outputs should always be connected to wires, the module drives them.


text:
Q: Why are we still using the DOM in the browser rather than a desktop paradigm From my understanding, the web interface was developed to use HTML because at the time it wasn't possible to simulate a desktop style application in the browser such as how Silverlight and Flash work, because of bandwidth limitations, and possibly processing power.
Why hasn't there in the past, and the present been a larger acceptance and push for technologies like Flash/Silverlight? From my experience they are more pleasing to develop with (of course my opinion), and you don't have to deal with cross browser compliance, and older browsers (for the most part).
Handling postbacks, AJAX, etc seems like extra unnecessary effort compared to the development paradigm of desktop applications. Do the DOM and it's complimenting technologies continue to thrive mainly on the fact that Silverlight/Flash requires a plugin install, and some mobile devices don't support the plugin?

A: The simple answer to "Why no desktop applications in Flash" is that you can just write them in Adobe Air, but apparently only few do.
I believe the answer is that people want web applications, not flashy Flash-application, and they want the web applications to be have just like all the other web applications they use.  Personally I want to be able to use a Flashblocker and still have full functionality of the application.

A: This is a very common effect in our industry.
For example, I personally use haXe and deploy my client code on the Flash Player, because IMHO it is the best web enabled platform I can target. Once the C# backend is finished, I will probably check out whether Silverlight is worth using, although my personal feeling is, that it died, before it actually took off.
Being very happy with my language choice, a thing I ask myself often is: Why don't more web developers use an open-source, multi-paradigm, expressive, cross-platform language?
There's many reasons, but they're always the same. A valid one is personal preference. But often it comes down to ignorance or reluctance towards new/niche technologies.
When it comes to Flash, I had numerous arguments about why it has its place and why to use it. People mostly argue, that the whole point of Flash is to create fancy sites that load for ages and perform horribly (and spread a lot of other misinformation).
In fact, the opposite is true and apps such as Aviary Phoenix or Sliderocket and games as Koyotl and Tanki Online prove it. Flash is a mature platform to create desktop-like experience in the browser.
In the end, too many strategic decisions are made by incompetent people, who prefer to follow trends and rather trust some fancy blogger than their developers. And who really have a lot of wrong ideas in their head.
New/niche technologies will always struggle for acceptance, unless they really make a breakthrough. Ruby for example succeeded in this through Rails and the big hype around it. Flash had such a breakthrough for designers, because in the 90s people thought shrill is good and it was the first widely spread platform that allowed to implement just that.
Despite Flex, Flash never really had such a breakthrough for developers. Possibly because GWT, qooxdoo and a lot of other deploy-on-HTML frameworks are sufficiently good too simply not use Flex or Flash, and there's significantly more Java and JavaScript developers (apparently companies prefer to choose technologies where there's a high quantity of potential employees).
You don't need to write your AJAX website from scratch nowadays. You can actually not have any understanding of HTML and do it anyway, in a language of your choice.
Right now, HTML5 is greatly advertised and pushed forward and many people infer the death of Flash from that. A lot of great reasons are given, why HTML5 is better than Flash. What is more likely, is that you'll have more and more resource hungry, bloated websites created with HTML5. Standard based crap is no better than 3rd party based crap.
Right now, there's a lot of things happening. The iPhone and other similar devices have created a giant market, that hasn't been there just 4 years ago. And the web standards are finally being driven forward by all the major companies in the same direction (vaguely).
Personally, I just hope that all the agitation settles within a year or two, that HTML5 stabilizes, matures and spreads until then, while Apple will hopefully take a less despotic stance and Flash Player becomes faster on mobile platforms. And that once this big step is done, people will just come back to choosing the right tool for the job, just as it were after the browser wars had come to stop. As of now, there's too much noise for people to think clearly.

A: A few reasons I can think of, off the top of my head:

*

*The traditional web stack is pretty mature these days; modern browsers have very few quirks left, and designing web sites for them is relatively pleasant, compared to a mere 5 years ago

*While there are differences between browsers, they are less relevant than differences between the underlying OS and hardware

*The request/response paradigm actually works very well for a lot of things, such as presenting text-heavy content

*Search engines aren't exactly keen on Flash or Silverlight content

*Flash and Silverlight are each controlled by a single company; using them means future platform support for your code is at these companies' mercy

*Many things you can do with HTML cannot be done with plugins: think bookmarks, copy-paste, on-the-fly translation, custom style sheets

*Plugins don't play well with non-standard browsers - think text browsers, audio browsers, and the wide range of other devices that can display web pages

*You can't easily automate Flash or Silverlight clients, while driving HTML web sites from scripts is usually pretty straightforward.

A: The technologies are all fairly immature.  Just look at how much change has occurred in any 5 year block.  With mobile/tablet technologies, it is going to change again.
I look at it as more of a merging.  It isn't just HTML/DOM or plug ins.  I've seen HTML extensions for accessing device features.  Plug-ins support both desktop and web concepts along with bringing their own ideas.
Depending on your perspective, this is a good thing or bad.  At the moment, my team is working in SilverLight (not for the web).  It isn't a bad technology.  You can build some very powerful, very attractive applications.  However, it comes with a lot of complexity over its predecessors (.Net and maybe Win32) because you couldn't do as much with those technologies and the expectations were lower.  Today, most developers writing any application are often competing (expectations, not actual competition) with the best of desktop, web and mobile technologies combined (speed, features, attractiveness, usability, ...)


text:
Q: Breaking a while loop and restarting code I wanted to know if it is possible to break a while loop and restart the code from a particular position without the use of an external reset button on the MCU reset pin.
Below is the while loop I would like to break when the "if" statement is true, I am using an LCD and would like to return to a particular part in my code where text is displayed (to imitate a home page).
As it is, when the "if" statement is true the while loop is broken and the code ends.
int main(void)
{
    /***************************************** BUTTON CONFIGURATION ********************************/

    DDRA &= ~((1<<PINA0) | (1<<PINA1) | (1<<PINA2) | (1<<PINA3));   // Config pins as inputs (ADC3 - Matching with ADMUX assignment below in ADC configuration)

    DDRC = 0xFF;        // Output pins for LEDs

    PORTA |= (1<< PINA0) | (1<<PINA1) | (1<<PINA2); // Three pins for three push buttons

    /****************************************** ADC CONFIGURATION **********************************/

    ADMUX |= (1<<MUX0) | (1<<MUX1) | (1<<REFS0);        // ADC3 and Internal voltage as reference voltage

    MCUCR &= ~((1<<ADTS2) | (1<<ADTS1) | (1<<ADTS0));   // Free running mode

    ADCSRA |= (1<<ADEN) | (1<<ADATE) | (1<<ADIE);   // ADC, Auto trigger source enable and start conversion

    sei();  // Enable global interrupts

    /***************************************** LCD CONFIGURATION ***********************************/

    LCD_Data_DDRB |= (1<<LCD_D7) | (1<<LCD_D6) | (1<<LCD_D5) | (1<<LCD_D4);     // Set output lines for lower 4 bits

    LCD_Data_DDRD |= (1<<LCD_B3) | (1<<LCD_B2) | (1<<LCD_B1) | (1<<LCD_B0);     // Set output lines for upper 4 bits

    LCD_Control_DDRB |= (1<<RS) | (1<<RW) | (1<<EN);                // Set RS, RW & EN output lines

    /******************************************** START CODE **************************************/

    LCD_Initialise();   // Run function to initialize the LCD

    LCD_startup();      // Run function which displays default start up text

    ADCSRA |= (1<<ADSC);    // Start conversion

    LCD_Send_Command(DISP_CL);

    while(1)
    {

      if(Default > Final)
      {
        LCD_Send_Command(DISP_CL);
        LCD_Send_Command(DISP_CS | LINE_1);
        LCD_Send_String(" text would go here");
        break;
      }

      else
      {
          ;
      }

    }

}

A: This is slightly hard to understand, since you don't show the code you want to "restart".
Perhaps you can use another loop surrounding the one you show:
while(1)
{
  code_that_is_restarted();
  while(1)
  {
    if(Default > Final) /* Very bad variable names */
    {
      break;  /* Exits the inner loop only. */
    }
  }
}

The break; will exit the innermost loop only, so execution will continue in code_that_is_restarted();.


text:
Q: How are vector operations performed on 20newsgroups_vectorized data set? When I fetch 20newsgroups_vectorized data by
newsgroups = fetch_20newsgroups_vectorized(subset='all')
labels = newsgroups.target_names
target = newsgroups.target
target = pd.DataFrame([labels[i] for i in target], columns=['label'])
data = newsgroups.data

data is the <class 'scipy.sparse.csr.csr_matrix'> with the shape
(18846, 130107)
How can I subset the data by target names (for example, extract only 'rec.sport.baseball') and use vector operations on those sparse row vectors (for example, calculate the mean vector or the distances)?

A: Unfortunately, subsetting the data by target names option is not available in fetch_20newsgroups_vectorized but it is available in
fetch_20newsgroups, just that you have to vectorize the data yourself.
Here is how you can do it.
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import TfidfVectorizer
newsgroups_train = fetch_20newsgroups(subset='all',
                                      categories=['rec.sport.baseball'])
vectorizer = TfidfVectorizer()
vectors = vectorizer.fit_transform(newsgroups_train.data)
print(vectors.shape)
# (994, 13986)

Read more here


text:
Q: disable python greeting/version info When I start a python interactive session from the command line I am greeted by :
 Python 3.9.6 (default, Jun 30 2021, 10:22:16)
 [GCC 11.1.0] on linux
 Type "help", "copyright", "credits" or "license" for more information.

Is there a way of disabling that message so that I go immediately to the >>> prompt?

A: Yes, there is a way to do so.
Type in the cmd:
python -q

instead of
python

and this should do the trick.


text:
Q: Cannot use loop on NMACoreRouter (swift) (HereMap SDK) I've an issue that I cannot use for loop on NMACoreRouter (HereMap SDK)
If i did it once time by action, it still work!. i dont know why cannot apply into loop.  Funny that the error return at the second loop it "NMARoutingError" only
Here is my code
//route
var coreRouter: NMACoreRouter!
var mapRoute: NMAMapRoute?
typealias RouteContainer = (plan: [NMAGeoCoordinates], mode: NMARoutingMode)

 for var shop in pickedShopData {

                self.calculateRouteLength(startLat: self.curentUserGeo.latitude, startLong: self.curentUserGeo.longitude, endLat: shop.shopLat, endLong: shop.shopLong)

        }

func calculateRouteLength(startLat: Double, startLong: Double, endLat: Double, endLong: Double) {

    coreRouter = NMACoreRouter()
    /* Define waypoints for the route */
    let startPoint = NMAGeoCoordinates(latitude: startLat, longitude: startLong)
    let endPoint = NMAGeoCoordinates(latitude: endLat, longitude: endLong)
    /* Initialize a RoutePlan */
    let routePlan = [startPoint, endPoint]
    /*
     * Initialize a RouteOption. HERE Mobile SDK allows users to define their own parameters for the
     * route calculation,including transport modes,route types and route restrictions etc.Please
     * refer to API doc for full list of APIs
     */
    let routeMode = NMARoutingMode()
    /* Other transport modes are also available e.g Pedestrian */
    routeMode.transportMode = NMATransportMode.scooter
    /* Disable highway in this route. */
    routeMode.routingOptions.insert(NMARoutingOption.avoidHighway)
    /* Calculate the shortest route available. */
    routeMode.routingType = NMARoutingType.fastest
    /* Calculate 1 route. */
    routeMode.resultLimit = 3

    coreRouter.calculateRoute(withStops: routePlan, routingMode: routeMode,
                              { [self] (result, error) in
            // check error and unwrap route
            guard let route = result?.routes?.first, error == NMARoutingError.none else {
                print("error \(error)")
                return
            }
            // check if map object already exist
            if let tempMapRoute = self.mapRoute {
                self.mapView?.remove(mapObject: tempMapRoute)
            }
            // create map object from route
            guard let mapRoute = NMAMapRoute(route) else {
                return
            }
            print("distance \(mapRoute.route.length)")
    })

}

A: I think your problem is that the NMACoreRouter is still calculating the first route while the second route is started.
Check NMACoreRouter.isBusy to ensure that the router has finished its calculation until you start the next one.
-Karin


text:
Q: Navbar tab full text is not showing inside button and how to change navtab row? I have used Navbar tab of bootstrap  and i want to only show nine buttons on one row but all the eighteen buttons are showing in single row with text inside in button being compressed.The full text is not showing which are more in length.I want to change the row after nine button and show the full text. I am not getting the solution.
<!DOCTYPE html>

  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

            <button type="button" class="btn btn-primary" href="#tab1" data-toggle="tab">

Sample

            </button>

            <button type="button" class="btn btn-default" href="#tab2" data-toggle="tab">

Plot Description

            </button>

            <button type="button" class="btn btn-default" href="#tab3" data-toggle="tab">

Ntfp

            </button>

            <button type="button" class="btn btn-default" href="#tab4" data-toggle="tab">

Sampling Form

            </button>

            <button type="button" class="btn btn-default" href="#tab5" data-toggle="tab">

Sapling Form

            </button>

            <button type="button" class="btn btn-default" href="#tab6" data-toggle="tab">

Seedling Form

            </button>

            <button type="button" class="btn btn-default" href="#tab7" data-toggle="tab">

Time Form

            </button>

            <button type="button"  class="btn btn-default" href="#tab8" data-toggle="tab">

TOF Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Tree Climb Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Soil Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

            <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

C# is also a programming language

D# is also a programming language

A: This is your solution. Add a new div close and new
 after ninth button.

          <button type="button" class="btn btn-primary" href="#tab1" data-toggle="tab">

Sample

            </button>

          <button type="button" class="btn btn-default" href="#tab2" data-toggle="tab">

Plot Description

            </button>

          <button type="button" class="btn btn-default" href="#tab3" data-toggle="tab">

Ntfp

            </button>

          <button type="button" class="btn btn-default" href="#tab4" data-toggle="tab">

Sampling Form

            </button>

          <button type="button" class="btn btn-default" href="#tab5" data-toggle="tab">

Sapling Form

            </button>

          <button type="button" class="btn btn-default" href="#tab6" data-toggle="tab">

Seedling Form

            </button>

          <button type="button" class="btn btn-default" href="#tab7" data-toggle="tab">

Time Form

            </button>

          <button type="button" class="btn btn-default" href="#tab8" data-toggle="tab">

TOF Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Tree Climb Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Soil Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

            </button>

C# is also a programming language

D# is also a programming language

A: This is your solution. Add a new div close and new
 after ninth button.

          <button type="button" class="btn btn-primary" href="#tab1" data-toggle="tab">

Sample

          </button>

          <button type="button" class="btn btn-default" href="#tab2" data-toggle="tab">

Plot Description

          </button>

          <button type="button" class="btn btn-default" href="#tab3" data-toggle="tab">

Ntfp

          </button>

          <button type="button" class="btn btn-default" href="#tab4" data-toggle="tab">

Sampling Form

          </button>

          <button type="button" class="btn btn-default" href="#tab5" data-toggle="tab">

Sapling Form

          </button>

          <button type="button" class="btn btn-default" href="#tab6" data-toggle="tab">

Seedling Form

          </button>

          <button type="button" class="btn btn-default" href="#tab7" data-toggle="tab">

Time Form

          </button>

          <button type="button" class="btn btn-default" href="#tab8" data-toggle="tab">

TOF Form

          </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Tree Climb Form

          </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Soil Form

          </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

          </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

          </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

          </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

          </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

          </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

          </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

          </button>

 <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">
Disturbance Form
 </button>

          <button type="button" class="btn btn-default" href="#tab9" data-toggle="tab">

Stand Form

          </button>

C# is also a programming language

D# is also a programming language

And add this rule to your css.
.buttoncontainer .btn-group {
  display: flex;
  width: auto !important;
}


text:
Q: receive updates according my tags How can I receive updates from Stack Overflow, according to my favorite tags?
I tested the Android app Stack Remote, but I can't login with it.
Is there an app for Android that lets me know when a new question is posted in my favorite tags, or is there another method to do this?

A: Every tag shows this on mouseover; you can either subscribe for updates via email or get updates via the tag-specific RSS feed.


text:
Q: Is there a one-line "dot product" between a numpy 1D array and an array whose entries are matrices? I want a simple way to get the "dot product" between a vector r = [ r[1], r[2], r[3] ] and an array A = [ A[0], A[1], A[2] ], with the A[i]'s being matrices,  resulting in
dot(r, A)  = r[0]*A[0] + r[1]*A[1] + r[2]*A[2]
where dot(r, A) is a matrix. For example, r might be a numpy 1D array and A a numpy ndarray.

A: Would this work?
>>> A
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])
>>> r
array([1, 2, 3])
>>> (A.T * r).T
array([[ 1,  2,  3],
       [ 8, 10, 12],
       [21, 24, 27]])

First row of A is multiplied by first element of r, second row by second element and so on and so forth. Just Transpose the Matrix and transpose the final result.
Beware - computationally expensive for big matrices.


text:
Q: Is there a sequence $a_k$ satisfying $e^{\lambda-\lambda^2}=\sum \limits_{k=0}^\infty \frac{\lambda^k}{k!}a_k$ for all $\lambda \in \Bbb R$?
Is there a sequence of real numbers $a_k$ satisfying $e^{\lambda-\lambda^2}=\sum \limits_{k=0}^\infty \frac{\lambda^k}{k!}a_k$ for all $\lambda \in \Bbb R$?

This is interesting because it is equivalent to asking whether there is an unbiased estimator $T(X)$ for $e^{-\lambda ^2}$ where $X \sim \operatorname{Poi}(\lambda)$. Indeed, if $e^{-\lambda^2}= \Bbb E[T] = \sum\limits_{k=0}^\infty \frac{\lambda^k e^{-\lambda}}{k!}f(k) $ then we are left we finding the sequence $a_k = f(k)$. Thus $a_k \to \infty$. I know that there is an unbiased estimator for $e^tx$ for every $t \in \Bbb R$, and so this is a natural question.
Plugging in $\lambda =0,1$ we get that $a_0=1$ and $\sum_{k=0}^\infty \frac{a_k}{k!}=1$. What other tricks might help?

A: Indeed there is; this is just the Maclaurin series for $f(z)=\exp(z-z^2)$.
This is an entire function and the series converges everywhere on the complex plane. We can be reasonably explicit.
$$\exp(z-z^2)=e^ze^{-z^2}=\sum_{j,k=0}^\infty\frac{z^j}{j!}\frac{(-z^2)^{k}}{k!}$$
so
$$a_n=n!\sum_{k=0}^{\lfloor n/2\rfloor}\frac{(-1)^k}{(n-2k)!k!}.$$
I'm not sure if one can simplify this further.

A: Yes, in fact you can just take derivatives to compute them explicitly.  You'll get $$a_k = \frac{d^k}{d \lambda^k} e^{\lambda - \lambda^2} \bigg|_{\lambda = 0}$$


text:
Q: Puppeteer getting element from elementHandle causing protocol error I'm trying to scrape a certain facebook page for its posts written by a certain user and starting with a certain word.
const puppeteer = require('puppeteer');

async function findPosts(page) {
    const USERNAME = 'test123';
    const posts = await page.$$('.userContentWrapper');
    return posts.filter(async post => {
        try {
            let usernameElement = await post.$('.fwb');
            let username = await page.evaluate(element => element.textContent, usernameElement);
            if (username === USERNAME) {
                let postElement = await post.$('[data-testid="post_message"] p');
                let postContent = page.evaluate(element => element.textContent, postElement);
                return /\[test \d+\]/.test(postContent);
            }
            return false;
        } catch(e) {
            console.log(e);
            return false;
        }
    });
}

(async () => {
    const browser = await puppeteer.launch({
        headless: false
    });
    const page = await browser.newPage();
    await page.goto('https://www.facebook.com/groups/groupid/');
    const pageTitle = await page.title();
    console.log(pageTitle);
    const posts = await findPosts(page);
    console.log(posts);
    await browser.close();
})();

I'm getting

Error: Protocol error (Runtime.callFunctionOn): Target closed. when
  I'm trying to get the usernameElement

at this line:

let usernameElement = await post.$('.fwb');

Not sure what's going wrong here, any suggestions?

A: The problem is that the filter function does not work with Promises. So the return posts.filter(...) will immediately return and after that the browser is closed. Therefore, when you try to run the $ function on the page, the page does not exist anymore and you get the Target closed error.
To make it work with async/await syntax, you could use a simple loop instead:
async function findPosts(page) {
    const USERNAME = 'test123';
    const posts = await page.$$('.userContentWrapper');
    const postsToReturn = [];
    for (let post of posts) {
        /* ... if else logic */
        postsToReturn.push(post); // instead of return true
    }
    return postsToReturn;
}


text:
Q: Problem with hough transformation on python I want to apply hough transformation to this image: 1
The code that I use is the following:
cdst = cv2.cvtColor(hull_img, cv2.COLOR_GRAY2BGR)
lines = cv2.HoughLines(hull_img, 1, np.pi / 180, 200)

a,b,c = lines.shape
for i in range(a):
    rho = lines[i][0][0]
    theta = lines[i][0][1]
    a = math.cos(theta)
    b = math.sin(theta)
    x0, y0 = a*rho, b*rho
    pt1 = ( int(x0+1000*(-b)), int(y0+1000*(a)) )
    pt2 = ( int(x0-1000*(-b)), int(y0-1000*(a)) )
    cv2.line(cdst, pt1, pt2, (0, 0, 255), 2, cv2.LINE_AA)

(where hull_img 1 is the first image that I have attached ).
But the result is : 2
Why the lines are broken? Why does not find all the lines? Am I doing something wrong? Should I change the code?
If anyone could help me i would be really grateful!
Thank you

A: I have the same problem, I followed your advice @fmw42 by adding this part of code before the hough transformation:
th3 =cv2.adaptiveThreshold(edged,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY,11,2)

contours, hierarchy = cv2.findContours(th3, cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
maxArea = 0
best = None
for contour in contours:
    area = cv2.contourArea(contour)
    if area > maxArea :
        maxArea= area
        best = contour

rect = cv2.minAreaRect(best)
box = cv2.boxPoints(rect)
box=order_points(box)
coordinates = box.tolist()

perimeter = cv2.arcLength(best,True)
epsilon = 0.01*cv2.arcLength(best,True)
approx = cv2.approxPolyDP(best,epsilon,True)

for cnt in contours:
    hull= cv2.convexHull(cnt)
    hull_img=cv2.drawContours(edged, [hull],0,(255,255,255),5)

It seems to improve, but trying it on different types of figures does not totally solve the problem. In some images, the lines found by Hough transformation do not quite follow the contour of the polygon.


text:
Q: Getting Syntax error in this python code, how to eleminate? ////// section begins /* use this afl when buy is different from cover and sell is different from short / RequestTimedRefresh( 1, onlyvisible = False ) ; _SECTION_BEGIN( "Algoji.com intraday.afl" ); intra = ParamToggle( "Activate Intraday Mode", "NO|YES" ); per10 = Param( "Trade Entry From(HHMM)", 920, 900, 2300, 1 ); per11 = Param( "Trade Entry Upto(HHMM)", 1445, 900, 2300, 1 ); per12 = Param( "Trade Exit(HHMM)", 1515, 900, 2300, 100 ); pop= ParamToggle( "Percentage or Points", "Points|Percentage"); slp = Param( "StopLoss", 0, 0, 1000, 0.1 ); tsl= Param("Trail Stop", 0, 0, 1000, 0.1); tgtp = Param( "Target", 0, 0, 1000, 0.1 ); Col = ParamColor( "Color of Modified Signals", colorYellow ); delay= ParamToggle("Trade Intrabar?", "YES|Candle Completion"); dlong= ParamToggle("Disable Long?", "NO|YES"); dshort= ParamToggle("Disable Short?", "NO|YES"); if(dlong){Buy=Sell=0;} if(dshort){Short=Cover=0;} dd= DaysSince1900(); d=prof= 0; if(delay) {Buy=Ref(Buy,-1); Sell=Ref(Sell,-1); Short= Ref(Short,-1); Cover= Ref(Cover,-1);} qt= Param("Trade Quantity", 0, 0, 1000000) ; exposure= Param("Exposure", 0, 0, 1000000) ; if(exposure>0) qt= round(exposure/ValueWhen(Day()!=Ref(Day(),-1), C)); maxl= Param("Qty using SL (MaxLoss)",0,0,100000 ); if(maxl>0 AND !pop) qt= round(maxl/slp); if(maxl>0 AND pop) { basicprice= LastValue(ValueWhen(Day()!=Ref(Day(),-1), C)); sl= slpbasicprice/100; qt= round(maxl/sl); } intraex = intra AND (TimeNum() > per12 * 100); intraen = !intra OR ( TimeNum() <= per11 * 100 AND TimeNum() >= per10 * 100 ); Buy1 = Buy; Sell1 = Sell; Short1 = Short; Cover1 = Cover; Buy=Sell=Short=Cover=0; bflag = sflag = sp=bp = 0; slarr = tgtarr = qtarr= Null; for ( i = 10; i < BarCount; i++ ) { if ( ( Cover1[i] OR intraex[i]OR( H[i] > slarr[i-1] AND (sl>0 OR tsl>0) ) OR ( L[i] < tgtarr[i-1] AND tgt > 0 ) ) AND sflag ) { Cover[i] = 1; CoverPrice[i]= C[i]; sflag = 0; d= dd[i]; prof= sp-C[i]; } if ( ( Sell1[i] OR intraex[i] OR( L[i] < slarr[i-1] AND (sl>0 OR tsl>0) ) OR ( H[i] > tgtarr[i-1] AND tgt > 0 ) ) AND bflag ) { Sell[i] = 1; SellPrice[i]= C[i]; bflag = 0; d= dd[i]; prof= C[i]- bp; } if ( Buy1[i] AND intraen[i] AND bflag == 0 ) { Buy[i] = 1; bflag = 1;         bp= C[i];       sl=slp; tgt= tgtp;      if(pop)         {sl= slpbp/100;        tgt= tgtpbp/100;} if ( slp ) slarr[i] = bp-sl; if ( tgtp ) tgtarr[i] = bp+tgt; } if ( bflag AND Buy[i]==0 ) { slarr[i] = slarr[i-1]; tgtarr[i] = tgtarr[i-1]; if(tsl>0 AND pop) slarr[i] = Max(slarr[i-1], H[i](1-tsl/100)); if(tsl>0 AND !pop) slarr[i] = Max(slarr[i-1], H[i]-tsl); } if ( Short1[i] AND intraen[i] AND sflag == 0 ) { Short[i] = 1; sflag = 1; Sp= C[i]; sl= slp; tgt= tgtp;       if(pop)         {sl= slpSp/100;        tgt= tgtpSp/100;} if ( slp ) slarr[i] = sp + sl; if ( tgtp ) tgtarr[i] = sp - tgt; } if ( sflag AND Short[i] == 0 ) { slarr[i] = slarr[i-1]; tgtarr[i] = tgtarr[i-1]; if(tsl>0 AND pop) slarr[i] = Min(slarr[i-1], L[i](1+tsl/100)); if(tsl>0 AND !pop) slarr[i] = Min(slarr[i-1], L[i]+tsl); } } Plot( slarr, "SL", Col, styleThick ); Plot( tgtarr, "TGT", Col, styleThick ); PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), Col, 0, H, Offset = 15 ); PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), Col, 0, L, Offset = 15 ); PlotShapes( IIf( Cover, shapeStar, shapeNone ), Col, 0, H, Offset = -25 ); PlotShapes( IIf( Sell, shapeStar, shapeNone ), Col, 0, L, Offset = -25 ); sig = IIf( BarsSince( Buy ) < BarsSince( Short ), 1, 0 ); messageboard = ParamToggle( "Message Board", "Show|Hide", 1 ); if ( messageboard == 1 ) { GfxSelectFont( "Tahoma", 13, 100 ); GfxSetBkMode( 1 ); GfxSetTextColor( colorWhite ); GfxSelectSolidBrush( colorDarkTeal ); // this is the box background color pxHeight = Status( "pxchartheight" ) ; xx = Status( "pxchartwidth" ); Left = 1100; width = 310; x = 5; x2 = 310; y = pxHeight; GfxSelectPen( colorGreen, 1 ); // broader color GfxRoundRect( x, y - 160, x2, y , 7, 7 ) ; GfxTextOut( ""+WriteIf(intra, "Intraday Mode Activated", "Intraday Mode Not Activated" ), 13, y-160 ); GfxTextOut( ( "Current Qty "+qt ), 13, y-140 ); GfxTextOut( ( "Last" + " Signal came " + ( BarsSince( Buy OR Short ) ) * Interval() / 60 + " mins ago" ), 13, y - 120 ) ; // The text format location GfxTextOut( ( "" + WriteIf( sig == 1, "BUY @ " + ValueWhen(Buy,C) , "SHORT @ " + ValueWhen(Short,C) ) ), 13, y - 100 ); GfxTextOut( "Stop Loss : " + WriteIf(slp==0, "Not Activated", ""+slarr), 13, y - 80 ); GfxTextOut( "Target : " + WriteIf(tgtp==0, "Not Activated", ""+tgtarr), 13, y - 60 ); GfxTextOut( ( "Current P/L : " + WriteVal( IIf( sig == 1, (C-ValueWhen(Buy,C))*qt, (ValueWhen(Short,C)-C)*qt ), 2.2 ) ), 13, y-40 ); // GfxTextOut( ( "jhjh " ), 13, y-20 ); } //section begins for auto trade instr= ParamList("Instrument Name","EQ|FUTIDX|FUTSTK|OPTIDX|OPTSTK|FUTCOM"); stag= ParamStr("Strategy Tag", "STG1"); qty= NumToStr(qt[BarCount-1], 1.0, False) ; bp= sp= NumToStr(Close[BarCount-1],1.2, False); if(dlong){Buy=Sell=0;} if(dshort){Short=Cover=0;} if(delay) {Buy=Ref(Buy,-1); Sell=Ref(Sell,-1); Short= Ref(Short,-1); Cover= Ref(Cover,-1);} global algoji; algoji = Name() + NumToStr( Interval() / 60, 1.0, False ) ; procedure aStaticVarSet( SName, Svalue ) { global algoji; StaticVarSet( Sname + algoji, Svalue ); } function aStaticVarGet( SName ) { global algoji; Var = StaticVarGet( Sname + algoji ); if ( IsNull( Var = StaticVarGet( Sname + algoji ) ) ) Var = 0; return Var; } sym = Name(); //_TRACE("t"+t); Checkdt=Nz(aStaticVarGet("lastdt")); dt = LastValue( DateTime() ); Checkdtss=Nz(aStaticVarGet("lastdtss")); dtss = LastValue( DateTime() ); Checkdtc=Nz(aStaticVarGet("lastdtc")); dtc = LastValue( DateTime() ); Checkdts=Nz(aStaticVarGet("lastdts")); dts = LastValue( DateTime() ); RTBuy = LastValue( Buy) AND Checkdt != dt; RTShort = LastValue( Short) AND Checkdtss != dtss; RTCover = LastValue( Cover) AND Checkdtc != dtc; RTSell = LastValue( Sell) AND Checkdts != dts; if ( RTCover ) {      aStaticVarSet("lastdtc",dtc );      StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE( "#"+Nz(StaticVarGet("counter"))+",SX,"+sym+",,," +bp +","+qty+","+instr+",,");    Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SX",sym,"M","",bp,qty,instr,stag); } if ( RTSell ) {   aStaticVarSet("lastdts",dts );      StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE( "#"+Nz(StaticVarGet("counter"))+",LX,"+sym+",,," +sp +","+qty+",,,");     Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LX",sym,"M","",sp,qty,instr,stag); } if ( RTBuy ) {    aStaticVarSet("lastdt",dt );    StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE( "#"+Nz(StaticVarGet("counter"))+",LE,"+sym+",,," +bp +","+qty+","+instr+",,");    Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LE",sym,"M","",bp,qty,instr,stag); } if ( RTShort ) {      aStaticVarSet("lastdtss",dtss );    StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); sp= NumToStr(Close[BarCount-1],1.2, False); _TRACE( "#"+Nz(StaticVarGet("counter"))+",SE,"+sym+",,," +sp +","+qty+","+instr+",,");    Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SE",sym,"M","",bp,qty,instr,stag); } Button = ParamToggle( "Enable Button Trading", "YES|NO" ); expiry= ParamStr("Expiry",""); strike= ParamStr("Strike",""); type= ParamStr("Option Type", ""); sym = Name()+ "|"+expiry+ "|" +strike+ "|" +type; function GetSecondNum() { Time = Now( 4 ); Seconds = int( Time % 100 ); Minutes = int( Time / 100 % 100 ); Hours = int( Time / 10000 % 100 ); SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds ); return SecondNum; } function PopupWindowEx( popupID, bodytext, captiontext, timeout, left, top ) { displayText = bodytext + captiontext; if ( ( StaticVarGetText( "prevPopup" + popupID ) != displayText) OR ( StaticVarGet( "prevPopupTime" + popupID ) < GetSecondNum() ) ) { StaticVarSetText( "prevPopup" + popupID, displayText); StaticVarSet( "prevPopupTime" + popupID, GetSecondNum() + timeout ); PopupWindow( bodytext, Captiontext + popupID, timeout, Left, top ); } } x1= Status( "pxchartleft" )+10; y1= Status( "pxcharttop" )+20; if ( Button == 0 ) { click = GetCursorMouseButtons() == 9; Px = GetCursorXPosition( 1 ); Py = GetCursorYPosition( 1 ); x2 = x1 + 60; y2 = y1 + 60; GfxSelectSolidBrush( ColorRGB( 0, 102, 0 ) ); //buy GfxSelectFont( "Tahoma", 13, 100 ); GfxSetBkMode( 1 ); GfxSetTextColor( colorWhite ); GfxRoundRect( x1, y1, x2, y2 , 7, 7 ) ; GfxTextOut( "LE", x1 + 20, y1 + 20 ); sx1 = x2; sy1 = y1; sx2 = sx1 + 60; sy2 = sy1 + 60; GfxSelectSolidBrush( ColorRGB( 255, 204, 204 ) );//sell GfxRoundRect( sx1, sy1, sx2, sy2 , 7, 7 ) ; GfxSetTextColor( ColorRGB( 153, 0, 0 ) ); GfxTextOut( "SE", sx1 + 20, sy1 + 20 ); ex1 = x1; ey1 = y1+60; ex2 = ex1 + 60; ey2 = ey1 + 60; GfxSelectSolidBrush( ColorRGB( 255, 204, 204 ) );//sell GfxRoundRect( ex1, ey1, ex2, ey2 , 7, 7 ) ; GfxSetTextColor( ColorRGB( 153, 0, 0 ) ); GfxTextOut( "LX", ex1 + 20, ey1 + 20 ); GfxSelectSolidBrush( ColorRGB( 0, 102, 0 ) );//sell GfxRoundRect( ex2, ey1, ex2+60, ey2 , 7, 7 ) ; GfxSetTextColor( colorWhite ); GfxTextOut( "SX", ex2 + 20, ey1 + 20 ); if ( px > x1 AND pxy1 AND py < y2 AND Click ) { _TRACE( "# ," + NumToStr(Nz(StaticVarGet("counter")),0,False) + ", BUY triggered from button, " );        AlertIf( 1, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 1, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 );    PopupWindowEx( "ID:1", "BUY", "Buy Triggered from Button "+Name(), 1, -1, -1 );     AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LE",sym,"M","",sp,qty,instr,stag);    } //https://algoji.com/ if ( px > sx1 AND pxsy1 AND py < sy2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", SHORT triggered from button, " );        AlertIf( 2, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 2, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 );    PopupWindowEx( "ID:3", "SHORT", "Short Triggered from Button "+Name(), 1, -1, -1 );     AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SE",sym,"M","",sp,qty,instr,stag); } //https://algoji.com/ if ( px > ex1 AND pxey1 AND py<ey2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", SELL triggered from button, " );      AlertIf( 3, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 2, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 );    PopupWindowEx( "ID:3", "SELL", "Sell Triggered from Button "+Name(), 1, -1, -1 );   AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LX",sym,"M","",sp,qty,instr,stag); } //https://algoji.com/ if ( px > ex2 AND px<(ex2+60) AND py>ey1 AND py < ey2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", Cover triggered from button, " );      AlertIf( 4, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 2, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 );    PopupWindowEx( "ID:3", "Cover", "Cover Triggered from Button "+Name(), 1, -1, -1 );     AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SX",sym,"M","",sp,qty,instr,stag); } }

A: It is not a Python, it is AFL. It will be much easier if you post it as a code.
If you run it in AFL Formula Editor it will help you to debug it - simply click "Apply" and you will have all errors highlined.
I've found that you missed some "*" in your formula.


text:
Q: using C# DLL in vc6 I have a c# dll that i can call it in vc.net (VS2010), when i try to run to run same source code in VC6 it gives error on
 IMyTestDLLPtr pIMYTESTDLL(__uuidof(CMYTestDLL));

and following is the whole code of this small utility
#include "stdafx.h"
#include <iostream>

// Import the type library in DLL
#import  "MY.TestDLL.tlb" raw_interfaces_only

using namespace My_TestDLL;
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
   // Initialize the COM interface
   HRESULT hr = CoInitialize(NULL);
   // Make a smart pointer to the EPASS interface in DLL
   IMyTestDLLPtr pIMYTESTDLL(__uuidof(CMYTestDLL));

   // Pass Params to API
   BSTR result = 0;
   hr = pIMYTESTDLL->DLLFunction(1, _bstr_t("11111111111"),  &result);

   CoUninitialize();
   // Display the results
   cout << result << '\n';
   return 0;
}

Anyone please help how i can utilize it in vc6


text:
Q: Can't import mysql.connector I've run a series of commands in my terminal prompt yet i can't get PyCharm to recognize the mysql prompt.
Running:
$ pip3  install mysql-connector-python-rf
Collecting mysql-connector-python-rf
Downloading https://files.pythonhosted.org/packages/21/79/2ff01ab7aa08db3a16b70b990c579c1024c6b2a734263cc7513a758867de/mysql-connector-python-rf-2.2.2.tar.gz (11.9MB)
100% |████████████████████████████████| 11.9MB 89kB/s
Building wheels for collected packages: mysql-connector-python-rf
Running setup.py bdist_wheel for mysql-connector-python-rf ... done
Stored in directory: /home/deuser/.cache/pip/wheels/87/58/fb/d95c84fad7e1bebfed324c13e107ebb08e1997c9226532859a
Successfully built mysql-connector-python-rf
Installing collected packages: mysql-connector-python-rf
Successfully installed mysql-connector-python-rf-2.2.2
So i succesfully install it yet it remains unrecognized in Pycharm

A: You need to install the library for your project's environment. Open Preferences -> Interpreter -> Select your system or create new virtualenv and install the library here


text:
Q: Unable to use facebook connect application on IE8: xd_receiver popup does not close In both Opera and Firefox, my facebook connect application successfully loads xd_receiver and everything works.  In IE8, it loads xd_receiver in the popup as expected, but the popup does not close and the data is not transmitted to my app.  The url the popup is visiting is the correct xd_receiver page, as is hinted by the fact that everything works in Firefox and Opera.  Any tips?

A: For IE8:
Tools > Internet Options > Security > Local Intranet > Sites (Button) > Automatically Detect...
-> uncheck this, then it works fine
grrr IE8!

A: It was because I was testing locally.  IE8 had some special security rules that tend to break local apps.


text:
Q: how to get data from redis zset with score list? I want to get data from zset with a score list, e.g.
zadd zset 1 a 2 b 3 c 4 d

I want a command like
'zrange zset [2, 4]'

and the result is
b, d

Thanks!

A: There is a ZRANGEBYSCORE command for just that.

A: you can use a piece of code to do this, like :
for score in score_list
    members = zrangebyscore(zset, score, score)
    member_list += members

the time cost of ZRANGEBYSCORE is O(LOG(N)+M) and M is the count of members returned. so we can say the cost in our zrangebyscore is O(LOG(N)), N is the size of zset.
So the overall time cost is O(M*LOG(N)) which M is the length of score_list. It will be the best time cost.
The only bad thing is we cost M RTTs in network transport. We can use the pipeline to speedup the queries.
redis document says:

A Request/Response server can be implemented so that it is able to process new requests even if the client didn't already read the old responses. This way it is possible to send multiple commands to the server without waiting for the replies at all, and finally read the replies in a single step.

So if you use pipeline tech, It will only cost one RTT time. And I think every language's client for redis has implemented the pipeline. good luck !