text:
Q: Trouble running a batch file with a space in the path and space in the argument I am trying to run a batch file that's located in:
C:\Test Batch\BatchTest.bat

That will copy a file from another specified location, let's say
C:\Users\UserName\Desktop\Company Downloads\downloadedDoc.doc

I can run the batch file as:
cmd  /c start "" "C:\Test Batch\TestBatch.bat"

And the batch actually does run.
But when I try to add an argument for it to copy like this:
cmd  /c start "" "C:\Test Batch\TestBatch.bat" "C:\Users\User Name\Desktop\Company Downloads\downloadedDoc.doc"

I get:
'C:\Test' is not recognized a an internal or external command, operable program or batch file.

Ultimately the batch file and file to be copied will be specified by a user and will likely have spaces in the names or path. So a simple answer to use paths without spaces will not suffice.

A: Try changing the startup directory with the /d argument to start like so:
cmd /c start "" /d"C:\Test Batch\" "TestBatch.bat" "C:\Users\User Name\Desktop\Company Downloads\downloadedDoc.doc"

The start command has some oddities parsing quotes.

A: It's a known feature of cmd.exe which is started by start.exe. This happens only when the command has a space in its name or path and at least one of the arguments is quoted.
A workaround is to replace the command with a call.
start "" CALL "C:\Test Batch\TestBatch.bat" "C:\Users\User Name\down.doc"


text:
Q: How to prevent state reset while navigating between screens? react native In react native app, I have a home screen and a second screen that the user uses to add items that should be displayed on the home screen. The problem is when I add items in the second screen and go to the home screen I can see the added items but when I go again to the second screen to add other items, it deletes the previously added items.
Any help to explain why this happens and how to handle it?
Thanks in advance
Here's the code of the app.
export default function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen name="Home" component={Home} />
        <Stack.Screen name="AddItem" component={AddItem} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

and here's the home screen component
class Home extends Component {
  render() {
    const { expenseList } = this.props.route.params || '';
    return (
      <View style={styles.container}>
        <Text style={styles.text}>Budget:</Text>
        <Button
          title="+"
          onPress={() => this.props.navigation.navigate('AddItem')}
        />
        <View>
          {expenseList === '' && (
            <TouchableOpacity
              onPress={() => this.props.navigation.navigate('AddItem')}>
              <Text>Create your first entry</Text>
            </TouchableOpacity>
          )}
          {expenseList !== '' && (
            <FlatList
              style={styles.listContainer}
              data={expenseList}
              renderItem={(data) => <Text> title={data.item.name} </Text>}
            />
          )}
        </View>
      </View>
    );
  }
}

and the second screen
class AddItem extends Component {
  state = {
    name: '',
    amount: '',
    expenseList: [],
  };

  submitExpense = (name, amount) => {
    this.setState({
      expenseList: [
        ...this.state.expenseList,
        {
          key: Math.random(),
          name: name,
          amount: amount,
        },
      ],
    });
  };

  deleteExpense = (key) => {
    this.setState({
      expenseList: [
        ...this.state.expenseList.filter((item) => item.key !== key),
      ],
    });
  };
  render() {
    return (
      <View style={styles.container}>
        <TextInput
          style={styles.input}
          onChangeText={(name) => this.setState({ name })}
          value={this.state.name}
          placeholder="Name"
          keyboardType="default"
        />
        {this.state.name === '' && (
          <Text style={{ color: 'red', fontSize: 12, paddingLeft: 12 }}>
            Name is required
          </Text>
        )}
        <TextInput
          style={styles.input}
          onChangeText={(amount) => this.setState({ amount })}
          value={this.state.amount}
          placeholder="Amount"
          keyboardType="numeric"
        />
        {this.state.amount === '' && (
          <Text style={{ color: 'red', fontSize: 12, paddingLeft: 12 }}>
            Amount is required
          </Text>
        )}

        <Button
          title="Add"
          style={styles.btn}
          onPress={() => {
            if (
              this.state.name.trim() === '' ||
              this.state.amount.trim() === ''
            ) {
              alert('Please Enter the required values.');
            } else {
              this.submitExpense(
                this.state.name,
                this.state.amount
              );
            }

          }}
        />
        <Button
        title="Go to Dashboard"
          style={styles.btn}
        onPress = {() => { this.props.navigation.navigate("Home", {
                expenseList: this.state.expenseList,
              });}}
        />
        <FlatList
          style={styles.listContainer}
          data={this.state.expenseList}
          renderItem={(data) => <Text> title={data.item.name} </Text>}
        />
      </View>
    );
  }
}

A: You have a few options:
1- Use Redux:
https://react-redux.js.org/using-react-redux/connect-mapstate
2- Save your state in the AsyncStorage and get it wherever you want
3- Pass your state as param in the route:
navigation.navigate('Details', {
            itemId: 86,
            otherParam: 'anything you want here',
          });

redpajama_set_name: RedPajamaStackExchange


text:
Q: iOS UITableView - crash when inserting new section with error message which may indicate that I should call moveSection:toSection: method I reload, insert and delete table view's rows and sections in a single begin/end update block. I do not call moveSection:toSection: nor moveRowAtIndexPath:toIndexPath: method.
I am aware that deletion and reloading of existing cells are being executed first, regardless of the order of method calls in update block. I do not insert rows for the new section that is inserted. Also, I am updating data source before table view update block.
Deletion and reloading work just fine for me, but I have a problem with inserting new sections. I got error messages of type:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 5.  The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (3), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'

It is interesting that I do not delete or reload any table view's rows and sections in the corresponding table view update block. Also, there is 1 row in all sections that come before section 5. New section was inserted at index 0. So it seems to me that I might be missing moveSection:toSection: method call..?
I couldn't find more complex examples of simultaneous inserting, deleting and reloading rows and sections in a single update block on Internet, so I would really appreciate any suggestions and links to the examples that could guide me how to handle more complex table view updates.


text:
Q: Determine the varying area of the shaded region How to estimate the area of the shaded region shown in the attached Figure?

Note that in the figure, $p$ has a maximum and minimum values of $p_a$ and $p_b$ respectively. Moreover, $p$ follows a Gaussian distribution function of the form:
$$
p =  \frac{\alpha}{\beta \sqrt {2\pi}} e^{-\frac{(\theta-\pi)^{2}}{2\beta^{2}}}+p_a
$$
Yet another limitation is $p_a$ could be greater than the radius of the outer circle (i.e. $p_a > D/2$). I tried the following approach:
$$
A =  2 \int_0^\pi p\ R\ d\theta
$$
However, I feel the solution is valid only if $p_a$ < $R$ (i.e. the radius of the circle). Am I right? If yes, how to approach if $p_a$ > $R$. Any hint would be highly appreciated.

A: If $p(\theta)$ is the annulus thickness as a function of the angle, symmetric around $\theta=0$, then the annulus area is given by:
$$
area=2\int_0^{\pi}\int_{R-p(\theta)}^R r\,dr\,d\theta=
2\int_0^{\pi} \left(Rp(\theta)-{1\over2}p^2(\theta)\right)\,d\theta,
$$
but that doesn't work (of course) for $p(\theta)>R$, because a negative radial coordinate is a nonsense.
EDIT.
But if $p(\theta)>R$ for every $\theta$ then of course:
$$
area=2\int_0^{\pi}\int_{R}^{p(\theta)-R} r\,dr\,d\theta=
2\int_0^{\pi} \left({1\over2}p^2(\theta)-Rp(\theta)\right)\,d\theta.
$$


text:
Q: Angular 2 HTTP post no HTTP-resource found I am using Angular 2 in order to send http requests to the server.
The server is running with ASP.Net.
My API:
public class LagerController : ApiController
{
    public IHttpActionResult RepHistorie(string vnr, string lagerort)
    {
        ...
    }
}

So I would call the API with
http://123.456.7.89/api/lager?vnr=W17291092373&lagerort=0382691395

This works fine when using a tool called postman with wich you can test API's.
But when making a post request with Angular 2, it doesn't work.
It says that the HTTP-resource is not found.
Angular 2:
submit() {
  var body = 'vnr=W17291092373&lagerort=0382741400';

  var link = 'http://123.456.7.89/api/lager';
  this.http.post(link, body)
    .subscribe(data => {
      console.log(data);
    }, error => {
      console.log("Oooops!");
    });
}

It seems like the parameters aren't added correctly.
Edit: Changed tag

A: This needs clarification, since the API above seems to be a GET Request.
In case it is a POST Request , then you should use the whole URL while running the API
In case you want to submit an object , you should use [FromBody] as a parameter
Example
[HttpPost]
public IHttpActionResult( [FromBody]YourObject item ) {

}

====
Client-side
var postUrl = 'http://123.456.7.89/api/lager?vnr=W17291092373&lagerort=0382691395';
var postObject = {};
http.post(postUrl,postObject)

For GET request where you would like to use QueryString
[HttpGet]
public IHttpActionResult RepHistorie([FromQuery]string vnr,[FromQuery]string lagerort){
                ...
}

====
// Query string can be built using RequestOptionsArgs as well
var builtUrl = 'http://123.456.7.89/api/lager?vnr=W17291092373&lagerort=0382691395';
http.get(builtUrl)

Alternative way is to
var getUrl = 'http://webapi/api/lager';
var requestOptions = {};
http.get(getUrl,requestOptions);

Reference:

*

*Angular HTTP: https://angular.io/api/http/Http , check get() and post() methods

*RequestOptionsArgs : https://angular.io/api/http/RequestOptionsArgs


text:
Q: Showing $\mathbf Q(\sqrt2,\sqrt3)=\mathbf Q(\sqrt2+\sqrt3)$
Showing $\mathbf Q(\sqrt2,\sqrt3)=\mathbf Q(\sqrt2+\sqrt3)$

BUT I want to show this using The Theorem of the Primitive Element,

So I have to verify that $c$ cannot be $1$ and I need the $\mathbf Q$-monomorphisms, what are these ?

A: Well, there's a mistake in my argument which is detailed in the comment section.
I think it is beneficial to leave this answer as is in case somebody comes upon this and can then learn from it too.
My original post:
Here's one way to do it:
Theorem
Let $F$ be an infinite field. If $F(\alpha_1,\alpha_2)$ is a simple and algebraic extension of $F$ then $\exists t \in F$  s.t $F(\alpha_1,\alpha_2) = F(\alpha_1 + t\alpha_2)$.
This can be generalized for any n BTW
Proof:
I'll assume you know (since we're using the primitive element theorem) that under these conditions there is only a finite number of sub-fields in $F$.
$F$ is infinite then $\exists t_1 \neq t_2 \in F$ s.t $F(\alpha_1 + t_1\alpha_2) = F(\alpha_1 + t_2\alpha_2)$.
Then $\alpha_2 = \frac{(\alpha_1 + t_1\alpha_2)-(\alpha_1 + t_2\alpha_2)}{t_1-t_2} \in F(\alpha_1 + t_1\alpha_2)$ then clearly $\alpha_1 \in F(\alpha_1 + t_1\alpha_2)$ as well.
This ends that theorem.
Now $\mathbb{Q}(\sqrt{2},\sqrt{3})$ applies to the above by the primitive root theorem.
Then $\mathbb{Q}(\sqrt{2} + \sqrt{3}) \subset \mathbb{Q}(\sqrt{2},\sqrt{3}) = \mathbb{Q}(\sqrt{2}+ t\sqrt{3})$
Now notice that $t \neq 0$ necessarily and that $t\sqrt{2} + t\sqrt{3} = a_0 + a_1\sqrt{2} + a_1t\sqrt{3} $
implying $ 0 = a_0 + (a_1-t)\sqrt{2} + (a_1t-t)\sqrt{3} $
 and as $\{a_0,\sqrt{2},\sqrt{3}\}$ is a linearly independent set we have $a_1 = t = a_1t$ then $t=1$


