text:
Q: BFS to DFS octree conversion in python I'm working with an octree that has been built by third party software. This software reports how to traverse the tree in a breadth first manner, but I want to traverse the tree in a depth first manner.
For my application (building a grid out of particle data for astrophysics applications) I tend to think of octrees in terms of their 'refined' lists, i.e. for a cell that doesn't refine, we would have:
False

Whereas for a single cell that refines into an Oct, we would have:
True
False
False
False
False
False
False
False
False

My goal is to convert such a refined list that is generated in a Breadth First manner into a Depth First manner (in python), but am at a loss as to where to start.
For an example this code:
def construct_octree(refined=[True]):

    # Loop over subcells
    for subcell in range(8):

        # Insert criterion for whether cell should be sub-divided. Here we
        # just use a random number to demonstrate.
        divide = random.random() < 0.5

        # Append boolean to overall list
        refined.append(divide)

        # If the cell is sub-divided, recursively divide it further
        if divide:
            construct_octree(refined)

    return refined

oct = construct_octree()

would create the refined list for a depth first traversal.

A: So you're working with hyperion?  As mentioned, trees aren't inherently depth-first or breadth-first.  However, the way hyperion treats them is actually ideally set up for depth first traversal.  Consider this octree in list format:
refine3 = [True,       # 1
             False,    # 2
             False,    # 3
             True,     # 4
               False,  # 10
               False,  # 11
               False,  # ..
               False,  # ..
               False,  # 14
               False,  # 15
               False,  # 16
               False,  # 17
             False,    # 5
             False,    # 6
             False,    # 7
             True,     # 8
               False,  # 18
               False,  # 19
               False,  # 20
               False,  # ..
               False,  # ..
               False,  # ..
               False,  # ..
               False,  # 25
             False,    # 9
             ]

Depth-first traversal is 1, 2, 3, 4, 10, 11, 12... or the green line on the diagram:

To do that, all you need is:
for node in refine3:
    print(node)

Breadth-first (the orange line) can be done as well, but it would be more complicated.


text:
Q: 'DDLog.h' file not found I am trying to enable the logging inside CocoaAsyncSocket by doing the following inside GCDAsyncSocket.m:
#ifndef GCDAsyncSocketLoggingEnabled
#define GCDAsyncSocketLoggingEnabled 1
#endif

However, when I build the project I receive the following error:

What I am missing here?
Note: I am importing both CocoaAsyncSocket and CocoaLumberjack inside my Swift project using Cocoapods as following:
def shared
  pod 'CocoaAsyncSocket'
  pod 'CocoaLumberjack/Swift'
end

target 'Project' do
  shared

  target 'MyFrameworkTests' do
    inherit! :search_paths
    shared
  end
end

target 'MyFramework' do
  shared
end

target 'MyFrameworkTests' do
  shared
end

A: I searched for a lot of issues, including this, and didn't seem to find a clear answer.
My experience tells me that the header file is not found, meaning the file does not exist.
There are two ways:
1. Manually integrate CocoaLumberjack, CocoaAsyncSocket
You can download source code directly, where the Source folder contains the information you want.
2.Cocoapods Specs
The first method I tested, it worked.
The second method I am not familiar with, there is no test.
It should be noted that all libraries integrated by Cocopods are compiled separately and have no dependencies.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Best way to make a custom select in Angular? I'm using the MEAN stack (Angular 6) and I'm still looking for the best way to build a custom and reusable <select> form control which uses an Array of strings returned from the BE to generate all <option> tags. Let's say for example we have 3 materials wood, metal and plastic and the returned Array can be one of the following (stored in the materials variable):
(in my example.component.ts)

form = new FormGroup({
  'material' = new FormControl('')
});

get material() {return this.form.get('material');}

materials = [
  {
    key: "mat_wood",
    value: "Wood"
  },
  {
    key: "mat_metal",
    value: "Metal"
  },
  {
    key: "mat_plastic",
    value: "Plastic"
  }
]

or
(in my example.component.ts)

form = new FormGroup({
  'material' = new FormControl('')
});

get material() {return this.form.get('material');}

materials = [
  {"mat_wood": "Wood"},
  {"mat_metal": "Metal"},
  {"mat_plastic": "Plastic"}
]

and we have this HTML structure:
(in my example.component.html)

<form [formGroup]="form">

    {{}}

    <select formControlName="material">
      <option *ngFor="let mat of materials" value="{{}}">{{}}</option>
    </select>

</form>

Which eventually has to be compiled to this:
  <select formControlName="material">
    <option value="mat_wood">Wood</option>
    <option value="mat_metal">Metal</option>
    <option value="mat_plastic">Plastic</option>
  </select>

Here we have a classical example of a custom select structure. The  displays the selected option's text to the user. The <select> has opacity set to 0 and is positioned on top of the , so when the user clicks, he clicks on it and activates it.
For each option I need to put the mat_[something] in the value attribute and the readable Something as text in the option, just like in the example above:
<option value="mat_wood">Wood</option>.
Question is: How can I put the selected option text inside the ? I'm looking for a reusable way of doing it.

EDIT:
Looking at the first answer shows (and I forgot to mention) that using a template variable does the job. But if we have an enclosing *ngFor loop that generates multiple selects, then we need to have dynamically generated template variables. Is that even possible?

A: One way is you could refer to select as template variable say mySelect.
<select #mySelect formControlName="material">
  <option value="mat_wood">Wood</option>
  <option value="mat_metal">Metal</option>
  <option value="mat_plastic">Plastic</option>
</select>

And refer to its options.text property like this.
{{ mySelect && mySelect.selectedIndex > -1 ? mySelect.options[mySelect.selectedIndex].text : ''}} inside your span element.
You can read about template variables here

A: Try this example for dynamic option
In Html
<mat-form-field>
  <mat-select placeholder="Select"    [(value)]="selected">
    <mat-option *ngFor="let data of materials" [value]="getKey(data)">{{getValue(data)}}</mat-option>
  </mat-select>
</mat-form-field>

You selected: {{selected}}

In TS
@Component({
  selector: 'select-value-binding-example',
  templateUrl: 'select-value-binding-example.html',
  styleUrls: ['select-value-binding-example.css'],
})
export class SelectValueBindingExample {
  selected = 'option2';
  materials = [
  {"mat_wood": "Wood"},
  {"mat_metal": "Metal"},
  {"mat_plastic": "Plastic"}
]
getValue(obj)
{
return obj[Object.keys(obj)[0]]
}
getKey(obj)
{
return Object.keys(obj)[0]
}
checkValue()
{
 console.log( this["mySelect"])
}
}


text:
Q: Group the rows that are having the same value in specific field in MySQL I am having the following data in MySQL table.
+--------+----------+------+
| job_id | query_id | done |
+--------+----------+------+
|  15145 | a002     |    1 |
|  15146 | a002     |    1 |
|  15148 | a002     |    1 |
|  15150 | a002     |    1 |
|  15314 | a003     |    0 |
|  15315 | a003     |    1 |
|  15316 | a003     |    0 |
|  15317 | a003     |    0 |
|  15318 | a003     |    1 |
|  15319 | a003     |    0 |
+--------+----------+------+

I would like to know if it's possible to have a sql query, which can group by query_id IF ALL 'done' fields are marked as 1. The possible output I imagine would be:
+----------+------+
| query_id | done |
+----------+------+
|  a002    |  1   |
|  a003    |  0   |
+----------+------+

I've tried the following SQL query:
select job_id, query_id, done from job_table group by done having done = 1 ;

But no luck.  I would really appreciate for any help!

A: I'm not particullarly proud of this solution because it is not very clear, but at least it's fast and simple. If all of the items have "done" = 1 then the sum will be equal to the count SUM = COUNT
SELECT query_id, SUM(done) AS doneSum, COUNT(done) AS doneCnt
FROM tbl
GROUP BY query_id

And if you add a having clause you get the items that are "done".
HAVING doneSum = doneCnt

I'll let you format the solution properly, you can do a DIFERENCE to get the "not done" items or doneSum <> doneCnt.
Btw, SQL fiddle here.

A: All "done" jobs :
SELECT * FROM job_table GROUP BY done HAVING MIN(done) = 1;

All "undone" jobs :
SELECT * FROM job_table GROUP BY done HAVING MAX(done) = 0;

All jobs having the same value ("done" OR "undone") :
SELECT * FROM job_table GROUP BY done HAVING MAX(done) = 0 OR MIN(done) = 1;

A: The output in your example can be obtained as:
SELECT query_id, min(done) as done
FROM job_table
GROUP by done

A: I think you should be looking at this
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name

A: try something like
SELECT qry_id, 1
FROM (
    SELECT qry_id, done
    FROM tbl
    GROUP BY qry_id, done
) AS t
GROUP BY qry_id
HAVING COUNT(*)=1
UNION
SELECT qry_id, 0
FROM (
    SELECT qry_id, done
    FROM tbl
    GROUP BY qry_id, done
) AS t
GROUP BY qry_id
HAVING COUNT(*)>1


text:
Q: Emitting event to clients during server shutdown in nodejs and socket.io I am working on nodejs for client server functionality and using socket.io for emitting and receiving events. I am able to emit and receive events in my code but facing an issue in emitting and receiving an event during process shutdown. I want to emit an event to all clients during server(nodejs) shutdown. I am using it like this
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);

process.on('SIGINT', shutdown);

function shutdown() {
  console.log('Inside shutdown server');
  //io.emit('shutdown', 'Server is going DOWN');
  io.sockets.emit('shutdown', 'Server is going DOWN');
  server.close(function () {
    console.log('closed express');
  });
  process.exit(0);
}

But shutdown event is not being received at other end. is there any thing I am missing here?
Code at receiving side:(nodejs)
socket.on('shutdown', function(msg) {
    console.log('inside shutdown ' + msg);
});

Please help me out in fixing this.
Thanks in advance...

A: Apparently, socket.io handles sending messages in the next tick, so you must defer calling process.exit(0) to the next event loop iteration:
function shutdown() {
  // ...
  process.nextTick(() => {
    process.exit(0);
  })
}


text:
Q: How to delete the Log statements in my project using proguard rules? I need to delete all the Log statement inside my project using proguard.
Previously i was using the default proguard-android.txt file for obfuscating and didn't find any Success. i was able to see the Log statement when using any apk decompiler.
The rules were -
-assumenosideeffects class android.util.Log {

    public static int v(...);
    public static int i(...);
    public static int w(...);
    public static int d(...);
    public static int e(...); }

After searching for a while i came to the answer which quoted that i need to use 'proguard-android-optimize.txt' because by default the optimize is not enabled.
But again i am getting error below -

java.lang.IllegalArgumentException: Form-encoded method must contain
  at least one @Field.

I think the proguard must have deleted the

@FormUrlEncoded

in retrofit2.
Tell me where am i wrong?

A: Try this Proguard setting:
-keepattributes *Annotation*


