text:
Q: BMS and charger for LiFePO4 prismatic module I just purchased a lithium-ion battery module for an electric tractor project. I'm looking for advice on how to set up my BMS and charger.
Here are the details of the module from the seller: "Prismatic Cells are 3.2v and 22.5ah each. At 22.5ah each they are very stable cells and can be used without a cooling system. Modules are made of 40 cells. In this configuration the total output of each module is roughly 13v with 225ah (made by 4 groups of 10 cells)."
So 10 cells in parallel in a series of 4 groups need some sort of BMS. I'm thinking of options:

*

*Simple: use a 4S BMS to monitor the 4 parallel groups and hope the 10 cells in parallel are balanced.

*Less simple: connect two 20S BMS to every cell in the whole system.

*Other options of different BMS configurations such as four 10S.

I'd really like someone who knows their way around these batteries to tell me that option 1 is adequate, but want good advice, not just what I want to hear.
Bonus to anyone who sends links to good BMS and charger options.

A: I've done much with batteries and some "playing" with 24V 40 Ah LiFePO4. (8s 40 Ah cells). I'm very experienced with electronics in general. I would not claim to offer you safe expert advice. Take this as competent comment at your risk.
You plan to connect the cells 4s10P with (it sound like) hard connection across each 10P bank. This is a common method and makes individual BMS "channels" 'unavailable'. It's liable to be 'safe enough' as no cell can be either driven too high or too low in voltage. If a cell loses capacity for some reason it will be maintained at a voltage equal to other cells and its current contribution will lag at the bottom end. You knew that.
At the top end its slightly more complex as a cell that reaches full capacity ahead of the others will perhaps be attempting to go into CC mode when the others are still in CV. The voltage is not up to normal CV level (typically around 3.65V). What this may mean is that a cell that is substantially sicker than the rest MAY be driven to its death slightly faster than if operated optimally - but I'd not see that as a major problem.
Operating cells hard clamped together means that you cannot determine the health of individual cells.   This is common practice with Lithium chemistry secondary cells, so OK enough.
So while a BMS per cell is safest, and given the cost of the battery you are using possibly not too much dearer $% wise, it does seem that 4 BMs "channels will be enough.
_______________,
LiFePO4 have, based on my observations, a mode which makes them somewhat more immune to series string imbalance that LiIon cells. While the LiFePO4 cell has a nominal  final voltage of say 3.65V, if you keep charging at CC when this point is reached, rather than entering CV mode, they go into a fast voltage increase mode - ie they act as if they have much lower than their rated capacity. TI (and no doubt others) use this to advantage in fast charging -  missing out the CV stage and allowing Vbat to rise at CC above 3.65 volts - but not much above. Without rechecking I think its only about 3.7V for charge termination. They claim this allows full capacity to be reached faster.
You'll probably (wisely) decide not to trust the following :-) - but it may give you food for thought. My observation, which I have not seen reported elsewhere (buyer beware :-) ) is that LiFePO4 can be charged up to normal LiIon terminal voltage (~~= 4.2V/cell). This state is approached very rapidly at CC once notional endpoint voltage is reached as the battery exhibits low effective capacity. My theory (wild inspired guess) is that while the large majority of the energy is stored in the olivine LiFePO4 structure you effectively have a small additional LiIon cell at the interface to the cell proper outside the olivine structure. It's this small LiIon cell that accepts the extra energy. The practical implication of this is that if you have say 4S cells with a target voltage of 3.65V / cell or 14.6V total, then by setting a Vbat abs max of say 14.8V = 3.7 V/cell then a cell which reaches full charge first will then increase it's voltage above nominal completion BUT in a non damaging way.
example only - 3 cells at 3.6V each = 10.8V. 14.8 max available.
14.8 - 10.8 = 4V on one cell. Actual values can be adjusted to where you are comfortable.

A:
Simple: use a 4S BMS to monitor the 4 parallel groups

That is the one and only option.

and hope the 10 cells in parallel are balanced.

No need to hope: cells in parallel are all at the same terminal voltage (by definition) so they naturally self-balance.


text:
Q: Not getting the desired output(no. of connected objects/islands) in this program(Segmentation Fault)? I have to find number of connected objects in a given 2-D binary matrix.
After giving inputs i am not getting the output
Error i get: Program terminated due to "Segmentation fault" (11)
My Test Case:
Enter number of rows:
5
Enter number of columns:
5
Enter the matrix:
0 0 0 0 0
1 0 0 1 0
1 0 0 0 1
0 1 0 1 0
0 0 0 0 0
Number of connected objects = 2

My Code:
#include<stdio.h>
#include<stdlib.h>
typedef int Color;
typedef struct cell
{
 char kind;
 Color color;
} Cell;
typedef struct pos
{
 int h,v;
} Pos,Size;
typedef struct world
{
 Size size;
 Cell **cells;
} World;
typedef struct node
{
 Pos pos;
 struct node *next;
} Node;
typedef struct stack
{
 Node *np;
} Stack;
void push(Stack *s,Pos pos)
{
 Node *np=malloc(sizeof(*np));
 np->pos=pos;
 np->next=s->np;
 s->np=np;
}
int isEmpty(Stack *s)
{
 return !s->np;
}
Pos pop(Stack *s)
{
 Pos ret=s->np->pos;
 Node *next=s->np->next;
 free(s->np);
 s->np=next;
 return ret;
}
World *make_world(Size size,Stack *s);
void ruin(World *w);
void paint(World *w,Pos pos,Color *color);
int main(void)
{
 int rows,cols;
 puts("Enter number of rows:");
 scanf("%d",&rows);
 puts("Enter number of columns:");
 scanf("%d",&cols);
 Stack land={ NULL };
 World *world=make_world((Size){.v=rows,.h=cols},&land);
 Color color=0;
 while(!isEmpty(&land))
 {
    paint(world,pop(&land),&color);
 }
 printf("Number of connected objects = %d",color);
 ruin(world);
}
enum { BLANK=0,LAND='1',SEA=0,NONE=-1};
World *make_world(Size size,Stack *landList)
{
 World*w=malloc(sizeof(*w));
 w->size=size;
 w->cells=malloc(size.v * sizeof(*w->cells));
 for(int r=0;r<size.v;++r)
 {
    w->cells[r]=calloc(size.h,sizeof(**w->cells));
 }
 puts("Enter the matrix:");
 for(int r=0;r<size.v;++r)
 {
    for(int c=0;c,size.h;++c)
    {
        char ch=0;
        scanf(" %c",&ch);
        if((w->cells[r][c].kind=ch)==LAND)
        push(landList,(Pos){ .v=r, .h=c});
    }
 }
 return w;
}
void ruin(World *w)
{
 for(int r=0;r<w->size.v;++r)
 free(w->cells[r]);
 free(w->cells);
 free(w);
}
void fill(World *w,Pos pos,Color *color,Cell *neighbor)
{
 if(pos.h<0 || pos.v<0 || pos.h>=w->size.h || pos.v>=w->size.v)
 return;
 Cell *cell=&w->cells[pos.v][pos.h];
 if(cell->color!=BLANK)
 return;
 if(neighbor!=NULL)
 {
    if(cell->kind!=neighbor->kind)
    {
        return;
    }
    cell->color=neighbor->color;
}
else
{
    cell->color=++*color;
}
fill(w, (Pos){.v=pos.v-1,.h=pos.h-1},color,cell);
fill(w, (Pos){.v=pos.v-1,.h=pos.h},color,cell);
fill(w, (Pos){.v=pos.v-1,.h=pos.h+1},color,cell);
fill(w, (Pos){.v=pos.v,.h=pos.h-1},color,cell);
fill(w, (Pos){.v=pos.v,.h=pos.h},color,cell);
fill(w, (Pos){.v=pos.v,.h=pos.h+1},color,cell);
fill(w, (Pos){.v=pos.v,.h=pos.h-1},color,cell);
fill(w, (Pos){.v=pos.v,.h=pos.h},color,cell);
fill(w, (Pos){.v=pos.v,.h=pos.h+1},color,cell);
}
void paint(World *w,Pos pos,Color *color)
{
 fill(w,pos,color,NULL);
}

A: There is a typo in the inner for-loop for(int c=0;c,size.h;++c), which should be for(int c=0;c < size.h;++c).
Condition (c,size.h), as written in your code, is a comma operator, which evaluates all the operands separated by a ,, but "returns" only the result of the last expression as rvalue. Hence,  (c,size.h) has the same effect as if you wrote size.h as condition, and if size.h is not 0, the condition will always evaluate to true; Consequently, you run into an infinite loop, increasing c all the time and yielding undefined behaviour (probably a segmentation fault).
Anyway, please turn on warnings in your development environment / compiler call; I suppose that you should have gotten something like "expression result unused" on expression c...

redpajama_set_name: RedPajamaStackExchange


text:
Q: Haskell non functions recursion (or value recursion or recursive let bindings) I'm new to Haskell and reading Haskell from first principles.
in chapter 10 page 378 I came across with this new syntax
fibs = 1 : scanl (+) 1 fibs

seems like fibs is a function bcs its being used or called on right
but its type is fibs :: Num a => [a] so its a value
how a value can be accessed inside it's own definition ?
if I do try to see what inside fibs, it just printout towards infinity.
and other example
i = 1 + i which is perfectly valid syntax,
but when I run it in side ghci it also halt it.

*

*what kind of recursion it is if its not recursion what it is ?

*what is the execution flow ?

*how i can can accessed on right side when its not been assigned at
all ?

*what is the value of i for first time on right ?

*what is the value of i on right ?

any articles that can help ?

A: In many (most?) languages functions are "special" values, which receive special status in the language syntax and semantics.
In Haskell, not so much. They share many properties with non-functions. In particular:

*

*We can pass functions (and non functions) as arguments to functions.

*We can return functions (and non functions) from functions.

*We can put functions (and non functions) into containers like lists, pairs, and so on.

*We can recursively define functions (and non functions).

The last point might be puzzling if you are not used to it, but there's no reason to allow recursion only when defining a function value in a lazy language like Haskell.
For instance one can define the infinite list 1:1:1:.... by letting list = 1 : list. If you can only understand recursive definitions for functions, just know that it is similar to list() = 1 : list(), except list is not a function, but a list.
You can also try to understand that 1:2:3:4:.... could be defined recursively as list = 1 : map (+1) list. Indeed, unfolding the definition we get:
list
= 1 : map (+1) list
= 1 : map (+1) (1 : map (+1) list)
= 1 : 2 : map (+1) (map (+1) list)
= 1 : 2 : map (+1) (map (+1) (1 : map (+1) list))
= 1 : 2 : 3 : map (+1) (map (+1) (map (+1) list))
...