text:
Q: Change window title for ActivePivot Live I want to change the window title for ActivePivot Live, so that users having multiple Live instances open, can better find the right one.
I've tried calling Window.setTitle from my GinBootstrappers.afterApplicationLoaded method, but that seems to only show for a second or less, before being changed back to "ActivePivot Live"

A: Found my own answer.
GinBootstrapper.APPLICATION_NAME is public and not final,
so in my Bootstrapper, I can simply add this line to the constructor:
APPLICATION_NAME = "My Application Name";

A: The window title is set by the application and it is not possible to change it.


text:
Q: What to do with .desktop files that comes in tar.gz I recently downloaded Blender from its website and when I unpacked the tar.gz archive I found out that there is a blender.desktop file. I know that it is used for creating menu or desktop shortcuts. I just don't know how can I use .desktop files.

A: What are .desktop files (launchers)
.desktop files are text configuration files that, when properly installed, inform the menu system of the desktop on the existence of an application on the system.
The desktop environment will populate its application menu based on the information found in .desktop files present in system folders (including /usr/share/applacations), or in the folder $HOME/.local/share/applications in the user's home folder. When the user clicks the menu item, the application is launched based on the information contained in the .desktop file.
What to do with your desktop file

*

*Move it to the folder ~/.local/share/applications.

*Check whether the Exec= line is correctly pointing to the executable. Open your .desktop file with a text editor. Make sure that the line starting with Exec= points to the actual executable file of the program. If the executable is in a folder included in the the search PATH (issue echo $PATH in the terminal to see the search path), it is sufficient to include the name of the executable. Else, the full path of the executable must be provided.

If the Exec= line points to a correct executable, the launcher will automatically appear in your application menu.


text:
Q: Dovecot can't receive external mails, AddressValueError After updating
from dovecot-1:2.2.10-7.el7.x86_64 to 1:2.2.10-8.el7.x86_64
from dovecot-mysql-1:2.2.10-7.el7.x86_64 to 1:2.2.10-8.el7.x86_64
from dovecot-pigeonhole-1:2.2.10-7.el7.x86_64 to 1:2.2.10-8.el7.x86_64
I can not receive emails from external mail addresses. Sending mails works fine as well as receiving them when they are send from a local mail address.
In /var/log/maillog I have the following Error:
Oct 30 15:11:21 hostname postfix/smtpd[28227]: connect from sonic304-22.consmr.mail.ir2.yahoo.com[77.238.179.147]
Oct 30 15:11:21 hostname postfix/smtpd[28227]: Anonymous TLS connection established from sonic304-22.consmr.mail.ir2.yahoo.com[77.238.179.147]: TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)
Oct 30 15:11:21 hostname policyd-spf[28530]: Traceback (most recent call last):
Oct 30 15:11:21 hostname policyd-spf[28530]:  File "/usr/libexec/postfix/policyd-spf", line 707, in <module>
Oct 30 15:11:21 hostname policyd-spf[28530]:    instance_dict, configData, peruser)
Oct 30 15:11:21 hostname policyd-spf[28530]:  File "/usr/libexec/postfix/policyd-spf", line 419, in _spfcheck
Oct 30 15:11:21 hostname policyd-spf[28530]:    res = spf.check2(ip, helo_fake_sender, helo, querytime=configData.get('Lookup_Time'))
Oct 30 15:11:21 hostname policyd-spf[28530]:  File "/usr/lib/python2.7/site-packages/spf.py", line 297, in check2
Oct 30 15:11:21 hostname policyd-spf[28530]:    receiver=receiver,timeout=timeout,verbose=verbose,querytime=querytime).check()
Oct 30 15:11:21 hostname policyd-spf[28530]:  File "/usr/lib/python2.7/site-packages/spf.py", line 378, in __init__
Oct 30 15:11:21 hostname policyd-spf[28530]:    self.set_ip(i)
Oct 30 15:11:21 hostname policyd-spf[28530]:  File "/usr/lib/python2.7/site-packages/spf.py", line 405, in set_ip
Oct 30 15:11:21 hostname policyd-spf[28530]:    self.ipaddr = ipaddress.ip_address(i)
Oct 30 15:11:21 hostname policyd-spf[28530]:  File "/usr/lib/python2.7/site-packages/ipaddress.py", line 163, in ip_address
Oct 30 15:11:21 hostname policyd-spf[28530]:    ' a unicode object?' % address)
Oct 30 15:11:21 hostname policyd-spf[28530]: AddressValueError: '77.238.179.147' does not appear to be an IPv4 or IPv6 address. Did you pass in a bytes (str in Python 2) instead of a unicode object?
Oct 30 15:11:21 hostname postfix/spawn[28087]: warning: command /usr/libexec/postfix/policyd-spf exit status 1
Oct 30 15:11:21 hostname postfix/smtpd[28227]: warning: premature end-of-input on private/policy-spf while reading input attribute name

Any ideas what's the cause of the error?

A: I have fixed my problem. As stated in the comments, the corresponding Bug report is https://bugs.centos.org/view.php?id=12393.
The fix provided in the comment by Yohei TOMIYAMA works for me.
Before you fix it, make sure it's the same bug. The following versions of the packages must match:
yum list installed | grep pypolicyd-spf
pypolicyd-spf.noarch   1.3.2-2.el7   @epel

yum list installed | grep python-ipaddress
python-ipaddress.noarch   1.0.16-2.el7  @base

The package python-ipaddress may only be required by pypolicyd-spf or this fix will break anything else. You can check this with
rpm -q --whatrequires python-ipaddress
pypolicyd-spf-1.3.2-2.el7.noarch

Now the fix:
rpm -e --nodeps python-ipaddress
vim /usr/libexec/postfix/policyd-spf

At line 40 change the line as following:
- import ipaddress
+ import ipaddr as ipaddress

That's it. Depending on the configuration of the mail-provider they retry sending the mail in intervals. After an hour or so most of the missing mails should be received.
As mentioned above, thanks to Yohei TOMIYAMA for providing this fix.


text:
Q: $PT$ and Lorentz transformation and causality in QFT This question was asked twice already, here: A question about causality and Quantum Field Theory from improper Lorentz transformation , and here: Causality and Quantum Field Theory. But I didn't get the answer to the question troubling me.
We were discussing causality in class, specifically for a scalar field with no interactions:
$$\left<0|[\phi(x),\phi(y)]0\right>=D(x-y)-D(y-x)$$
Where we have the measure:
$$ [\phi(y),\phi(x)]=\int\frac{d^4p}{(2\pi)^4}\delta(p^2-m^2)\left(e^{-ip\cdot(x-y)}-e^{-ip\cdot(y-x)}\right).$$
The measure is Lorentz invariant and only depends on $(x-y)$, and there exist a transformation for spacelike separated events where $(x-y)\to-(x-y)$ and then it's easy to see that the measure must be equal to zero. That I agree, but what about the other method
where I can use an improper Lorentz transformations? As far as I know, Lorentz transformations are the transformations that keep the metric the same, this implies that the transformation $\Lambda=-I_{4x4}$ is a Lorentz transformation:
$$\eta'=\Lambda\eta\Lambda^{T}=-I_{4x4}\eta(-1)I_{4x4}=I_{4x4}\eta I_{4x4}=\eta$$
And here I didn't assume spacelike separation. Why is this not valid? Is the $\mathcal{PT}$ transformation not physical?


text:
Q: are there side-effects to remapping/aliasing less to vim? I added the following to .bashrc to remap less to vim
alias vsi='vim -R -c ":map Q :q!<enter>" -' # Vim Standard Input [readonly]
alias less='vsi'

the reason is that I don't want to maintain two config files with my key bindings preference, and I find vim more useful and predictable (often I can't find the looked-up text because it's not highlighted or not in view)
it seems that less was developed after vi and more, because they couldn't open "enormous" files, what was considered "enormous" back then that vi and more couldn't handle? and is it not an issue today?
will this alias break scripts or programs that depend on less?

A: The viewing of incomplete input is an issue:
seq 10000 | pv -qL 10 | less

A: It will not break scripts or commands that depend on less since shell aliases would not be expanded for scripts or other commands.
Shell aliases are only there for convenience in your interactive shell session. They are not carried over into shell scripts and commands that you start from that shell session because aliases are not part of the environment that is inherited by child processes.
The only issue would be if you yourself forgot that you had this alias and then proceeded to use it with extra options in an interactive shell session.  These options would then be given to vim.
You may also consider using view rather than vim -R.

Regarding "enormous files", these are files that are of sizes larger than your RAM, or at least of the same size a sizeable chunk of the available RAM.  Traditionally, editors would load the whole file into memory as you opened them, and some still do this.  Opening large files would therefore

*

*be slow

*potentially run the editor into a resource restriction (out of memory)

I believe that the Vim editor is working around this using its "swap files" (the ones that you may have seen with the .swp filename suffix).  See :help swap-file in Vim.
The less pager will, by default, keep all read data in memory when reading from a pipe.  If more data is read than there is available RAM for, you will have issues.  Fortunately, there is a -B (or --auto-buffers) option that forces less to only keep the last portion of the read data in memory. However, this obviously makes it impossible to jump back to previously viewed lines of input.
The more pager is sometimes less in disguise (just a hard link to the less binary). On systems where more is actual more, the pager does not allow scrolling backwards when viewing data read from pipes.
Neither less nor more needs to read a file completely to be able to view the contents of it. Both would seek through the file to the appropriate location.

A: It could lead to unexpected behavior, for instance if the less command is issued with switches. I like to run less with the "-N" switch for line numbers, like so: less -N filename. When I alias less to vim, I don't get my expected line numbers (for vim, the "-N" switch is for "No-compatible mode" which makes vim "behave a bit better, but less Vi compatible" according the man page). Can you be confident your use case will never highlight less and vim's divergent behavior?


text:
Q: C# function error as cannot redirect to another page so I am still new to C# and I currently testing out my project regarding a search function when user key in what they want to find out in a the textbox and press enter and it will redirect them to my search page. However everytime i tried to type things in the search button and press enter what came out is
    http://localhost:51182/Default.aspx
to
    http://localhost:51182/Default.aspx?ctl00%24search=(whatever I keyed).
As the search function is in the masterpage.aspx i cannot use asp:buttons or what.
This is my code in the masterpage.
<form class="navbar-form navbar-right">
      <input type="text" id="search" class="form-control" placeholder="Search..." runat="server">
            <button class="btn btn-default" type="submit" id="Button1" onserverclick="Button1_OnClick"></button>
         </form>

This is my c# code for masterpage.
protected void Button1_OnClick(object sender, EventArgs e)
{
  //The code was commented out since the search name was not able to be recognized in my webform input id so i tried to deal with the response first.
  //String searchtext = search;
  //String Search = Server.MapPath("Website\\HTML\\SearchEngine.aspx");
   Response.Redirect("~/Website/HTML/SearchEngine.aspx?search=");
}

I mainly put the codes that I think that matters and if required the other part just say so. In addition to it if this is a duplicate to other question, I am sorry as I been trying it out on some other question answer for their fixes to this but i wasn't able to get my working then I submit this question.
Hope you guys can help me out.

A: <form class="navbar-form navbar-right">... </form>

In ASP.NET WebForm, you cannot use another form tag, since there is a main form tag with runat="server" already.
The easiest way to achieve is to use Panel. When user types inside textbox and press Enter key, it will call Button1_OnClick event.
For example,
<asp:Panel ID="SearchPanel" runat="server" DefaultButton="SearchLinkButton">
    <asp:TextBox runat="server" ID="SearchTextBox" CssClass="form-control"
        placeholder="Search..." />
    <asp:LinkButton runat="server" ID="SearchLinkButton" CssClass="btn btn-primary"
        OnClick="SearchLinkButton_Click">

    </asp:LinkButton>