text:
Q: HTML & JS: stretching  content I have a canvas with some paths drawn on it. Is it possible to somehow manually stretch its content vertically?

A: Ok, I found the answer: what I actually needed was CanvasRenderingContext2D.scale(x, y)


text:
Q: Real Analysis Folland Proposition 1.5 I don't understand the last sentence of Proposition 1.5.
In short, $X_j$ is not necessarily in $\mathcal{E}_j$, therefore, we cannot use Proposition 1.4.
In more detail, ${\bigotimes}_1^n \mathcal{B}_{X_j}$ is, by definition, a $\sigma$-algebra on $X$ generated by
$$\{\pi_j^{-1}(E_j) : E_j\in\mathcal{B}_{X_j}, j=1,...,n \}.$$
Here, $\mathcal{B}_{X_j}$ is the Borel $\sigma$-algebra on a separable metric space $X_j$ and $X=\prod_1^nX_j$ equipped with the product metric defined as
$$\rho ((x_1,x_2,...,x_n),(y_1,y_2,...,y_n))=\textrm{max}(\rho_1(x_1,y_1),\rho_2(x_2,y_2),...,\rho_n(x_n,y_n)) .$$
Also,
$$\pi_j^{-1}(E_j)=\{x\in X : x_j\in E_j \}. $$
We showed  that $\mathcal{B}_{X_j}$ is generated by $\mathcal{E}_j$ and $\mathcal{B}_X$ is generated by $\{\prod_1^n E_j : E_j\in \mathcal{E}_j \}$. The definition of $\mathcal{E}_j$ is given in Proposition 1.5.
Now if $X_j\in\mathcal{E}_j$, then, by Proposition 1.4, ${\bigotimes}_1^n \mathcal{B}_{X_j}$ is generated by $\{\prod_1^n E_j : E_j\in \mathcal{E}_j \}$. Consequently, since ${\bigotimes}_1^n \mathcal{B}_{X_j}$ and $\mathcal{B}_X$ are generated by the same set, ${\bigotimes}_1^n \mathcal{B}_{X_j}=\mathcal{B}_X$.
However, $X_j$ is not necessarily in $\mathcal{E}_j$. Or am I missing something?
Thank you in advance.
I attached the image of the page with Propositions 1.4 and 1.5.

A: Just notice that in this case if we define $\tilde{\mathcal{E}}_j = \mathcal{E}_j\cup\{X_j\}$, then the $\sigma$-algebra generated by both sets is the same, since $X_j$ can be written as an infinite union of those open balls.

A: $X_j$ itself is an open set so it's a countable union of the generating set $\mathcal{E}_j$.


text:
Q: Pandas Crosstab with frequency, row percentage and col percentage on the same output I am trying to replicate the very useful tabulate twoway function in Stata, where on the same output you can see the frequency, the corresponding row percentage and the corresponding column percentage for each possible combination of two categorical variables in the data.
That is, each cell in the resulting table contains three stacked values corresponding to the above numbers.
Example output in Stata: this is the tabulation of a single variable car type, where, in the data, i have 52 observations where car type is domestic and 22 observations where car type equals foreign.
 Domestic   Foreign  Total

 52         22       74
 70.27      29.73    100.00
 100.00     100.00   100.00

Is it possible to do that in Pandas? Example:
df = pd.DataFrame({'A' : ['one', 'one', 'two', 'three'] * 6,
                   'B' : ['A', 'B', 'C'] * 8,
                   'C' : ['foo', 'foo', 'foo', 'bar', 'bar', 'bar'] * 4,
                   'D' : np.random.randn(24),
                   'E' : np.random.randn(24)})

something that would combine
pd.crosstab(df.A,df.B)

with pd.crosstab(df.A, df.B).apply(lambda r: r/r.sum(), axis=1)
and pd.crosstab(df.A, df.B).apply(lambda r: r/r.sum(), axis=0)
on the same output. What do you think? I am thinking about aggfunc but here I need to get the whole dataframe, not just a Series...
Thanks!

A: Consider concatenating all three into one df, using crosstab's margins. Below uses your example:
newdf = pd.concat([pd.crosstab(df.A, df.B, margins=True),
                   pd.crosstab(df.A, df.B).apply(lambda r: r/r.sum(), axis=0),
                   pd.crosstab(df.A, df.B).apply(lambda r: r/r.sum(), axis=1)])

newdf = newdf.loc[['one','two','three','All']]              # RE-ORDER INDEX VALUES
newdf = newdf[['A', 'B', 'C', 'All']]                       # RE-ORDER COLUMNS
newdf['All'] = np.where(pd.isnull(newdf['All'])   &         # ROW PERCENTAGES SUM
                        (newdf['A'] + newdf['B'] + newdf['C']==1),
                        1, newdf['All'])
print(newdf)
#              A         B         C   All
# A
# one    4.000000  4.000000  4.000000  12.0
# one    0.500000  0.500000  0.500000   NaN
# one    0.333333  0.333333  0.333333   1.0
# two    2.000000  2.000000  2.000000   6.0
# two    0.250000  0.250000  0.250000   NaN
# two    0.333333  0.333333  0.333333   1.0
# three  2.000000  2.000000  2.000000   6.0
# three  0.250000  0.250000  0.250000   NaN
# three  0.333333  0.333333  0.333333   1.0
# All    8.000000  8.000000  8.000000  24.0


text:
Q: How does this optocoupler work? I am working on an embedded system and unfortunately I have not got a proper schematic for checking power failure. However, I have a PCB for that so I drew a schematic based on the PCB.
I just roughly understand how the below schematic works but not sure 100 %.
Especially, Anode is connected to emitter which is also connected to the ground in J1(Connector Pin 1). How does it work?
Also, R1 does not connect to anywhere in PCB. It is just connected with a a bit long wire. I just guess it has to go ground. Is that right?
J2 is a relay and pin 3 and 4 are connected with a jumper that micro controller keep reading from if power is alive.
J1 is connected to a line from power supply,
U1-optocoupler (4N35),
J1 - 4 pins connector,
J2 - 2*2 relay

If I get rid of the ground symbol, Does it make sense?
Actual PCB looks like this

Thank,
J

A: The floating cathode of the opto-coupler LED makes no sense.  You got something wrong in tracing the board.  Either there is a trace underneath something you can't see, or the board has inner layers.
Unless this board has a negative supply, ground connected to the emitter and anode doesn't make any sense either.
Bottom line is your reverse-engineered schematic is wrong.  That needs to be fixed before you proceed.


text:
Q: error on opening a csv file using a jet oledb connection in excel vba First time I'm using stackoverflow so here goes...
I've been getting errors intermittently when I try to run a macro in excel which I use for pulling in data from a CSV file. The error normally goes away if I start a fresh session, but this time it's been particularly persistant. It basically errors on the .Open line below, giving me a "Run-time error '2147467259' (80004005) Unspecified error":
Public Sub LoadFile()

file_path = Range("FlatFileLocation")

Set oConn = CreateObject("ADODB.Connection")

strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & file_path & "; Extended Properties=""text;HDR=Yes;FMT=Delimited(,)"";"

oConn.Open strcon

.....

Other info:
1) the file I'm trying to access is not open by another user
2) I close my connections at the end of the sub. also, i just tried restarting my machine and the error happened the first time I tried running the file
3) When I open my session up without any of my existing addins it seems to work. Is there any way of checking whether there is some sort of addin conflict going on?
There were other posts that suggest using CSVReader. Questions I have before trying this route are:
1) can I use this CSVReader across multiple user machines? The problem I would have here is needing to install it on a number of machines. I might be able to put a file on a shared drive however.
2) Can I query the resultant file with a SQL string? At the moment I use something like this:
....
strsql = "SELECT * FROM ( " & strsql & " ) WHERE ( ABS(PrevRisk) + ABS(CurrRisk) >= " & RiskThreshold & " ) ;"
Set oResult = New ADODB.Recordset
oResult.Open strsql, oConn
....

Thanks in advance for your help!


text:
Q: Angular [routerLink] does not work when part of HTML imported from database I sort of understand why the following does not work but perhaps I can get some guidance or some workaround?
So I am using a module that builds tree structure from an array that I import from a webApi. I do not have much control over the node name (that is what is displayed on every level of the tree) via Angular but I can control the HTML of the node name using [innerHTML]="node.data.name | safeHtml" All is well and good and if I click on inspect element of a node I see the following

<a [routerlink]="/account-detail/a7e9f9ba-e202-4122-8275-4010b47ffc55">Account 1</a>

The problem is that clicking on the link does not work. I did test this exact same HTML by pasting it above the tree view directly in the Angular HTML template and it works fine then. My guess is that because I import this HTML that there is no binding between the dom and Angular script. Unfortunately I am not sure and I have no idea what to search for on Google. I also tried like (click) command but exactly same issue. No errors also in the console.
Any advice would be highly appreciated. I must also just add that if I use a normal href method it works but of course that is a complete page refresh.

A: in angularjs it could be achieved using $compile directive, but this $compile directive has been dropped on newer versions. i faced this issue some days ago. there is a npm module that can be used to achieve this. here is the link to my question, you can find the solution in answer.


text:
Q: I can't navigate without the navigation prop of react-navigation with react-i18next container I apply the navigation example without the navigation prop of the react-navigations docs (NavigationService), but I can't make it work with react-i18next.
I applied the example of the documentation https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html in my code:
// App.js

import React from 'react';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/lib/integration/react';
import { createAppContainer } from 'react-navigation';
import { I18nextProvider, withNamespaces } from 'react-i18next';
import { persistor, store } from './src/store';
import I18n from './src/localization';
import Navigation from './src/navigation';
import NavigationService from './src/navigation/NavigationService';
import Loader from './src/screens/components/Loader';

class NavigationStack extends React.Component {
  static router = Navigation.router;
  render() {
    const { t } = this.props;
    return <Navigation screenProps={{ t, I18n }} {...this.props} />;
  }
};

const ReloadNavOnLanguageChange = withNamespaces(['common', 'server'], {
  bindI18n: 'languageChanged',
  bindStore: false,
})(createAppContainer(NavigationStack));

export default class App extends React.Component {
  ...
  render() {
    return (
      <Provider store={store}>
        <PersistGate loading={<Loader />} persistor={persistor}>
          <I18nextProvider i18n={ I18n } >
            <ReloadNavOnLanguageChange ref={navigatorRef => {
              NavigationService.setTopLevelNavigator(navigatorRef);
            }} />
          </I18nextProvider>
        </PersistGate>
      </Provider>
    );
  };
};

// Navigation.js

...
export default Navigation = createSwitchNavigator(
  {
    AuthLoading: AuthLoadingScreen,
    Login: LoginScreen,
    App: AppScreen
  },
  {
    initialRouteName: 'AuthLoading'
  }
);

// NavigationService.js

Apply the same code that's in https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html

// Any JS module of my project (actions, helpers, components, etc.)

import NavigationService from 'path-to-NavigationService.js';
...
NavigationService.navigate('Login');