Note that the above definition "works" because it can generate a part of the value before it recursively need its own value. In the i = i + 1 example you mention, this does not happen, since i + 1 needs the value of i immediately, before any part of the output can be produced. (Well, at least on the standard integer types.) Hence, it has the same behavior we would observe from an infinite recursive function such as i() = i() + 1.

A: In Haskell, let is what's known as letrec i.e. "recursive let" in other languages, meaning that both occurrences of a name in an equation refer to the same entity.
This makes sense as the equation is not an assignment, but a definition.(*)
fibs = 1 : scanl (+) 1 fibs

Here on the right fibs refers to the same fibs as the one on the left. It is not being called, but rather it is being used. It is being used according to its definition. It is defined with a lazy data constructor, :.
The evaluation can be imagined to proceed by naming all the interim entities and writing down their definitions according to what we already have:
print $ take 4 fibs ==>
take 4 fibs =
= take 4 (let {fibs = 1 : scanl (+) 1 fibs} in fibs)
= take 4 (let {fibs = 1 : s1 ; s1 = scanl (+) 1 fibs} in fibs)
= take 4 (let {fibs = 1 : s1 ; s1 = scanl (+) 1 fibs} in (1 : s1))
= take 4 (1 : let {fibs = 1 : s1 ; s1 = scanl (+) 1 fibs} in s1)
= 1 : take 3 (let {fibs = 1 : s1 ; s1 = scanl (+) 1 fibs} in s1)
= 1 : take 3 (let {s1 = scanl (+) 1 (1 : s1)} in s1)
= 1 : take 3 (let {s1 = 1 : scanl (+) 2 s1} in s1)
= 1 : take 3 (let {s1 = 1 : s2; s2 = scanl (+) 2 s1} in (1 : s2))
= 1 : take 3 (1 : let {s1 = 1 : s2; s2 = scanl (+) 2 s1} in s2)
= 1 : 1 : take 2 (let {s1 = 1 : s2; s2 = scanl (+) 2 s1} in s2)
= 1 : 1 : take 2 (let {s2 = scanl (+) 2 (1 : s2)} in s2)
= 1 : 1 : take 2 (let {s2 = 2 : scanl (+) 3 s2} in s2)
= 1 : 1 : take 2 (let {s2 = 2 : s3; s3 = scanl (+) 3 s2} in (2 : s3))
= 1 : 1 : 2 : take 1 (let {s2 = 2 : s3; s3 = scanl (+) 3 s2} in s3)
= 1 : 1 : 2 : take 1 (let {s3 = scanl (+) 3 (2 : s3)} in s3)
= 1 : 1 : 2 : take 1 (let {s3 = 3 : scanl (+) 5 s3} in s3)
= 1 : 1 : 2 : take 1 (let {s3 = 3 : s4; s4 = scanl (+) 5 s3} in (3 : s4))
= 1 : 1 : 2 : 3 : take 0 (let {s3 = 3 : s4; s4 = scanl (+) 5 s3} in s4)
= 1 : 1 : 2 : 3 : []
= [1,1,2,3]

That's how it goes.(**)
The i in let { i = i+1 } in i uses + which is strict, so any attempt to use the value of i loops, as + demands the values of both its arguments before ever returning its value, unlike the lazy : which actually demands none.

You've asked,

how a value can be accessed inside it's own definition ?

The above gives the answer, which is twofold. Firstly, because the (implied) let is recursive, both the names on the left and the right of the equal sign refer to the same entity. Secondly, since Haskell's evaluation is lazy, there are no assignments (and no "values" really in the usual sense) -- just definitions. A list is not a list, but a definition of a computational process to compute that list, etc.

(*) or in technical jargon, a lazy binding.
(**) turns out it's a song, and a nice one too.