</asp:Panel>

A: So you can't have nested forms, but that's not to say that you can't have multiple forms on the same page, they just can't overlap, and only one can be an ASP.NET Form[runat=server]. Just make sure the search form, which can be a vanilla HTML form, is placed in the master page outside of any Form[runat=server] and format the search form like so:
<form class="navbar-form navbar-right" action="/Website/HTML/SearchEngine.aspx">
      <input type="text" name="search" class="form-control" placeholder="Search..." />
      <button class="btn btn-default" type="submit"></button>
</form>


text:
Q: How can I get a value based on two other columns when one column value is ambigous in Python? I want to assign a variable depending on two column values. The input table df_input looks like this:
import pandas as pd
df_input = pd.DataFrame(
    {
        "entity": [
            "Table_A",
            "Table_A",
            "Table_A",
            "Table_B",
            "Table_B",
            "Table_C",
        ],
        "field": [
            "Column 1",
            "Column 2",
            "Column 3",
            "Column 1",
            "Column 2",
            "Column 1",
        ],
        "type": ["new",
            "new",
            "new",
            "old",
            "new",
            "old",],
    }
)

Table_A = pd.DataFrame(
                        {
                        "Column 1": [123],
                        "Column 2": ["XYZ"],
                        "Column 3": [True],
        }
)

This is how the Data looks like.

My goal is to determine the type, because certain functions are triggered depending on this value. But that is outside the scope for this question. My problem right now is that I want the type based on the entity and the field. So I tried this piece of code:
for field in df_input.field:
    print(f"{field=}")
    if field == Table_A.columns:
        type_variable = df_input.iloc[field]['type']
        print(f"{type=}")

In this case Table_A is a table which will be transformed based on the type value. But it is out of scope for this question.  All I receive is this error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Output:
new
new
new
old
new
old

I know why this error occurs. Right now I am not able to solve this issue. I would like to achieve that the type_variable will be output, depending on the table and the column so I can move on with this variable in the next function. Can anybody help me with that issue?

A: You wrote
    if field == df_test.columns:

The question is unclear, but perhaps you wanted in:
    if field in df_test.columns:

You might be better off mapping with just a python dict,
rather than df_test.


text:
Q: using Zgrep and awk to parse a .tgz file and print first row I would like to use Zgrep and Awk to print specific lines.
I use the below script. However, I am not able to print the specific line requirement.
zcat SYS.20210519.tgz | awk '/11055/ && /2.5.5.5/'
It would be nice if someone could help. Thanks.
File name   :  SYS.20210519.tgz
File INPUT :
20210519 072532  11055  ERROR   Connection is not writable, error[grpId[2.5.5.5/49.3.14.13:17126] connId[142706130] testMode[true] connInfo[ConnInfo[connId=142706130, connGrp=2.5.5.5/49.3.14.13:17126,

File output (Needed) :
20210519 072532  11055  ERROR   Connection is not writable, error[grpId[2.5.5.5/49.3.14.13:17126]

A: With your shown samples, could you please try following. Using zcat to read your Input_file then sending its output as standard input to awk program. Where using match function to match regex, which will print till value of error[grpId till ] occurrence.
zcat Input_file |
awk 'match($0,/.*error\[grpId\[[^]]*\]/){print substr($0,RSTART,RLENGTH)}'


text:
Q: Is there a collection of measurable not necessarily nested but converging sets such that we cannot permute measure and limit We know that for $\{E_n\}_{n\geq0}$ Lebesgue measurable sets s.t. $E_0\subset E_1\subset...$ we have $\lim\limits_{n\rightarrow\infty}E_n=\bigcup\limits_{n=0}^{\infty}E_n$ and $\mu(\lim E_n)=\lim(\mu(E_n))$
Similarily if $E_0\supset E_1\supset...$ and $\mu(E_0)<\infty$ we have $\lim\limits_{n\rightarrow\infty}E_n=\bigcap\limits_{n=0}^{\infty}E_n$ and $\mu(\lim E_n)=\lim(\mu(E_n))$
But what if we lose the property of nestedness? What would be some interesting examples of collections of sets where we cannot permute limit and Lebesgue measure?

A: An example: $E_n=[n,n+1]$
Then $\mu(E_n)=1$ for every $n$ but $\lim_{n\to\infty}E_n=\varnothing$ so that $\mu(\lim_{n\to\infty}E_n)=\mu(\varnothing)=0$.

edit:
With the lemma of Fatou it can be shown that:$$\mu(\liminf E_n)\leq\liminf\mu(E_n)\tag0$$
If some $c>0$ and some integer $n_0$ exists such that $n>n_0\implies E_n\subseteq[-c,c]$ then this can also be applied on the sets $[-c,c]-E_n$ leading to: $$\mu(\liminf E_n)\leq\liminf \mu(E_n)\leq\limsup\mu(E_n)\leq\mu(\limsup E_n)<\infty\tag1$$
You are dealing with a convergent sequence of measurable sets iff $\liminf E_n=\limsup E_n$ so in that case $(1)$ implies that: $$\mu(\lim E_n)=\lim \mu( E_n)$$

This shows you that it is somehow inevitable to come up with "sets that dissapear to infinity" for an example that you ask for.


text:
Q: Rails: render .HEIC images in browser tranforming to jpg from Cloduinary using image_tag I'm currently trying to display a HEIC image in the browser via Cloudinary. According to the documentation one can change the format of the image to display as jpg, The documentation also states support for conversion of .HEIC images. However, when I try to use the fetch_format option from Cloudinary the browser still not rendering the HEIC image as JPEG although the image is there. This is what I tried:
<%= image_tag post.image, :fetch_format=> 'jpg' , class: "card-home__img" %>

and also
<%= cl_image_tag(url_for(post.image), :format => :png ,:type => 'fetch', class: "card-home__img") %>

Without success, how can I render an image as jpg format from cloduinary?
althought the AnalyzeJob from ActiveStorage kicks in the file still uploads but is unable to render as jpg
Redirected to http://res.cloudinary.com/XXXXXXXXX/image/upload/xxxxxxxxxxxq3r4.HEIC
Completed 302 Found in 24ms (ActiveRecord: 16.1ms | Allocations: 2588)
[ActiveJob] [ActiveStorage::AnalyzeJob] [ac0d5880-xxxxxxxxxxxxxxxxxxxxxxxxxx]   Cloudinary Storage (338.6ms) Downloaded file from key: kjpith3bxxxxxxxxxxxxxxxx
[ActiveJob] [ActiveStorage::AnalyzeJob] [ac0d5880-a243-4fef-xxxxxxxxxxxxxxxxxxxx] Skipping image analysis because ImageMagick doesn't support the file


text:
Q: $17!=3556xy428096000,$then $(x+y)$ equals?(without using a calculator) $17!=3556xy428096000,$then $(x+y)$ equals?
a)$15$ b)$6$ c)$12$ d)$13$
With help of calculator $(x+y)$ can be easily calculated as $15$.But without a calculator,I can only conclude that the sum of digits $(3+5+5+6+x+y+4+2+8+9+6)$ is a multiple of $3$, & excluding $(x+y)$ the sum of the digits $(3+5+5+6+4+2+8+9+6) =48$.Thus excluding option d) the ans can be any of a),b) or c).
Please help me to find the exact answer.
Thank you

A: First use the fact that the factorial is divisible by $9$, and therefore the digit sum is divisible by $9$.
Then use the fact that the number with decimal representation $abcdefg\dots$ is divisible by $11$ if and only if $a-b+c-d+e-f+\cdots$ is divisible by $11$.

A: Actually, the number was copied incorrectly (somehow) and it was driving me crazy trying to figure out what I was doing wrong.
Since $17 > 13$, $17!$ must be divisible by $7 \cdot 11 \cdot 13 = 1001$.  That means if we take the digits preceding the trailing zeros, and place them in groups of three, like so—$355, 6\text{XY}, 428, 096$—the alternating sums must be the same modulo $1001$.  We have, then,
$$
355+428 = 6\text{XY}+96
$$
and then $\text{XY} = 87$.

A: Testing divisibility by 9 gives
$$
48 + x + y \equiv 0 \pmod {9}.
$$
Testing divisibility by 11 gives
$$
12 - x + y \equiv 0 \pmod {11}
$$
So $x - y \equiv 1 \pmod {11}$ and $x + y \equiv 6 \pmod{9}$.
Since $x, y$ are both digits, $x = 1 + y$, and $x + y$ is odd.


text:
Q: Which one of these is the phase 1? Which one of these is the phase 1? And why isn't there a neutral wire at all? The cable is Chinese. The device it powers is a 3-phase motor that powers hydraulics. I am sorry for asking this question here, but I don't know a better place. I have never come across this kind of color code. There is a connection between the black and the grey cable resistance is 230 ohms.
To put my question in a more technical way:
is it possible, from just the view on the colored wires in the motor cable, to deduct the internal design of the motor? What if I measured the DC resistances between all these four wires with a simple multimeter?

A: just hook it up. if the motor runs in the wrong direction, just reverse 2 of the phases

A: Assuming this is a standard colour code it looks to me like we have green, blue, red, black. Three-phase motors will often not have a neutral.
We know that green is going to be a protective earth wire.
This leaves blue, red, and black. The United States of America and Canada each have these colours:
The United States of America:

 1. Black, 2. Red, 3. Blue

Canada:

 1. Red, 2. Black, 3. Blue

As mentioned to you, you won't know which is correct without consulting the manufacturer but I think you can take a fairly educated guess that one of these is correct. Also, @Rolan points out a great point. If you choose the wrong combination the motor will just run in reverse. Simply swap two phases to correct it.


text:
Q: How do i add dll file to my project forever? I have this code in constructor:
            InitializeComponent();

            textBox3_text_valid = 0;
            label8.Visible = false;
            label8.Visible = false;
            Logger.exist();

I added to my project a reference dll OpenHardwareMonitor.dll
The problem is that the dll is in my debug directory.
But when i Rebuild Solution and Save All
And then send the project exe file only to my brother or running this program in my pc after i deleted the debug directory im getting error that the OpenHardwareMonitor.dll is missing.
In the properties in my project under reference on openhardwaremonitor.dll i see:
Aliases : Global
Copy Local : True
Ember Interop : False
How can i add the dll to the project to the exe file or something so i wont need to send it to my brother the dll ?
And if i must send my brother the dll file where should he put it ? He dosent have the Debug directory.

A:
The problem is that the dll is in my debug directory.

Don't do that then. I would suggest you create a lib directory or something like that, and add a reference to the library from there. By default, that will copy it when you build (i.e. Copy Local will be true).
In general, you should never be manually copying things into your output directories - you should assume they can be wiped at any time by the build process. Instead, put things into directories which you "own" and let the build process copy them.
Also, where possible you could use nuget for third party libraries - that makes managing them somewhat simpler.

A: you should create a folder in your solution or your project , then copy your dll into this folder. right click on your project and select properties, go to the reference paths tab, select path of this folder and then click add folder button.


text:
Q: What do I Need to Return an Object with a unique_ptr Member? Let's say that I have this object:
struct foo {
    std::unique_ptr<int> mem;
    virtual ~foo() = default;
};

I can no longer return a foo object created in a function:
foo make_foo() {
    foo result;

    result.mem = std::make_unique<int>({});
    return result;
}