When the authorization token is validated and the result is negative, the login screen must be opened (NavigationService.navigate('Login')) but it returns the error _navigator.dispatch is not a function in NavigationService.js:
const navigate = (routeName, params) => {
   // DISPATCH ERROR
   _navigator.dispatch(
     NavigationActions.navigate({
       routeName,
       params
     })
   );
};

Dependencies:

*

*react 16.5.0

*react-native 57.1

*react-i18next 9.0.0

*react-navigation 3.1.2

Any suggestion? Has anyone else found this scenario?

A: Using the innerRef option of the withNamespaces hoc of react-i18next instead of passing the function through the ref property of the root component… AS THE DOCUMENTATION OF REACT-I18NETX SAYS!
// App.js

...
const ReloadNavOnLanguageChange = withNamespaces(['common', 'server'], {
  bindI18n: 'languageChanged',
  bindStore: false,
  innerRef: (ref) => NavigationService.setTopLevelNavigator(ref)
})(createAppContainer(NavigationStack));

export default class App extends React.Component {
  ...
  render() {
    return (
      ...
      <ReloadNavOnLanguageChange />
      ...
    );
  };
}


text:
Q: Notification sound in android In my android application, I want to notify the user with a sound without showing the notification. Is that possible ?
Notification n = new Notification();
                n.icon = com.android.mms.R.drawable.wap_message;
                n.defaults |= Notification.DEFAULT_SOUND;
                n.flags = Notification.FLAG_AUTO_CANCEL;

This is the code I am using to show the notification, So I commented icon and flags of the notification as follows
Notification n = new Notification();
                //n.icon = com.android.mms.R.drawable.wap_message;
                n.defaults |= Notification.DEFAULT_SOUND;
                //n.flags = Notification.FLAG_AUTO_CANCEL;

But it is not working.

A: why don't you use MediaPlayer instead of Notification to play the notification sound. If you use the Notication then it shows the icon. In your case using the MediaPlayer is better option.


text:
Q: What is the difference between QByteArray and QList or QVector? QByteArray holds individual bytes, and if we make a QList of unsigned chars that will also hold the individual bytes.
What is the reason QByteArray exists when there can made a QList<unsigned char>?
What is the difference between QByteArray and QList<unsigned char> or QVector<unsigned char>?
What points am I missing?

A: QByteArray is a usefull  wrapper around char*. Suitable for streaming with QDataStream, string operations and other data management.
From the docs you also can find that:

Behind the scenes, it always ensures that the data is followed by a
  '\0' terminator, and uses implicit sharing (copy-on-write) to reduce
  memory usage and avoid needless copying of data.

QList, at first is not linear(subsequent) in memory (you should use QVector), and have no such usefull API

A: QList allocates memory on heap and does not guarantee any data locality, so there can be a performance difference between using QList and QByteArray.
From: http://doc.qt.io/qt-5/qlist.html#details

QVector should be your default first choice. QVector will usually give better performance than QList, because QVector always stores its items sequentially in memory, where QList will allocate its items on the heap unless sizeof(T) <= sizeof(void*) and T has been declared to be either a Q_MOVABLE_TYPE or a Q_PRIMITIVE_TYPE using Q_DECLARE_TYPEINFO. See the Pros and Cons of Using QList for an explanation.

QByteArray also provides convenience methods for working with bytes (and strings in general).


text:
Q: Why is Lombok generating an extra Getter when overriding a generic getter? I have an interface that defines an id field (and other fields, but simplifying), which uses Java's generics.
And I am using Lombok to generate Getters and a Builder for a class which implements this.
With IdType getId() in the interface, Lombok is generating both Object getId(), and UUID getId(). Both the methods work when called through reflection, but it is deeply weird, and messed up some code that was assuming that a class would not have multiple methods with the same name and different return types.
(I <3 Reflection)
Here's a unit test that shows this behavior. Is my lombokking wrong? Is there another annotation I need to apply? Do I just shrug and write my code to get all the getters to check for this and avoid it?
Java 8, Lombok 1.18.16, currently up to date.
public class LombokGeneratesDuplicateMethodsTest {
    interface WithId<IdType> {
        IdType getId();
    }

    @Getter
    @Builder
    static class Record implements WithId<UUID> {
        private UUID id;
        private String name;
    }

    @Test
    public void testStuff() throws Exception {
        Collection<Method> getIds = Arrays.stream(Record.class.getDeclaredMethods())
                .filter(m -> Modifier.isPublic(m.getModifiers()))
                .filter(m -> !Modifier.isStatic(m.getModifiers()))
                .filter(m -> !Void.TYPE.equals(m.getReturnType()))
                .filter(m -> m.getParameterTypes().length == 0)
                .filter(m -> m.getName().equals("getId"))
                .collect(Collectors.toList());

        assertThat(getIds.size()).isEqualTo(2);  // This seems wrong...

        UUID someId = UUID.randomUUID();
        Record record = Record.builder().id(someId).name("Gunter").build();
        for (Method getId : getIds) {
            assertThat(getId.invoke(record)).isEqualTo(someId);
        }

        WithId<UUID> withId = record;
        assertThat(withId.getId()).isEqualTo(someId);
        assertThat(record.getId()).isEqualTo(someId);
    }
}

A: Has nothing to do with Lombok.
Try it. Write this code:
interface Example<T> {
    T get();
}

class Foo implements Example<String> {
    public String get() {return null;}
}

then:
>javac Foo.java
>javap Foo
Compiled from "Foo.java"
class Foo implements Example<java.lang.String> {
  Foo();
  public java.lang.String get();
  public java.lang.Object get();
}

This is in the JLS. The Object-returning method is called a synthetic bridger. It's there, but not particularly visible to javac (javac knows about it, but acts as if it does not exist). At the class file level (so, JVMs, and to some extent, reflection), it does exist.
So, how to fix?
Check for the synthetic flag. It'll be set for the Object-returning one:
class Foo implements Example<String> {
        public String get() {return null;}

        public static void main(String[] args) throws Exception {
                for (Method m : Foo.class.getDeclaredMethods()) {
                        System.out.println(m.getReturnType() + " " + m.getName() + ": " + m.isSynthetic());
                }
        }
}

then:
> javac Foo.java; java Foo
void main: false
class java.lang.String get: false
class java.lang.Object get: true

(I <3 Reflection)

At risk of raining on your parade, this is... not a good mindset for a good java programmer in my opinion. Java doesn't make reflection easy, and the tooling mostly assume you don't aggressively use it either. For example, refactor scripts don't do well when you call a bunch of methods using reflection instead of actually calling them.


text:
Q: WordPress custom post meta filter not displaying options when filter is set I have two custom post types set up - "Books" and "Authors". I am using custom metadata which allows you to link a book to an author via a select box (by querying posts from the authors post type to create the select options).
This works fine, but I'm also trying to create a custom filter on the posts screen for the books post type that allows you to filter by author, which isn't behaving as expected. Here's the code I'm using to add the filter:
function book_filter() {
  global $typenow;
  global $wp_query;
    if ( $typenow == 'book' ) {
      $authors = new WP_Query(
        array(
          'post_type' => 'author',
          'nopaging' => true
        )
      );
      wp_reset_postdata();

      /*
      $authors = get_posts( array(
        'post_type' => 'author',
        'numberposts' => -1
      ));
      */

      $current_author = '';
      if( isset( $_GET['author'] ) ) {
        $current_author = $_GET['author'];
      } ?>
      <select name="author" id="author">
        <option value="all" <?php selected( 'all', $current_author ); ?>>All authors</option>
        <?php
        if ($authors->have_posts()) {
            while ($authors->have_posts()) {
                $authors->the_post();
                if ($current_author == get_the_ID()) {
                  echo '<option value="' . get_the_ID() . '" selected>' . get_the_title() . '</option>';
                } else {
                  echo '<option value="' . get_the_ID() . '">' . get_the_title() . '</option>';
                }
            }
        }

        /* foreach( $authors as $author ) { ?>
          <option value="<?php echo $author->ID; ?>" <?php selected( $author->ID, $current_author ); ?>><?php echo get_the_title($author->ID); ?></option>
        <?php } */

        ?>
      </select>
  <?php }
}
add_action( 'restrict_manage_posts', 'book_filter' );

function do_book_filter( $query ) {
  global $pagenow;
  $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
  if ( is_admin() && $pagenow=='edit.php' && $post_type == 'book' ) {
    if (isset( $_GET['author'] ) && $_GET['author'] !='all' ) {
      $query->query_vars['meta_key'] = 'author';
      $query->query_vars['meta_value'] = $_GET['author'];
      $query->query_vars['meta_compare'] = '=';
    }
  }
}
add_filter( 'parse_query', 'do_book_filter' );

Initially, all the authors are shown in the filter, and selecting an author to filter by does actually work. The problem is that, once it's been filtered, the authors disappear from the select box dropdown. I tried adding an else statement to if ($authors->have_posts()) {... and this confirmed that it isn't fetching posts from the authors post type after a filter has been set.
I'm also using another custom filter (removed from the code for simplicity) which just uses a standard array variable rather than a query and that one is working fine, so I guess it must something to do with the custom post type query.
You'll see in the code that I've tried get_posts (commented) as well as WP_Query but they both present the same issue.
Where am I going wrong here?


text:
Q: Voltage is changing. Then why do we use a constant value (if given as battery is 3V)in doing sums.? Actually the potential difference changes throughout each part in a circuit and the electrons dont have the same energy (say the battery is 3V) throughout the circuit.then why ,when do we use V=3V as a constant value in proceeding sums...the battery just initially provides the electrons a energy of 3V right?

A: The voltage from a source is the potential energy given per unit charge. As we pass through the circuit, this energy is converted to other types of energy and the value decreases. This is the principle of the loop law that $ \sum V = 0$ through a closed loop.
If we consider an ideal loop where the resistance in the wires is 0, then we can calculate the drop in voltage across each element in the circuit (bulbs, motors etc.) and use this to determine the voltage at any point.
In reality, some voltage is also lost from dissipation in the wires (converted to thermal energy). In a short circuit (no devices to use the energy) the wires get very hot because the entire potential difference is being dissipated as thermal energy in the wire.


text:
Q: Limit keyboard input to specific characters with while loop and get() I am trying to limit the scope of possible inputs on a figure to 'y' and 'n' in a while loop in Matlab. However, the code below does not work as it (to my understanding at least) should.
answ = get(fig, 'CurrentCharacter');
while answ ~= 'n' & answ ~= 'y'
  answ = get(fig, 'CurrentCharacter');
end

How can I achieve the desired behavior? Only the first input seems to be caught by get. When I display the variable, the loop just goes on forever, even if the character in answ clearly is 'n' or 'y' and does not change with subsequent key presses. Additionally, sometimes the figure will disappear and the input will start getting caught by the terminal.
Executing the code in a command window seems to yield the desired behavior:
>> answ