text:
Q: Some problems when scaling Socket.IO to multiple Node.js processes using cluster My node.js server uses cluster module in order to work on multiple processes.
If the server receives requests from clients with Socket.IO, it conveys the data to another server with redis publish. And it receive refined data with redis subscribe, and then it just toss this data to clients.
I use one node process to receive data with redis sub, and other processes to send data to clients with socket.io.
And the client connect socket.io when page loaded.
Here, this is my problem.
The connect event occured repeatedly not even the page loaded.
When the client connect, I get the socket.id from that socket, and I use it later when I want to send data to that client socket. But this connect occur repeatedly, I think socket that client use changed. So, the first socket.id that I remembered will be useless. I can't send data from that socket.id. I stored auth information in the socket object, so the changed client socket is no help.
index.pug
    $(document).ready(function(){
       var socket = io.connect();
       (...)

app.js
    var cluster = require('cluster');
    var socketio = require('socket.io');
    var NRP = require('node-redis-pubsub');
    var nrpForChat = new NRP(config.chatRedisConfig);
    var nrpForCluster = new NRP(config.clusterRedisConfig);

    var startExpressServer = function(){
      var app = express();
      var server = require('http').createServer(app);
      var io = socketio.listen(server);
      var redis = require('socket.io-redis');
      io.adapter(redis({ host: 'localhost', port: 6380 }));

      io.sockets.on('connection', function(socket){
        socketController.onConnect(io, socket, nrpForChat);
      });

      server.listen(config.port, function(){
        console.log('Server app listening on port '+config.port);
      });

      nrpForCluster.on('to:others:proc', function(data){
        var socket = io.sockets.connected[data.target.sockid];
        if (socket) {
          if (data.event == '_net_auth') {
            if (data.data.res){
              socket.enterId = data.data.data.enterId;
              socket.memberKey = data.data.data.memberKey;
              socket.sid = data.data.data.sid;
              socket.emit(data.event, data.data);
            }else{
              console.log('auth failed.');
            }
          }
        } else {
          socket.emit(data.event, data.data);
        }
      });

      module.exports = app;
    }

    var numCpus = require('os').cpus().length;

    if (cluster.isMaster) {
      for (var i = 0; i < numCpus; i++) {
        cluster.fork();
      }
    }
    else {
      if (cluster.worker.id == numCpus) {

        nrpForChat.on('chat:to:relay', function(data){
          nrpForCluster.emit('to:others:proc', data);
        });

        if (numCpus == 1) {
          startExpressServer();
        }
      }
      else {
        startExpressServer();
      }
    }

A: By default, socket.io connects with several consecutive http requests.  It essentially starts in HTTP polling mode and then after some initial data exchange, it switches to a webSocket transport.
Because of this, a cluster that does not have any sort of sticky load balancing will not work.  Each of the initial consecutive http requests that are all supposed to go to the same server process will probably be sent to different server processes in the cluster and the initial connection will not work.
There are two solutions that I know of:

*

*Implement some sort of sticky load balancing (in the clustering module) so that each client repeatedly goes to the same server process and thus all the consecutive http requests at the beginning of a connection will go to the same server process.

*Switch your client configurations to immediately switch to the webSocket transport and never use the HTTP polling.  The connection will still start with an http request (since that's how all webSocket connections start), but that exact same connection will be upgraded to webSocket so there will only ever be one connection.
FYI, you will also need to make sure that the reconnect logic in socket.io is properly reconnecting to the original server process that is was connected to.
socket.io has node.js clustering support in combination with redis.  While the socket.io documentation site has been down for multiple days now, you can find some info here and Scaling Socket.IO to multiple Node.js processes using cluster and here's a previously cached version of the socket.io doc for clustering.


text:
Q: How to Label Equation with Tag by Number For example, if I write a code as follows,
The equation with tag is \ldots
\begin{align}\label{E:1}
1 + \tan^2x & = 1 + {\sin^2x \over \cos^2x} \nonumber \\[5pt]
& = {\cos^2x + \sin^2x \over \cos^2x} \nonumber \\[5pt]
& = {1 \over \cos^2x} \tag*{by Lemma A} \nonumber \\[5pt]
& = \sec^2x.
\end{align}
Using \eqref{E:1}, we have \ldots

then it produces as follows.

What I intended is: "Using (1), we have ...", because (1) is the equation number.
How do I fix this incorrect labeling?
Thank you.

A: You're abusing \tag, in my opinion: readers will be confused about the meaning of the equation number.
Anyway, here's how you can do it: move the \label in the line where the equation number will appear.
\documentclass{article}
\usepackage{amsmath}

\begin{document}

The equation with tag is
\begin{align}
1 + \tan^2x & = 1 + \frac{\sin^2x}{\cos^2x} \notag \\
& = \frac{\cos^2x + \sin^2x}{\cos^2x} \notag \\
& = \frac{1\vphantom{\cos^2x}}{\cos^2x} \tag*{by Lemma A} \\
& = \sec^2x.\smash[b]{\vphantom{\frac{1}{\cos^2x}}} \label{E:1}
\end{align}
Using \eqref{E:1}, we have \ldots

\end{document}

I changed \nonumber to \notag (which is amsmath specific) and also changed \over to the LaTeX preferred format (there are several reasons to).
In order to fix the vertical spacing, I added a phantom (one smashed at the bottom).

How to make a better parenthetical remark?
\documentclass{article}
\usepackage{amsmath}

\begin{document}

The equation with tag is
\begin{equation}\label{E:1}
\begin{aligned}[b]
1 + \tan^2x & = 1 + \frac{\sin^2x}{\cos^2x} \\
& = \frac{\cos^2x + \sin^2x}{\cos^2x} \\
& = \frac{1\vphantom{\cos^2x}}{\cos^2x} \makebox[2em][l]{\quad(by Lemma A)} \\
& = \sec^2x.\smash[b]{\vphantom{\frac{1}{\cos^2x}}}
\end{aligned}
\end{equation}
Using \eqref{E:1}, we have \ldots

\end{document}

Using a 2em wide box doesn't influence too much the global centering.


text:
Q: How to refer to data in a previous viewpager I have an android project that is using fragments and a viewpager.
I am using a separate countdown timer for every page, that only runs when the view of the page is 'onscreen'. At first the time for every page is the same, but after a while page 1 might be 20 seconds left, page 2 60 seconds and so on.
My problem is that I don't know how to save the remaining time, the moment the user swipes to the next page. I am using a onpagestatelistener that has the following code, but this is saving the new value of questionId and the old value of the new time. How do I refer to the value of the questionId and the matching newtime-value of the page that was in view before the user swiped?
viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
    public void onPageScrollStateChanged(int state) {
        if (state == ViewPager.SCROLL_STATE_DRAGGING) {
            saveTime();
        }
    }
    public void onPageScrolled(int position, float arg1, int arg2) {}
    public void onPageSelected(int pos) {
        questionId =  mQuestions.get(pos).getNr()
        runTime();
    }
});

public void saveTime(){
    mQuestions.get(questionId).setTime(newTime);
}

public void runTime(){
    if (mTimer != null) {
        mTimer.cancel();
        mTimer = null;
    }
    mTimer = new CountDownTimer(90000, 1000) {//MillisInFuture, countDownInterval
        public void onTick(long millisUntilFinished) {
            newTime = (millisUntilFinished/1000);
        }
        public void onFinish() {
        }
    }.start();
}

A: First of all you can use SharedPreferences.
Besides, of course you can save data in adapter which you use for ViewPager, you can save this data in DB or create some singleInstance in your parent Activity or Fragment.


text:
Q: How to format responses of ec2 endpoint to json I am trying to perform a GET-Request to the ec2-Endpoint https://ec2.eu-central-1.amazonaws.com/?Action=DescribeInstances&Version=2016-11-15 in order to get a list of all ec2 instances within my aws account (in eu-central-1 region). Unfortunately the response's content is formatted in xml. Is there a chance to change the format of the response to json?
I've already set the GET-Request's Accept-Header to "application/json" but without success.
If I query the iam-endpoint https://iam.amazonaws.com/?Action=ListUsers&Version=2010-05-08 with the same Accept-Header the response's content is being delivered properly in json string format.
These are the headers for the ec2-query (not working):
GET /?Action=DescribeInstances&Version=2016-11-15 HTTP/1.1
Host: ec2.eu-central-1.amazonaws.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
X-Amz-Date: 20180706T091958Z
Authorization: <valid AWS4 authorization header>
Cache-Control: no-cache
Postman-Token: 69c8f349-95b5-4e9d-991c-5ce2a55b0cbe

And the headers of my iam-query (working):
GET /?Action=ListUsers&Version=2010-05-08 HTTP/1.1
Host: iam.amazonaws.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
X-Amz-Date: 20180706T092222Z
Authorization: <valid AWS4 authorization header>
Cache-Control: no-cache
Postman-Token: ad86f2ae-870c-4289-a9d3-1f2ad9082c8f

Executing aws cli tools command aws ec2 describe-instances lists all instances in json format, so I think there should be a way to achieve this with a GET-request.
Thank you very much for your help.

A: Probably too late, but might help others.
I also tried to get json output from DescribeInstances without luck.
It seems to be impossible at the moment, since even aws cli receives it in xml and then converts it to json. You can see it using --debug flag:
aws ec2 describe-instances --debug


text:
Q: TortoiseHG Workbench resolving conflicts Windows 8 elevation issue When attempting to use "Tool Resolve" within the TortoiseHG Workbench on a file using Windows 8
I get the following error
abort: The requested operation requires elevation

The auto generated command looks like this
% hg resolve --repository "C:\MecurialRepositories\Test" -- "C:\MecurialRepositories\Test\Web.config"

Not really sure why this is the case, it works with TortoiseGit on the same machine.  I've tried to uninstall/reinstall and registry clean but it looks like there are additional permissions I need to set.

A: The diff tool wouldn't work for me from TortoiseHG on Windows 8 unless I ran TortoiseHG using "run as administrator". I found that updating KDiff to version 0.9.98 removed the need for privilege elevation.


text:
Q: Tropical versus max-plus Is the max-plus algebra an example of tropical mathematics or is it an independent structure? How can we turn a max-plus algebra into tropical geometry or viceversa-if possible?

A: A max-plus algebra is a tropical algebra. See: http://arxiv.org/PS_cache/math/pdf/0507/0507014v1.pdf


text:
Q: Set Cell to a number of lines in a GridView c#.net I am using a GridView in asp.net (c#) that is bound to a EntityDataSource
I want to set one column of text to be 3 lines (height) and than fit in the width .
I have played a bit with it but with no success
here is the code itself
                       <asp:TemplateField HeaderText="Description" SortExpression="Description">
                            <EditItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                            </ItemTemplate>
                            <ControlStyle Height="20px" />
                            <ItemStyle Height="50px" Width="150px" Wrap="False" />
                        </asp:TemplateField>

btw there is no special need for me for it to be as a template field...
Anyone has an idea ?
Thanks !

A: The ItemStyle would be applied to the cell; try applying the size to the label and textbox too.  Also, wouldn't you want the Wrap property to be set to True so content would wrap and you'd get the content within 3 lines?

A: Instead of TextBox you can use or a .NET server control:
<asp:TextBox id="TextArea1" TextMode="multiline" runat="server" />

Or you can use a client tag, with the runat = "server"
<textarea id="TextArea1" cols="20" rows="2" runat="server"></textarea>

With this tips you can take it like a textbox on three rows.


text:
Q: Call method from pouchdb sync I have a class setup like this
class FinanceDB {

  constructor() {
    this.PouchDB = require('pouchdb');
    this.db = new this.PouchDB('fin'); //8080
    this.remoteDB = new this.PouchDB('http://localhost:5984/rfin');

    this.db.sync(this.remoteDB, {
      live: true,
      retry: true
    }).on('change', function (change) {

      console.log('yo, something changed!');
      this.dosomething();

    }).on('error', function (err) {
      console.log("error", err);
      // yo, we got an error! (maybe the user went offline?)
    })
  };

  dosomething() {
    console.log('what now?');
  };
}

When the database changes, the console reads 'yo, something changed!' as expected. But my class method is never run and I don't get any errors. How do I call a method from inside pouchdb sync?

A: With a function in the callback here:
on('change', function (change) {

  console.log('yo, something changed!');
  this.dosomething();

})

You are getting the dynamic this which is detached from your class in the callback.
In Es6, you can now just switch to an Arrow function to get 'this' to be lexically scoped:
on('change', (change) => {

  console.log('yo, something changed!');
  this.dosomething();

})

In the past, the usual method was to create a new variable set equal to this before setting up the callback:
var that = this;
...
on('change', function (change) {

  console.log('yo, something changed!');
  that.dosomething();

})

A comparison of the arrow and regular function in a JSfiddle here.


text:
Q: Iterate through Linked List in Java Say, I have two references to an Object in a LinkedList List1:
LinkedList<Object> List1 = new LinkedList<Object>();
Object first;
Object last;

I don't want to use the list index of these objects to refer to them, because the length of my list changes. I think this would not work.
Now I want to iterate through the sublist defined by first and last, where first defines the beginning of the sublist in List1 and last defines the end of the sublist in List1.
My problem now is that AFAIK I can't do something like
while (current != last){
// do something
current = someiterator.next();

}

because I'm comparing two objects that in general will point to different locations. Furthermore, I also can't compare the references by their value, because the list may have one value appearing several times.
So how can I iterate through this sublist of List1?

A: You could use something like
list1.sublist(list1.indexOf(first), list1.indexOf(last))

Ok, I think I understand your question better now. The above method will use the .equals method and thus not compare references. Here is probably a better solution for you:
import java.util.*;

public class Test {

    public static void main(String[] args) {

        String first = "beta";
        String last = "delta";

        List<String> list1 = new LinkedList<String>();
        list1.add("alpha");
        list1.add(first);
        list1.add("gamma");
        list1.add(last);
        list1.add("epsilon");

        boolean firstFound = false;
        for (String s : list1) {

            if (firstFound || (firstFound = s == first))
                System.out.println(s);

            if (s == last)
                break;
        }
    }
}

A: No, your comparison while (current != last) will work fine. In Java, objects live on the heap and you only work with references. Comparing two references using == returns true iff they refer to the same object, which seems to be exactly what you want.

A: If you cannot rely neither on == nor .equals(), I don't see how you could possibly define a sublist...

A: You should use Object.equals() to compare your objects. If your Objects are real Objects and not primitive or Strings (they equal if their value equals) you should be able to do so:
 boolean start = false;
 for(Object o : list){
     if(o.equals(first){
         start = true;
     }else if(o.equals(last)){
        break;
     }
     if(start){
         // do something
     }
 }

Or rather use the answer of aioobe

A: One way is not to add the objects directly, but to create a wrapper, so you will have
 List<WrapperObject<Object>> aList = new LinkedList<WrapperObject<Object>>();

Now you can verify the equality of the entries by checking the wrappers instead of the wrapped objects.


text:
Q: Dataweave 2.0 array filtering based on another arrays values I'm attempting to try and match/filter the following lineId values in the unmatchedIds array to then filter the result set of exampleFile, by processorTransactionId. The result would be the removal of the last financialTransactionEntity, with the processorTransactionId = "000000062121029333".
In theory the sizes of both the unmatchedIds array and exampleFile array could be unbounded.
Any guidance/advice/examples would be much appreciated. I'm having difficult using the dataweave filter to achieve this at the moment.
{
  "unmatchedIds": [
    {
      "lineId": "000000062121029111"
    },
    {
      "lineId": "000000062121029222"
    }
  ]
}

exampleFile
[{
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "Burger Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000001000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029111"
        }
    },
    {
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "McDonalds Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000002000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029222"
        }
    },
    {
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "McDonalds Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000002000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029333"
        }
    }

]

A: You can make use of data selector with filter. See below
%dw 2.0
output application/java

import * from dw::core::Arrays

var unMatchedIds = {
  "unmatchedIds": [
    {
      "lineId": "000000062121029111"
    },
    {
      "lineId": "000000062121029222"
    }
  ]
}

var payload = [{
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "Burger Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000001000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029111"
        }
    },
    {
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "McDonalds Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000002000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029222"
        }
    },
    {
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "McDonalds Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000002000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029333"
        }
    }

]

---

using (unMatchedArray = unMatchedIds.unmatchedIds.*lineId)
payload[?(unMatchedArray contains $.financialTransactionEntity.processorTransactionId)]

unMatchedArray here is just a list of unmatched ids coming from your original object (unMatchedIds). Data selector will just include entry if financialTransactionEntity.processorTransactionId is in the unMatchedArray.

A: You can use groupBy and filter functions to achieve the result. First, you can group unMatchIds by lineId and then you can apply a filter on your actual payload to eliminate all unmatched items.
output application/json
var unMatchIdsGrouped = var.unMatchIds.unmatchedIds groupBy $.lineId
---
payload filter ((item) -> unMatchIdsGrouped[ item.financialTransactionEntity.processorTransactionId] !=null)

A: I would suggest transforming the unmatchedIds object to an array of id's, then filtering exampleFile objects based on whether or not the processorTransactionId is found in the compared array using contains full script:
%dw 2.0
output application/java

var unMatchedIds = {
  "unmatchedIds": [
    {
      "lineId": "000000062121029111"
    },
    {
      "lineId": "000000062121029222"
    }
  ]
}