As may be indicated I need the destructor to be virtual because this will be a base class. But even if I'm using the default destructor, that's not enough, I still can't return an object created in a function.
I get the error:
error C2280: foo::foo(const foo &): attempting to reference a deleted function

Is there a way to navigate around this issue?

A: Per [class.copy.ctor]/8

If the definition of a class X does not explicitly declare a move constructor, a non-explicit one will be implicitly declared as defaulted if and only if [...]

*

*X does not have a user-declared destructor.

Since
virtual ~foo() = default;

is a user-declared destructor you no longer have a move constructor so it tries to use the copy constructor but can't because that is deleted as you have a non-copyable member.
To get the move constructor back, and to keep the default constructable, you need to add
foo() = default;
foo(foo&&) = default;
foo &operator=(foo &&) = default; // add this if you want to move assign as well

to foo

The reason you have to add foo() = default; when you add foo(foo&&) = default; is that foo(foo&&) = default; is a used-declared constructor and if you have any user-declared constructors then the default constructor is no longer provided.

This is a "hack" but what you could do is move the virtual destructor into another class and then inherit from that.  That will give you a virtual destructor in foo without having to declare it and give you the default constructors you want.  That would look like
struct make_virtual
{
    virtual ~make_virtual() = default;
};

struct foo : make_virtual {
    std::unique_ptr<int> mem;
};

A: Either provide your own copy constructor and a default constructor, convert the member to a shared pointer or provide a move constructor. One possible solution:
struct foo {
    unique_ptr<int> mem;
    foo() = default;
    foo(const foo& copy);
    virtual ~foo() = default;
};

foo::foo(const foo& copy) : mem(new int(*copy.mem)) {}

foo make_foo() {
    foo result;
    result.mem = make_unique<int>();
    return result;
}


text:
Q: Python3: Counting occurrence of characters in a nested dict I'm currently working on a small piece of code and I seem to have run into a roadblock. I was wondering if it's possible to find the most common occurrence of a character that follows a specific group of characters?
For example, say I have the following sentence:
"fishies are super neat, a fish is a good pet. also, fishing is for dads."
How would could I determine, for example, the most common character that occurs after the fragment "fish"?
In this specific example, doing it by hand, I get something like this:
{"i": 2, " ": 1}
Currently, I have this chunk of code written to grab the "fish" portion of the word:
b = Class(n, 'file.txt')
ngrams = [b.file[i:i+n] for i in range(len(b.file)-1)]

this will break up all of the text into chunks of 4 like so: ['fish', 'ishi', 'shie', 'hies', 'ies ', 'es a'.....]
My goal is to combine these two thoughts so that I can print something that looks like the following:
{'fish' : {'i':2, ' ':1} ..... }
I also currently have a defaultdict defined in __init__ like so: self.counts=defaultdict(lambda: defaultdict(int))
This is the closest I can get to achieving my desired solution, although I am unsure how to grab the individual characters that follow and how to count those characters:
b.counts = {i : { j : 5 for j in ngrams } for i in ngrams }
5 is merely a placeholder so I could see what printed. j in ngrams was also a placeholder to see what printed. Any input or ideas from anyone would be greatly appreciated!

A: import re

raw_string = "fishies are super neat, a fish is a good pet. also, fishing is for dads."

key =  ['fish', 'ishi', 'shie', 'hies']
out = {}
for item in key:
    data = []
    for word in re.findall(item+'.', raw_string):
        data.append(word[-1])
    results = {item:data.count(item) for item in data}
    out[item] = results

Output:
{'fish': {'i': 2, ' ': 1}, 'ishi': {'e': 1, 'n': 1}, 'shie': {'s': 1}, 'hies': {' ': 1}}

A: You could try something like this:
import re
from collections import Counter

sentence = "fishies are super neat, a fish is a good pet. also, fishing is for dads."
word = 'fish'
result = {}
result[word] = Counter(re.findall(f'{word}(.)', sentence, flags=re.IGNORECASE))

print(result)

Note that this will also count cases where the fragment you are looking for appears in the middle of a word. If you only want to count words that start with the fragment, you could use something like re.findall(f'\\W{word}(.)') instead.

A: sentence = "fishies are super neat, a fish is a good pet. also, fishing is for dads."
s_list = sentence.split("fish")
stat = {}
for i in s_list[1:]:
    if i[0] in stat.keys():
        stat[i[0]] += 1
    else:
        stat[i[0]] = 1

print(stat)


text:
Q: Is it best practice to use spring jpa findall for complex relation mappings Is it good practice to use spring jpa findAll or use a select query as findAll is taking much time due to complexity of the relationship that too eager fetch....
Pls help

A: In general it is not a good practice to set the Eager fetch directly in the entities on the Many side of a relationship unless those related entities are tightly coupled and you know you won't select one without the other.
You should use a custom select query to specify join fetch where you actually need it.
N.b. for the OneToOne and ManyToOne relationship the default is already Eager


text:
Q: How to partially differentiate following implicit equation of Z with respect to X? I don't understand the logic behind this partial derivative and how it's derived. From equation 1, our objective function is written implicitly as a function of x,y. We treat y constant, and z a f(x).
Z is a function of x and y and implicitly written:
$$x^{3}+y^{3}+z^{3}+6xyz=1$$
To find dz/dx(partial) we differentiate implicitly with respect to x, treating y as a constant:
$$3x^{2}+3z^{2}\dfrac {\partial z}{\partial x}+6yz+6xy\dfrac {\partial z}{\partial x}=0$$
This is where I am lost. How and why is there a last component that includes x. It doesn't make sense and seems like the last component is being added twice.
Solving this equation for our partial:
$$\dfrac {\partial z}{\partial x}=-\dfrac {x^{2}+2yz}{z^{2}+2xy}$$
I'm confusing myself because it's written implicitly and somehow I don't think I have the correct formula; I understand how the 3rd z term got differentiated but this last 6xyz term being included twice isn't clicking

A: Applying the product rule:
$$\dfrac{\partial}{\partial x}(u \cdot v) = u \cdot \dfrac{\partial v}{\partial x} + v \cdot \dfrac{\partial u}{\partial x} $$
The last term $6xyz$ can be split into two separate factors $6x$ and $yz$. Differentiating leads to:
$$\dfrac{\partial}{\partial x}6x \cdot yz + 6x \cdot \dfrac{\partial}{\partial x} yz = 6 \cdot yz + 6x \cdot y\dfrac{\partial z}{\partial x}$$


text:
Q: Check a site to display notifications Suppose the address www.foo.com/notification.txt is updated often with a formatted string that must be shown as a notification in an Android device. What's the best approach for getting that string?
I've tried several things. My last attempt was creating a class that extends a BroadcastReceiver and configuring ALARM_SERVICE to call it repeatedly:
AndroidManifest.xml:
 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
 <receiver  android:process=":remote" android:name="Alarm"></receiver>
    <receiver android:name=".AutoStart">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED"></action>
        </intent-filter>
    </receiver>

Alarm.java:
package br.com.mypackage.cfqm;
import java.io.BufferedReader;
import java.io.InputStreamReader;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;

import android.app.AlarmManager;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log;
import android.widget.Toast;

public class Alarm extends BroadcastReceiver
{
    int period_ms = 5*60*1000;
    SharedPreferences prefs;
    String user;
    String pass;
    Context context;

    public void check_notifications(){
            //http request to get and parse the notifications
        String[] notifications = http_request("http://foo.com/notification.html")).split("\n");

        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancelAll();
        int notification_next_id = 0;

        for (String notification_line:notifications){
            String[] notification = notification_line.split(";");
            if (notification.length==3)
                notify(notification_next_id++,notification[0],notification[1],notification[2]);
        }
    }

    public void notify(Integer id,String title,String text,String url){
            //displays a single notification
        NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        NotificationCompat.Builder notificationBuilder =
            new NotificationCompat.Builder(context)
                .setSmallIcon(R.drawable.ic_action_search)
                .setAutoCancel(true)
                .setContentTitle(title)
                .setContentText(text);
        Intent resultIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

        TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
        stackBuilder.addParentStack(Main.class);
        stackBuilder.addNextIntent(resultIntent);
        PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
        notificationBuilder.setContentIntent(resultPendingIntent);
        notificationManager.notify(id,notificationBuilder.build());
        Log.v("cfqm","notificado");

    }

    public String http_request(String url) {
            //makes a http request
        try {
            HttpClient httpClient = new DefaultHttpClient();
            HttpContext localContext = new BasicHttpContext();
            HttpGet httpGet = new HttpGet(url);
            HttpResponse response = httpClient.execute(httpGet, localContext);
            String result = "";

            BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
            String line = null;
            while ((line = reader.readLine()) != null)
              result += line + "\n";
            return result;
        }
        catch (Exception e){
            e.printStackTrace();
            return "";
        }

    }

     @Override
     public void onReceive(Context ctx, Intent intent)
     {
         context = ctx;

         StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
         StrictMode.setThreadPolicy(policy);

         // The function below will be called periodically
         check_notifications();
     }

     public void SetAlarm(Context context)
     {
         prefs = PreferenceManager.getDefaultSharedPreferences(context);
         user = prefs.getString("user","");
         pass = prefs.getString("pass","");

         AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
         Intent i = new Intent(context, Alarm.class);
         PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
         am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), period_ms, pi); // Millisec * Second * Minute
     }

     public void CancelAlarm(Context context)
     {
         Intent intent = new Intent(context, Alarm.class);
         PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, 0);
         AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
         alarmManager.cancel(sender);
     }
 }

I can make the function check_notifications to run repeatedly if all I do there is Log a string. But wheter I use http_request inside weird things happen, from the app crashing, to the whole system freezing. I understand I was supposed to run it async. But how?

A: You have to use AsyncTask.
Android Documentation here:
Async Class
Its pretty simple.
Also if you want this to run periodically, consider using a Service(Service Class)
Also the app crashes because you are running something on main thread, and not in the background. So everything freezes until you got the result from webpage.
And in situations of heavy load on that webpage you have to wait.
Async class Example:
 private class MyAsyncTask extends AsyncTask<URL, Integer, Integer> {

 protected Integer doInBackground(URL... urls) {
     int count = urls.length;
     long totalSize = 0;
//This is for many urls. If you download staff only from one url use url[0] instead of a for-loop.
     for (int i = 0; i < count; i++) {
         //do something with url[i]
     }
     return 0; //or return some stats you can later use (eg how many bytes downloaded)
 }

 protected void onProgressUpdate(Integer... progress) {
//You can completely skip this method. It is to show a progress bar of how % is done
     setProgressPercent(progress[0]);

 }

 protected void onPostExecute(Integer result) {
//This is where everything finishes, and you got the result of your webpage

     showDialog("Downloaded " + result + " bytes");
 }
}

And then, create a new AsyncTask object, and start the task like this:
asyncTaskObj.execute(...);


text:
Q: How to install libvirt in Eclipse How to install libvirt-java-0.4.9 in Eclipse Juno Service Release, I cant get it. Pleas help

A: Libvirt is a Python library and you need to install it from source code or from packages and after this, you find it at /user/local/lib/python2.7/dist-package/libvirt,
go to window -> preference-> pydev ->interpreter-python librery an new folder and add the path
libvirt will be setup in eclipse


text:
Q: Splitting array based on values It's been a long time since I had to work on some javascript code and I'm a lot rusty.
I need to split an array like this:

Object (
    [0] => 2013-04-12
    [1] => text
    [2] => text
    [3] => text
    [4] => text
    [5] => 2013-04-11
    [6] => text
    [7] => text
    [8] => text
    [9] => text
    [10] => text
    [11] => text
    [12] => 2013-04-10
    [13] => text
    [14] => text
    [15] => text
    [16] => text
    [17] => 2013-04-09
    [18] => text
    [19] => text
    [20] => text
)