answ = n

>> answ ~= 'n' & answ ~= 'y'

ans = 0

answ = x

>> answ ~= 'n' & answ ~= 'y'

ans = 1

A: You should not use a loop to listen for characters, but use figure Callbacks!
For instance:
fig = figure('KeyPressFcn',@Key_Down);

function Key_Down(src,event)
    switch event.Character
        case 'y'
            disp('y')
        case 'n'
            disp('n')
    end
end

'KeyPressFcn' is an event raised when a key is pressed, and Matlab will call your Key_Down function. In the event structure you'll find the Key, the modifier (Shift, CTRL, etc) and other info.


text:
Q: How to change display format of legend in MATLAB I am looking for a way to force the legend entries in a particular format. I following code, they are displayed like

Instead I want  it like 1e-1,1e-2,1e-3,1e-4, 1e-5.
Is there a way to do this.
MWE:
sig=[0.1 0.01 0.001 0.0001 0.00001];
for j=1:length(sig)
    for x=1:10
       Cost(j,x) = 2*x+j;
    end
plot(1:10,Cost(j,:));
end
legend(strcat('\sigma^2_n=',num2str((sig)')));
set(h,'Interpreter','latex')

A: You should specify that you'd like to use scientific notation when you convert sig to a string by passing a custom format specifier to num2str
legend(strcat('\sigma^2_n=',num2str(sig.', '%.0e')));

If you want to remove the leading 0 in the exponent, you can remove them with a regular expression
S = regexprep(cellstr(num2str(sig.', '%.0e')), '(?<=e[-+])0*', '');
legend(strcat('\sigma^2_n=', S))


text:
Q: What are the "complex legal concerns" negated by Ubuntu Advantage? I am looking at the benefits of subscribing to Ubuntu Advantage and I have noticed the following line in the list of benefits to being a Ubuntu Advantage subscriber:

Legal coverage: IP indemnification coverage so you can easily deploy Ubuntu in your business without complex legal concerns

What exactly are the complex legal concerns that are negated by Ubuntu Advantage?

A: The "IP" here means: intellectual property. I'm not lawyer but given the context:

We take care of intellectual property (IP) infringement legal claims brought against customers in their use of Ubuntu.

Continue reading:

Throughout the open-source world, all possible care is taken to respect intellectual property rights. In the unlikely event of an intellectual property issue in Ubuntu, Canonical will replace or modify the infringing portion of the software so that it becomes non-infringing, or obtain the rights for you to continue using the software.

If for some reason you get a claim for using any package/software that comes with the usage of Ubuntu, they will replace that piece of software and assume all the costs/damages that the claim could cause:

In order to allow our support customers to deploy Ubuntu without complicated legal concerns, Canonical will assume the legal defence, pay all legal defence costs, and pay any resulting damages judgement or settlement, for any claim brought against our support customers worldwide by any third party for alleged infringement of patents, copyrights, trademarks, or trade secrets due to our support customer's use of the Ubuntu software during the term of their support services contract.

Reference:

*

*Ubuntu Assurance | Ubuntu Advantage | Ubuntu


text:
Q: microsoft sync framework when local cache reach maximum capacity What machanisms or methods, if any, are available to handle the case where the SQL CE has reached it's storage capacity to fully sync an SQL server?
I am just planning ahead so I can't actually try things out, but 4 GB doesn't seem like alot because I might have BLOBs in my database.

A: 4GB is a lot of local data. Assuming it is important, how do you plan to back it up?
Repeating this over several clients each of which has their own SQL CE means a lot of potential data loss and redundant/repeated data
I'd consider using SQL Server Express now because you can upgrade this later


text:
Q: I cannot open Safari, when I did open -a Safari error -10810 appeared
I tried searching what error -10810 is but nothing came up on Google. Any idea on how to fix this or go around this?

A: When opening an application with the open command, you should use the -a option, e.g:
open -a "Safari"

From the man page for the open command:

-a application
       Specifies the application to use for opening the file

Note: If you use the -a option, you typically do not need to specify the pathname or even use the .app extension. Just the format as in the example shown above should work.

In Terminal, the executable permission (and others) output of:
ls -l /Applications/Safari.app/Contents/MacOS/Safari

Should be:
-rwxr-xr-x

If not, then in Terminal, run the following command:
sudo chmod 0755 /Applications/Safari.app/Contents/MacOS/Safari

This will ensure the proper permissions on the Safari executable and should stop you from getting the error you've got.


text:
Q: Non blocking connect to loopback address (127.0.0.1 or localhost) When I do a non blocking connect to the loopback address from the iOS Simulator (which probably uses the same TCP stack as the Mac and FreeBSD), I see that connect always succeeds, even when the server process isn't running.
I detect that connect succeeded by using select() with zero timeout. So, as long as select() returns 0, I assume that the connection is in progress, if it returns -1 I fail with an error and if it returns 1, the socket is ready for reading (as the server must have responded), and I begin reading after reporting that the connect succeeded.
This works well for all addresses except the loopback. On the loopback select() always returns 1, even when there is no server running. So, I begin reading, which fails and I handle it. But I should have detected this through select()!

A: You are getting the error before that, right on connect().
Before going to proceed with select(), check that errno is EINPROGRESS and not something else.  In *BSD, connections to a non-listening port on a localhost error out (or may error out) immediately.
I just ran a very simple test like this (headers skipped):
int
main(void)
{
    int fd;
    int r;
    struct sockaddr_in remote;
    struct hostent *he;

    he = gethostbyname("localhost");
    if (he == NULL)
            return -1;

    memcpy(&remote.sin_addr, he->h_addr, sizeof(remote.sin_addr));
    remote.sin_port = htons(9671);
    remote.sin_family = AF_INET;

    fd = socket(PF_INET, SOCK_STREAM, 0);
    fcntl(fd, F_SETFL, O_NONBLOCK);

    r = connect(fd, (struct sockaddr *)&remote, sizeof remote);
    if (r < 0) {
            perror("connect");
    }
    return 0;
}

With nothing listening on port 9671, I got:

*

*on Linux: connect: Operation now in progress

*on FreeBSD: connect: Connection refused
Of course, it is always a good idea to check the error codes of all syscalls (something the example above does not do for simplicity's sake - it's just an illustration, after all).

A: The problem was that I was relying on select() to tell me if the connect was successful. Select only tells you if something changed on that fd. I should've actually called connect() again on the socket and verify that the if it fails, errno is either EINPROGRESS, ECONN or EALREADY. Except for ECONN, all the other values mean that we should retry; ECONN means it's already connected. Any other errno value means we failed to connect.


text:
Q: ggplot2 to plotly- Only shows traces and not data on the tooltip I have taken my plot1 plot and converted it to an interactive plot using ggplotly(), but when I try and use the tooltip, all it shows is the "Trace 1", "Trace 2" etc. for the 5 rectangles I have drawn with geom_text within my original plot. How do I get the tooltip to actually show the data when I hover over the data point rather than showing "Trace 1", "Trace 2" etc. ?
Here's my code:
    plot1 <- ggplot(dfplot, aes(x,y)) +
      geom_text(aes(x=200, y=min(dfplot[,1]-3), label="Weak"), size=4)+
      geom_text(aes(x=400, y=min(dfplot[,1]-3), label="Strong"), size=4)+
      geom_text(aes(x=600, y=min(dfplot[,1]-3), label="Very Strong"), size=4) + ...
    finalplot1 <- ggplotly(plot1)

I want the plotly version to stop saying 'trace 1" in the tooltip and start showing the x and y coordinate values from the dataframe. How do I do this?

A: So below is the regular scatter plot example.
library(ggplot2)
library(plotly)
lol <- ggplot(diamonds,aes(x=carat,y = price)) + geom_point()
ggplotly(lol)

This is how you can customize the tooltip.Remember also to add ,tooltip=c("text") like below.
lol2 <- ggplot(diamonds,aes(x=carat,y = price)) + geom_point(aes(text=paste('<br>cut:',cut)))

ggplotly(lol2,tooltip = c("text"))


text:
Q: Inner trait breaks implicit parameter object Test {

  trait Foo

  trait TC[A]

  object TC {
    implicit def tc1[F <: Foo] = new TC[F] {}
    implicit def tc2[F1 <: Foo, F2 <: Foo] = new TC[(F1, F2)] {}
  }

  object Bar {
    trait X
    val c = new Foo with X
    def bar[A](a: this.type => A)(implicit tc: TC[A]) = 1
  }

  Bar bar (_.c)

  Bar bar (b => (b.c, b.c))
}

The last line gives compiler error "could not find implicit value for parameter tc...".
Now: moving trait X outside of object Bar makes it work.
The next to last line works in both cases.
Is there any good reason for this, and/or is it possible to make it work without moving the trait out of the object?

A: This is not going to be a full blown answer (and contains a high dose of speculation), but given that you got none until now I imagine that it's better than nothing.
It seems that the problem lies with the fact that the compiler treats X in new Foo with X as a path-dependant type, even though we are in an object definition rather than a class.
Because of this, the compiler then infers A = (Test.Foo with b.X, Test.Foo with b.X) forSome { val b: Test.Bar.type } in the second call to bar.
This requires the compiler to find an implicit value of type TC[(Test.Foo with b.X, Test.Foo with b.X) forSome { val b: Test.Bar.type }], and apparently tc2 is no fit (I am not intimate enough with the corner cases fo the scala type system to know for sure if there is a genuine incompatibility, or if the compiler just has no clue)
[speculation mode]
The problem with the path-dependent type handling smells like a bug to me (or at least an underspecified oddity). I think that the culprit is that the body of an object is compiled no different from a class, and then is somehow made into a singleton object, which means that new Foo with X is really seen as new Foo with this.X instead of new Foo with Bar.X, and thus treated as a path dependent type (even though they should IMHO denote the very same thing in this case).
[/speculation mode]
And now for the weird part (which is also the work around that you requested): turning this:
val c = new Foo with X

into this:
val c = new Foo with Bar.X

actually fixes the compilation. As I understand it, this is because by explicitly specifying Bar we force the compiler to recognize that Bar.X is a stable path, which clears the problem with path dependent types.
Now, the real work around is of course to really move X outside Bar as you suggested. It works and is painless, so why not do it?


text:
Q: Boot Ubuntu ISO under qemu Probably a very simple issue: I'm trying to boot the offical Ubuntu 20.04.2 ISO image under qemu. For this purpose I've first created a disk image:
qemu-img create ubuntu-20.04.2.0.img 10G

And then tried:
qemu-system-x86_64 -enable-kvm -hda ubuntu-20.04.2.0.img -cdrom ubuntu-20.04.2.0-desktop-amd64.iso -boot d -m 512

Which results in a kernel panic because "no working init" was found. I've encountered this issue before when trying to boot an image for the wrong architecture but I don't see what the problem is here.

A: I suspect the problem is that you're giving the VM too little memory: try -m 4096 instead of -m 512.

A: Have you tried qemu-system-x86_64 -hda confImage -m 1024?


text:
Q: ASP.NET MVC 4.8 + AngularJs migration to Since AngilarJs is getting EOL-ed I'm trying to figure out how to migrate relatively large application without complete (and ideally significant rewrite) to something (what?) more modern.
We have ASP.NET 4.8 multi-page (not SPA) application with server-side DevExpress controls (grids mostly), regular HTML controls and AngularJs (50 simple controllers with few components/services) on top of that.
It is clear how to modernize ASP.NET 4.8 to Core.NET. DevExpress controls can be migrated to client-side counterparts. But I'm struggling what to choose for client side if I want to keep multi-page application. Migration to SPA is also possible but that will be a big rewrite.

A: So, this question seems opinion-based so may get closed, but I will try to answer.
From someone who's done this, there's no silver bullet I'm afraid. Even the chaps behind AngularJS realised this, that's why there's no direct upgrade path from AngularJS 1.5 to Angular 2+. There is most definitely going to be significant rework.
However, you should be able to keep most of your backend work. It seems like it's largely your frontend you want to upgrade. I would recommend going for Angular. It's close to what you were writing before, but is a lot easier to write in. You will most definitely need to retrain a bit though. There are significant differences.
In terms of SPA or not, I would actually recommend you take the time to move to an SPA but if you're against that, you can use hard links which will load up a new page each time.


text:
Q: React undefined map in IE10 I am trying to adapt a React app to eork with IE. I saw similar questions and tried everything but not helped.
I'm getting "Map is undefined" error in IE9 and IE10. In IE11 everything is ok after doing this:
package.json:
"browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version",
      "ie >= 9"
    ]
  }

index.js:
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';
import "core-js";
import 'core-js/es/set';
import 'core-js/es/map';

What can I do to solve this?


text:
Q: Launching flutter app on my physical iPhone via xcode set in portrait mode works, but not when launching through android studio In my main.dart file where I have declared the device orientation
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
  runApp(Egenkontroll());
}

When I launch the app through xcode on my physical iPhone 7, I get my views in portrait mode which I want, but when I launch in through android studio on my device portrait mode is not enabled, and the views adjust to the devices orientation, which I don't want.
Does this matter when I publish the app on the appstore?

A: SystemChrome.setPreferredOrientations is async task so either await or put your run inside then
 SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitUp])
      .then((_) =>
      runApp(Egenkontroll())
      );

OR
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(Egenkontroll());


text:
Q: How to implement progress bar during HTTP Client request call Just a question I'm confused about how I could achieve this. I just want to implement progress bar on how long the response from HTTP client request call. I saw a lot of tutorials on how to implement this progress bar but it all centered to a file being downloaded from the server. I want to ask what would be the best approach to do this.
This is my situation. I have a web API that generates a zip file that contains multiple word file that was generated base on the parameters from the calling site. Basically, a lot of things happening from pulling the records from the database and generating these files that's why it took time for the response to be sent and I want to at least show progress bar out of this so that when our user click the button to generate this file they can see the progress of the report to be generated.
This is how i consume the API:
using (var client = new HttpClient())
{
    client.BaseAddress = new Uri ("MYBASEURI");
    client.DefaultRequestHeaders.Accept.Clear();
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/zip"));
    var content = new StringContent(strModel, Encoding.UTF8, "application/json");
    var response = await client.PostAsync("API_URI", content);
    if (!response.IsSuccessStatusCode)
    {
        ExceptionResponse ex = await response.ExceptionResponse();
        return null;
    }
    var data = await response.Content.ReadAsStreamAsync();
    return File(data, "application/zip", "File.zip");
}

I'm calling this method on form submit since it has parameters needed for the report to generate.


text:
Q: Effective way to store and retrieve documents in Firestore I am developing an android application where there is a Store  which adds products.
I save the products under the store unique ID.
e.g.:target:{Apples,iphone,powerbank}
flipkart:{flour,macbook,charger}
Now when I want to see what target sells I could use RecyclerView and show what target sells. Same for Flipkart.
but these products fall into different categories.So if I want my RecyclerView only to show Fruits I'll have to go through each document.
I had thought a way to solve this problem by Storing the product ids in each category but I believe it will take a lot of time to get each product.
Any suggestion on a structure I could use?
sorry for being so descriptive.

A: You have to normalize your data and store in firestore.
lots of ways t do this. take this example, define a product, assign an id and categories to it / create a category branch and then add the product id into it and then find out what each id belong to.
now your shop will have just list of product id and you goto product branch to get all the information of the product for your view.

A: firestore supports queries and you can use them for specifying which documents you want to retrieve from a collection or collection group. If you want to normalize the data depends on the application. You can add a string list called categories and then use a query to retrieve documents that are in a specific category. I personally used this in many apps and it is very helpful. I hope this helps and don't forget to check the docs.


text:
Q: authorization header in https request Firstly, sorry for my grammar mistakes, I'm a Chinese who cannot find an answer in the Chinese community, so I search for help here. Please help me, thanks!
1 Problem
Simply put, I use HTTPAnalyzer to trace an https request, and this request contains a header named authentication (I have put this header at the end of this post)
So the problem is that, If I resend this https request, it returns a 401 error. But if I tick off "Auto Authentication" like this:
HTTPAnalyzer Screenshoot
The request builder just worked out! The server responded correctly!
So I'm totally confused, what did HTTPAnalyzer do to deal with authentication?
2、the way I have tried to find answer
Firstly I checked these two requests sent by HTTPAnalyzer request builder.I didn't tick off that option in the first one.The thing is that, although all data(header and body)I put in request builder are the same, HTTPAnalyzer automatically changed this authorization header when I ticked off "Auto Authentication".some part of this header changed but the whole header is encoded, so I don't know how it changed.
Then I tried to decode this.I searched on Google, knowing that this header is commonly encoded in base64. However, I tried to decode this header, but it turned out to be random characters and have no meaning.
So I am really confused.Please help me to decode this header and tell me how to handle this authorization process.
So many thanks!
I 'll paste this header below:
Authorization: Negotiate [encoded data, 8628 characters]


text:
Q: Symfony 4 ORMException Hello i m faced with this Exception:

Entity of type App\Entity\CrfCvs is missing an assigned ID for field 'cvsIde'. The identifier generation strategy for this entity requires the ID field to be populated before EntityManager#persist() is called. If you want automatically generated identifiers instead you need to adjust the metadata mapping accordingly.

I have an object CrfCvs who have two related objects:CvsVts and CvsUtl like that:
CrfCvs
<?php

namespace App\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * CrfCvs
 *
 * @ORM\Table(name="CRF_CVS")
 * @ORM\Entity
 */
class CrfCvs
{
    /**
     * @var float|null
     *
     * @ORM\Column(name="CVS_ECG", type="float", precision=10, scale=0, nullable=true)
     */
    private $cvsEcg;

    /**
     * @var float|null
     *
     * @ORM\Column(name="CVS_BLO_DRA", type="float", precision=10, scale=0, nullable=true)
     */
    private $cvsBloDra;

    /**
     * @var string|null
     *
     * @ORM\Column(name="CVS_END_ISS", type="string", length=255, nullable=true)
     */
    private $cvsEndIss;

    /**
     * @var float|null
     *
     * @ORM\Column(name="CVS_END_RHI", type="float", precision=10, scale=0, nullable=true)
     */
    private $cvsEndRhi;

    /**
     * @var \DateTime|null
     *
     * @ORM\Column(name="CVS_END_DAT", type="datetime", nullable=true)
     */
    private $cvsEndDat;

    /**
     * @var float|null
     *
     * @ORM\Column(name="CVS_HEA_HCT", type="float", precision=10, scale=0, nullable=true)
     */
    private $cvsHeaHct;

    /**
     * @var float|null
     *
     * @ORM\Column(name="CVS_HEA_HB", type="float", precision=10, scale=0, nullable=true)
     */
    private $cvsHeaHb;

    /**
     * @var float|null
     *
     * @ORM\Column(name="CVS_NUM_DAY", type="float", precision=10, scale=0, nullable=true)
     */
    private $cvsNumDay;

    /**
     * @var \DateTime|null
     *
     * @ORM\Column(name="CVS_DAY", type="datetime", nullable=true)
     */
    private $cvsDay;

    /**
     * @var string|null
     *
     * @ORM\Column(name="CVS_LAS_ID", type="string", length=255, nullable=true)
     */
    private $cvsLasId;

    /**
     * @var string|null
     *
     * @ORM\Column(name="CVS_OXF_ID", type="string", length=255, nullable=true)
     */
    private $cvsOxfId;

    /**
     * @ORM\Column(name="CVS_IDE", type="string", length=255, nullable=false)
     * @ORM\Id
     */
    private $cvsIde;

    /**
     * @ORM\OneToMany(targetEntity="App\Entity\CvsVts", mappedBy="cvsIde", cascade={"persist"})
     */
    private $cvsVts;

    /**
     * @ORM\OneToMany(targetEntity="App\Entity\CvsUlt", mappedBy="cvsIde", cascade={"persist"})
     */
    private $cvsUlt;

    public function __construct()
    {
        $this->cvsUlt = new ArrayCollection();
        $this->cvsVts = new ArrayCollection();
    }

    /**
     * @return float|null
     */
    public function getCvsEcg(): ?float
    {
        return $this->cvsEcg;
    }

    /**
     * @param float|null $cvsEcg
     */
    public function setCvsEcg(?float $cvsEcg): void
    {
        $this->cvsEcg = $cvsEcg;
    }

    /**
     * @return float|null
     */
    public function getCvsBloDra(): ?float
    {
        return $this->cvsBloDra;
    }

    /**
     * @param float|null $cvsBloDra
     */
    public function setCvsBloDra(?float $cvsBloDra): void
    {
        $this->cvsBloDra = $cvsBloDra;
    }

    /**
     * @return string|null
     */
    public function getCvsEndIss(): ?string
    {
        return $this->cvsEndIss;
    }

    /**
     * @param string|null $cvsEndIss
     */
    public function setCvsEndIss(?string $cvsEndIss): void
    {
        $this->cvsEndIss = $cvsEndIss;
    }

    /**
     * @return float|null
     */
    public function getCvsEndRhi(): ?float
    {
        return $this->cvsEndRhi;
    }

    /**
     * @param float|null $cvsEndRhi
     */
    public function setCvsEndRhi(?float $cvsEndRhi): void
    {
        $this->cvsEndRhi = $cvsEndRhi;
    }

    /**
     * @return \DateTime|null
     */
    public function getCvsEndDat(): ?\DateTime
    {
        return $this->cvsEndDat;
    }

    /**
     * @param \DateTime|null $cvsEndDat
     */
    public function setCvsEndDat(?\DateTime $cvsEndDat): void
    {
        $this->cvsEndDat = $cvsEndDat;
    }

    /**
     * @return float|null
     */
    public function getCvsHeaHct(): ?float
    {
        return $this->cvsHeaHct;
    }

    /**
     * @param float|null $cvsHeaHct
     */
    public function setCvsHeaHct(?float $cvsHeaHct): void
    {
        $this->cvsHeaHct = $cvsHeaHct;
    }

    /**
     * @return float|null
     */
    public function getCvsHeaHb(): ?float
    {
        return $this->cvsHeaHb;
    }

    /**
     * @param float|null $cvsHeaHb
     */
    public function setCvsHeaHb(?float $cvsHeaHb): void
    {
        $this->cvsHeaHb = $cvsHeaHb;
    }

    /**
     * @return float|null
     */
    public function getCvsNumDay(): ?float
    {
        return $this->cvsNumDay;
    }

    /**
     * @param float|null $cvsNumDay
     */
    public function setCvsNumDay(?float $cvsNumDay): void
    {
        $this->cvsNumDay = $cvsNumDay;
    }

    /**
     * @return \DateTime|null
     */
    public function getCvsDay(): ?\DateTime
    {
        return $this->cvsDay;
    }

    /**
     * @param \DateTime|null $cvsDay
     */
    public function setCvsDay(?\DateTime $cvsDay): void
    {
        $this->cvsDay = $cvsDay;
    }

    /**
     * @return string|null
     */
    public function getCvsLasId(): ?string
    {
        return $this->cvsLasId;
    }

    /**
     * @param string|null $cvsLasId
     */
    public function setCvsLasId(?string $cvsLasId): void
    {
        $this->cvsLasId = $cvsLasId;
    }

    /**
     * @return string|null
     */
    public function getCvsOxfId(): ?string
    {
        return $this->cvsOxfId;
    }

    /**
     * @param string|null $cvsOxfId
     */
    public function setCvsOxfId(?string $cvsOxfId): void
    {
        $this->cvsOxfId = $cvsOxfId;
    }

    /**
     * @return string
     */
    public function getCvsIde(): string
    {
        return $this->cvsIde;
    }

    /**
     * @param string $cvsIde
     */
    public function setCvsIde(string $cvsIde): void
    {
        $this->cvsIde = $cvsIde;
    }

    public function getCvsVts()
    {
        return $this->cvsVts;
    }

    /**
     * @param Collection $cvsVts
     */
    public function setCvsVts(ArrayCollection $cvsVts): void
    {
        $this->cvsVts = $cvsVts;
    }

    public function getCvsUlt()
    {
        return $this->cvsUlt;
    }

    /**
     * @param Collection $cvsUlt
     */
    public function setCvsUlt(ArrayCollection $cvsUlt): void
    {
        $this->cvsUlt = $cvsUlt;
    }

    public function addCvsUlt(CvsUlt $item)
    {
        $this->cvsUlt[]=$item;
        $item->setCvsIde($this);
        return $this;
    }

    public function addCvsVts(CvsVts $item)
    {
        $this->cvsVts[]=$item;
        $item->setCvsIde($this);
        return $this;
    }

    public function removeCvsUlt($exp)
    {
        $this->cvsUlt->removeElement($exp);
    }

    public function removeCvsVts($exp)
    {
        $this->cvsVts->removeElement($exp);
    }

}

CvsVts
<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * CvsVts
 *
 * @ORM\Table(name="CVS_VTS", uniqueConstraints={@ORM\UniqueConstraint(name="id", columns={"id"})})
 * @ORM\Entity
 */
class CvsVts
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")\
     */
    private $id;

    /**
     * @var float|null
     *
     * @ORM\Column(name="VTS_REC_VAS", type="float", precision=10, scale=0, nullable=true)
     */
    private $vtsRecVas;

    /**
     * @var float|null
     *
     * @ORM\Column(name="VTS_REC", type="float", precision=10, scale=0, nullable=true)
     */
    private $vtsRec;

    /**
     * @var float|null
     *
     * @ORM\Column(name="VTS_NIC", type="float", precision=10, scale=0, nullable=true)
     */
    private $vtsNic;

    /**
     * @var float|null
     *
     * @ORM\Column(name="VTS_LAC", type="float", precision=10, scale=0, nullable=true)
     */
    private $vtsLac;

    /**
     * @var float|null
     *
     * @ORM\Column(name="VTS_OXY", type="float", precision=10, scale=0, nullable=true)
     */
    private $vtsOxy;

    /**
     * @var float|null
     *
     * @ORM\Column(name="VTS_SAT", type="float", precision=10, scale=0, nullable=true)
     */
    private $vtsSat;

    /**
     * @var float|null
     *
     * @ORM\Column(name="VTS_RR", type="float", precision=10, scale=0, nullable=true)
     */
    private $vtsRr;

    /**
     * @var float|null
     *
     * @ORM\Column(name="VTS_PP", type="float", precision=10, scale=0, nullable=true)
     */
    private $vtsPp;

    /**
     * @var float|null
     *
     * @ORM\Column(name="VTS_MAP", type="float", precision=10, scale=0, nullable=true)
     */
    private $vtsMap;

    /**
     * @var string|null
     *
     * @ORM\Column(name="VTS_BP", type="string", length=255, nullable=true)
     */
    private $vtsBp;

    /**
     * @var \DateTime|null
     *
     * @ORM\Column(name="VTS_TIM", type="datetime", nullable=true)
     */
    private $vtsTim;

    /**
     * @var \DateTime|null
     *
     * @ORM\Column(name="VTS_DAT", type="datetime", nullable=true)
     */
    private $vtsDat;

    /**
     * @ORM\ManyToOne(targetEntity="CrfCvs",cascade={"persist"})
     * @ORM\JoinColumn(name="CVS_IDE", referencedColumnName="CVS_IDE")
     */
    private $cvsIde;

    public function __construct()
    {
        $this->cvsIde = new CrfCvs();
    }

    /**
     * @return float|null
     */
    public function getVtsRecVas(): ?float
    {
        return $this->vtsRecVas;
    }

    /**
     * @param float|null $vtsRecVas
     */
    public function setVtsRecVas(?float $vtsRecVas): void
    {
        $this->vtsRecVas = $vtsRecVas;
    }

    /**
     * @return float|null
     */
    public function getVtsRec(): ?float
    {
        return $this->vtsRec;
    }

    /**
     * @param float|null $vtsRec
     */
    public function setVtsRec(?float $vtsRec): void
    {
        $this->vtsRec = $vtsRec;
    }

    /**
     * @return float|null
     */
    public function getVtsNic(): ?float
    {
        return $this->vtsNic;
    }

    /**
     * @param float|null $vtsNic
     */
    public function setVtsNic(?float $vtsNic): void
    {
        $this->vtsNic = $vtsNic;
    }

    /**
     * @return float|null
     */
    public function getVtsLac(): ?float
    {
        return $this->vtsLac;
    }

    /**
     * @param float|null $vtsLac
     */
    public function setVtsLac(?float $vtsLac): void
    {
        $this->vtsLac = $vtsLac;
    }

    /**
     * @return float|null
     */
    public function getVtsOxy(): ?float
    {
        return $this->vtsOxy;
    }

    /**
     * @param float|null $vtsOxy
     */
    public function setVtsOxy(?float $vtsOxy): void
    {
        $this->vtsOxy = $vtsOxy;
    }

    /**
     * @return float|null
     */
    public function getVtsSat(): ?float
    {
        return $this->vtsSat;
    }

    /**
     * @param float|null $vtsSat
     */
    public function setVtsSat(?float $vtsSat): void
    {
        $this->vtsSat = $vtsSat;
    }

    /**
     * @return float|null
     */
    public function getVtsRr(): ?float
    {
        return $this->vtsRr;
    }

    /**
     * @param float|null $vtsRr
     */
    public function setVtsRr(?float $vtsRr): void
    {
        $this->vtsRr = $vtsRr;
    }

    /**
     * @return float|null
     */
    public function getVtsPp(): ?float
    {
        return $this->vtsPp;
    }

    /**
     * @param float|null $vtsPp
     */
    public function setVtsPp(?float $vtsPp): void
    {
        $this->vtsPp = $vtsPp;
    }

    /**
     * @return float|null
     */
    public function getVtsMap(): ?float
    {
        return $this->vtsMap;
    }

    /**
     * @param float|null $vtsMap
     */
    public function setVtsMap(?float $vtsMap): void
    {
        $this->vtsMap = $vtsMap;
    }

    /**
     * @return string|null
     */
    public function getVtsBp(): ?string
    {
        return $this->vtsBp;
    }

    /**
     * @param string|null $vtsBp
     */
    public function setVtsBp(?string $vtsBp): void
    {
        $this->vtsBp = $vtsBp;
    }

    /**
     * @return \DateTime|null
     */
    public function getVtsTim(): ?\DateTime
    {
        return $this->vtsTim;
    }

    /**
     * @param \DateTime|null $vtsTim
     */
    public function setVtsTim(?\DateTime $vtsTim): void
    {
        $this->vtsTim = $vtsTim;
    }

    /**
     * @return \DateTime|null
     */
    public function getVtsDat(): ?\DateTime
    {
        return $this->vtsDat;
    }

    /**
     * @param \DateTime|null $vtsDat
     */
    public function setVtsDat(?\DateTime $vtsDat): void
    {
        $this->vtsDat = $vtsDat;
    }

    /**
     * @return int
     */
    public function getId(): int
    {
        return $this->id;
    }

    /**
     * @param int $id
     */
    public function setId(int $id): void
    {
        $this->id = $id;
    }

    public function getCvsIde()
    {
        return $this->cvsIde;
    }

    public function setCvsIde(CrfCvs $cvsIde)
    {
        $this->cvsIde = $cvsIde;
    }

}

CvsUlt
<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * CvsUlt
 *
 * @ORM\Table(name="CVS_ULT", uniqueConstraints={@ORM\UniqueConstraint(name="id", columns={"id"})})
 * @ORM\Entity
 */
class CvsUlt
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")\
     */
    private $id;

    /**
     * @var string|null
     *
     * @ORM\Column(name="ULT_ISS", type="string", length=255, nullable=true)
     */
    private $ultIss;

    /**
     * @var float|null
     *
     * @ORM\Column(name="ULT_PLE_EFF", type="float", precision=10, scale=0, nullable=true)
     */
    private $ultPleEff;

    /**
     * @var float|null
     *
     * @ORM\Column(name="ULT_ASC", type="float", precision=10, scale=0, nullable=true)
     */
    private $ultAsc;

    /**
     * @var string|null
     *
     * @ORM\Column(name="ULT_NAM", type="string", length=255, nullable=true)
     */
    private $ultNam;

    /**
     * @var float|null
     *
     * @ORM\Column(name="ULT_TIM", type="float", precision=10, scale=0, nullable=true)
     */
    private $ultTim;

    /**
     * @var \DateTime|null
     *
     * @ORM\Column(name="ULT_DAT", type="datetime", nullable=true)
     */
    private $ultDat;

    /**
     * @ORM\ManyToOne(targetEntity="CrfCvs",cascade={"persist"},inversedBy="cvsUlt")
     * @ORM\JoinColumn(name="CVS_IDE", referencedColumnName="CVS_IDE")
     */
    private $cvsIde;

    public function __construct()
    {
        $this->cvsIde = new CrfCvs();
    }

    /**
     * @return number
     */
    public function getId()
    {
        return $this->id;
    }

    public function getUltIss()
    {
        return $this->ultIss;
    }

    public function getUltPleEff()
    {
        return $this->ultPleEff;
    }

    public function getUltAsc()
    {
        return $this->ultAsc;
    }

    public function getUltNam()
    {
        return $this->ultNam;
    }

    public function getUltTim()
    {
        return $this->ultTim;
    }

    public function getUltDat()
    {
        return $this->ultDat;
    }

    public function getCvsIde()
    {
        return $this->cvsIde;
    }

    public function setId($id)
    {
        $this->id = $id;
    }

    public function setUltIss($ultIss)
    {
        $this->ultIss = $ultIss;
    }

    public function setUltPleEff($ultPleEff)
    {
        $this->ultPleEff = $ultPleEff;
    }

    public function setUltAsc($ultAsc)
    {
        $this->ultAsc = $ultAsc;
    }

    public function setUltNam($ultNam)
    {
        $this->ultNam = $ultNam;
    }

    public function setUltTim($ultTim)
    {
        $this->ultTim = $ultTim;
    }

    public function setUltDat($ultDat)
    {
        $this->ultDat = $ultDat;
    }

    public function setCvsIde($cvsIde)
    {
        $this->cvsIde = $cvsIde;
    }

}

And my CrfCvsType is like this :
<?php

namespace App\Form;

use App\Entity\CrfCvs;
use ICanBoogie\Inflector;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use function ICanBoogie\downcase;

class CrfCvsType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $binary = array('Yes' => 1, 'No' => 0);
        $inflector = Inflector::get();
        $this->comments = $options['comments'];

        foreach ($this->comments as $comment) {
            if ($comment->getName() !== "CVS_IDE") {
                switch ($comment->getName()) {
                    case 'CVS_END_DAT':
                    case 'CVS_LAS_ID':
                    case 'CVS_OXF_ID':
                    case 'CVS_NUM_DAY':
                    case 'CVS_HEA_HB':
                    case 'CVS_HEA_HCT':
                    case 'CVS_END_RHI':
                    case 'CVS_END_ISS':
                    case 'CVS_DAY':
                        $builder
                            ->add($inflector->camelize(downcase($comment->getName()), Inflector::DOWNCASE_FIRST_LETTER), null, array('label' => $comment->getComment(), 'required' => true));
                        break;
                    case 'CVS_BLO_DRA':
                    case 'CVS_ECG':
                        $builder
                            ->add(
                                $inflector->camelize(downcase($comment->getName()), Inflector::DOWNCASE_FIRST_LETTER),
                                ChoiceType::class, array(
                                    'label' => $comment->getComment(),
                                    'required' => false,
                                    'choices' => $binary,
                                    'placeholder' => 'Choisir une valeur',
                                )
                            );
                        break;
                }
            }
        }
        $builder->add('cvsVts', CollectionType::class, [
            'entry_type' => CvsVtsType::class,
            'entry_options' => ['label' => false],
            'allow_add' => true,
            'prototype' => true,
            'by_reference' => false
        ]);

        $builder->add('cvsUlt', CollectionType::class, [
            'entry_type' => CvsUltType::class,
            'entry_options' => ['label' => false],
            'allow_add' => true,
            'prototype' => true,
            'by_reference' => false
        ]);

        $builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) {
            /** @var CrfCvs */
            $crf_cvs = $event->getData();
            //dd($crf_cvs);
        });
        $builder->add('Enregistrer',SubmitType::class);
            //->add('cvsUlt')
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => CrfCvs::class,
            'comments' => null,
        ]);
    }
}