var exampleFile = [{
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "Burger Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000001000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029111"
        }
    },
    {
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "McDonalds Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000002000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029222"
        }
    },
    {
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "McDonalds Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000002000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029333"
        }
    }

]

---
exampleFile filter (unMatchedIds.unmatchedIds.lineId contains $.financialTransactionEntity.processorTransactionId)

A: Here's another answer ....Hope it helps
    %dw 2.2
output application/json
var inpUnmatchedIds = {
  "unmatchedIds": [
    {
      "lineId": "000000062121029111"
    },
    {
      "lineId": "000000062121029222"
    }
  ]
}
var exampleIds = [{
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "Burger Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000001000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029111"
        }
    },
    {
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "McDonalds Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000002000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029222"
        }
    },
    {
        "financialTransactionEntity": {
            "cardAcceptor": {
                "name": "McDonalds Inc.",
                "countryCode": "GBP"
            },
            "financialTransaction": {
                "debitOrCredit": "C",
                "amountInOriginalCurrency": {
                    "amount": "0000002000",
                    "exponent": "2"
                },
                "originalCurrencyCode": "826",
                "transactionDate": "2020-02-18"
            },
            "processorTransactionId": "000000062121029333"
        }
    }
]
---
exampleIds filter (value) -> ((((inpUnmatchedIds pluck $.lineId))[0]) contains (value.financialTransactionEntity.processorTransactionId))


text:
Q: Force eviction of Hazelcast IMap entries at TTL I came across a problem where Hazelcast's map is evicting entries at a significant delay from configured TTL. Found a solution to set the following properties to force eviction at TTL here: https://github.com/hazelcast/hazelcast/issues/8894. The properties can be reset as:
Config config = new Config();
config.setProperty("hazelcast.internal.map.expiration.task.period.seconds", "1");
config.setProperty("hazelcast.internal.map.expiration.cleanup.percentage", "100");
config.setProperty("hazelcast.internal.map.expiration.cleanup.operation.count", "271");
The problem now is that these properties apply to the entire hazelcast instance. Is anyone aware if this can be set for only a single map in the instance? MapConfig as such does not have a setProperty() method.
P.S: the above properties work only for hazelcast 3.8 and above.

A: Even though the entry is not removed yet, expired entries will be unreachable and will be sweeped eventually either by the periodic cleanup process or when user tries to reach that entry. With those properties you can define the behavior of the cleanup process.
About your second question; yes, those properties are cluster level, they can't be applied per map basis.


text:
Q: XNA and Windows Forms I am trying to make a main menu in Windows Forms. When you click a label in the form, the XNA game should start playing.
But it didn't work.
my code in the program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace _2DSpaceShooter
{
    if WINDOWS || XBOX
    static class Program
    {

        static void Main(string[] args)
        {

            Application.Run(new MainMenu());
        }
    }
    endif
}

My code in the label click event
private void label1_Click(object sender, EventArgs e)
{
    using (Game1 game = new Game1())
    {
        game.Run();
    }
}

Please help me!!!
I am sorry for possible English mistakes (I am not American)

A: I don't know if you can do it, but if you can one of the simplest way is by using GameComponents. Making your game as a GC enables you to launch multiples parts of it at one time, without having issues with threads.

A: As @eudabash mentioned in the comment section, you'll need to do the game.Run() in a seperate thread:
Game1 game = new Game1();

Thread thread = new Thread(() =>
{
    game.Run();
};
thread.Start();

or, if you're on .Net 4.0 (I think. Or even 3.5)
Game1 game = new Game1();

Task.Factory.StartNew(() =>
{
    game.Run();
}

Optionally make 'game' a field in your Form1 class, so you can access it anywhere. Just make sure to only retrieve data from Game, and never edit the UI from within Game. Cross-thread operations and whatnot. If you need to, remember to invoke.


text:
Q: Fill a dynamic 2D array with words of multiples text files in C with this C code I want to fill a dynamic array of char with the words parsed in each differents text files returned by the readdir function.
#include <string.h>
#include <malloc.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

char *getWord(FILE *fp){
    char word[100];
    int ch, i=0;

    while(EOF!=(ch=fgetc(fp)) && !isalpha(ch))
        ;//skip
    if(ch == EOF)
        return NULL;
    do{
        word[i++] = tolower(ch);
    }while(EOF!=(ch=fgetc(fp)) && isalpha(ch));

    word[i]='\0';
    return strdup(word);
}

int readWords(const char * fn,char ** arr){
    char *word;
    FILE * fp;
    int size=0;
    //read first time to get the number of words
    fp=fopen(fn,"r");

    while(word=getWord(fp)){
        size++;
    }

    fclose(fp);
    printf("size:%d\n",size);
    arr = (char **) malloc (size * sizeof (char *));
    //reopen to insert in dynamic array
    fp=fopen(fn,"r");
    for (int i = 0; i < size; i++){
        arr[i] = (char *) malloc (100 * sizeof (char));
        word=getWord(fp);
        // printf("%s",word);
        strcpy(arr[i],word);
    }
    fclose(fp);

    return size;
}

int main(int narg, char *arg[] )
{
    struct dirent *de;  // Pointer for directory entry
    char absdir[256];
    char absfn[256];
    FILE * F;
    int s;

    // opendir() returns a pointer of DIR type.
    DIR *dr = opendir(arg[1]);
    strcpy(absdir,arg[1]);
    strcat(absdir,"/");

    if (dr == NULL)  // opendir returns NULL if couldn't open directory
    {
        printf("Could not open current directory" );
        return 0;
    }

    while ((de = readdir(dr)) != NULL){
        if (de->d_type!=4){ // is file?
            strcpy(absfn,absdir);
            strcat(absfn,de->d_name);
            printf("abs_fn:%s \n",absfn);
            char** arr_words;

            s=readWords(absfn,&arr_words);

            printf("%s number of words:%d\n", absfn,s);
            for (int i=0;i<s;i++)
                printf("word %d:%s\n",i,arr_words[i]);

            //free 2D array

            for(int i=0;i<s;i++)
                free(arr_words[i]);
            free(arr_words);

        }

    }
    closedir(dr);
    return 0;
}

the words are well parsed with getWord but i can't find the solution to fill the char **arr passed in argument and to use it latter in the main function.
I want to allocated the char **arr_words  dynamically with  the following form
arr_words[0]=First word of file text
arr_words[1]=Second word
arr_words[s-1]=Last Word

the Readword function return the number of words read in each files.
thanks

A: Your bug is a more advanced one of the problem described here: Dynamic memory access only works inside function
arr is a local variable. It's a pointer to the first pointer in an array of pointers. In order to return this to main (hang on tight now), your function need to pass a pointer to a pointer to the first pointer in an array of pointers...
Or in plain C, the dreaded three-star programming, char***. But this is actually a valid use for it, about the only valid use of three levels of indirection that exists.
Alternatively, you can just use the return for the char** and skip this extra level of indirection, which might be more readable.
Which form to use is a bit subjective, but you need to change your function to one of these:
int readWords(const char * fn, char*** arr)
{
  ...
  *arr = malloc (size * sizeof (char *))
  ...
}

or
char** readWords(const char * fn, int* wordsRead)
{
   ...
   arr = malloc (size * sizeof (char *));
   ...
   *wordsRead = size;
   return arr;
}

A: #include <string.h>
#include <malloc.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

char *getWord(FILE *fp){
    char word[100];
    int ch, i=0;

    while(EOF!=(ch=fgetc(fp)) && !isalpha(ch))
        ;//skip
    if(ch == EOF)
        return NULL;
    do{
        word[i++] = tolower(ch);
    }while(EOF!=(ch=fgetc(fp)) && isalpha(ch));

    word[i]='\0';
    return strdup(word);
}

char** readWords(const char * fn,int *wordsRead){
    char *word;
    char**arr;
    FILE * fp;
    int size=0;
    //read first time to get the number of words
    fp=fopen(fn,"r");

    while(word=getWord(fp)){
        size++;
    }

    fclose(fp);
    printf("size:%d\n",size);
    arr = malloc (size * sizeof (char *));
    //reopen to insert in dynamic array
    fp=fopen(fn,"r");
    for (int i = 0; i < size; i++){
        arr[i] = (char *) malloc (100 * sizeof (char));
        word=getWord(fp);
        // printf("%s",word);
        strcpy(arr[i],word);
    }
    fclose(fp);
    *wordsRead = size;

    return arr;
}

int main(int narg, char *arg[] )
{
    struct dirent *de;  // Pointer for directory entry
    char absdir[256];
    char absfn[256];
    FILE * F;
    int s;
    int wordsRead;
    char buffer[100];

    // opendir() returns a pointer of DIR type.
    DIR *dr = opendir(arg[1]);
    strcpy(absdir,arg[1]);
    strcat(absdir,"/");

    if (dr == NULL)  // opendir returns NULL if couldn't open directory
    {
        printf("Could not open current directory" );
        return 0;
    }

    while ((de = readdir(dr)) != NULL){
        if (de->d_type!=4){ // is file?
            strcpy(absfn,absdir);
            strcat(absfn,de->d_name);
            printf("abs_fn:%s \n",absfn);
            char **arr_words;
            arr_words=readWords(absfn,&wordsRead);

            printf("%s number of words:%d\n", absfn,wordsRead);
            for (int i=0;i<wordsRead;i++){

                printf("word %d:%s\n",i,arr_words[i]);
            }
            //free array of pointers

            for(int i=0;i<s;i++)
                free(arr_words[i]);
            free(arr_words);

        }

    }
    closedir(dr);
    return 0;
}


text:
Q: NGINX Configuration issue I have a issue with my nginx configuration. The problem is that it always use the proxy conf it never use the beta.node365-p.se conf.
I want that if the requested domain is beta.node365-p.se the server should handel it locally but if the request is for something else it should proxy it to the other apache server.
server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    server_name  beta.node365-p.se;

    location / {
            try_files $uri $uri/ =404;
    }

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }

}

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    server_name "";

    location / {
            proxy_buffers 16 4k;
            proxy_buffer_size 2k;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://31.44.238.211:80;
    }
}

A: Change server_name ""; by server_name _; and let default_server options in the second vhost only.
The first server_name case means you match request without Host directive (i.e. HTTP/1.0 requests).
The second means you match a wildcard server name choosen as a second option if other vhost don't contain the right server_name considering the Host header of the initial request.
Update :

*

*Your conf is missing listen directives in vhosts.

*You are not passing the right Host header while proxying, change proxy_set_header Host $host; by proxy_set_header Host "beta.node365-p.se";.