into json objects or arrays where index 0 is always the date:

Object0 (
    [0] => 2013-04-12
    [1] => text
    [2] => text
    [3] => text
    [4] => text
)
Object1 (
    [0] => 2013-04-11
    [1] => text
    [2] => text
    [3] => text
    [4] => text
    [5] => text
    [6] => text
)

Object2 (
    [0] => 2013-04-10
    [1] => text
    [2] => text
    [3] => text
    [4] => text
)

Object3 (
    [0] => 2013-04-09
    [1] => text
    [2] => text
    [3] => text
)

So as you can see, I can only use the value to figure out each new array, which can be of different sizes.
Thanks for any help.
UPDATE
Sorry I didn't publish my code in the initial question because what I had written was way too crap (and I was very ashamed).
Here the code I used in the end thanks to the solution from Bangerang.
Thanks everyone for your help and contributions.
var events = [];
var result = [];
var j = 0;
for (var i = 0; i < tableData.length; i++){
    if (/^(\d{4})-(\d{2})-(\d{2})$/.test(tableData[i])){ //Returning true if it's just numbers
        j = j + 1;
        events[j] = [];
        events[j].push(tableData[i]);
        result.push(events[j]);
    } else {
        events[j].push(tableData[i]);
    }
}

// Then I write the json message which will be eval to use with FullCalendar.
var json_events = '[';
for (var i = 1; i <= events.length; i++){
    if (typeof events[i] !== 'undefined' && events[i].length > 0) {
        for (var j = 0; j < events[i].length; j++){
            if(/@/.test(events[i][j])){

                json_events += '{"start":"' + events[i][0] + '",';
                json_events += '"textColor":"black",';

                var tmp = events[i][j].split("@");
                json_events += '"backgroundColor":"' + tmp[0] + '",';

                var text_pattern = new RegExp(/<b>([a-z_]+)<\/b>(.+)/);
                var title_desc = text_pattern.exec(tmp[1]);
                json_events += '"title":"' + title_desc[1] + '",';
                json_events += '"description":"' + title_desc[0] + '"';
                json_events += '},';
            }
        }
    }
}
json_events += ']';
json_events = json_events.replace("},]","}]");

A: Assuming that the date's is the only ones with just numbers in it you can try this:
var object = [];
var result = [];
for (var i = 0; i < objects.length; i++){
    if (/^\d+$/.test(objects[i])){ //Returning true if it's just numbers
        object = []
        object.push(objects[i]);
        result.push(object);
    }else {
        object.push(objects[i]);
    }
}

A: basically,
result = []

sourceArray.forEach(function(element) {
    if(element looks like a date)
        result.push([])
    result[result.length - 1].push(element)
})

post your actual code if you want more ;)

A: Currently, the work is not really complicated. You just have to go through your array, and create a new one when you encounter a date formatted cell. Until then, you fill the previous created array with the non-date encountered values. I suppose that all of the array content are string, so we will determine here the date format using a simple regex ^[0-9]{8}$
var result = new Array();
var date_format = /^[0-9]{8}$/;

for (var k in big_array) {
    // if date format, add a new array
    if (date_format.test(result[k])) {
        result.push(new Array());
    }
    // finally, push the value in the last array
    result[result.length-1].push(big_array[k]);
}

This is a really simple algorithm exercise, so i would recommend to practice more the code's writing and avoid asking next time, or at least show what you tried.
Best regards.


text:
Q: passwordless login set up automation for ubuntu I have space separated file containing ip addresses and credentials like this:
10.0.0.1 user_master password_master
10.0.0.3 user_slave1 password_slave1
...
10.0.0.20 user_slave20 password_slave20

I want create mutual passwordless ssh login between master(first line) and all other slaves. All machines are new Ubuntu 14.04 with no openssh-server installed.
Right now I am able to use ssh-keygen and ssh-copy-id to create public key login without inputing password one by one manually, but it's tedious when there are many machines.
I want to know how to write script to automate this process. I find it hard for me especially when I have to pass credentials after ssh to other machine then exit.
Or is there a out-of-box tool designed for this automation task?

A: You can create simple bash script ex: upload.sh and write some automation script :
#!/bin/bash

remote_host=(192.168.1.1 192.168.1.2 192.168.1.3 172.90.44.21)

for i in "${remote_host[@]}"
do
    echo Uploading SSH Key to Host : $i
    ssh-copy-id -i ~/.ssh/id_rsa.pub $i
done

You can input your remote address on remote_host array
Make it executable
chmod upload.sh

and then, execute it
./upload.sh


text:
Q: COM, COM+, DCOM, where to start? I am curious about COM+, DCOM. I know that MSFT does not encourage you to use this tools natively (meaning with C/C++, in fact there is not a lot of documentation available) but I want to learn to use these technologies, like embedding Internet Explorer into a C program.
I thought that maybe I could find people that worked with this or that knows about this technology.
Where to start? Any ideas? Any example (like Hello World DCOM)?

A: I compiled a list of books, which should be read in this order:

*

*'Inside COM' from Dale Rogerson, This should be your first book. It explains the basics of reference counting, interfaces, IUnknown, components, idl, IDispatch, automation types and apartments. From this book you will notice that it takes quite some code to make components and that you can easily skip a 'Release', which leads to resource leaking. Also this books lacks some details.

*'ATL Internals' from Tavares. ATL helps you with both client use as making COM components. With smart pointers (e.g. CComPtr) it's hard to get the reference counting wrong these days. ATL also facilitates in making components in c++. Unfortunately ATL hides many functionality in macro's and has a counter intuitive way to implement IUnknown. An alternative might be 'Inside ATL'.

*'Essential COM' from Don Box. This book is mentioned frequently but it is not a good beginners book. It misses the overall picture, but is great in its details (e.g. the difference between 'size_is' and 'length_is' in idl).

*'Understanding ActiveX and OLE: A Guide for Developers and Managers'. This books touches some of the more esoteric interfaces like IPersist, IStorage; IMoniker etc., but does not go into great detail.

Be aware that COM is somewhat of an old technology, though still viable especially for native developers.

A: If you are serious about learning COM, Don Box's "Essential COM" is definitely an absolute "must read". COM can be confusing and in my humble opinion Don Box is one of the few people who actually "got it".
The example code in "Essential COM" is in C++. You won't find many books that support COM in C. You can write COM in C, but it will be very, very painful. COM is optimized for C++ development.
This book is not perfect nor "complete". There are some (granted, a bit esoteric) areas that the book skims over. For example, the book has like 1 1/2 pages on "monikers" (I have never seen a treatment of monikers that satisfies me). I consider this book to be THE fundamental book.
Second, in real life you are likely to want to use a supporting library such as ATL, rather than writing all the COM glue directly. There are too many ways to make subtle mistakes in COM even in the basic set up. ATL will give you good patterns and implement the boring code for you. In learning, you are better off using plain C++.
There are many books about ATL and several are quite good. I understand that ATL has changed quite a bit since the old days of VC++6, but I don't have first hand knowledge there: sadly, most of the COM code I work with is forever locked to the flavor of C++ in VC6.
Make sure whatever book you get is written for the version of Visual Studio and/or ATL you are planing on using.
Some background on COM books:
Note that there are a lot of books out there that misunderstand COM, or focus on the wrong things. The older books are worse in this respect. Some of the first few books treated COM as little more than a plumbing detail needed to make OLE work ("Object Linking and Embedding", that's what allows you to drag-and-drop a spreadsheet range into a Word document). Because of that, a lot of the material out there is very confusing. It took a while before people realized that OLE wasn't that important and that COM really was.
By the time Don Box published "Essential COM", the cracks on the foundation of COM had started to become evident. There isn't anything terribly flawed with COM, but the needs of the development community had evolved and outgrown what COM could do without serious revamping.
.NET was born out of that effort to address the limitations in COM, especially in the area of "type information". Just a few years after "Effective COM" was published, the attention of the community shifted away to .NET. Because of that, good COM training material is now and will likely remain forever limited.
So, COM is not broken, and it works great for the things it's used for (that's why Explorer still uses it). It's just not the best solution anymore for many of the problems that need solving today.
In summary:
I recommend "Essential COM" for the basics. Then, any of many good ATL books available (no strong preferences there), and then use other resources like MSDN or -- of course -- Stack Overflow, to cover areas that are of particular interest to you.
If you'd rather avoid relying on resources of the dead-tree variety, go ahead and learn ATL from the web. But some books are worth reading the old fashioned way -- and "Essential COM" is one of them.
Good luck.

A: COM is still useful if you want to work with, or extend, various Windows APIs, such as shell extensions, scripting host, and so on.
Essential COM (Box) and ATL Internals (Rector and Sells) are excellent sources. Effective COM (Box, et al) is also ok.
If you really want the full picture on COM, try and get a copy of the immense Inside OLE (Brockschmidt).
Distributed COM (Eddon, Eddon) is decent on DCOM, as is Inside COM+ Base Services (Eddon, Eddon) on COM+.
even some supposedly "pure" C++ books have bits on COM in them. Matthew Wilson's Imperfet C++ has some useful parts for seeing how it works on the inside, and his Extended STL book has a couple of chapters on how to adapt COM to STL collections.
If you want to know more about how to write COM servers, you'll probably need to bone up on ATL. The aforementioned ATL Internals is a must. Despite its humble sounding title, Beginning ATL COM has some useful stuff in it too.
Also helpful in the learning process might be to contrast COM with .NET. The .NET and COM Interoperability Handbook is a big swallow, but has some useful stuff in it. Also, I would check out Shared Source CLI Essentials, just to help contrast the two technoloqies.
HTH

A: Start with "Inside COM", then move on to "Inside DCOM" and then read the "Essential COM". You will get a grip on COM. Both the books Inside COM and Inside DCOM are Microsoft Publications. Excellent books for the one who wants to know COM/DCOM thoroughly.

A: Essential COM is especially for implementing or using COM components from C++, without using an IDE, framework, or library to help.
COM is trivial to use from VB or from Delphi, for example, which hide the COM-specific glue from the application programmer. In C++ you'd often use some class library that tries to abstract the details ... Essential COM  will tell you what those details are (and kind of implements its own library/framework in doing so).

A: COM, COM+ and DCOM are three completely different things.  At this point, there is very little reason to learn COM and almost no reason to learn DCOM.  The only reason I can think of is if you have to maintain or integrate legacy components.  COM+ is still used because it allows for out of process hosting of components and nice things like distributed transaction management.
The best way to start writing up some COM is using ATL.  In .NET COM+ is called Enterprise Services.
The best book I know on COM is Don Box's Essential COM and Tim Ewald's COM+ book is excellent too.

A: Actually, if you want to learn more about COM, Microsoft publishes a book about COM and how it works...  http://www.amazon.com/Inside-Microsoft-Programming-Dale-Rogerson/dp/1572313498/ref=sr_1_2?ie=UTF8&s=books&qid=1243029018&sr=8-2


text:
Q: Converting encoding using ogr2ogr on macOS I'm trying to convert my shapefiles from ISO-8859-10, also known as latin6 using ogr2ogr on my Mac like this (learned from here):
export SHAPE_ENCODING="latin6"
ogr2ogr file_utf8.shp file.shp -lco ENCODING=UTF-8

But, nothing is converted. Well, a new shapefile is created but it still has the same old encoding. I've tried with SHAPE_ENCODING="ISO-8859-10" and still no happy result. Then I tried just a random word like SHAPE_ENCODING="blablabla" but then ogr2ogr gives me an error:
Failed to create field name 'FIELD1' : cannot convert to blablabla