I've use embedded Form with Macros and javascript to generate the form.At this step all work very well,But when i try to submit the form,Only the CvsUlt related object is persist,the CvsVts  show me this Error :

ORMException
  HTTP 500 Internal Server Error
  Entity of type App\Entity\CrfCvs is missing an assigned ID for field 'cvsIde'. The identifier generation strategy for this entity requires the ID field to be populated before EntityManager#persist() is called. If you want automatically generated identifiers instead you need to adjust the metadata mapping accordingly.

the Controller code:
 public function new(Request $request, CrfCvsRepository $crfCvsRepository, SequenceGenerator $sequenceGenerator)
    {

        $this->denyAccessUnlessGranted('ROLE_SAISIE', null, 'Unable to access this page!');
        //On recupère les commentaires de la table pour Afichage
        //--------------------------------------------------------

        $columns = $crfCvsRepository->getColumsComments();
        $pat = $request->attributes->get('pat');
        $crfcvs = new CrfCvs();

        $crf_cvs_form = $this->createForm(CrfCvsType::class, $crfcvs, array(
            'comments' => $columns
        ));
        //dd($crf_cvs_form);
        //dd($request);
        $crf_cvs_form->handleRequest($request);
        if ($crf_cvs_form->isSubmitted() && $crf_cvs_form->isValid()) {
            //dd($request);
            //Génération de la clé primaire de la table
            $em = $this->getDoctrine()->getManager();

            //---------------------------------------------------------------------------
            if ($lastid_value = $crfCvsRepository->findLast()) {
                $crfcvs->setCvsIde($sequenceGenerator->getNextKey($lastid_value[0]->getCvsIde()));
            } else {
                $crfcvs->setCvsIde("CVS_00000001");
            }
            $crfcvs->setCvsLasId($pat);
            //---------------------------------------------------------------------------
            //dd($crfcvs);

            $em->persist($crfcvs);
            $em->flush();
            return $this->redirectToRoute('patient', ['pat' => $this->get('session')->get('pat')]);
        }

        return $this->render('crf_cvs/new.html.twig', [
            'crf_cvs' => $crfcvs,
            'form' => $crf_cvs_form->createView(),
            'pat' => $pat,
            'comments' => $columns
        ]);
    }