text:
Q: Hot to map html input properties to object with jQuery? I want to read all page inputs ids and values
into object and pass it to function which loop throuhg them and extract id and value.
I started with:
function send()
{
var data = [];
var inputs = $(":text");
for (var i = 0, l = inputs.length; i < l; i++) {
   var input;
   input.id = inputs[i].attr("id");
   input.text = inputs[i].val();
   data[i] = input;
}
receive(data);
}

function receive(data)
{
    for (var input in data) {
        alert(input.id);
        alert(input.text);
    }
}

Why this does not work?

A: If you give your input elements a name attribute, you could just do this...
var data = $(":text").serializeArray();

...which results in this data structure (taken from the docs)...
[
  {
    name: "a",
    value: "1"
  },
  {
    name: "b",
    value: "2"
  },
  {
    name: "c",
    value: "3"
  },
  {
    name: "d",
    value: "4"
  },
  {
    name: "e",
    value: "5"
  }
]

A: For adding items to an array, you likely want to use .push() instead of accessing it via the numeric index.  Also, jQuery provides a .each to iterate over a set.
var data = [];
$(':input:not(:button)').each(function() {
   data.push({
      id: this.id,
      text: $(this).val()
   });
});

One more thing.  jQuery does include a .map function, which returns an array "mapped" over a given set which could shorten the above code down to...
var data = $(':input:not(:button)').map(function() {
    return { id: this.id, text: $(this).val() };
});

A: Use jquery's serializeArray function
HTML:
<form id="test">
    <input type="hidden" name="a1" value="test" />
    <input type="text" name="a2" value="test2" />
    <input type="text" name="a3" value="test2" />
    <input type="text" name="a4" value="test2" />
</form>

JS:
function getData(){
    var data = $("#test").serializeArray();
    for(var i in data){
       alert(data[i].name+":"+data[i].value);
    }
}

jsFiddle example:
http://jsfiddle.net/k2Dd4/

A: I am not sure of the exact implementation in jQuery, but in Javascript I would do it as
var inputs = document.getElementsByTagName("input");
var textelems;

for (var i=0;i<inputs.length;i++) {
    if (inputs[i].type == "text") {
        tempElem = [];
        tempElem['id'] = inputs[i].id;
        tempElem['value'] = inputs[i].value;
        textelems.push(tempElem);
    }
}

This would give you a 2D-array (tempElems) where each index is a textbox with its own indexes of id and value.

A: Correct code would look like:
function send()
{
var data = [];
var inputs = $(":text");
for (var i = 0, l = inputs.length; i < l; i++) {
    var input = {};
    input.id = $("#" + inputs[i].id).attr("id");
    input.text = $("#" + inputs[i].id).val();
    data[i] = input;
}
receive(data);
}

function receive(data)
{
    for (var i = 0, l = data.length; i < l; i++) {
       alert(data[i].id);
       alert(data[i].text);
    }
}


text:
Q: Problem with PDFTextStripper().getText when using PDType0Font in pdfbox I've started to work with PDType0Font recently (we've used PDType1Font.HELVETICA but needed unicode support) and I'm facing an error where i'm adding lines to the file using PDPageContentStream but PDFTextStripper.getText doesn't get the updated file contents.
I'm loading the font:
PDType0Font.load(document, fontFile)

And creating the contentStream as follows:
PDPageContentStream(document, pdPage, PDPageContentStream.AppendMode.PREPEND, false)