So it seems like ogr2ogr understands the latin6 encoding but then doesn't do the job for me. Maybe this is a macOS only problem?
If I do the conversion to GeoJSON with SHAPE_ENCODING="latin6" the GeoJSON file gets recoded to UTF-8 fine:
export SHAPE_ENCODING="latin6"
ogr2ogr -f GeoJSON file_utf8.geojson file.shp

Then I can convert the GeoJSON file back to Shape again:
export SHAPE_ENCODING="utf-8"
ogr2ogr -f "ESRI Shapefile" file_utf8.shp file_utf8.geojson

Is there a way of converting encoding without going through the GeoJSON conversion process?

A: Here's an answer based on Dimitry Baryshnikovs comment to my question. If there isn't a CPG file with the same name as the shape file, create one and add the line 885910.
In my case I already had CPG files but they were all wrong (consisted of the line ISO 88591) which caused the big problem. After altering my CPG files to 885910 I had no problem running the line of code:
ogr2ogr file_utf8.shp file.shp -lco ENCODING=UTF-8


text:
Q: Error: Could not resolve host: github.com during clone operation When I tried to HTTPS clone Odoo modules from git-hub, I got the following error message:
fatal: unable to access 'https://github.com/odoomrp/odoomrp-wip.git/': Could not resolve host: github.com

This is my ubuntu command:
git clone https://github.com/odoomrp/odoomrp-wip.git

Thanks for your help!

A: VM was not connected to network adapter. Right clicking on the network icon of the VM and selecting Connect Network Adapter resolved the issue.


text:
Q: How to create a Textmate like side panel in Qt How can I create a side panel like the file explorer in Textmate using C++/Qt? To be more precise like the left side panel in the image below:

(source: garzaincredible.com)
The closest thing to my need seems to be QDockWidget, but I still didn't figure out how to use it.

A: That's called a "Drawer". In Qt, there's a special Qt::WindowFlags flag for this: Qt::Drawer. The intention is to use this flag on a QDockWidget:
QDockWidget* dock = new QDockWidget(parent, Qt::Drawer);

This will create a Cocoa drawer for the dock widget. You don't need to make sure that Qt::Drawer is only used on OS X; that flag is simply ignored on other platforms, so you can specify it unconditionally.