Please help me to solve this.

A: You need change your strategy annotation from your cvsIde.
/**
 * @ORM\Column(name="CVS_IDE", type="string", length=255, nullable=false)
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="NONE")
 */

Link : https://github.com/KnpLabs/DoctrineBehaviors/issues/45


text:
Q: KStream issue to read payload coming as before and after in avro format I am developing KStream application on confluent kafka platform. Data is present on source topic in nested avro format  as mentioned below
{
   "type":"record",
   "namespace":"xyz",
   "table":"abc",
   "op_type":{
      "string":"D"
   },
   "op_ts":{
      "string":"2020-05-16 09:03:25.000462"
   },
   "pos":{
      "string":"00000000000000010722",
      "before":{
[
            "fields":            {
               "column1":"value"
            },
            {
               "column2":"value"
            },
            {
               "column3":"value"
            }
         ]
      },
      "after":{
[
            "fields":            {
               "column1":"value"
            },
            {
               "column2":"value"
            },
            {
               "column3":"value"
            }
         ]
      }
   }

I want to filter records based on op_type="D" as wanted to separate deleted records to other Kafka topic.
I am facing issue to write schema on output topic facing deserialization error : for required row found array.
I have created POJO objects using apache maven-avro plugin.
for "before tag" I mentioned type as array and passing object of before class to it.
Same for "After tag" I mentioned type as array and passing object of after to it.
Rightnow I can not use KSQL here as service is not available in my project.
Need solution how to resolve this nested schema or anyother way to filter deleted records to other kafka topic from source topic.

A: To resolve above issue, I used generic avro serializer to process data using Kafka streams.
If we use specific avro serializer, we can not filter nested data. Using generic avro serializer will help to filter perticular record with string. I used that and resolved above issue.


text:
Q: How to query the number of items in a SharePoint list by filter condition I am using sending an http request to sharepoint to calculate the total number of the items in the list, but if I want to query the total number based on specific condition(such as ApproveStatus = Approved), I wrote the link like below, but it still shows the total number of whole items, the condition did not work.
https://mysite.sharepoint.com/sites/Reqeust/_api/web/lists/getbytitle('RequestList')/?$select=ItemCount&$filter=ApproveStatus%20eq%20%27Approved%27

can anyone help me how to do the filter? Thank you so much

A: The ItemCount property returns the total items in the list. The solution available now sadly involves filtering all the items that match your condition and using the length of the result.
See proposed solution in this question; https://sharepoint.stackexchange.com/questions/215795/item-count-with-a-filter-condition-using-rest-api-gets-result-in-web-browser-er/215802#215802


text:
Q: Converting NFA to DFA without epsilon transition function Based on my understanding an epsilon is always required to convert NFA to DFA.
Is it possible to convert below NFA to DFA? If so, what will the DFA look like here?

A: NFA's do not have "epsilon states". They have "epsilon transitions": transitions labeled using the epsilon letter, denoting that no input character is consumed by that transition.  An NFA graph need not contain any epsilon transitions.
Epsilon transitions are generated by a compiler which translates a regular expression to an NFA graph. They help to represent the bypass paths that correspond to optional matches.  If you have a regular expression without any optional, such as ab, the NFA graph doesn't (have to) contain any epsilon edges.
An important concept in NFA simulation and NFA to DFA translation is the "epsilon closure": a set of states reachable from a state by following epsilon transitions. If any state S is in the closure, and that state has an epsilon transition to some state T, then T is also in the closure. Hence "epsilon closure".
We construct sets of NFA states to deal with the ambiguity that the NFA graph has multiple transitions on the same input character to multiple states. Then we perform an epsilon closure to deal with the additional ambiguity that there are transitions without consuming an input symbol, representing optional matching.
NFA simulation constructs sets of NFA states dynamically; the NFA to DFA "subset construction" pre-computes these sets and turns them into the nodes in an a graph which is the DFA.
To DFA, informally, step by step.
To turn your NFA graph into a DFA, we first start with a blank slate. We hold no NFA states. The arrow tells us that the NFA begins in state 1. We ask ourselves, what NFA states are in the epsilon closure of the set which consists of state 1? And we notice: there are no epsilon transitions. So the closure set is { 1 }. Our DFA machine is empty so far, so we take this set { 1 } and we call that object S0: the initial state of our DFA.
Now that we have a DFA state, we ask ourselves: what transitions lead out of this state for each of the input alphabet characters? We first evaluate a. Starting with set S0 which represents NFA states { 1 }, we compute the set of NFA states which are reachable on symbol a.  These states are { 1, 2 }, because 1 points back to itself on a, and also transitions to 2 on a.  Having this transition set, we need to take into account epsilons: we need to extend that set by computing its epsilon closure. Since there are no epsilons, there is nothing to do. We have { 1, 2 } and we will call that state S1 of the DFA. So far we have this emerging picture of the DFA:
      a  b    NFA set
 S0: S1  ?    { 1 }
 S1:  ?  ?    { 1, 2 }

We know that S0 transitions to S1 on a. We don't know yet what it does for b, and we haven't considered transitions out of S1 yet.
We next move to b (in the context of evaluating S0). On b, the states reachable out of { 1 } consist of the set { 2 }. Again, epsilon-closing on this does nothing. And { 2 } does not look like any existing DFA state, so we make a new state S2:
      a   b
 S0: S1  S2   { 1 }
 S1:  ?   ?   { 1, 2 }
 S2:  ?   ?   { 2 }

Now we have finished S0, so we move to the next unfinished state, S1, which consists of the NFA set { 1, 2 }. We ask, which states are reachable from this set upon the consumption of a?  The answer is { 1, 2 }.  The epsilon closure of this is { 1, 2 }.  And we note: { 1, 2 } is identical to S1. Thus, S1 transitions to itself on a:
      a   b
 S0: S1  S2   { 1 }
 S1: S1   ?   { 1, 2 }
 S2:  ?   ?   { 2 }

Then we consider S1/b. What set is reachable from { 1, 2 } on the consumption of b? The answer is: { 1, 2 }. So, S1 transitions to itself on b also.
      a   b
 S0: S1  S2   { 1 }
 S1: S1  S1   { 1, 2 }
 S2:  ?   ?   { 2 }

Now S2/a is interesting. The { 2 } doesn't have any transitions on a: the set is empty. We can represent this situation in various ways, one of which is that we create a set called E (error).  If a is seen in state S2, then it is an error; the machine doesn't accept that character.
      a   b
 S0: S1  S2   { 1 }
 S1: S1  S1   { 1, 2 }
 S2:  E   ?   { 2 }
  E:          { }

For S2/b we see that { 2 } transitions to { 1 } and that { 1 } is just S0:
      a   b
 S0: S1  S2   { 1 }
 S1: S1  S1   { 1, 2 }
 S2:  E  S0   { 2 }
  E:          { }

If the machine gets into state E it is stuck there, and so we can just fill its entries like this:
      a   b
 S0: S1  S2   { 1 }
 S1: S1  S1   { 1, 2 }
 S2:  E  S0   { 2 }
  E:  E   E   { }

Lastly, we note that in the original NFA, state 2 is the acceptance state. In the DFA, therefore, any state whose NFA set contains state 2 is an acceptance state.
      a   b  acc?
 S0: S1  S2        { 1 }
 S1: S1  S1   y    { 1, 2 }
 S2:  E  S0   y    { 2 }
  E:  E   E        { }

If the machine gets into state E, that is a permanent failure. (Whoever is feeding input to the DFA might notice this situation and stop feeding it.)


text:
Q: Expression Trees OrderBy Exception I have below code snippet and getting an error as mentioned below.
string[] companies = {
 "Consolidated Messenger", "Alpine Ski House", "Southridge Video", "City Power & Light",
 "Coho Winery", "Wide World Importers", "Graphic Design Institute", "Adventure Works",
 "Humongous Insurance", "Woodgrove Bank", "Margie's Travel", "Northwind Traders",
 "Blue Yonder Airlines", "Trey Research", "The Phone Company",
 "Wingtip Toys", "Lucerne Publishing", "Fourth Coffee"
};

var exp = companies.AsQueryable<string>();

// Compose the expression tree that represents the parameter to the predicate.
ParameterExpression pe = Expression.Parameter(typeof(string), "company");

// The IQueryable data to query.
IQueryable<String> queryableData = companies.AsQueryable<string>();

MethodCallExpression orderByCallExpression1 = Expression.Call(
    typeof(Queryable),
    "OrderBy",
    new Type[] { queryableData.ElementType },
    Expression.Lambda<Func<string, string>>(pe, new ParameterExpression[] { pe })
  );

System.InvalidOperationException: 'No generic method 'OrderBy' on type
  'System.Linq.Queryable' is compatible with the supplied type arguments
  and arguments. No type arguments should be provided if the method is
  non-generic. '

Please guide whats wrong in here?

A: There are two "problems" with OrderBy method: it has overloads and it is generic. First you need to select correct overload:
var openOrderBy = typeof(Queryable)
    .GetMethods(BindingFlags.Static | BindingFlags.Public)
    .First(m => m.Name == "OrderBy" && m.GetParameters().Length == 2);

(note: here I'm using simple check based on parameters count, you can read more here)
Then you need to bind it to concrete types:
var closedOrderBy = openOrderBy.MakeGenericMethod(
    typeof(string), // type of item in collection, TSource
    typeof(string)); // type returned by lambda, TKey

Now you can use that MethodInfo in Expression.Call:
var pe = Expression.Parameter(typeof(string), "company");

var orderByCall = Expression.Call(null, // for static methods
    closedOrderBy,
    companies.AsQueryable().Expression,
    Expression.Lambda<Func<string, string>>(pe, pe));

You can test it with extra lambda:
var result = Expression.Lambda<Func<IQueryable<string>>>(orderByCall)
    .Compile().Invoke().ToList();

result.ForEach(Console.WriteLine);

Demo

Update: as @Ivan Stoev said in comment, answer can be simplified

var queryableData = companies.AsQueryable();
var pe = Expression.Parameter(typeof(string), "company");

var orderByCall = Expression.Call(typeof(Queryable),
    "OrderBy",
    new []{ queryableData.ElementType,
            queryableData.ElementType }, // <-- fix #1 select correct overload
    queryableData.Expression,            // <-- fix #2 pass first argument
    Expression.Lambda<Func<string, string>>(pe, pe)
  );


text:
Q: Madelung energy
I was reading Solid State Physics by Charles Kittel, and equation (19) (in the image above) aroused my confusion. For non-nearest neighbours (indicated in equation(19) as "otherwise") why is the Coulomb potential term the only term that remains when we write the repulsive interaction? Why is the central field repulsive potential term not written?
The image size has become too small perhaps, for which I apologise. Any explanation would be welcome.

A: It is simply a choice of approximation that is made here. Since the exponential function decays much faster than the $R^{-1}$ term, it can be argued that for large enough distances (assumed to be anything larger than nearest neighbors), the exponential term is negligible.

A: Just a small elaboration on the already appeared correct explanation in term of range of the exponential  vs the coulomb term.
Energy in ionic systems is dominated by the electrostatic contribution (Madelung's term). However, a purely coulombic interaction would not allow a stable system (attraction between unlike charges is unlimited from below). The stabilizing effect comes from the short-range repulsion due to the overlap between the ionic wavefunctions. Such a term decays exponentially with distance.
In a solid ionic-system with compact structure, like NaCl or CsCl,  unlike charges get as closest as possible, limited only by the repulsive interaction due to the overlap of electronic wavefunctions. Like charges experience two repulsive forces. One is due to the coulomb interaction, the other to the short rage repulsion. However, at the distance of first neighbors, Coulomb repulsion dominates and pushes like atoms towards larger distances, making them second neighbors. moreover at those distances, repulsive interaction due to the electronic overlap is negligeable.
Interestingly, such an effect is visible not only in the solid but also in the liquid structure as determined by scattering experiments.


text:
Q: How to highlight dynamic words from response for different input string javascript, jquery, regex [blog]: https://jsfiddle.net/kb413ae8/ "click here" for working fiddle
Kids Markers & Crayons is a response string for which highlighting of text should append, based on input we pass in searchQuery variable in code.
if Markers is provided as searchQuery input, Markers should be highlighted, which is currently working fine in above fiddle link.
if space is provided after word markers and pass has a searchQuery input in code, Kids 'b tag with class='boldTxt'>Markers & Crayons is appended. which is weird. Happens same for all word with space.
Highlight of text/word should happen if first character in searchQuery input matches with first character of word in response. does not matter where the word is. Thanks

var data = {"ResultSet":{"result":[
{"rank":"999999","term":"Kids Markers & Crayons"},
{"rank":"999999","term":"Crayola Fine Line Markers"},
{"rank":"999999","term":"Crayola Super Tips Washable Markers"},
{"rank":"999999","term":"Crayola Washable Markers Broad Line Classic"},
{"rank":"999999","term":"Post-it Assorted Page Markers"},
{"rank":"999999","term":"Crayola Markers Broad Line Classic"},
{"rank":"999999","term":"Crayola Crayons"},
{"rank":"999999","term":"Crayola Washable Markers Classic Colors"},
{"rank":"999999","term":"Crayola Washable Crayons Large"}]
,"totalResultsAvailable":"32","totalResultsReturned":11}};

for(i=0; i<9; i++) {
 var result = data.ResultSet.result[i].term;
 //console.log('result: ' + result);
 var searchQuery = 'Markers ';
 /*searchQuery inputs
   searchQuery = 'c'; o/p: c should be highlighted at beginning of word, In classic 'c' is highlighting twice which should not be highlighted at end or in mid of word.
   searchQuery = 'markers '; o/p:  tag is added which has to be removed.
   searchQuery = 'markers & c '; o/p:  tag is added which has to be removed.
   searchQuery = 'ola'; o/p: ola should be highlighted at beginning of word, In Crayola 'ola' is highlighting, which should not be highlighted at end or in mid of word.
 */
var searchResult = result;
words = searchQuery.split(' ');

$.each(words, function() {

  var word = this.trim();
  var regex = new RegExp('(' + word + ')(?!>|b>)', 'gi');

  searchResult = searchResult.replace(regex, "$1");
});
console.log(searchResult);
$('#wag-typeaheadlists').append('
' + searchResult + '
')
}
.boldTxt {
 color: red;
}

A: In your fiddle try adding the following line after you split the searchQuery.
words = words.filter(function(word){ return word != "" });
Hope it solves your problem!


text:
Q: Uncaught TypeError: Failed to resolve module specifier "prompt-sync". Relative references must start with either "/", "./", or "../" I got some related questions in stack overflow, but I am field to understand the answers. someone, please explain to me what to do.
Here is my JS code
    import p from "prompt-sync";
const prompt = p();

//for loop
let sum = 0;
let a = prompt("Enter number :");

for(let i=0;i<=a;i++)
{
    sum+=i;
}
console.log(sum);

I called this JS on the HTML page
<script type="module" src="JS/Loop.js"></script>

I am getting this error, in some solutions it mentioned like use URL but which Prompt URL should I have to import instead of prompt-sync

A: If you give a module name to Node.js then it will search node_modules to find it.
Browsers can't do that. You need to give them a URL (which will typically end in .js).
If you want a relative path, then you need to explicitly start that path with ./ (or ../). You can't just mention the name .
e.g.
import p from "../scripts/prompt-sync.js"

That said, the module you are trying to use describes itself as:

A sync prompt for node. very simple. no C++ bindings and no bash scripts.
Works on Linux, OS X and Windows.

It makes use of Node.js specific APIs (e.g. var fs = require('fs'); and process.stdin).
It isn't going to run in a browser environment.