my function that adds content to the pdf is:
  private fun addTextToContents(contentStream: PDPageContentStream, txtLines: List<String>, x: Float, y: Float, pdfFont: PDFont, fontSize: Float, maxWidth: Float) {
     contentStream.beginText()
     contentStream.setFont(pdfFont, fontSize)
     contentStream.newLineAtOffset(x, y)
     txtLines.forEach { txt ->
       contentStream.showText(txt)
       contentStream.newLineAtOffset(0.0F, -fontSize)
     }
     contentStream.endText()
     contentStream.close()

When i'm trying to read the content of the file using PDFTextStripper.getText i'm getting the file before the changes.
However, if I'm adding document.save before reading to PDFTextStripper, it works.
      val txt: String = PDFTextStripper().getText(doc) //not working

      doc.save(//File)
      val txt: String = PDFTextStripper().getText(doc) //working

if I'm using PDType1Font.HELVETICA in
contentStream.setFont(pdfFont, fontSize)

Everything is working without any problems and without saving the doc before reading the text.
I'm suspecting that the issue is with the code in PDPageContentStream.showTextInternal():
        // Unicode code points to keep when subsetting
    if (font.willBeSubset())
    {
        int offset = 0;
        while (offset < text.length())
        {
            int codePoint = text.codePointAt(offset);
            font.addToSubset(codePoint);
            offset += Character.charCount(codePoint);
        }
    }

This is the only thing that is not the same when using PDType0Font with embedsubsets and PDType1Font.
Can someone help with this?
What am I doing wrong?

A: Your question, in particular the quoted code, already hints at the answer to your question:
When using a font that will be subset (font.willBeSubset() == true), the associated PDF objects are unfinished until the file is saved. Text extraction on the other hand needs the finished PDF objects to properly work. Thus, don't apply text extraction to a document that is still being created and uses fonts that will be subset.
You describe your use case as

for our unit tests, we are adding text (mandatory text for us) to the document and then using PDFTextStripper we are validating that the file has the proper fields.

As Tilman proposes: Then it would make more sense to save the PDF, and then to reload. That would be a more realistic test. Not saving is cutting corners IMHO.
Indeed, in unit tests you should first produce the final PDF as it will be sent out (i.e. saving it, either to the file system or to memory), then reload that file, and test only this reloaded document.


text:
Q: Show formatted text via CKEditor 4 sorry the question is a bit trivial, but I'm using CKeditor 4 for my form, I set it perfectly, the toolbar for bold, lowercase etc. is then shown correctly.
My question is, once I have saved the text sent by this form in the database, I need to take it obviously formatted (for example bold) but the text is displayed compact and with code such as  raw.
How can I print formatted text? I didn't find anything clear to do this in the guide. Thank you

A: Please see:
https://ckeditor.com/docs/ckeditor4/latest/examples/htmlformatting.html#editor1
https://ckeditor.com/docs/ckeditor4/latest/guide/dev_output_format.html
This is what you can do from CKEditor point of view.
Please note however that you are submitting that HTML to server and then save it into data base - this is beyond editor control and most likely where formatting gets destroyed. I would recommend putting some break-points in your server code and debug it to check where exactly formatting gets removed.


text:
Q: Kotlin understanding missing var keyword in for loop I am a beginner in Kotlin and going through for loop
Simple code sample:
 for (i in 1..5) print(i)

Please can someone advise me why we do not specify the counter/iterator variable type "i" with the keyword var / val. Since "var /val" is the standard way to declare variables in Kotlin.

A: This is simply how the for loop syntax is designed. I cannot speak for the designers, but I believe that's a design decision to avoid unnecessary bloat, and maybe confusion.
You cannot use an existing variable as the loop variable. The loop variable is scoped to the loop, and shadows existing ones from outer scopes. So it's kind of implied that you're declaring a new variable here, even without a keyword (however I have to admit that the shadowing behaviour would be clearer if we had to write the val/var keyword here).
Also, the loop variable is actually a val inside the loop's body (it cannot be reassigned), but it can feel like a var because it changes for each loop turn and is technically declared outside the loop's body. In effect, it's like a new val declared in the loop's body with a new value for each loop iteration.
So your example code can be thought of as:
var temp = 1
while (temp <= 5) {
    val i = temp
    println(i)
    temp++
}

That's probably why the designers decided to not put any keyword here: it's unnecessary, and both val and var would be confusing in their own way.


text:
Q: how to access the styles from CSS Can we get the value from inside a css definition in the code if CSS resource is used?
e.g.
.iv_menu_thumbnail {
  display: block;
  width: 24px;
  height: 24px;
  margin: 3px;
  float: left;
  cursor: pointer;
}`

Can we know via code the value of width and i want to access from one of my java class?
Thanks in advance

A: var width = $('.iv_menu_thumbnail').width();
console.log(width);

This will get the width of the element if this is what youre asking for.
As far as I'm concerned you cannot get non numerical values from a css declaration.
But you can set your own values via jQuery using the
.css()

So it would look like this if you want to set a new css value. (or overwrite it)
$(someelement).css('float', 'left');

A: As far as I know, you can only inspect the computed CSS property on an element where this has been applied. Like:
$(someElementOrId).css('width');

or
$(someElementOrId).width();

Note that the former and the latter differ - the former does not contain the unit of measure, the latter does.

A: You can have a variables in your Css Resource file and set the width attribute with that variable, and then access the width varialbe from code.
CssResource
Css Resource file
@def small 1px;
@def black #000;
border: small solid black;

Java Code
interface MyResources extends CssResource {
  int small();
}


text:
Q: Estimating Landsat 7 azimuth (heading)? I am trying to understand if the Landsat 7 satellite ETM+ orbit has any significant azimuth or if it could be assumed as 0° (as it is not a pointable sensor).
I searched in the web but could not find any good answer so far.
Zenith is supposed to be equal zero as Landsat images are always nadir.
What about the azimuth?
Would knowing the scene center coordinates (they're 46.036323 N and 10.456876 E) be of any help?
The image looks like a sort of isosceles trapezoid, with the major basis towards the North (as I would expect for the Northern Hemisphere). It is also tilted differently from south to North (as I also would expect).

One question arose while I was trying to solve my task. The metadata file of Landsat provides coordinates of the four image corners. Anyway they refer to the black background.
The azimuth is intended to be calculated through these corners or the corners of the "real"-non-background image?
And why do I have to use latitude rather than longitude?
Is it not better to use longitude?
I thought to use (for instance) the right corners, subctracting the longitudes of them (e.g. upper right long-lower right long) and obtain what I was looking for in terms of degrees, does it make sense for you?
Here is an image showing a part of Landsat paths in a Worldwide Reference System (descending orbit) and my Landsat scene. RS is geographic, WGS84. According to this what I should looking at is the non-background image.

A: Since Landsat satellites are not placed a true polar orbit -- they are in a "near polar" orbit -- their heading (azimuth) is never zero. See NASA's Landsat Handbook and Landsat Science. It is closest to zero at the equator (8.2°) but deviates from this the closer it gets to the poles. Thus, yes, knowing the center coordinates (latitude, actually) of the image could be used to determine its orientation. However, it may be easier to estimate the orientation from the coordinates (lat & long) of the corner points of the scene.
   ________
  /       /  <--  estimate azimuth
 /       /      from heading of top right
/_______/  <-- from bottom right

The trapezoidal shape of the scene is due to the significant amount of earth rotation that occurs during the scanning of the scene while the satellite is moving in its orbit. Ideally, you would correct for this.
From the 2nd ref, "Inclination: 98.2°" I assume that is the tilt of the orbital plane from the equatorial plane, measured at the equator. And that implies an angle of 8.2° off the plane of the meridian. As the satellite it approaches the poles it's azimuth will approach +/- 90°.

Well done for persevering. If the meta data only give the corners of the Black rectangle as you state, then you are correct: my simple solution above is useless without knowing the coordinates of the actual skewed image inside.
My reference to latitude (the position) determining orientation was along this line of reasoning: knowing the satellite's orbital parameters, you can relate time, position and orientation. You'd need to understand spherical-geometry, though.
And, as you say, you can estimate the orientation via the relative latitude and longitude of the sides of one of the "big black triangle", if you happened to know them.


text:
Q: How can I make a circle from grid of GameObjects? What I am trying to achieve is something like this:

What I have so far is the edges for the circles.

I know this would involve a nested for loop. This is what I have so far:
public GameObject player;
private GameObject playerGrid;

public int numOfObjects;
private Vector3 centerPos;
public int size = 2;

public Vector2 speed = new Vector2(50, 50);
private float smoothTime = 0.25f;

void Start()
{
    playerGrid = new GameObject();
    centerPos = transform.position;

    for (int i = 0; i < numOfObjects; i++)
    {
        float pointNum = (i * 1.0f) / numOfObjects;
        float angle = pointNum * Mathf.PI * 2;
        float r = size / 2 * (Mathf.PI);
        float x = Mathf.Sin(angle) * r;
        float y = Mathf.Cos(angle) * r;
        Vector3 pointPos = new Vector3(x, y, 0) + centerPos;
        GameObject obj = Instantiate(player, pointPos, Quaternion.identity);
        obj.transform.SetParent(playerGrid.transform);
    }
}

I am stuck on how to implement the conditional for the nested for loop. Also, I have trouble understanding the calculations of column positions in the nested for loop. I believe the conditional would be the start and end of I for that column or row: for(int j = i + 1; j < i - 1, j++)
For the col positions, I would think it would be incrementing the angle enough to give the square its space for that column: float x = (Mathf.Sin(angle) + somethingHere) * r;
I just not sure how to progress from here.

A: Here's a simple way to draw a circle:
public float circleRadius = 5f;
public float objectSize = 1f;

void OnDrawGizmos()
{
    for (var x = -circleRadius; x <= circleRadius; x++)
    {
        for (var y = -circleRadius; y <= circleRadius; y++)
        {
            var pos = new Vector3(x, 0f, y);

            if (pos.magnitude >= circleRadius) continue;

            Gizmos.DrawSphere(pos * (objectSize * 2f), objectSize);
        }
    }
}


text:
Q: Detect Heap Overflow in Javascript I actually work on a javascript project.
In this project i detected an application crash when i send too much data in an AJAX request. In a text shield, each time an users write a character or copy past something, i send the data as a PATCH request into the back-end. If i want to trigger the crash, i just send 4 or 5 time 10000 'a' characters.
How to detect if this crash was triggered by a javascript heap overflow? and how to protect this memory corruption?
Do you have an example of javascript Heap overflow Exploit and his protection?


text:
Q: XAML: Make TreeViewItem using VS theme colors I'm creating a Visual Studio extension with a tool window. There I use a TreeView. I want this tree view to use the current Visual Studio theme. Thanks to the post How do you highlight TreeViewItem? I was able to set the the Text and Highlight colors. But there are more issues:

*

*the colors only update on (re-)start of visual studio but not directly when I change the theme

*How to I change the unfocused highlight colors?

*How do I change the expandable icon colors to the current theme colors?

*Any chance to make the highlight go over the full with as it is in the Solution Explorer window?

Here is my current XAML code:
<UserControl x:Class="DavidSpeck.CSharpDocOutline.DocOutlineView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:shell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.12.0"
         Background="{DynamicResource VsBrush.Window}"
         Foreground="{DynamicResource VsBrush.WindowText}"
         mc:Ignorable="d"
         d:DesignHeight="300" d:DesignWidth="300"
         Name="MyToolWindow">
<UserControl.Resources>
    <Style x:Key="CETreeViewItem" TargetType="{x:Type TreeViewItem}">
        <Style.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="{DynamicResource {x:Static shell:VsColors.ToolWindowTextKey}}" />
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="{DynamicResource {x:Static shell:VsColors.HighlightKey}}" />
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="{DynamicResource {x:Static shell:VsColors.HighlightTextKey}}" />
        </Style.Resources>
    </Style>
</UserControl.Resources>
<Grid>
    <StackPanel Orientation="Vertical">
        <TreeView Name="outlineTreeView"
                  Background="{DynamicResource VsBrush.Window}"
                  BorderThickness="0"
                  ItemContainerStyle="{StaticResource CETreeViewItem}">
        </TreeView>
    </StackPanel>
</Grid>


text:
Q: Error when creating stored procedure SQL Server 2008 R2 i'am getting error on '{' and 'END'
CREATE PROCEDURE getLogsdata
{
    @id int
}
AS
BEGIN

END

how to remove this errors

A: Use parenthesis () instead of curly braces {}, and include some code in your procedure.
create procedure dbo.getLogsdata (@id int) as
  begin;
    set nocount on;

    select *
    from dbo.logs
    where id = @id;
  end;
go


text:
Q: Hessian of restriction of a map to the boundary of a domain Let $(M^n,g)$ be a Riemannian manifold and let $\Omega \subset M$ be a smooth and bounded domain of $M$. Suppose $u : \overline{\Omega} \to \mathbb{R}$ is a smooth function satisfying both $u = 0$ and $\Vert \nabla u \Vert = 1$ on $\partial \Omega$.
Now let $F : \overline{\Omega} \to \mathbb{R}$ be a smooth function and suppose it attains its maximum at a point $x_0 \in \partial \Omega$. How can I relate the Hessian of $F$ at $x_0$ and the Hessian of the restriction $F \vert_{\partial \Omega}$ at $x_0$?

A: If by the Hessian of the restriction $\text{Hess}(F|_{\partial\Omega})$ you mean the Hessian w.r.t. the induced Levy-Civita connection on $\partial\Omega$, then it can be realated to the Hessian in $\Omega$ via the second fundamental form which essentilly keeps track of the contribution to second order effects from the extrinsic curvature of the boundary.
Let $n$ be a unit normal vector field on $\partial\Omega$ (such as the gradient of $u$). The scalar second fundamental form w.r.t. $n$, $II:T\partial\Omega\times T\partial\Omega\to\mathbb{R}$ is defined by
$$\tag{1}
\widetilde{\nabla}_\widetilde{X}\widetilde{Y}=\nabla_XY+II(X,Y)n
$$
Where $\widetilde{\nabla}$ is the Levy-Civita connection in $\Omega$, $\nabla$ is the induced LC connection in $\partial\Omega$, and $\widetilde X,\widetilde{Y}$ are arbitrary extensions of vector fields $X,Y\in\Gamma(T\partial\Omega)$.
One can derive a simple formula for the relation between the Hessians of the two connections in terms of the second fundamental form.
$$
\widetilde{\text{Hess}}(F)(\widetilde{X},\widetilde{Y})=\text{Hess}(F|_{\partial\Omega})(X,Y)-n(F)II(X,Y)
$$

Derivation
We may start by using the product rule for connections
$$
\nabla_U\langle\alpha,V\rangle=\langle\nabla_U\alpha,V\rangle+\langle\alpha,\nabla_U V\rangle
$$
where $\alpha$ is a covector field, $U,V$ are vector fields and $\langle\ ,\ \rangle$ is the natural pairing. Applying this to $\omega\in\Gamma(T^*\Omega)$, with $X,Y$ as before,
$$\begin{align}
\langle\widetilde{\nabla}_\widetilde{X}\omega,\widetilde{Y}\rangle &= \widetilde{\nabla}_{\widetilde{X}}\langle\omega,\widetilde{Y}\rangle-\langle\omega,\widetilde{\nabla}_{\widetilde{X}}\widetilde{Y}\rangle \\
&=\nabla_X\langle\omega|_{T\partial\Omega},Y\rangle-\langle\omega|_{T\partial\Omega},\nabla_X Y\rangle-II(X,Y)\langle\omega,n\rangle \\
&=\langle\nabla_X(\omega|_{T\partial\Omega}),Y\rangle-II(X,Y)\langle\omega,n\rangle
\end{align}$$
Removing the dummy argument, this gives an analogous rule to $(1)$ for covectors
$$
\left.\left(\widetilde{\nabla}_{\widetilde{X}}\omega\right)\right|_{T\partial M}=\nabla_X(\omega|_{T\partial\Omega})-\langle\omega,n\rangle II(X,\_)
$$
Now, then using $\text{Hess}(F)=\nabla(dF)$, and that $(dF)|_{T\partial\Omega}=d(F|_{\partial\Omega})$,
$$
\widetilde{\nabla}_{\widetilde{X}}(dF)=\nabla_X(dF|_{\partial\Omega})-\langle dF,n\rangle II(X,\_)
$$
Which can be rewritten as the given formula

The second fundamental form can in turn be readily related to other quantities. For instance, with a local defining function $u$, the second fundamental form w.r.t. $\text{grad}(u)$ is given by
$$
II=\frac{-1}{\|\text{grad}(u)\|^2}\widetilde{\text{Hess}}(u)|_{T\partial\Omega}
$$


text:
Q: Stolen Windows7 Keys! Help I work in the IT Department of my company and we use one multi-license Windows 7 Ultimate Productkey for our in-house machines. Lately I've come to the strong suspicion, that workers from other departments somehow got a hold of the key and are using it to install Windows 7 on their private machines at home.
I'm worried that it might leak further and be blacklisted (which would cause serious headache).
Is there any way to check how many machines are currently activated on the key or how I might be able to frame down the specific people doing this?
Thanks in advance!

A: Check your licensing documentation from Microsoft. I only deal with Windows on rare occasions, but I have to imagine they'd define some sort of procedure for dealing smoothly with a problem like this. It can't be that unusual.

A: I'm not so sure about Microsoft being nice about this unless you are a large account. I know when I login to the key section on the Microsoft licensing site I get a warning the security of the keys is my responsibility.
Taken directly from Microsoft Licensing center:

Product keys are assigned to and intended for the sole use of your organization. You will be held responsible for unauthorized use of product keys issued under your agreement. Take measures to keep your keys secure. Do not disclose your product keys to any unauthorized parties.


text:
Q: Angular general version is lower than local I have tried to use several suggestions from posts\questions in Stackoverflow in order to update my Angular version, in addition to the https://update.angular.io/.
This thing is inside a specific project it looks like the Angular version in the latest(~7.2.0) while , when using npm angular --version is 6.4.1.
What am I doing wrong, if at all..?

A: the 6.4.1 is your npm version it seems that npm ignored the angular word, try npm --version you will get the same output
use ng --version instead

A: try ng --version
in my case, i ran this in the folder where my local version was older than my global version... I got the following message:

Your global Angular CLI version (6.1.0) is greater than your local
  version (6.0.0). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch
  false".


text:
Q: Facebook Audience 6.2.0 /apex/com.android.art/lib64/libart.so (art::OatHeader::IsDebuggable() const+124) on Android 11 After updating to Facebook Audience 6.2.0 from 5.11.0 on an Android app with target SDK 29 I'm seeing a considerable amount of crash reports on a small percentage of Android 11 devices. According to a user that is having this crash and has reinstalled the app several times to test, the crash occurs a few seconds after startup being able to see a loading screen the first time and then immediately after that first time.
  #00  pc 00000000004dcd84  /apex/com.android.art/lib64/libart.so (art::OatHeader::IsDebuggable() const+124)
  #00  pc 00000000004dd3f4  /apex/com.android.art/lib64/libart.so (art::OatFileBase::ShouldUnquickenVDex() const+56)
  #00  pc 00000000004dd594  /apex/com.android.art/lib64/libart.so (art::OatFileBase::LoadVdex(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)+80)
  #00  pc 00000000004e1594  /apex/com.android.art/lib64/libart.so (art::OatFile::Open(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool, bool, art::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const>, art::MemMap*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >*)+468)
  #00  pc 00000000004e7d78  /apex/com.android.art/lib64/libart.so (art::OatFileAssistant::OatFileInfo::GetFile()+696)
  #00  pc 00000000004e7038  /apex/com.android.art/lib64/libart.so (art::OatFileAssistant::OatFileInfo::Status()+76)
  #00  pc 00000000004e7458  /apex/com.android.art/lib64/libart.so (art::OatFileAssistant::OatFileInfo::ReleaseFileForUse()+56)
  #00  pc 00000000004ec944  /apex/com.android.art/lib64/libart.so (art::OatFileManager::OpenDexFilesFromOat(char const*, _jobject*, _jobjectArray*, art::OatFile const**, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*)+292)
  #00  pc 00000000004a0718  /apex/com.android.art/lib64/libart.so (art::DexFile_openDexFileNative(_JNIEnv*, _jclass*, _jstring*, _jstring*, int, _jobject*, _jobjectArray*)+144)
  #00  pc 0000000000010a88  /apex/com.android.art/javalib/arm64/boot-core-libart.oat (art_jni_trampoline+264)
  #00  pc 000000000001f584  /apex/com.android.art/javalib/arm64/boot-core-libart.oat (dalvik.system.DexFile.openDexFile+244)
  #00  pc 00000000000215d4  /apex/com.android.art/javalib/arm64/boot-core-libart.oat (dalvik.system.DexPathList.makeDexElements+1348)
  #00  pc 0000000000020b78  /apex/com.android.art/javalib/arm64/boot-core-libart.oat (dalvik.system.DexPathList.<init>+664)
  #00  pc 000000000001d934  /apex/com.android.art/javalib/arm64/boot-core-libart.oat (dalvik.system.BaseDexClassLoader.<init>+228)
  #00  pc 0000000000057f90  /apex/com.android.art/javalib/arm64/boot-core-libart.oat (dalvik.system.DexClassLoader.<init>+80)
  #00  pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548)
  #00  pc 00000000001a8a78  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
  #00  pc 000000000031830c  /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+376)
  #00  pc 000000000030e638  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+996)
  #00  pc 000000000067d794  /apex/com.android.art/lib64/libart.so (MterpInvokeDirect+576)
  #00  pc 000000000012d914  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_direct+20)
  #00  pc 00000000001cdc00  /data/app/~~USEx1p9tx0-5YVxYZoz1fQ==/com.mycompany.mygame-OdPieLgz_xrP3A7H8t3zyw==/oat/arm64/base.vdex (com.facebook.ads.internal.dynamicloading.DynamicLoaderFactory.makeLegacyAdsSdkClassLoader+160)
  #00  pc 000000000067e314  /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+1224)
  #00  pc 000000000012d994  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20)
  #00  pc 00000000001cdd48  /data/app/~~USEx1p9tx0-5YVxYZoz1fQ==/com.mycompany.mygame-OdPieLgz_xrP3A7H8t3zyw==/oat/arm64/base.vdex (com.facebook.ads.internal.dynamicloading.DynamicLoaderFactory.makeAdsSdkClassLoader+8)
  #00  pc 000000000067e314  /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+1224)
  #00  pc 000000000012d994  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20)
  #00  pc 00000000001cd96e  /data/app/~~USEx1p9tx0-5YVxYZoz1fQ==/com.mycompany.mygame-OdPieLgz_xrP3A7H8t3zyw==/oat/arm64/base.vdex (com.facebook.ads.internal.dynamicloading.DynamicLoaderFactory.doMakeLoader+70)
  #00  pc 000000000067e314  /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+1224)
  #00  pc 000000000012d994  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20)
  #00  pc 00000000001cd90c  /data/app/~~USEx1p9tx0-5YVxYZoz1fQ==/com.mycompany.mygame-OdPieLgz_xrP3A7H8t3zyw==/oat/arm64/base.vdex (com.facebook.ads.internal.dynamicloading.DynamicLoaderFactory.access$000)
  #00  pc 000000000067e314  /apex/com.android.art/lib64/libart.so (MterpInvokeStatic+1224)
  #00  pc 000000000012d994  /apex/com.android.art/lib64/libart.so (mterp_op_invoke_static+20)
  #00  pc 00000000001cd6fa  /data/app/~~USEx1p9tx0-5YVxYZoz1fQ==/com.mycompany.mygame-OdPieLgz_xrP3A7H8t3zyw==/oat/arm64/base.vdex (com.facebook.ads.internal.dynamicloading.DynamicLoaderFactory$a.run+34)
  #00  pc 0000000000305c34  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.16249794272548105830)+268)
  #00  pc 0000000000669e20  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+780)
  #00  pc 000000000013cff8  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88)
  #00  pc 000000000015ab08  /apex/com.android.art/javalib/arm64/boot.oat (java.lang.Thread.run+72)
  #00  pc 0000000000133564  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+548)
  #00  pc 00000000001a8a78  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
  #00  pc 0000000000553890  /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*)+460)
  #00  pc 00000000005a2c2c  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1308)
  #00  pc 00000000000af888  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64)
  #00  pc 000000000004fe08  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)

This is different from the /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) issue (/apex/com.android.runtime/lib64/bionic/libc.so (abort+160), abort crash in Android 10 devices) which still rarely occurs on 6.2.0.

A: According to the change log, version 6.2.1 (published on 03Feb2021) of the Android Facebook Audience Network SDK fixes this bug.

A: I also meet this crash, but not found how to solve it!

A: Feedback from FB tech support: "It looks like this issue was flagged to us previously, and our team has been working to resolve it. It should be fixed when SDK 6.3.0 becomes available."
Unfortunately, no timeline was given for version 6.3.0.


text:
Q: Order of static destructors If a class Foo has a static member variable Bar, I would expect Bar's destructor to run only after the last instance of Foo's destructor runs. This doesn't happen with the code snippet below (gcc 6.3, clang 3.8):
#include <memory>
#include <iostream>

class Foo;
static std::unique_ptr<Foo> foo;

struct Bar {
    Bar() {
        std::cout << "Bar()" << std::endl;
    }

    ~Bar() {
        std::cout << "~Bar()" << std::endl;
    }
};

struct Foo {
    Foo() {
        std::cout << "Foo()" << std::endl;
    }

    ~Foo() {
        std::cout << "~Foo()" << std::endl;
    }

    static Bar bar;
};
Bar Foo::bar;

int main(int argc, char **argv) {
    foo = std::make_unique<Foo>();
}

Outputs:
Bar()
Foo()
~Bar()
~Foo()

Why is the order of destruction not the reverse of construction here?
If ~Foo() uses Foo::bar this is a use after delete.

A:
I would expect Bar's destructor to run only after the last instance of Foo's destructor runs.

No, as a static data member, Foo::bar is independent of any instances of Foo.
And for the code you showed,
static std::unique_ptr<Foo> foo; // no Foo created here

Bar Foo::bar; // Foo::bar is initialized before main(), => "Bar()"

int main(int argc, char **argv) {
    foo = std::make_unique<Foo>(); // an instance of Foo is created, => "Foo()"
}

// objects are destroyed in the reverse order how they're declared
// Foo::bar is defined after foo, so it's destroyed at first => "~Bar()"
// foo is destroyed; the instance of Foo managed by it is destroyed too => "~Foo()"

A: The complication here is that the code doesn't instrument the constructor of foo. What happens is that foo gets constructed first, than Foo::bar gets constructed. The call to make…unique constructs a Foo object. Then main exits, and the two static objects get destroyed in reverse order of their construction: Foo::bar gets destroyed, then foo. The destructor for foo destroys the Foo object that it points to, which is the one created inmain.

A: In C++ the objects are constructed in order of occurrence and destructed in the reverse order. First comes foo construction, then bar construction then main is executed then bar is destructed and then foo. This is the behavior you are seeing. The switch appears because the constructor of foo doesn't construct a Foo, it constructs an empty unique_ptr, so you don't get to see Foo() in the output. Then bar is constructed with the output and in main you create the actual Foo after foo has long been constructed.

A: Static objects' lifetimes are based solely on the order of their definition. The compiler doesn't "know enough" when to call Bar::Bar() as much as calling Bar::~Bar().
To illustrate the problem better, consider this
class Foo;

struct Bar {
    Bar() {
        std::cout << "Bar()" << std::endl;
    }

    ~Bar() {
        std::cout << "~Bar()" << std::endl;
    }

    void baz() {}
};

struct Foo {
    Foo() {
        bar.baz();
        std::cout << "Foo()" << std::endl;
    }

    ~Foo() {
        std::cout << "~Foo()" << std::endl;
    }

    static Bar bar;
};

Foo foo;
Bar Foo::bar;

int main() {}

Prints
Foo()
Bar()
~Bar()
~Foo()

The addition of std::unique_ptr postpones Foo::Foo() after its construction in main, giving the illusion of the compiler "knowing" when to call Bar::Bar().
TLDR Static objects should be defined later than its dependencies. Before defining bar, it is just as much a bug to define a std::unique_ptr<Foo> and to define a Foo

A: In general, you should not write code which depends on the order of construction or destruction of static (or global) data. This makes unreadable and unmaintainable code (you might prefer static smart pointers, or
explicit initialization or startup routines called from main). And AFAIK that order is not specified when you link several translation units.
Notice that GCC provides the init_priority and constructor (with priority) attributes. I believe you should rather avoid using them. However, the __attribute__(constructor) is useful inside plugins, for plugin initialization.
In some cases, you might also use atexit(3) (at least on POSIX systems). I don't know if such registered functions are called before or after destructors (and I think you should not care about that order).


text:
Q: Formatting Double to exactly 2 Decimal places IF required I require a DecimalFormat or a better equivalent of representing a Double value (in Java) which could be:
25 or 25.5
I need for that to be represented as either a whole number (25) or to two decimal places if it has any (25.50). This is because i'm printing it out as money.
I have the following format already:
DecimalFormat decFormat = new DecimalFormat("##,###.##");

This works perfectly if the Double is a whole number; I get the output $25,000. Except if the value is 25,000.5; it prints $25,000.5 when I need it to be printed as $25,000.50. The problem is as stated in the docs:

#    a digit, zero shows as absent

So essentially the last zero is dropped off since it is optional.
I cannot do:
DecimalFormat decFormat = new DecimalFormat("##,###.#0");

as that is not allowed.
How can I achieve this?
Note:
These questions are related but do not cover what I need specifically with the DecimalFormat. Most of the answers suggest using a BigDecimal or printf. Is this the best thing to do? I don't have to use DecimalFormat but prefer to since i've started on that path (lots of code everywhere already using it).
Best way to Format a Double value to 2 Decimal places
How do I round a double to two decimal places in Java?
Round a double to 2 decimal places

A: This is definitely a bit of a hack, but I don't know if the DecimalFormat syntax allows for anything better. This simply checks to see if the number is real, and formats based on the spec you asked for.
    double number = 25000.5;
    DecimalFormat df;

    if(number%1==0)
         df = new DecimalFormat("##,###");
    else
        df = new DecimalFormat("##,###.00");

    System.out.println(df.format(number));

A: When you need to return Decimal Format value this works
import java.text.DecimalFormat;

/**
* @return The weight of this brick in kg.
*/
public double getWeight()
{

    DecimalFormat df = new DecimalFormat("#.##");

    double number = ( getVolume() * WEIGHT_PER_CM3 ) / 1000;

    //System.out.println(df.format(number));

    return Double.valueOf ( df.format( number ) );

}


text:
Q: How do I fix the mouse after pairing with Bluetooth? I have a laptop with Ubuntu 12.04 LTS on it.
I paired a Bluetooth mouse with it, which caused the touch pad on the laptop to stop working.
After the computer was suspended over night, I tried to use the mouse when it said:
Mouse is trying to access your computer, grant access?

But I can't click the buttons as now neither the touch pad nor the mouse works.
I can't alt+ tab to the window as it opens under the other windows and does not show in the list.
I tried enabling mouse control via the keyboard using Universal Access but I don't have a keypad on my laptop.

A: Good question. Here is a workaround.

*

*Open a terminal. Use the windows key to open the HUB and type terminal and use the arrows keys to open a terminal.

*Type the command xinput in the terminal. That will give you a list of the input keyboard and pointer inputs on your computer. It will look something like the table below.

*Find the entry that says touchpad and enable it as follows. You can enable it by typing xinput set-prop 12 "Device Enabled" 1 (set-prop means set the property and the 1 means put it on). To switch it off, for instance, you would use xinput set-prop 16 "Device Enabled" 0.

*Hit the button you want and enjoy control over your computer. Find out whether the error occurs again. If so, google, ask a question here or file a bug (in that order).

This is the table you will see in step 2:
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=12   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Power Button                              id=8    [slave  keyboard (3)]
    ↳ Sleep Button                              id=9    [slave  keyboard (3)]
    ↳ Laptop_Integrated_Webcam_1.3M             id=10   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=11   [slave  keyboard (3)]
    ↳ Dell WMI hotkeys                          id=13   [slave  keyboard (3)]

This is a comparable question: How to disable the touchpad?


text:
Q: how to find multiple findings with a single find command? is it possible or not. Any other possibilities/suggestions are much welcomed From the following code parenthesis and full-stop will be found and replaced.i.e. (2026).=>2026,
But if the following conditions occur code does not find it and leave it as it is.
a.2020)
b.2012).
c.(2015)

Selection.HomeKey unit:=wdStory

Selection.find.ClearFormatting

Selection.find.Style = ActiveDocument.styles("<Ref_caption_bmk>")

Selection.find.Replacement.ClearFormatting

 With Selection.find

         .text = "(\([0-9a-f]{4,5}\))(.)"
        .Replacement.text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
    Do While .Execute = True
    charcount = Len(Selection.text)
    Selection.MoveLeft unit:=wdCharacter, Count:=1
    Selection.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
    If (Selection.text = "(") Then Selection.Delete
    Selection.MoveRight unit:=wdCharacter, Count:=charcount - 3
    Selection.MoveRight unit:=wdCharacter, Count:=1, Extend:=wdExtend
    If (Selection.text = ")") Then Selection.Delete
    If (Selection.text = ".") Then Selection.Delete
    Selection.TypeText text:=","
    charcount = 0
    Loop
  End With

Is there any way to find all these conditions within this module itself?

A: Your specifications are unclear. That said, for what you seem to want, the result can be achieved with a wildcard Find/Replace expression no more complex than:
Find = ([!a-c][!.])\((20[0-9]{2})\).
Replace = \1\2

No VBA code needed.
You should also learn to code properly instead of slavishly using the macro recorder. For example:
Sub FR_Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "([!a-c][!.])\((20[0-9]{2})\)."
    .Style = "<Ref_caption_bmk>"
    .Replacement.Text = "\1\2"
    .Format = True
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub

The are many such examples here and on other forums.


text:
Q: ZSH Shell history not working I recently switched from bash to zshell but my history does not seem to be working. When I press the up arrow I don't get the previous commands. Is the shortcut different?
Also how do I enable shared history through tabs and new windows? I am on Lion, and using the standard Terminal

A: Up arrow should work, you can check what the shortcut is with this command:
bindkey | grep up-line

Depending on what your up-arrow sends to the terminal you might need to adjust it, use Ctrl-vUp to check. Use:
bindkey "KEYS" up-line-or-history

or
bindkey "KEYS" up-line-or-search

to fix it.
Shared history is enabled with:
setopt share_history

There may be some other options you want to set to avoid duplicates etc., see zshoptions(1).
Here's what I use:
setopt hist_expire_dups_first
setopt hist_find_no_dups
setopt hist_ignore_all_dups
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_no_store
setopt hist_reduce_blanks
setopt hist_save_no_dups
setopt hist_verify
setopt inc_append_history
setopt no_hist_allow_clobber
setopt no_hist_beep
setopt share_history

They've been added incrementally, so some of them might be redundant.


text:
Q: Sql Server MAX of sum(Amount) I have a table in which I have Payment details made by client. Columns are given below:
ID, ClientID, Amount

Now I want to find 5 maximum sum of amount group by client id.
I have found DENSE_RANK() but its not working for me as I want to find sum of amount.
Thanks.

A: ;WITH totalSum
AS
(
    SELECT  ClientID, SUM(Amount) totalAmount
    FROM    tableName
    GROUP   BY ClientID
)
SELECT ClientID, totalAmount
FROM
    (
        SELECT  ClientID, totalAmount,
                DENSE_RANK() OVER (ORDER BY totalAmount DESC) rn
        FROM    totalSum
    ) s
WHERE   rn <= 5

A: SELECT
    ID,
    ClientID,
    Amount
FROM
    PaymentDetails
GROUP BY
    ID
HAVING
   Amount = SUM(Amount)

A: Please Try:
SELECT
    ClientID,
SUM(Amount) Amount
FROM(
    SELECT ROW_NUMBER() OVER (PARTITION BY ClientID ORDER BY Amount DESC) DR,
        ClientID,
        Amount
    FROM YourTable
)x WHERE x.DR<=5
GROUP BY ClientID
ORDER BY ClientID

A: Does this work for you? (not sure I understand your problem)
If you want the TOP 5 totals, this is it.
The query for finding the SUM() of the TOP 5 Amounts per Client is different.
;WITH OrderingCTE AS
(
    SELECT   ID
            ,ClientID
            ,Amount = SUM(Amount)
            ,rNum   = ROW_NUMBER() OVER (PARTITION BY ClientID ORDER BY SUM(Amount) DESC)
    FROM MyTable
    GROUP BY ID
            ,ClientID
)
SELECT *
FROM OrderingCTE
WHERE rNum <=5


text:
Q: How to implement Bootstrap Sidebar in MVC 5 I am wanting to implement a navigation sidebar in MVC 5, but I couldn't find any built in classes in the Bootstrap 3that came with the project. I've tried with the following code:
_Layout.cshtml

//the sidebar code is here...

hello

Project

Account settings

            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

            </button>

@Html.ActionLink("Home", "Index", "Home")

@Html.ActionLink("About", "About", "Home")

@Html.ActionLink("Contact", "Contact", "Home")

            @Html.Partial("_LoginPartial")

    @RenderBody()

© @DateTime.Now.Year/p>

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
<link href="~/Content/Custom.css" rel="stylesheet" />
@RenderSection("scripts", required: false)

CSS
#Wrapper {
background-color: #3F51B5;
z-index:1;
height: 100%;
width:300px;
position:fixed;
}

#page-content-wrapper{
margin-left:300px;
}

So far, what I've done is that I put a margin-left: 300px to the page content and add a
 to encapsulate the side navigation bar and have styling to it. The results I get is as below:

However, I found out these problems with this implementation:

*

*If I put the side menu in the _Layout.cshtml means that every page will have that side menu . But I would like the side menu to appear only when a user logged in.

*If I put the side menu in each individual View, this will cause the ugly white space at the left side of the page since every View is rendered in @RenderBody().

*If I put the side menu in the _Layout.cshtml, how do I include the jQuery code to toggle and hide the side menu when a button is clicked?

Is there any better implementation of this?

A: To keep the solution simple I would create two layouts:
_Layout.cshtml
_LayoutNoSidebar.cshtml

To toogle sidebar, include this template in your _Layout.cshtml:
https://blackrockdigital.github.io/startbootstrap-simple-sidebar/