text:
Q: Problem by passing components with images I just tried to create a component which includes a .jpg and pass it to the App.js (I used "create-react-app").
Unfortunately, my browser tells me about a compiling error:
Failed to compile
./src/bla/components/Pics.js
Module not found: Can't resolve './bla/tb1.jpg' in 'C:\lernordner\testapp\test\src\bla\components'
This error occurred during the build time and cannot be dismissed.
'''
Can someone tell me what I`m doing wrong? The directory path is okay.
Thank you!
App.js :
import React, { Component } from 'react';
import Pics from './bla/components/Pics.js';

class App extends Component {
  render() {
    return (

         <Pics />

    );
  }
}

export default App;

Pics.js :
import React from 'react';
import Test from './bla/test.jpg';

function Pics() {
  return ;
}

export default Pics;

A: import statement in your code will import the whole image file. Now if that is correct, Having the whole file contents assigned to src attribute image shouldnt display image.  You have to pass the image path in src attribute.
Something like this:
function Pics() {
    return ;
}

A: have you tried like this? if it still doesn't work it's problem with directory
const Pics = () => {
  return ;
}


text:
Q: d3.js Indented tree with straight links My code is based on the D3.js Indented tree example.
I want straight links instead of the curved links between parent/child-objects.
I understand this has something to do with the following code, however, I can't find a solution. I want the links to be straight with a 90-degree turn.
var diagonal = d3.svg.diagonal()
    .projection(function(d) { return [d.y, d.x]; });

A: The problem is to extract the x and y points from the links. One way of doing this is:
Link generator:
self.diagonal = d3.svg.line().interpolate('step')
        .x(function (d) { return d.x; })
        .y(function (d) { return d.y; });

And then use the generator like this:
link.enter().append('svg:path', 'g')
        .duration(self.duration)
        .attr('d', function (d) {
            return self.diagonal([{
                y: d.source.x,
                x: d.source.y
            }, {
                y: d.target.x,
                x: d.target.y
            }]);
        });

A: You're almost there. You need to use a normal line with a suitable interpolation, e.g.
var line = d3.svg.line().interpolation("step")
                 .x(function(d) { return d.y; })
                 .y(function(d) { return d.x; });

You may have to tweak the exact interpolation mode.


text:
Q: Passing data to server Xamarin JSON I am sending data to my server. The total number of date is more than 2000. I am sending the data one at a time. How can I send the data all at once? It takes so long for the data to be sent. I am using JSON Objects to send my data. How can I get the all the data from my local database and send it to my server all at once?
var sql = "SELECT * FROM tblContacts WHERE Coordinator = '" + contact + "'";
var getContacts = conn.QueryAsync<ContactsTable>(sql);
var resultCount = getContacts.Result.Count;
var current_datetime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:00");

if(resultCount > 0)
{
   for (int i = 0; i < resultCount; i++)
   {
       var result = getContacts.Result[i];
       var contactID = result.ContactID;
       var fileAs = result.FileAs;
       var firstName = result.FirstName;
       var middleName = result.MiddleName;
       var lastName = result.LastName;

       var link = Constants.requestUrl + "Host=" + host + "&Database=" + database + "&Contact=" + contact + "&Request=nLm8YE";
       string contentType = "application/json";
       Object json = new JObject
       {
          { "ContactID", contactID },
          { "FileAs", fileAs },
          { "FirstName", firstName },
          { "MiddleName", middleName },
          { "LastName", lastName }
        };

        HttpClient client = new HttpClient();
        var response = await client.PostAsync(link, new StringContent(json.ToString(), Encoding.UTF8, contentType));
   }
}

A: Put it into a JArray:
if(resultCount > 0)
{
   JArray arr = new JArray();
   for (int i = 0; i < resultCount; i++)
   {
       var result = getContacts.Result[i];
       var contactID = result.ContactID;
       var fileAs = result.FileAs;
       var firstName = result.FirstName;
       var middleName = result.MiddleName;
       var lastName = result.LastName;

       var link = Constants.requestUrl + "Host=" + host + "&Database=" + database + "&Contact=" + contact + "&Request=nLm8YE";
       string contentType = "application/json";
       Object json = new JObject
       {
          { "ContactID", contactID },
          { "FileAs", fileAs },
          { "FirstName", firstName },
          { "MiddleName", middleName },
          { "LastName", lastName }
        };
        arr.Add(json);
   }
   HttpClient client = new HttpClient();
        var response = await client.PostAsync(link, new StringContent(arr.ToString(), Encoding.UTF8, contentType));
}

however this would require your enpoint to accept the incoming data as an array and being able to iterate and consume it on the server side.


text:
Q: Git repo sync - connection lost I'm trying to download android source (Cyanogenmod). i have spent more than 12hrs to download 2.5GB files, Now my connection lost for a while, it shows
 error: RPC failed; result=56, HTTP code = 200
    fatal: The remote end hung up unexpectedly
    fatal: early EOF
    fatal: index-pack failed
    fatal: unable to access 'https://android.googlesource.com/platform/prebuilts/misc/': Could not resolve host: android.googlesource.com
    fatal: unable to access 'https://github.com/CyanogenMod/android_packages_inputmethods_LatinIME/': Could not resolve host: github.com
    fatal: unable to access 'https://android.googlesource.com/platform/prebuilts/misc/': Could not resolve host: android.googlesource.com
    error: Cannot fetch CyanogenMod/android_packages_inputmethods_LatinIME
    error: Cannot fetch platform/prebuilts/misc
    error: Exited sync due to fetch errors

Can i resume the download or i should download from the beginning, please help me to resume my download.
Thank you!

A: Once you have applied the fix that I describe below, you should simply re-run repo sync in order to resume and fully complete the resource synchronization process that was interrupted by these fatal errors.
The solution to the DNS-related error that you've encountered [fatal: Could not resolve host] is detailed on the Known Issues resolution page at Google's AOSP Developer Site. Apply this fix by adding the appropriate host entry for your remote repository android.googlesource.com inside your development machine's /etc/hosts config file. Begin by clicking here and here to execute the IP address lookup tool provided by the free web resource: http://network-tools.com/nslook/.
Google's full description of this issue with detailed resolution I've included here:

Difficulties syncing the source tree (DNS issues).
Symptom: When running repo sync, the process fails with various errors
    related to not recognizing the hostname. One such error is
    <urlopen error [Errno -2] Name or service not known>.
    EDIT: Another fatal error might be Could not resolve host.
Cause: Some DNS systems have a hard time coping with the high number
    of queries involved in syncing the source tree (there can be several
    hundred requests in a worst-case scenario).
Fix: Manually resolve the relevant hostnames, and hard-code those
    results locally.

You can resolve them with the nslookup command, which will give you
      one numerical IP address for each of those (typically in the "Address"
      part of the output).

    $ nslookup googlesource.com
    $ nslookup android.googlesource.com

You can then hard-code them locally by editing /etc/hosts, and adding two
    lines in that file, of the form:

    aaa.bbb.ccc.ddd   googlesource.com
    eee.fff.ggg.hhh   android.googlesource.com

Note that this will only work as long as the
    servers' addresses don't change, and if they do and you can't connect
    you'll have to resolve those hostnames again and edit etc/hosts
    accordingly.

A: You don't resume a clone, you can try a shallow clone instead.
As mentioned here:

Error code 56 indicates a curl receive error of CURLE_RECV_ERROR which means there was some issue that prevented the data from being received during the clone process.
  Typically this is caused by a network setting, firewall, VPN client, or anti-virus that is terminating the connection before all data has been transferred.

You can know more with:
set GIT_TRACE_PACKET=1
set GIT_TRACE=1
set GIT_CURL_VERBOSE=1

You can try changing http.postBuffer or switching to ssh url clone.

A:
Could not resolve host: android.googlesource.com

Which could be a DNS server problem. Try first restarting your modem in order to flush its DNS cache. If you're still seeing the problem, try changing your Primary DNS to either one these two publicized DNS servers that Google operates:

*

*8.8.8.8

*8.8.4.4

Note that, if your Primary DNS has already been configured as described and you've also long-rebooted the router without resolution (pun intended), then adjusting your Primary DNS configuration to point at other public DNS servers is not likely to fix your situation. However, a reputable list of no-cost public servers can be found here.

A: Spartan i checked the Cyanogenmod its working normally i prefer use internet download manager.i download 60mp and recall it.successfully fetched and resumed.


text:
Q: Cannot Update string to Date object in mongodb 4.2 I have a string field which consists of date, I am trying to run following command mentioned in Update string to Date object in mongodb
db.getCollection('rft').updateMany(
  {},[{ "$set": { "createdate": { "$toDate": "$create_date" } }}]
);

Getting an error:
Error: Failed to execute script.
Error: the update operation document must contain atomic operators
Details:
DBCollection.prototype.updateMany@src/mongo/shell/crud_api.js:625:1
@(shell):1:1
Can someone please help in updating the records to get new field with date time.

A: Your query seems to work as expected , check playgroud unless something different is expected ...


text:
Q: Verify the rarefaction wave solution of a general convex scalar problem I am self-studying Numerical Methods for Conservation Laws by Leveque. I've been stuck on Exercise 3.7 for a while.
Question
Consider a general conservation law
$$
u_t+f(u)_x=0
$$
where $f(u)$ is convex. Suppose we have initial data
$$
u(x,0)=\begin{cases}
u_l &\text{if } x<0\\
u_r &\text{if } x>0
\end{cases}
$$
where $u_l<u_r$.
Show that the rarefaction wave with $v=(f')^{-1}$
$$
u(x,t) = \begin{cases}
u_l &\text{if  } ~x<f'(u_l)t\\
v(x/t) &\text{if  } ~f'(u_l)t\leq x \leq f'(u_r)t\\
u_r &\text{if  } ~x>f'(u_r)t
\end{cases}
$$
is a solution in the weak sense, i.e. it satisfies
$$
\int_0^\infty\int_{-\infty}^\infty \left[\phi u_t + \phi f(u)_x\right]dxdt = 0
$$
for $\phi \in C_0^1(\mathbb{R}\times \mathbb{R}^+)$ or, integrating by parts
$$
\int_0^\infty \int_{-\infty}^\infty\left[\phi_t u +\phi_x f(u)\right]dxdt=-\int_{-\infty}^\infty \phi(x,0)u(x,0)dx
$$
Comments
This question is similar to How to test the weak solution to a hyperbolic conservation law but different enough to warrant a new question, I think.
I originally was going to write up my attempt, but it boils down to splitting up the integrals and performing several substitutions and integrations by parts, and then comparing all the terms to see if they cancel. It's such a mess that I'm not sure anyone would even read it all. Somewhere, I'm messing up my application of integration by parts, or I'm not swapping the integral order correctly.
If it would be better, I can include my full attempt. Please let me know.

A: Split up the integral by considering the domain in $xt$ space. The figure below considers $f(u)=\frac{1}{2} u^2$.

The location of the rarefaction wave trailing edge is defined by $x=f'(u_l)t$, and the leading edge is defined by $x=f'(u_r)t$. The left side of eq. 1 can be written
\begin{align*}
  \int_0^\infty \int_{-\infty}^\infty\left[\phi_t u +\phi_x f(u)\right]dxdt
  &= \int_{-\infty}^\infty \int_0^\infty\phi_t u~dtdx+\int_0^\infty\int_{-\infty}^\infty\phi_x f(u) dx dt\\
  &=I_t+I_x
\end{align*}
First consider $I_t=\int_{-\infty}^\infty \int_0^\infty\phi_t u~dtdx$.
\begin{align*}
  I_t&=\int_{-\infty}^\infty \int_0^\infty\phi_t u~dtdx\\
  &=\int_{-\infty}^0 \int_0^\infty\phi_t u_l~dtdx+\int_{-\infty}^\infty \int_0^\infty\phi_t u~dtdx\\
  &=\int_{-\infty}^0 -\phi(x,0)u_ldx\\&~~~~~+\int_{0}^\infty\left[\int_0^{x/f'(u_r)} \phi_t u_r~dt+\int_{x/f'(u_r)}^{x/f'(u_l)} \phi_t v(x/t)~dt+\int_{x/f'(u_l)}^\infty \phi_t u_l~dt\right]dx
\end{align*}
where we have used $\phi\in C_0^1(\mathbb{R}\times \mathbb{R}^+)$ to assert that $\phi(\infty,0)=0$.
Then, for convenience, define the following
\begin{align*}
 I_{tl}&=\int_{x/f'(u_l)}^\infty \phi_t u_l ~ dt=-\phi(x,x/f'(u_l))u_l\\
 I_{tm}&=\int_{x/f'(u_r)}^{x/f'(u_l)} \phi_t v(x/t)dt\\
 I_{tr}&=\int_0^{x/f'(u_r)}\phi_t u_r~dt=\phi(x,x/f'(u_r))u_r-\phi(x,0)u_r
\end{align*}
Now consider $I_x=\int_0^\infty\int_{-\infty}^\infty\phi_x f(u) dx dt$.
\begin{align*}
 I_x&=\int_0^\infty\int_{-\infty}^\infty\phi_x f(u) dx dt\\
 &=\int_0^\infty\left[\int_{-\infty}^{f'(u_l)t}\phi_x f(u_l) dx+\int_{f'(u_l)t}^{f'(u_r)t}\phi_x f(v(x/t)) dx+\int_{f'(u_r)t}^{\infty}\phi_x f(u_r) dx\right]dt
\end{align*}
So
\begin{align*}
 I_{xl}&=\int_{-\infty}^{f'(u_l)t}\phi_x f(u_l) dx=\phi(f'(u_l)t,t)f(u_l)\\
 I_{xm}&=\int_{f'(u_l)t}^{f'(u_r)t}\phi_x f(v(x/t)) dx\\
 I_{xr}&=\int_{f'(u_r)t}^{\infty}\phi_x f(u_r) dx=-\phi(f'(u_r)t,t)f(u_r)
\end{align*}
Now apply integration by parts to $I_{tm}$ and $I_{xm}$. Then
\begin{align*}
I_{tm} &=\int_{x/f'(u_r)}^{x/f'(u_l)} \phi_t v(x/t)dt\\
&=\phi v(x/t)\big|_{t=x/f'(u_r)}^{t=x/f'(u_l)}-\int_{x/f'(u_r)}^{x/f'(u_l)}\phi v'(x/t)(-\frac{x}{t^2})dt\\
&=\phi(x,x/f'(u_l))v(f'(u_l))-\phi(x,x/f'(u_r))v(f'(u_r))+\int_{x/f'(u_r)}^{x/f'(u_l)}\phi v'(x/t)\frac{x}{t^2}dt\\
&=\phi(x,x/f'(u_l))u_l-\phi(x,x/f'(u_r))u_r+\int_{x/f'(u_r)}^{x/f'(u_l)}\phi v'(x/t)\frac{x}{t^2}dt
\end{align*}
where $v(f'(\nu))=\nu$ by the definition of $v$ as the inverse of $f'$. (Note, by the assumed convexity of $f(u)$, its inverse exists.)
\begin{align*}
I_{xm} &=\int_{f'(u_l)t}^{f'(u_r)t}\phi_x f(v(x/t)) dx\\
&=\left.\phi f(v(x/t))\right.\vert_{x=f'(u_l)t}^{x=f'(u_r)t}-\int_{f'(u_l)t}^{f'(u_r)t}\phi f'(v(x/t))v'(x/t)\frac{1}{t}dx\\
&=\phi(f'(u_r)t,t)f(v(f'(u_r)))-\phi(f'(u_l)t,t)f(v(f'(u_l)))-\int_{f'(u_l)t}^{f'(u_r)t}\phi v'(x/t)\frac{x}{t^2}dx\\
&=\phi(f'(u_r)t,t)f(u_r)-\phi(f'(u_l)t,t)f(u_l)-\int_{f'(u_l)t}^{f'(u_r)t}\phi v'(x/t)\frac{x}{t^2}dx
\end{align*}
where $f(v(f'(u_r)))=f(u_r)$ by the definition of $v$ as the inverse of $f'$.
Let's summarize what we have.
\begin{align*}
 \int_0^\infty \int_{-\infty}^\infty\left[\phi_t u +\phi_x f(u)\right]dxdt &= I_t+I_x\\
 &= \int_{-\infty}^0 -\phi(x,0)u_l dx+ \int_0^\infty \left[ I_{tl}+I_{tm}+I_{tr} \right]dx+\int_0^\infty\left[I_{xl}+I_{xm}+I_{xr}\right]dt
\end{align*}
Looking at the results for each of these integrals, we might hope that everything will cancel nicely with an appropriate substitution. Consider $\int_0^\infty I_{tl} dx$ and $\int_0^\infty I_{xl} dt$. For the $I_{tl}$ integral, let $w=x/f'(u_l)$, so $f'(u_l)dw=dx$.
\begin{align*}
 \int_0^\infty I_{tl} dx &= -\int_0^\infty \phi(x,x/f'(u_l))u_l~dx\\
 &= -\int_0^\infty \phi(f'(u_l)w,w)f'(u_l)u_ldw\\
 \int_0^\infty I_{xl} dt &= \int_0^\infty \phi(f'(u_l)t,t)f(u_l)~dt
\end{align*}
Not quite cancellation, but maybe we can work with it.
$$
\int_0^\infty I_{tl}~dx+\int_0^\infty I_{xl}~dt=(f(u_l)-f'(u_l)u_l)\int_0^\infty \phi(f'(u_l)w,w)~dw
$$
Similarly, consider $\int_0^\infty I_{tr}~dx$ and $\int_0^\infty I_{xr}~dt$. Let $w=x/f'(u_r)$, so $f'(u_r)dw=dx$.
\begin{align*}
 \int_0^\infty I_{tr}~dx &= \int_0^\infty \phi(x,x/f'(u_r))u_r~dx-\int_0^\infty\phi(x,0)u_r~dx\\
 &= \int_0^\infty \phi(f'(u_r)w,w)f'(u_r)u_r~dw -\int_0^\infty\phi(x,0)u_r~dx\\
 \int_0^\infty I_{xr}~dt &= -\int_0^\infty \phi(f'(u_r)t,t)f(u_r)~dt
\end{align*}
So
$$
\int_0^\infty I_{tr}~dx +\int_0^\infty I_{xr}~dt = (f'(u_r)u_r-f(u_r))\int_0^\infty \phi(f'(u_r)w,w)~dw - \int_0^\infty \phi(x,0)u_r~dx
$$
Now consider $I_{tm}$ and $I_{xm}$. Again, make the substitution $w=x/f'(u_*)$.
\begin{align*}
 \int_0^\infty I_{tm}~dx&=\int_0^\infty\left[\phi(x,x/f'(u_l))u_l-\phi(x,x/f'(u_r))u_r+\int_{x/f'(u_r)}^{x/f'(u_l)}\phi v'(x/t)\frac{x}{t^2}dt\right]~dx\\
 &=\int_0^\infty\left[\phi(f'(u_l)w,w)f'(u_l)u_l-\phi(f'(u_r)w,w)f'(u_r)u_r\right]dw+\int_0^\infty\int_{x/f'(u_r)}^{x/f'(u_l)}\phi v'(x/t)\frac{x}{t^2}~dtdx\\
 \int_0^\infty I_{xm}~dt&=\int_0^\infty\left[\phi(f'(u_r)w,w)f(u_r)-\phi(f'(u_l)w,w)f(u_l)\right]dw-\int_0^\infty\int_{f'(u_l)t}^{f'(u_r)t}\phi v'(x/t)\frac{x}{t^2}~dxdt
\end{align*}
Note that
\begin{align*}
 \int_0^\infty I_{tm}~dx+\int_0^\infty I_{xm}~dt
 &= (f(u_r)-f'(u_r)u_r)\int_0^\infty \phi(f'(u_r)w,w)~dw\\
 &+(f'(u_l)u_l-f(u_l))\int_0^\infty \phi(f'(u_l)w,w)~dw\\
 &+\int_0^\infty\int_{x/f'(u_r)}^{x/f'(u_l)}\phi v'(x/t)\frac{x}{t^2}~dtdx-\int_0^\infty\int_{f'(u_l)t}^{f'(u_r)t}\phi v'(x/t)\frac{x}{t^2}~dxdt
\end{align*}
I claim that
$$
\int_0^\infty\int_{x/f'(u_r)}^{x/f'(u_l)}\phi v'(x/t)\frac{x}{t^2}~dtdx=\int_0^\infty\int_{f'(u_l)t}^{f'(u_r)t}\phi v'(x/t)\frac{x}{t^2}~dxdt
$$
Both of these integrals have the integrand $\phi(x,t)v'(x/t)x/t^2$ and are over the region between the trailing and leading edge of the rarefaction wave in $xt$ space. By Fubini's theorem, they are equal.
Finally, by examining all of the integrals computed so far, we can see that
\begin{align*}
 \int_0^\infty \int_{-\infty}^\infty\left[\phi_t u +\phi_x f(u)\right]dxdt &= I_t+I_x\\
 &= \int_{-\infty}^0 -\phi(x,0)u_l dx+ \int_0^\infty \left[ I_{tl}+I_{tm}+I_{tr} \right]dx+\int_0^\infty\left[I_{xl}+I_{xm}+I_{xr}\right]dt\\
 &=-\int_{-\infty}^0 \phi(x,0)u_l~dx-\int_0^\infty \phi(x,0)u_r~dx\\
 &=-\int_{-\infty}^\infty \phi(x,0)u(x,0)~dx
\end{align*}
which is precisely what we wanted to show.

A: Note that $u$ is continuous, hence its first derivatives include jumps, but no higher-order singularity such as Dirac deltas. Therefore, one might prefer using the original weak formulation directly, which reduces to proving $$\iint (u_t+f(u)_x)\phi\,\text{d}x\,\text{d}t = 0$$ for all well-behaved test function $\phi$ with compact support (the weak formulation in OP is derived from the present one using integration by parts). Also, one observes that $u_t$ and $f(u)_x$ equal zero outside the domain defined by $\lbrace 0\leq t, f'(u_l)t\leq x\leq f'(u_r)t\rbrace$, in which we have $u = v(\xi)$ with $\xi = x/t$ and $v = (f')^{-1}$. Furthermore,
\begin{aligned}
\int_{0}^{\infty}\int_{-\infty}^{\infty} u_t \phi\, \text d x\,\text d t &= -\int_{0}^\infty\int_{f'(u_l)t}^{f'(u_r)t} v'(\xi) \frac{x}{t^2} \phi\, \text d x\,\text d t ,
\end{aligned}
\begin{aligned}
\int_{0}^{\infty}\int_{-\infty}^{\infty} f(u)_x \phi\, \text d x\,\text d t &= \int_{0}^\infty\int_{f'(u_l)t}^{f'(u_r)t} \underbrace{f'(v(\xi))}_{x/t} \, v'(\xi) \frac{1}{t} \phi\, \text d x\,\text d t .
\end{aligned}
Therefore, the sum of these two integrals vanishes, thus ending the proof (via integration by parts on the left-hand side).


text:
Q: CondaUpgradeError: This environment has previously been operated on by a conda version that's newer I was trying to fix an issue with an old environment earlier today and screwed up conda. I get this:
Solving environment: failed

CondaUpgradeError: This environment has previously been operated on by a conda version that's newer
than the conda currently being used. A newer version of conda is required.
  target environment location: /Users/U6020643/anaconda3
  current conda version: 4.5.11
  minimum conda version: 4.8

The original problem: I recently upgraded to Catalina, and could not build Pandas when installing it to recreate an environment.
Rehoming: Was this post regarding How to Restore Anaconda after Update to MacOS Catalina. I downloaded the script and ran it. It appeared to work. But I had the same problem with Pandas.
./cpr rehome ~/anaconda3

Installing a revision: At some point in my debugging I also ran this, which I have a hunch caused the problem.
conda install --revision 0

Trying to install Conda 4.8: I found this post and attempted the accepted solution.
I added allow_conda_downgrades: true to my ~/.condarc file. conda update conda produced the same CondaUpgradeError and so did conda install conda==4.8.1.
Next I found the package-cache via conda info and attempted to install 4.8 from there. Here is my conda info output.
     active environment : None
       user config file : /Users/me/.condarc
 populated config files : /Users/me/.condarc
          conda version : 4.5.11
    conda-build version : 3.15.1
         python version : 3.7.0.final.0
       base environment : /Users/me/anaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/osx-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/osx-64
                          https://repo.anaconda.com/pkgs/pro/noarch
          package cache : /Users/me/anaconda3/pkgs
                          /Users/me/.conda/pkgs
       envs directories : /Users/me/anaconda3/envs
                          /Users/me/.conda/envs
               platform : osx-64
             user-agent : conda/4.5.11 requests/2.19.1 CPython/3.7.0 Darwin/19.6.0 OSX/10.15.6
                UID:GID : 502:20
             netrc file : None
           offline mode : False

Then I downloaded osx-64/conda-4.8.3-py37_0.tar.bz2 from Anaconda here, put it into /Users/me/anaconda3/pkgs/, and tried:
conda install /Users/me/anaconda3/pkgs/conda-4.8.3-py37_0.tar.bz2

Which resulted in this issue, where I continue to be stuck.
Preparing transaction: done
Verifying transaction: failed

RemoveError: 'conda-package-handling' is a dependency of conda and cannot be removed from
conda's operating environment.

Before marking as duplicate: consider carefully the similar posts. The version numbers here are different, the path and circumstances that resulted in this problem are different, and I have attempted those solutions without luck.

A: Standalone Conda
I would try downloading a standalone version of Conda that matches the old version of Conda you had (something in v4.8.x), and then try using this to upgrade the Conda package in the base env.
I don't know for sure this will work, but it is pretty simple and will not change anything unless it does work.
Downloads
You can download builds of conda-standalone (PyInstaller-based binaries) from either the Anaconda or Conda Forge channel. Browse to your version (or something close), download the archive (to wherever), unzip, and in the folder standalone_conda you will find a conda.exe file, which is the binary you'll need.
Configuration
Next, you need to set the environment variable CONDA_ROOT_PREFIX to point to your base env's folder, which from your output is /Users/me/anaconda3/. So,
export CONDA_ROOT_PREFIX=/Users/me/anaconda3

Then, to test, check
./conda.exe info

and verify that the values for base environment:, package cache:, and envs directories point to the correct locations, which in a default install would be /Users/me/anaconda3, /Users/me/anaconda3/pkgs, and /Users/me/anaconda3/envs, respectively.
Upgrade
Attempt upgrading the conda package in the base env:
./conda.exe upgrade -n base -c defaults conda

Hopefully, the error you reported before doesn't recur, but I'm actually not sure. Make sure to review any changes if the solve does work.
In the end you can discard the conda.exe and go back to using the one in base.


text:
Q: Add a label next to my form inputs that has a dynamic size After a few trials I managed to create these form textareas that look pretty nice (or so I think).

    <form class="cf">

      Name
      <input class="shadowDepth1" type="text" id="input-name" placeholder="Name">
      Email
      <input class="shadowDepth1" type="email" id="input-email" placeholder="Email address">
      Subject
      <input class="shadowDepth1" type="text" id="input-subject" placeholder="Subject">

  </form>

The next step I believe would be to add a label next to each one that describes the input.
What I want though is for the label to look just like the inputs (maybe with bold or a different color) but occupy space dynamically.
So if the label's contents are big then it will push the input that is next to it, in order to accommodate itself.
A somewhat close example would be this effect.
How can I make this sort of dynamic relation between label and input?
EDIT:
This is basically the idea for the input. I think that because the input width is to 100% it will not go next to my label even with float: left. Making it with a width of eg. 70% will fix the issue but it will remove the dynamic part. Because in the end I want all my text inputs to end at the same area.

A: You probably need to float your elements to the right. First switch order of input and header (so input comes first), because after floating to the right the first element will be on right side. Then add class to inputs and headers and set attribute "float: right" to this class. And last put empty "

" after each header, so it will break to new line. Last you can float entire form to the left, if you dont want to have it on right side.

    <form class="cf">

      <input class="di-wrapper shadowDepth1" type="text" id="input-name" placeholder="Name">
   Name

      <input class="di-wrapper shadowDepth1" type="email" id="input-email" placeholder="Email address">
   Email

      <input class="di-wrapper shadowDepth1" type="text" id="input-subject" placeholder="Subject">
   Subject

  </form>


text:
Q: db:migrate error during rake on Rails 4.0.0 Working on project in Rails 4.0.0, ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin10.8.0], with Rake 10.1.1
I was working on an app for a class in Rails, I made an error and deleted the changes made while in Git. When I went to redo the project, and ran the rake DB migration, I was given the following error message:
Joses-MacBook-Air:crumblr JRV$ rails generate migration CreateHearts Post_id:integer
  invoke  active_record
  create    db/migrate/20140120235500_create_hearts.rb
Joses-MacBook-Air:crumblr JRV$ bundle exec rake db:migrate
==  CreateHearts: migrating ===================================================
-- create_table(:hearts)
rake aborted!
An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: table "hearts" already exists: CREATE TABLE "hearts" ("id" INTEGER        PRIMARY KEY AUTOINCREMENT NOT NULL, "Post_id" integer) /usr/local/rvm/gems/ruby-1.9.3-  p392/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:91:in `initialize'
4.0.0/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top    (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

How do I get rid of the old table reference?

A: There are a couple of commands you can use:
rake db:rollback will rollback the latest migration
rake db:rollback STEP=3 allows you to rollback by more than 1 migration (3 in this example)
rake db:reset will drop the database, recreate it and load the current schema into it.
and if you want to rollback then migrate back up again you can use
rake db:migrate:redo STEP=3 rollback 3 migrations and redo the migration
http://guides.rubyonrails.org/migrations.html


text:
Q: VB.Net - how can i get the type of the object contained in an List If I have a list...
dim l as List(of MyClass) = new List(of MyClass)

and I want to get the type of the objects contained in the list, how do I do that?
The obvious answer, that doesn't seem to be possible from my actual implementation, would be to do something like this...
public function GetType(byval AList as IList(of GenericType)) as System.Type
  dim lResult as system.type = nothing
  if AList.Count > 0 then lResult = AList(0).GetType
  return lResult
end function

But what if the list is empty and I still want to know the type it contains?

A: There's a good article on this at MSDN, here
Basically you can use GetGenericArguments() to get an array of the types provided as arguments to your generic type. In the case of a List, there's only one argument so you will get what you need using eg
dim l as List(of MyClass) = new List(of MyClass)
dim t as Type = (l.GetGenericArguments())(0)


text:
Q: Turn off the screen completely dark on android How to code the android to turn the screen completely off just like you press the power button to lock your screen.
I have tried to use
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 0 )

The screen does deem to very dark but it still is emitting light.
Thanks for the help.

A: I would suggest this one:
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
wl.acquire();

Also refer this example.


text:
Q: Count three (or more) many-to-many relations in template I have three models:

class Target(models.Model):
    fqdn = models.CharField(max_length=100)
    ports = models.ManyToManyField('Port')

class Port(models.Model):
    status = models.CharField(max_length=20)
    services = models.ManyToManyField('Service')

class Service(models.Model):
    name = models.CharField(max_length=200)
    vuls = models.ManyToManyField('Vul')

class Vul(models.Model):
    code = models.CharField(max_length=100)
    name = models.CharField(max_length=200)

and a Template, where I want to count the vuls for a specific Target:

{% for t in targets %}
Target: {{ t.fqdn }}
Count Vuls: {{ t.ports.services.vuls.count }}
{% endfor %}

If I count the ports:
t.ports.count

there is no problem ...
But how counting "over" more than one many-to-many-relations?

A: I think to have a "solution" ...
class Target(models.Model):
    fqdn = models.CharField(max_length=100)
    ports = models.ManyToManyField('Port')
    #counts vuls for every target
    def getSumVuls(self):
        sum = 0
        for p in ports.all():
            for s in p.services.all():
                sum = sum + s.vuls.count()
        return sum

class Port(models.Model):
    status = models.CharField(max_length=20)
    services = models.ManyToManyField('Service')

class Service(models.Model):
    name = models.CharField(max_length=200)
    vuls = models.ManyToManyField('Vul')

class Vul(models.Model):
    code = models.CharField(max_length=100)
    name = models.CharField(max_length=200)

in the template I call the getSumVuls()-method:
{% for t in targets %}
Target: {{ t.fqdn }}
Count Vuls: {{ t.getSumVuls }}
{% endfor %}

I'm not realy happy with this "solution" ... I think that performance is a problem!?!?