Reclaiming space after delete statement in SQL Server

Question: I have some tables used in reporting and some of them grow huge with the daily ETL so I have implemented som jobs that delete rows more that x days old. E.g. everyday 10% new data gets added and I delete 10% of the oldest rows in another job.
Do I need to do something for efficiency? Some tables are heaps with nonclustered indexes and some also have clustered indexes. E.g. to I need to rebuild the tables in case of heaps or rebuild index in case of clustered index on the table? If so how often? Most tables are only used once per day and when all joins and calculations are done they get extracted for visualization in a non-live manner.
I know a little about index fragmentation and heap fragmentation and that one can query fragmentation in percent.
How much do I need to worry about the above scenario?
Comment: How many rows, on average, are in the table at any given time?
Comment: @J.D. I would say 20 million on average
Answer: You can identify and resolve heap / index fragmentation following this guide: How to identify and resolve SQL Server Index Fragmentation
You likely only need to reorganize, and not worry so much about rebuilding as often. There's recommendations for when to use one over the other, but rebuilding is a heavier operation that likely doesn't result in much more benefit than reorganizing.
While 20 million rows is a nice little chunk of data, it isn't anything enormous by any means. I would still potentially recommend always using clustered indexes and you'll see the best benefits during the JOINs and calculations on those tables.
Using clustered indexes in a smart way will also reorganize your data for you in a sense. What I mean by that, is if every day you're loading 20 million records into an empty table, and then add a clustered index on that table after the data has been fully loaded, it'll efficiently organize the data sorted on that clustered index. It can basically take the place of manually rebuilding / reorganizing operations that are pretty heavy operations by themselves. Adding the clustered index to the table after the data has been fully loaded is usually the most efficient way for it to reorganize the data.
Answer: Check out the online documentation for the DELETE statement, especially the statement on locking behavior since the underlying table is a heap.
https://learn.microsoft.com/en-us/sql/t-sql/statements/delete-transact-sql?view=sql-server-ver15#locking-behavior
Converting the heap to a clustered index(as discussed in that section of documentation) can also help BUT it comes with a big caveat: different insert behavior for heap vs clustered index can have a significant impact on ETL performance especially if concurrent inserts into the table.
If the underlying table is a clustered index, then for the CI and all non-clustered indexes both rebuild and reorganize are available. Either can allow maintaining a high average percent full in the data pages; there are many factors to consider in choosing between them that are out-of-scope for the original question.
That section of DELETE documentation also discusses the tablock hint.  The tablock hint is especially important to consider if the table is to remain a heap rather than be converted to a clustered index. If the tablock hint can be added to the DELETE statement, the page level locks will allow pages to be de-allocated from the heap when emptied by the delete, allowing the heap to remain more compact.
If the table remains a heap, while its non-clustered indexes have both reorganize and rebuild options, the heap does not have a reorganize option. But there is an ALTER TABLE… REBUILD option. This option should be used with great care. It will result in all non-clustered indexes for the table being rebuilt.  Paul Randal discusses this in the blog post below.
https://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-2930-fixing-heap-fragmentation/
So, changing the heap to a clustered index is an important schema change that should be considered carefully.
If the tablock hint can be added to the DELETE, I recommend that.
If ALTER TABLE… REBUILD is needed, I recommend as seldom as possible - hopefully only once and afterward leaning on the tablock hint.
And using reorganize or rebuild to maintain the non-clustered indexes as necessary.
Comment: Thanks! Great info and analysis.
Answer: I wouldn't worry about fragmentation instead I would think about partitioning (if your version and edition allows) so instead of DELETING rows I would truncate (switch) partitions.
Answer: I'd like to focus specifically on the re-use of space aspect. (Lots if useful information has already been said in other answers.)
In essence, you should monitor the size of each heap and b-tree over time. Or at least as a one-time thing before and after deleting data.
Whether space is reclaimed? Well, it depends:
For a heap, you end up with the case where SQL server do not reclaim storage after deleting data. Doing a table rebuild would be essential here (or convert the heap to a clustered table).
For an index, it depends on how data is organized compared to what you delete. If you have an index on "OrderDate" and delete the oldest data, then pages will just be deallocated from the beginning of the linked list of pages; and all is fine.
But you also have an index on LastName for the same table (bad example I know, but have some imagination :-) ), then deleting data based on old OrderDate will spread out the removed rows all over the place for your LastName index, leaving un-used space in the indexes. Is that bad? Perhaps not, since you later add new data, and that is likely to have a similar spread of LastName as the rows you removed, meaning you won't get page splits.
So, look at the heap as one type of entity, B-Trees where the order matches your removal/add data as another entity and B-Trees that doesn't match as a third type of entity.
And as already been said, partitioning can be helpful!


Visual Studio Unit Test - DELETE permission denied

Question: I am running a Sql statement similar to the following inside of a cleanup method of a unit test in Visual Studio 2008:
DELETE FROM MyTable
WHERE EmployeeID = @EmployeeID AND UserID = @UserID
...
@EmployeeID & @UserID are assigned appropriate values via parameters in an SqlCommand and ExecuteScalar() is called to execute the statement.
I am receiving DELETE permission denied on object 'MyTable' SqlException when I run this.
Delete permissions have been granted to the user that my SqlConnection connects with, and I can't find any reason that I should be receiving this exception. I am successfully running a similar delete statement on another table in the same database with the same login credentials.
Any help is greatly appreciated. Thanks
Answer: do you have any database triggers associated with this table, when a record is deleted the trigger tries to delete something from another table? (this other table not having the appropriate user rights)


compare delta value in the long call option for profit gain

Question: I have a question about delta and its relation with the long call option. If I plan to buy a long call option to bet the stock price will go up. Is larger delta value better or smaller delta value better in terms of profit gain? For example, a stock is at 100 dollars right now. I decide to buy a call option with an expiration date 6 months later. The option with strike price 110 dollars has delta 0.45 and the option with strike price 120 dollars has delta 0.40. So, which option is better? Moreover, if we also consider in the money options (options with strike price lower than 100 dollars), does the answer change? Thanks
Comment: @Fattie - Delta has two components.  It's primary function is telling you approximately how much your option is going to move if the underlying moves one dollar.  This aspect is purely mathematical, based on option pricing formulas  rather than some sort of guess.  The secondary aspect is that many people use delta as the probability that the option will end up in-the-money at expiration (or as you said, a 'guess').  I have issues with this because delta will change as implied volatility changes so it can be a moving target.
Comment: You are omitting consideration the actual price of each option - all else being equal, the lower the strike price the better the call option, but of course the price will increase as well.
Comment: I think it's important to remember that delta is just what you would ***expect*** it to move.    It is "a guess" based on some logic; it is not set in stone.  Note that mathematicians have fancy words for "guess", such as "probability calculation", "high sigma outcome" etc etc.  It's a "guess".
Comment: BB, re "A" well yes, but it doesn't "help you decide which trade will be more profitable".  (Perhaps I misunderstand the question, or you and I are interpreting it differently.)  re "B", huh, I did not know that "many people use that as a guideline" - that just seems, well, incorrect to me. {ie, I agree with, if I understand you, your final sentence there!}
Comment: That should be an answer on this confusing QA.
Answer: You really need to model some numbers to get a big picture view of what the possibilities are.  Here are some current bid quotes for IBM's 11/20 calls:
IBM = $120
120c = $5.60
125c = $3.35
130c = $2.00
135c = $1.00
Assume that you buy one call.  What will the above calls be worth at expiration at $125, at $130, at $135 and so on?
Plan B: Pick an arbitrary amount, say $2,500.  Buy as many of each call as you can with $2,500.
Again, what will these positions be worth at expiration at $125, at $130, at $135 and so on?
The above ignores delta.
Download an Excel spreadsheet for option pricing or get some pricing software or use your broker's option analytics and repeat the above exercises and then vary the time between now and expiration.
By now, you show be realizing that asking whether a 45 delta call is a better choice than a 40 delta call isn't going to help you understand the big picture.
Comment: Yes. I agree that the absolute number of delta is not very useful. I think the changing ratio in the option value vs the changing ratio in the stock price is very important.
Comment: I just did my calculation. Basically, buying an option with six months expiration date is better than buying an option with one year expiration date. Assume always choose a strike price higher than the current price for the long-term call. Buying an option with higher striker is better than buying an option with lower strike price. Is this true?
Comment: What option to buy depends on the strategy being used and to some extent, IV and cost.  To simulate longer term investing, for something like the Stock Replacement Strategy (buying a  high delta call), you should go out 6-12 months. The Poor Man's Covered Call (a diagonal spread) would be similar. That doesn't mean that you can't utilize closer expirations.  It depends on what you're trying to achieve.
Comment: Do yourself a favor and pick up a copy of "Options as a Strategic Investment" by Lawrence G. McMillan.  Read it.  Then read it again.  Well written with many clear examples. Under 100 pages or so will give you a fundamental understanding of basic strategies.  Occasionally you can get a used copy of an older 3rd edition for under $10. There's no need to spend $75+ for the latest edition (1,000+ pages)  since it involves more complex products and strategies which will most likely not be of interest to you for awhile and might  take you years before being competent enough to utilize them.
Answer: If calls are out of the money, the "delta" gets closer and closer to zero as you get nearer expiration.
If calls are in the money, the "delta" gets closer and closer to one as you get nearer expiration.
You question,

Is larger or smaller delta value better in terms of profit?

Delta has nothing to do with profit.
You can have a high or low profit (or indeed high or low loss) with either a high or low delta.
Moreover, the delta would have changed (drastically) throughout the trade. Delta "when you first begin the trade", again, is sort of meaningless in terms of "how much profit will you make".
Say you asked: "how does the sell price affect profits?" ... the question is off-track.  Sure, obviously a higher selling price "affects" profits but it's kind of a misguided question.  (You can't - obviously - anyway know what the selling price will be when you enter.)
"Delta" is basically a tool to "help you think" about what you are doing while trading.

I easily found an article which nicely talks about "delta" article, perhaps it will help the OP.
Comment: I think delta tells us that how much the option price will increase if the stock price increases 1 dollar. Based on the absolute stock price and the absolute option price, we can calculate the % move in the option price and in the stock price. The % move ratio in the option price vs stock price will tell us a ratio. This ratio tells us how sensitive is this option. If an option is more sensitive, we are able to make more profit due to that 1 dollar increase in the stock price. This is my understanding.
Comment: Bascially, delta tells us the absolute value. From the absolute value, we can calculate the ratio and this ratio is very useful in determining the profit increase speed.
Comment: Hi @JerryZhang - yes, that's what I said!  :)  I'm not sure why you explain delta in the comments here?  As I explained, it is **largely meaningless** to ask "how delta affects profits".  It would be like asking "how does the sell price affect profits?"  Obviously, self-evidently, a higher sell price means more profit.
Comment: Fattie, you need to read a bit more about delta.  If you own a call with a delta of .60, that tells you that if the stock moves up $1, you can expect your call to appreciate by about 60 cents.  And if one has multiple positions in the stock and various options, the net delta of all of them tells you what your positional exposure is per dollar of move in the underlying.  That concept is very important for hedging positions.
Comment: hi @BobBaerker - sure, but the OP's question is "misguided" as I attempt to explain in paras 5, 6 and 7.  As you mention in your example "The above ignores delta." and as you conclude "realizing that asking whether a 45 delta call is a better choice than a 40 delta call isn't going to help you understand the big picture."
Comment: I don't think that you understand delta. A higher delta option appreciate more than a lower delta option, given the same amount of price change in the underlying.  You can't achieve a higher profit with a lower delta option unless you own more of the lower delta options than high (but that's a different story).  In isolation, delta does tells you how much profit you will make.  Outside of isolation, there are other factors that work in concert as well as in opposition (time decay, change in implied volatility).  Short answer?   Delta helps you project P&L but it isn't the entire story.


What is the UX behind showing cleaner profiles on cleaning-on-demand apps?

Question: When I am using an app to order cleaners to clean my house, many apps show the profile of cleaners with ratings. As a user, I do not care who cleans the house as long as my house is super clean. What could be the UX thought behind showing profiles of cleaners while using the service?
Comment: This is the similar to the displaying features, reviews and ratings of an item in e-commerce. This is the way to build trust and persuade customer.
Comment: Assuming the purpose of the app is to let you choose the best cleaner, surely you'd want some sort of review/rating system in order to make a judgement?
Answer: Without knowing the user experience behind the decision we won't know for sure. But please do not assume that your preference is the same with other users or targeted users for this app.
For example my father needed a cleaning lady in his house but we couldn't convince him until we told him who the person was, whose house she cleaned before and other information, so you can see that users have different needs. Maybe you are a power user and just look at ratings and some need to also see the profile in detail to get convinced.
Answer: Most often, user experiences are target and audience-specific and the UX designer is geared with the responsibility of making an experience that blends with all or majority of the audience he intends to reach.
While a user might just be interested in anybody cleaning the house, another user might be also be interested in how the cleaner has been rated by previous users, yet another user might not be interested in these and just feels like he/she wants someone that is named 'Wurah' to clean his/her house.
As variety for the audience differ, the user experience should be able to cover all of these diversities in an appealing manner.
It would now be left for the user to decide which information are of his/her concerns.


How to get used to a new keyboard in practical exams

Question: I recently had a coding practical examination in school and I was previously using a Mac book while the exam was done on a Stuck on Windows computer. I'm not a very fast typer to begin with, but silly typo errors every now and then will really make my blood boil especially with the clock ticking. My main concern would be how to get used to the texture of the new keyboard in a short amount of time(like the difference in pressure required to press the keys), other than the fact the keys for both keyboards are very different.
Comment: you can take your own virtual keyboard like Tony Stark :D... There is no way bro other than practice.
Answer: The simplest way is to find out ahead of time what computers will be used for the next practical and either acquire the same brand/model keyboard to attach to your Mac, or find a computer you can use for typing practice that has the same type of keyboard.
That is to say, the only way to get used to a very different keyboard is spend time typing on it -- and the only way to do that, is to have the type keyboard you need to get used to, in order to spend time typing on it.
It's likely you can arrange to use the actual computers used for the practical exam ahead of time -- it should be sufficient to inform the examiners you want to remove keyboard differences as a source of stress and problems on the test, since they're interested in your ability to code, not in your ability to adapt to an unfamiliar keyboard under stress.
Answer: The type of keyboard is mostly irrelevant: you get used to a different amount of force needed very quickly, as long as the keys are in the same place. So A-Z, 1-0 and Space you quickly get used to, but there are some annoying differences in the rest because they're not in the same place.
The biggest difference between Mac and Windows keyboards:

on Windows, the keys on the bottom row are Ctrl, Win, Alt, Space
on the Mac, they are Ctrl, Fn (if you have a laptop), Option (Alt), Cmd (which serves the function that Ctrl has in Windows), space

The only way to deal with this is to practice.
Comment: Hmm, so am I supposed to boycott myself of Mac for 1 week at least and keep typing on a Windows keyboard?


How to add some specific content to bottom of every category page in magento1.x?

Question: I want to add some content to bottom of every category product list page. The content should change depends-upon the category without editing code or layout xml file ?
Answer: I would create for every category a CMS Block with the content and set this block after the content in the category custom layout update.
After creating a CMS Block for the category, go in adminhtml to the category. Open the tab custom design and add this xml in Custom Layour Update
<reference name="content">
    <block type="cms/block" name="cat_1_content">
        <action method="setBlockId"><block_id>cat_test</block_id></action>
    </block>
</reference>

Change the block_id cat_test and the block should appear after you content. Repeat this for every category. Don't forget to flush the cache.
I think it's the best way to do it without changing code. The benefit of the cms block is, you can use the default Magento editor.
Answer: You're best creating a category attribute (text area) which is visible on all category pages like category description, if text is provided for a category it displays on category page else it doesn't.
You can create a module by following this atwix tutorial
Comment: I thought about the same solution, but the OP don't want to do it with code.


Nonhomeomorphic CW-complexes that are stably homeomorphic

Question: Can one find two finite CW-complexes $X$ and $Y$ such that $X \times I$ is homeomorphic to $Y \times I$, where $I = [0, 1]$, but $X$ is not homeomorphic to $Y$?  I know how to find such topological spaces $X$ and $Y$, but not CW-complexes.
Answer: Yes.
See example 1.4 in the paper "Cancellation laws in topological products" by E. Santillán, Morfismos, vol. 2, no. 2, 1998, pp. 67-74, and also the original example by R. H. Fox depicted on p.284 of his famous paper "On a problem of S. Ulam concerning Cartesian products", Fundamenta Mathematicae, vol. 34, no. 1, 1947, pp. 278-287. All these examples are finite CW complexes.


List additional cart items in ecommerce website

Question: I am using an ecommerce website.  When I log in, I would expect my cart to be empty. But it shows the cart items selected by another user who previously used the same machine and logged out. Is this a security issue?
Comment: Looks the shopping cart is stored in a browser cookie and logging off does not delete it. Unless there is extra info on the cookie it would not insecure per se but just a leak of information. You shouldnt know what others buy.
Answer: In short, yes.
That is not a well designed website and I'd stay clear, certainly don't put any of your payment details into it!
With regards to your question, it's a little vague so I want to expand on it to ensure I clear all ground.
If you're speaking specifically on what could happen if user1 could see user2's basket (nothing else)? Then the only security concern is user1 knowing what user2 has in their basket. From a certain perspective, it's harmless, however, usually after a basket comes check out, and if user2 entered more private information, we can only assume this data is there still also!
On the above assumption, it would seem if you were just logging in, and seeing someone else's basket, that website doesn't support sessions (why oh why!?). So, other than a terribly built website, in the context in which you speak, nothing else could be done.
If this website did store sessions, you wouldn't quite be able to just log in and view another users basket, however, let's assume for this question that we can do that, then yes, it's a huge security issue.
Session's are something created and act as a global variable on a server, the session has a unique identifier to you, and nobody else. A session is identified through a token, which is delivered to the browser as a cookie.
They are used for a variety of purposes, simply transferring information from one page to another or storing items in a shopping cart for a specific user requires a session.
Hijacking this session, simply put, essentially makes you the owner of that account.
Session Hijacking is a thing, and a terribly effective attack on vulnerable websites, see here to see why.


Rotate image to point

Question: I have the following:
<code>CGPoint pos //center of an image
CGPoint target //a point, somewhere in the coordinate system
float rotation //the current rotation of the image to the x-axis, clockwise, so "right" would be 90°
</code>
Now I want the image to rotate around it's centerpoint (pos) so that it looks directly towards the targetpoint.
My idea was: Calculate the angle corresponding to the x-axis, subtract rotation, and then rotate it.
Two things:
1.) I fail at calculating the angle. (Yes, I know it's all in rad...)
2.) What's best for rotating?

CGAffineTransform? But then I'd need an imageView
Or: save context, set origin to center of image, rotate context, draw image, restore context? More complicated, but no imageview neeeded...
Answer: Draw it on a CALayer, and move the layer around anyway you like.
Comment: Ok, i made that... could you please help me with that CALayer stuff? I have my image and need to rotate it x rad....

Rotate image to point


Parametrization of a line

Question: This is a very basic question, and its funny that I'm able to solve more advanced problems like this, but I was presented with a basic one and got stumped. I have the equation
$$y=-\frac{3}{4}x+6.$$
In $\mathbb{R}^2$, this is a line. I want to find a parametrization of this line. I guess the problem here is I never really understood the concept of parametrization. I'm just a robot-I follow the steps the book tells me, but I really dont understand the intuition behind it. What is the point of parametrization (in laymen's terms, which is hard to find anywhere), and how would I do it for this equation?
Comment: Please don't use the slash for fractions. As written, $3/4x$ could be interpreted as $3/(4x)$ (well, if you ignore the fact that you say you are talking about a line), though you clearly mean $\frac{3}{4}x$.
Answer: Think of a parametrization as describing the "trace" of the curve, with $t$ representing time. You want to write equations
\begin{align*}
x &= f(t),\\
y &= g(t)
\end{align*}
that describe someone tracing the line as $t$ varies.
How would you trace the graph of a function $y=g(x)$? Well, the points on the graph are all of the form $(x,g(x))$, so the simplest is to use a parametrization like
\begin{align*}
x &= t,\\
y &= g(t).
\end{align*}
If you think about what the points $(x(t),y(t))$ look like as $t$ ranges from $a$ to $b$, you'll see that you are giving the graph of $y=g(x)$ from $x=a$ to $x=b$.
That gives you one way to give the line.
Another is to pick a point on the line, and just say "go along this direction, backwards or forwards". A direction is given by a vector $(u,v)$. So if your line goes through the point $(a,b)$, and has direction $(u,v)$, then one possible parametrization just says: "start at $x=a$ and $y=b$, and then move $x$ and $y$ in the direction $(u,v)$: if you move in the $x$ direction by $ku$, then you need to move in the $y$ direction by $kv$." That is,
\begin{align*}
x &= a + tu\\
y &= b + tv.
\end{align*}
You can do that with the graph you have above by determining a point and a direction. For the direction: the slope of the line with direction $(u,v)$ is $\frac{v}{u}$, because $v$ is the rise and $u$ is the run.
Comment: @mohabitar: For parametrizing the graph of a function, not much, except the point of view; we think of the graph of $y=g(x)$ as something that is whole and complete, we tend to think of parametrizations as describing a dynamic situation where a point is "moving over time." And parametrizations can be used to describe more general curves that cannot be given by simple functions, curve that cross themselves multiple times, etc.
Comment: But so whats the difference between using x and t in the equation?
Answer: I may be misunderstanding your question, but you have a parametrization given by your equation:
$$ x\mapsto (x,-\frac 34 x+6) $$
or if you want something with integer coefficients:
$$ t\mapsto (4t, 6-3t).$$
The point of paramterization is that on one hand you reduce the number of variables you;re working with (in this case from two: $x,y$ to one $t$), but more importantly you make an implicit situation, that is, one defined by equations into an explicit one, that is, a way to generate the solutions.
In this case the point is perhaps not obvious because the equation is so simple, but imagine that if you have a very difficult equation then how much easier it is to work with the solutions when you are given a way to generate them (that is, by a parametrization) than when they are just given as the solutions of the equation.
Perhaps a better example to work with is the solutions to the equation
$$ x^2+y^2=1.$$
A possible parametrization is $$t\mapsto (\cos t, \sin t).$$
The sad truth about parametrizations is that they actually rarely exist. I guess you could interpret this as saying that if you can find a parametrization, then you should be happy.
Addendum
To answer the question in the comments: Imagine that you have to solve a system of equations in two variables. In other words you have two curves given by their equation on the plane and you have to find their intersection points. If you can parametrize one of them, then you can plug the parametrization into the other and solve an equation of a single variable. Here is an example:
Say you need to find the solution to the equation system
$$ x^2+y^2=0 \qquad 2x^3y-2xy^3=1.$$
(this is a rather random choice)
If you just go head-to-the-wall approach, you might solve the first as a quadratic equation and plug that into the second an end up with a degree six equation. Good luck with that. (Actually it might be solvable in this case, I have no idea, but in general a degree six equation cannot be solved with a formula).
On the other hand, if you use the parametrization of the first equation given above, you end up with the equation
$$ 2\cos^3t\sin t-2\cos t\sin^3 t=1.$$
This can easily be reduced to
$$\sin 4t =\frac 12$$
which can be easily solved.
The point is that parametrization helped you solve a system of equations that would normally be very difficult or impossible to solve explicitly.
Comment: How has my equation been reduced to one variable with parametrization?
Comment: You can write both $x$ and $y$ in terms of $t$.  For example, relating to your question, you have $t\mapsto (t,-\frac{3}{4}t+6 )$
Answer: There are an infinite amount of ways to parametrize this line.  A good way here would be to let say
$$\displaystyle x=t$$
replacing x with t in the first equation, you know that
$$\displaystyle y=-\frac{3}{4}t+6$$
And there you are!
When you want to parametrize an equation, start by letting one of your variables equal to t, and then solve for the other variable(s), replacing t in the equation.
Note the great explanation from Arturo Magidin, you want to think of the position of a particle at some time $t$.

Parametrization of a line


Measuring Green's Function

Question: I am confused about Green's functions. I understand that $G^R(r,r',t,t')$ tells you the amplitude of a particle that was inserted into the system at position $r$ at time $t$ has to be at some position $r'$ at some later time $t'$. But what about $G^>(r,r',t-t')$ (assuming local in time) or  $G^>(r,r',\omega)$? How would you measure $G^>(r,r',\omega)$?
Answer: The notations are not universal, so I do not know what you mean by $G^{<,>,R}$ but clearly a Green's function CAN NOT be measured. A Green's function is just a mathematical artefact, it exists in the form of two points correlators, like
$$G\left(x_{1},x_{2}\right)\sim\left\langle a\left(x_{1}\right)a^{\dagger}\left(x_{2}\right)\right\rangle $$
where the average $\left\langle \cdots\right\rangle $ is usually done with respect to a statistical average over a ground state, and $a$ is an annihilation operator (bosonic or fermionic), and $\sim$ means that I did not put the possible prefactor (usually $\pm i/\hbar$, $\pm i$, $\pm 1/\hbar$ or $\pm 1$ depending on the context and the chosen dimensionally) and any kind of time-ordering (eventually time-anti-ordering) operators or $\Theta$-like function which define the domain of validity of the Green's function in time.
Green's function also exists in the form of higher number of points, like for instance
$$G^{\left(4\right)}\left(x_{1},x_{2},x_{3},x_{4}\right)\sim\left\langle a\left(x_{1}\right)a\left(x_{2}\right)a^{\dagger}\left(x_{3}\right)a^{\dagger}\left(x_{4}\right)\right\rangle $$
where one sees the ordering of the operators might be of importance.
All this to say that ultimately, a Green's function has no intrinsic meaning at all. You can always say it measures the correlation between two points ... but it has no intrinsic meaning.
Once you define a Green's  function, you still have to define all observables in term of this Green's function. In the same way a wave-function has no meaning at all. Once you got the Green's function and the set of rules for calculating observables, you can start doing calculations !
In short : a Green's function itself is NOT an observable, it is a mathematical tool.
Green's function method applied to many-body problem is reviewed quickly in

https://en.wikipedia.org/wiki/Green%27s_function_(many-body_theory)
Any textbook on condensed matter having quantum field somewhere in its title.

If you really want to use Green's functions for many-body applications, I suggest you to not open textbook on quantum field theory, since you will see many many terms related to relativistic problems only. At least not at the beginning. The subtle differences between the statistical field theory and the quantum field theory (that's the terminology for many-body vs. relativistic problems) might be quite confusing for a beginner. See e.g. this answer of mine for a few more details about the difference between the two.
Note finally that the imaginary part of a two-points Green's function is related to the decay time of a particle, that their poles are usually eigenvalues (up to prefactors) of Hamiltonians (in simple situations, for instance without interaction), and that many many authors forget to precise which convention they use for their Green's function. They sometimes do not even give the definition of the observables... So it is sometimes frustrating for beginners to try learning about this topic.
Comment: Specifically, the Green's function I am interested in is: $\left<\Psi(r,t)\Psi^{\dagger}(r',t')\right>$, where $\Psi(r,t)$ is a the field operator that annihilates a particle at position r at time t.

Measuring Green's Function


I'm on minecraft bedrock and I lost my hotbar and crosshair

Question: I'm on minecraft bedrock and I lost my hotbar and crosshair. I know how to press F1 but that doesn't work on bedrock. Please help
Comment: Just google how to toggle HUD on minecraft bedrock.
You should very quickly find an answer
Answer: There's a "Hide HUD" option. Tap/click the pause button (or where the pause button should be if it's hidden), go to settings, and turn off that option.
Answer: This happens pretty often when playing a world with behaviour or resource packs. When it happens, the easiest way to fix it is to save and quit (assuming you can remember where the buttons are, since they disappear). Alternatively, you can just close the game and reopen it, though this may lose some progress since the last autosave.


Where do I find custom maps in Trackmania when playing on Linux

Question: I am playing Trackmania: Nations Forever on steam, but my system is Arch Linux. And I cant find anywhere to put my custom maps. Where are they stored?
Answer: Welcome to the arqade!
While I don't know how TMNF installs on Linux, I can give you some hints as to how to find the location. I wanted to post this as a comment at first for that reason, but it would have been hard to read.
Idea 1
On Windows, downloaded maps for TMNF are put in this dir:
C:\Users\<username>\Documents\TmForever\Tracks\Challenges\Downloaded

By that logic, you could look if ~/Documents/TmForever/... exists.
Idea 2
Create a map using the map editor and save it. It needn't be any good, it just has to have a name. Then, search for it using something like
find ~/ -name "<trackname>.Challenge.Gbx"

You might have to fiddle with capitalisation; if all fails, start the search at / and search for <trackname>*
Created maps are stored near the place you'd put your downloaded maps, i.e.
.../TmForever/Tracks/Challenges/
                                My Challenges/<trackname>.Challenge.Gbx
                                Downloaded/<PLACE TRACKS HERE>

HTH


What affects the rush incident rate?

Question: In Fallout Shelter you're able to rush the product of a resource. According to the game, it is influenced by the luck of the people assigned to the room and whether or not you have recently rushed the room. However, as the incident rate goes down, so do the rewards for rushing. What are the underlying mechanics? I would like to maximize my rush success chances, and the possible payoffs.
Comment: You answered your own question in the question....just an FYI
Comment: @Dupree3 The question is asking what *exactly* affects this. "it is influenced by the luck of the people in the room" is hardly exact.
Comment: @Unionhawk Sounds pretty self explanatory to me, answered his own question
Comment: No, @Dupree3, I didn't. I'm asking for far more detail than just "these two factors have an affect". I'm looking for mechanics and any other possible options.
Answer: There are mainly 3 factors which seems to take effect on the rush accident rate:

The summed amount of stats. For example the Reactor: I have one reactor with 3 People inside it, all have around S:3. It has a higher accident rate than a room with just one Person in it with S:10, but the same accident rate as a Person with S:9. This leads me to the conclusion, that the right stat in sum(!) will take effect on the accident rate.
Beside the correct stat for a room (S:Reactor, P:Water, A:Dinner,...) the L factor takes effect. Just like in the real fallout games too. L will always improve percentage values. In this case I have a room with same needed stats (S:9 for example), one with L:2 one with L:8 (maybe due to more people in it). The room with higher L has a accident rate of 14 as the other room has a accident rate of 19 percent.
The time! If you rush a room too often in a too short range of time, the accident rate will grow. On rooms with a good stuffing (high stats which are needed + luck) your able to rush 1-3 times before it will get to a "critical" accident rate of 30%. After a few collections it's back to its original accident rate of 10%.

Hopefully this will help you.
Comment: @Ionic Can you double-check whether it's just time that reduces accident rate, or is it actually the collection of resources? James suggested it's resource collection, and I've witnessed the same. Test: 1.) Check accident rate immediately after resource collection. 2.) Do nothing in that room until ~20 seconds before next resource drop. 3.) Check accident rate again. 4.) Collect resources. 4.) Check accident rate again.
Comment: Do you have any evidence or a source for this? In my experience the SPECIAL values of the assigned people seems to only affect the time for the room to generate resources.
Comment: Ah your right. Sorry. I thought I've seen that those values also downed. Maybe it was some other dependency. Maybe this was a correlation of other values? As I've changed the person too.
Comment: Hi, I've updated the whole answer. I have checked some of the stats over time and that's my observation of it.
Comment: Yes it's seems to be the collection which counts. :-) I've changed the answer.
Comment: it's staffing, not stuffing :)
Comment: Please consider updating this answer to reflect the recent version changes.
Answer: I failed a 3 percent rush this morning in my water treatment plant (size 1) with two dwellers. Dweller 1 had 8 (+5) perception and dweller 2 had 9 (+2) perception. In addition dweller 1 had 3 luck and dweller 2 had 9 (+1) luck. I succeeded at rushing at 13 percent right after, and then rushed again at 23 percent and failed. I don't undertand what's going on behind the scenes at all. I also tested the probability of passing at rush at high percentages. I rushed a room with 6 dwellers (not sure of the exact stats) again and again at 80 percent and 90 percent (after it goes up to 90 and you fail, it goes down to 80 immediately). I rushed maybe 50 times and never succeeded one time. The probability of failing seems much higher than passing regardless of percentages.
Answer: Failure rate = 40 - 2 * (Average room Luck + Average room Skill) +  10 for each successive rush (up to +50)
Use one maxed dweller in a tripple lvl 3 room and you always complete the first rush.
Average room luck also increases chance to get +200 caps when picking up reasources.
Source: https://docs.google.com/spreadsheets/d/1Nai09D_aM2syl3iPP5hkveDcOUwhsoUDR6s1lwC0e8c/htmlview?pli=1&sle=true#
Comment: That's odd. Did they change the formula? It was definitely the SUM of the skills before, not the average.
Comment: The new 1.5 patch may have changed the formula to always be at least 10%
Answer: I am currently gathering intel on this as well and here is what I have seen from my own observations

The incident rate seems to start at around 31% (this is with 2-4 people in the room with ok stats)
It increases every time you do a rush whether you fail or succeed by about 10%
The chance of failure also seems to decrease again once you successfully collect a resource from the room (with out having rushed it ofcourse).

I have not had good luck finding lucky people to see how they impact the results, not a large variation in stats as I have just started and do not have the stat raising rooms as of yet for further exploration of this.
Comment: I have some highly special dwellers whose skills reduce the rate as low as 12%.
Answer: The Vault Dweller's luck and how much time has elapsed since the last rush, although I don't know the exact numbers.
Comment: Can you elaborate?
Comment: From my experience, there are two types of probabilities, the shown values and the ACTUAL success rate. The shown values are determined by the number of people inside, (haven't tested whether high/low level changes it) Luck affects how it actually plays out (if you have a room with low luck people it tends to start failing at ~40%, but if you have a few lucky people it'll only start failing at ~70%)

What affects the rush incident rate?


Magento2 Auto Increment SKU

Question: I am willing to get product SKU value to auto-increment in Magento 2. For example the last product created sku was 100001 then the next product would be 100002 and so on.
Answer: Till now Magento does not have such functionality. Though Magento provides the feature to set the mask for autogenerating SKU field.
To do so, go to

Stores > Configuration > Catalog > Product Fields Auto-Generation

and set value of Mask for SKU field.
If you still want to auto-generate SKU field like 100001, 100002 etc., then you need to create a custom module which will observe the event of product edit form load. On this event, check whether it is an old product being edited or a new product is being created.
If a new product is being created, then you would need to get last SKU from the table and fill the value of SKU with (last SKU + 1) value.
Note: Before doing above exercise, you would need to make two changes for SKU attribute:

Change SKU data type to integer
Make the SKU field read-only, so that admin cannot change the generated value

Please check and let me know if you have any question.
Answer: I've found this module on github which seems to be exactly what you're looking for
https://github.com/rakeshmagento/magento2-auto-sku-generator
From the Link:
magento2 auto generate sku for new product based on custom confgiuration. Auto SKU Generator Addon provides the functionality of generating the SKU automatically
Examples
1 : Prefix -> D, Start From -> 1, SKU Length -> 5
D00001, D0002, D0003 ,........
3 : Prefix -> SKU, Start From -> 1, SKU Length -> 7
SKU0001, SKU0002, SKU0003, SKU0004 ,....................
Comment: I've added more info.
Comment: While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.  Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/117595)

Magento2 Auto Increment SKU


Displaying/scrolling through heaps of pictures in the browser

Question: I want to be able to browse through heaps of images in the browser, fast. THe easy way (just load 2000 images and scroll) slows down the scrolling a lot, assumedly because there's too much images to be kept in memory.
I'd love to hear thoughts on strategies to be able to quickly scroll through 10000s of images (as if you were on your desktop) in the browser. What would expected bottlenecks be? How to address them? How to fake things so that the user experience is still good? Examples in the wild?
Answer: You'll want to use AJAX to dynamically load the pictures as you scroll.
Basically, you'll load certain pictures based on how far down you've scrolled. Just don't forget to dump the ones that are off the screen so that the browser stays responsive.
If you just want to flip through lots of pictures one at a time you could preload the images that haven't been shown. Facebook albums preload the next image so that going to your next image is really fast.
Answer: I think RIA is your best bet here. Technologies like Flex and Silverlight were designed specifically to provide desktop-like behavior, while HTML/JS were never really intended to be used for that many images.
Additionally, if you haven't seen any Pivot demos yet, those are some good examples about how to maintain a good UX at massive scale. The best link I can find right now is unfortunately the sales-pitch video on the official site, but it still shows some neat interactions:
http://www.getpivot.com/
Comment: Yes, pivot is awesome, already checked it out, thanks. My challenge right now is the browser though, see how far we can get in that.


Kirchhoff's voltage law for an ideal circuit containing only a capacitor

Question: Let's say I have an ideal open circuit (i.e. there's no resistance in the conductors) containing only a charged capacitor and then I close it.  Now, the charge on one end of the capacitor will move to the other end until the voltage drop on the capacitor is zero. What confuses me is that if I try to apply Kirchoff's voltage law to the circuit, I just get $V_C=\frac{Q}{C}=0$, which is the steady state of the system after the discharge. So my question is what, at the fundamental level, makes Kirchoff's voltage law inapplicable to this circuit during the discharge, and how would you find the current in the circuit as a function of time before it reaches the steady state?
Comment: Then it's impossible. What happens when an unstoppable force hits an immovable object? You can approximate forces as unstoppable, or objects as immovable, but *not both at the same time*.
Comment: The wire has resistance.
Comment: My question is what will happen if there's no resistance in the wire.
Comment: But the charge would still move from one plate of the capacitor to the other, no? Like in an ideal conducting object where the charge arranges itself so that the electric potential on the face of the conductor will be constant. Why don't we have to assume resistance in that case while in this one we do?
Comment: @user253751 is a Luddite. It is perfectly reasonable to ask what happens at the extreme ends of a model, even if it's unlikely to be physically realizable.
Comment: @cms Okay then, what happens when an unstoppable force hits an immovable object?
Comment: A rail gun approximates this idea. A (large) capacitor is discharged into a system with a very low resistance.
Answer: Your question is a variant of many such question about situation where there is no resistance and the inductance of the circuit is ignored.
You have a loop which has self-inductance and so you are dealing with a LC circuit in which the charge (current) oscillates at a frequency given by $\omega^2=\frac{1}{LC}$.
Comment: So what you're saying is that you must regard either the resistance or inductance of the wire in order for you to be able to find the current in the circuit? What happens though when you try to analyze the movement of particles on the face of a conductor before it reaches a steady state? Would you also have to consider the resistance and inductance of the material?
Comment: @What I am saying is that you cannot just consider the capacitor as the sole circuit element as that is an unphysical situation. What you have when you include the inductor is simple harmonic motion of the current/charge/voltage.  With no resistance present and no dissipative processes this oscillatory motion is the steady state.
Comment: @Farcher "no dissipative processes" Can you stop the circuit radiating e-m waves (albeit at very low power)?
Comment: @PhilipWood I do not think that the radiation of em waves can be stopped but my answer was an attempt to keep things simple and neglect such a process as in most cases it is a very small effect.
Comment: @Farcher Quite so, but I find it interesting that even without resistance an LC circuit loses energy in theory.


Can Sidekicks take the average on the Hit Die to determine the max HP increase when they level up?

Question: Reading through the new rules for Sidekicks in Tasha's Cauldron of Everything (p. 142), it seems like they must roll for HP when they level up. Am I understanding this right? Or can I use Monster Manual rules for average?
Comment: What exactly do you mean by "Or can I use *Monster Manual* rules for average?" The PHB contains rules for taking the average on the hit die (rounded up) + Con mod when a character levels up, but the MM doesn't have such rules for monsters "leveling up" at all. The introduction to the MM (and the [corresponding section of the basic rules](https://www.dndbeyond.com/sources/basic-rules/monsters#HitPoints)) just explains how to read statblocks (i.e. they list HP as both a die expression and an average number), and lists hit die sizes (and their average values) by creature size.
Answer: There are no rules saying a sidekick can take average on Hit Dice.
Every player class in the Player's Handbook (and the Artificer class in both Eberron: Rising from the Last War and Tasha's Cauldron of Everything) states that a player can take the average on each Hit Dice they gain when leveling up, as well as stating that the 1st level in the class is not a roll of the Hit Die, but the whole amount.
However, according to what's stated in the sidekick rules on page 142 of TCoE, you would need to roll for each new Hit Die the sidekick gains.

Whenever the sidekick gains a level, it gains one Hit Die, and its hit point maximum increases. To determine the amount of the increase, roll the Hit Die (the type of die appears in the sidekick's stat block), and add its Constitution modifier. It gains a minimum of 1 hit point per level.

Of course, a DM could rule otherwise, allowing the sidekick to follow the rules for Hit Points average presented for monsters in the Monster Manual (page 7), or they could even rule that said sidekick could use the average of player classes' Hit Dice.


App Store password keyboard

Question: When I go to the App Store on my iPhone 4s, the password box pops up, but the keyboard to enter the password does not pop up, so I have no way to enter a password.  Any idea how I can correct this?
Comment: Did you tap the text input to enable focus on it?
Comment: Did you try restarting your iPhone?
Answer: Close the app, double-click the home button to bring up the currently running apps, and hold down on the App Store until they bounce. Then kill it.
Then you can go back into it.
I've had a bunch of issues like this with the App Store app. sometimes I don't get the update button for apps, or no keyboard, etc. Restarting the app afresh sorts it out.
A total phone restart should also work.
Answer: I solved the problem on my jailbroke iPhone 4S.
I opened 'ColourKeyboard' and went into the 'Respring' option, after respringing my App Store keyboard appeared and worked fine. You can check it by going into the App Store app and looking in the 'Featured' section then go into 'Apple ID'  then 'View Apple ID'.
Hope it works for you

App Store password keyboard


Why didn't the 6502 have increment/decrement opcodes for A?

Question: In 6502 Assembly, we can use INX and INY to increase the value stored in X and Y. They can be decreased with DEX and DEY. However, it seems that there are no such instructions for A, like INA or DEA. There is however an instruction to increment and decrement the content of an address (INC and DEC). But why are there no instructions like that for A? Does this have a reason? Or am I missing something? I know that you could just use ADC or SBC but I'm still wondering.
Comment: It really is strange when you think about it, as the accumulator is the one place you'd most expect to be supported by any given arithmetic instruction. Something like, say, an absolute memory address offset by the X register, seems far less likely to be incrementable in a single instruction. And yet the 6502 can increment/decrement literally anything *but* the accumulator, including that. (Well, you can using ADC/SBC, but there's no way I know of to do it in a single instruction unless it's a point in the code where the carry flag will always be in the same state.)
Comment: Does anyone know if the 6502 was developed under a tight deadline? That could be the reason why something got left out even though it was added in later updates.
Answer: The designers figured that you'd use X and Y for looping, indexing etc, and use A for adding and subtracting, shifts etc. So they saw a need for INX and INY, but didn't see a enough of a need for an instruction to increment or decrement the accumulator.
That's also the reason why X and Y cannot participate in many ALU operations, like adds, shifts, and whatever.
Unlike adc and sbc, the instructions to increment and decrement also do not heed the decimal mode. This might have been seen as a shortcoming early on, as the design was coming together.
(Later, with the 65C02, the instruction you are talking about was added, and variously called INA, INC A or INC.)
Comment: @MauryMarkowitz There are a lot of instructions that could be added to the 6502 to decrease code size and/or increase performance but weren't. The designers were trying to make a cheap microprocessor, not a fully featured one and they drew their line with `INA` on the wrong side of it.
Comment: @Maury You got a citation for the 5%? Just because I'm interested
Comment: @JeremyP: I can be quite certain that an NMOS 6502 that includes the indicated instructions wouldn't cost any more than the NMOS 6502s that were actually produced, because the only thing necessary to make any existing NMOS 6502 chips or other parts based on that core store the bitwise AND of A and X to e.g. address $1234 is to feed it the instruction bytes 8F 34 12, and the only thing necessary to make such a chip decrement $56 and compare the result with A is to feed it the instruction bytes C7 56.
Comment: @JeremyP: What's funny is that the designers of the 6502 failed to design in  some useful features, such as instructions to decrement an address and compare the result with the accumulator or store the bitwise AND of the values in A and X, that would have cost nothing beyond the ink necessary to document them.
Comment: @JeremyP It does not. The original 6502 actually does have instructions to do everything supercat is describing -- they're just undocumented.
Comment: "but didn't see a need for an instruction to increment or decrement the accumulator." - apparently the addition of INA/DEA reduced typical code size by about 5% - adding STZ and similar changes made the overall reduction 10 to 15%. I suspect they would have been aware of the advantages even during the original design.
Comment: Oh for sure, they didn't have the statistics that were available to WDC two years later.
Comment: @supercat you don't know that. There may have been design constraints you don't know about. for example, to `AND` `A` and `X` would probably require an extra data path to the ALU.
Comment: I seem to recall it was mentioned in Wagner: https://archive.org/details/softalkv3n10jun1983
Comment: @JeremyP: Back when such instructions were first discovered, one might have worried about whether use of such instructions might stress the silicon, but analysis of the layout shows that's not a problem.  Instructions in the range $8C-$8F, for example, are handled identically in the first two cycles, and in the first half of the third cycle where an internal data bus is precharged to $FF.  Then in the second half of that cycle, circuitry is activated which will clear any bits of that bus which are cleared in Y if the two lower bits of the opcode are 00, clear any bits that are cleared in A...
Comment: ...if the bit 0 of the opcode is set, and clear any bits that are cleared in X if bit 1 of the opcode is set.  If both lower bits of the opcode are set, then any bit which is cleared in X or A will be cleared.  There's no bus conflict, or associated stress, because nothing is trying to set any bits of the bus at the time when A, X, or Y would be copied to it.  The fusion of "DEC" and "CMP" is more interesting, and has the interesting quirk that it supports three addressing modes that are supported by CMP but not DEC.
Answer: If one writes opcodes in binary, using the format III-AAA-gg (with "III" generally being "Instruction", "AAA" being "Address mode", and "gg" as "general instruction group"), most instructions of the form III-AAA-01 or III-AA0-10 process addresses the same way using the address mode specified by AAA.  The latter group of instructions are read-modify-write except that 10I-AAA-xx are LD_/ST_, with the registers selected by xx (in particular, 10I-AAA-10 are LDX/STX).  The exception is that address mode 010, which would normally be immediate (e.g. ORA #imm is 000-010-01), becomes "accumulator" addressing for read-modify write instructions of the 0II-010-10 form.  The increment and decrement instructions have the form 11I-AA0-10, which doesn't match that pattern.
The opcode map is a bit goofy in the areas which would match the general III-AAA-10 and 10I-AAA-xx patterns, but aren't used for read-modify-write or LD_/ST_ instructions.  I would guess that instructions like "TXA" and "TAX", which are placed where "STX #imm" and "LDX #imm" would go, are placed at those spots to exploit the fact that instructions of the form 100-AAA-1x place X on the internal bus, and 101-AAA-1x loads X from the internal bus.  I'm not sure when chronologically it was decided that various instructions would be supported, but supporting accumulator mode with INC and DEC would have required some extra circuitry, and would also require relocating DEX (which uses the opcode that would have fit the patterns of 110-AAA-10 for "decrement something" and 1x0-AAA-1x for "put something into X").
Incidentally, one thing that made chip designs of the 1970s and 1980s very different from those of today was that chips had only three layers that could carry current and signals, and any place the bottom two layers crossed would form a transistor.  As a consequence, one needed to be very mindful of which signals would be sent to what part of a chip, or else a chip would spend more area on routing wires than on transistors.  Today's fabrication processes generally support at least five layers, and many support far more than that, which allows much more routing flexibility.
Comment: @lvd: It would be interesting to have a 6502 simulator that would allow editing the PLA.  I suspect that many of the 6502's annoyances could be eased if parts of the instruction set were reworked, while keeping the same chip layout otherwise, but I suspect some features were added after other parts of the instruction set had already been decided upon.
Comment: @lvd: If I were trying to design a chip given the 6502's list of features, I think I'd be inclined to make all instructions whose two LSBs aren't 00 compute and access an effective address based on bits 2-4 of the opcode, and then perform some action based on bits 0-1 and 5-7.  There's enough space in the opcode map to do that, and I would think that having the opcodes for LDX be the same as LDA except that the bottom two bits would be 10 rather than 01, would be simpler than having LDX, STX, and BIT use different address encodings.
Comment: Actually everything in 6502 controlled with its PLA or "microcode ROM" (though technically it is not pure ROM). The question could be whether `INC A/DEC A` was at all possible to implement within the existing PLA and why didn't they do it.
Answer: Although the instructions LSR, ROR, ASL, and ROL were described as having five addressing modes that include "accumulator mode", each of them should really be thought of as two instructions, e.g. "LSR memory" and "LSR accumulator".  If the 6502 hadn't included circuitry specifically to support the accumulator modes of those instructions, but simply advanced the state machine to "cleanup and fetch next instruction" after the second cycle for any bit pattern that would code an immediate-mode operand, the opcodes that would code the immediate-operand forms of those instructions would act as either one-cycle or two-cycle NOPs, depending upon whether incrementing of the program counter was suppressed during the second cycle, because the actual shifting work performed by the instructions occurs on the cycle after the memory-operand fetch, and immediate-mode opcodes don't perform a memory-operand fetch.
Making those instructions usable with both memory operands and the accumulator required a fair amount of extra circuitry--probably more than some other features that didn't make the cut, but they were included because some common operations would be awkward if only one were supported.  Without accumulator mode, the scenario of loading a bit from one I/O port, shifting it, and then outputting it, would have gone from:
LDA input
LSR
STA output

to
LDA input
STA temp
LSR temp
LDA temp
STA output

increasing the time from 7 bytes/10 cycles to 12 bytes/19 cycles.  Without memory mode, the scenario where one wants to shift a bit through a sequence of addresses would have increased from:
LSR buff+3
ROR buff+2
ROR buff+1
ROR buff

to
LDA buff+3
LSR
STA buff+3
LDA buff+2
ROR
STA buff+2
LDA buff+1
ROR
STA buff+1
LDA buff
ROR
STA buff

increasing the cost from 8 bytes/20 cycles ot 20 bytes/32 cycles.  If the carry flag state is known, a lack of INC A/DEC A would add one byte and zero cycles; if it's not known, it would add two bytes and two cycles.  If the 6502 had used all opcodes of the form xxxxxx11 as "some kind of add/subtract", using one opcode bit to enable/disable carry input, and one to control BCD mode, then I don't think the cost/benefit analysis of adding support for INC A/DEC A would have been particularly close to justifying it.  As it is, the frequent need for a CLC or SEC when using ADC or SBC means that INC A/DEC A would have offered some savings, but more general ADD/SUB instructions would have been better yet.


"Wer hat dich gesehen?" or "Wen hat dich gesehen?

Question: Which is correct and why? Sehen is an accusative verb so I thought that "Wen" would be correct but Google Translate says that "Wer" is correct. Could someone please explain? Thanks!
Comment: What is the intended meaning?
Comment: @CarstenS "Wen hat dich gesehen?" is not valid German in any context. Not even in any dialect I know of.
Comment: @YetiCGN, true, and the Google Translate part indeed indicates that "wer" was intended, but "wen hast du gesehen" is also correct German.
Comment: FWIW: There is "Wen hast du gesehen?" - subject and object reversed.
Comment: "Sehen is an accusative verb" - That's why you say "Wer hat dich gesehen" and not "Wer hat dir gesehen". "Wen hast du gesehen" is also grammatically correct but has a totally different meaning - "which are the people that you saw", instead of "which people did you see". "Helfen" for example is not an accusative verb, so you say "Wer hat dir geholfen" instead of "Wer hat dich geholfen".
Answer: The object in

Wer hat dich gesehen?

is dich. That's why it is dich (acc.) and not du.
Wer is the subject and therefore in nominative.
Answer: The correct answer is "Wer hat dich gesehen?"
The verb sehen is accusative (the grammatical case where only the masculine article changes), meaning the sentence contains a subject and a direct object. In the sentence Wer hat dich gesehen?, the the subject is Wer and the direct object is dich.
The other sentence Wen hat dich gesehen? is incorrect because you are referring to two accusative pronouns without a subject. A way to think about it would be like this:
Wer = Nomativ = Subject
Du = Nomativ = Subject
Wen = Wer in the Akkusativ Case = Direct object
Dich = Du in the Akkusativ Case = Direct object
An example of the sentence with Wen would be:
Wen hast du gesehen? = Who did you see?
Comment: I would rephrase "This sentence accusative". A noun phrase, meaning a pronoun or a noun with its article and adjective (if any), has a case. You might also say a verb is accusative if it takes an accusative object, though transitive is the more common term. But a sentence has several parts, and they can't all be accusative, so it's a bit misleading to call a sentence accusative. or to assign any case to it. Sorry for nitpicking, but I think it's important  to use these grammatical terms the correct way to avoid confusion; grammar is confusing enough as it is.
Comment: I understand what you mean and you are right - since this was a fairly beginner question I wanted to keep it simple and refer to the entire sentence (which is only 4 words) as falling into a specific gramamtical case. It is true that a sentence will have many cases - good add. Will change "sentence" to "verb"
Answer: DanielJerrehian's answer already pretty much covers it, but I think the root problem here is a misunderstanding of the term "accusative verb", which is not a standard grammatical term. A verb does not have a case, but it does require specific cases for the other parts of a sentence. But it's more complicated than a verb requiring a single case for everything else. Instead, the verb may require one sentence part with one case, another sentence part with another case, and possibly a third part with yet another case. All verbs require a subject, which is always in the nominative. In the sentence given, that would be wer. Nouns, or the phrases in a sentence which serve as nouns, other than the subject are called objects.
Some verbs are called "dative verbs" because in addition to the (nominative) subject, which is taken for granted, they also require an object in the dative case. This is for convenience since the verb itself isn't in the dative, it just wants something else to be in the dative. By extension you might also call a verb accusative if it requires an accusative object, but these are already called transitive verbs, so having a second name for them can be confusing. A verb might require both an accusative object and a dative object; the grammatical term for this is ditransitive. Unfortunately, while traditional grammar terminology supports subject only (intransitive), subject+accusative object (transitive), and subject+accusative object+dative object (ditransitive), there is no such term for subject+dative object. Hence the need for the rather ad hoc and confusing term "dative verb". It would be difficult to consistently generalize this terminology to more verbs because there are many variations: verbs that require an impersonal object, a reflexive object, an adjective, a specific type of subclause, or some combination of the above.


Execute Git processes that require a passphrase from within a groovy script

Question: I'd like to be able to automate several >git commants from within a Groovy script.  I'd like to execute a process using code like the following...
def cmd = "${GIT_EXEC} submodule update --init ";
def process = cmd.execute(null, new File('.'));
process.consumeProcessOutput(System.out, System.err);
process.waitFor();
rc = process.exitValue();

Here's the problem...
When you enter that command manually, you get prompted to enter your key passphrase.  Using my groovy script, you don't get prompted and the script just hangs.  :(
I have seen several other posts related to this area.  The consistent response was to use something called ssh-agent.  That tool is not on my Windows box, nor on the Windows boxes of the other developers & admins on the project.  I don't want to ask them to find a windows-friendly version of that and install it.
Here is where my situation is different from those others:  I don't need to prevent the shell from prompting for a passphrase.  I'd be delighted if the prompt would happen through my groovy script, the user could type it, and life would continue normally.
Is there a fancy way I can tell the process I invoke from within Groovy to go ahead and interact with the user, and not merely swallow the prompt?
What options do I have here?
Answer: How about using a pure-java Git client library like jgit to interact with git, instead of spawning a process?


Differential voltage to frequency

Question: Edited to clarify some questions
I'm working on a design that will take a 0.5V-4V signal from a laser displacement sensor (Keyence Il-1000) and convert it to a frequency signal (0.1-2Mhz) for input to an FPGA counter. The sensor needs 10-30v so I am powering it with a 24v switching power supply.
My board is plugged into the daughterboard header on of an FPGA board. This header has 5v and ground pins, which I use to power the AD7741 V/F converter. The FPGA and V/F converter are powered by 5v supply. My board also has 24v supplied by screw terminals. The two power supply grounds are joined at the PSU
I have a "working" circuit with an Analog Devices AD7741 V/F converter but I am not satisfied with the frequency jitter (around 2.5% of the full scale signal), so I tried to mitigate it by addressing the power supply noise. The noise pattern from the analog signal at the sensor matched the power supply noise. The noise pattern includes a 100mv voltage droop based on loading, and a ~100khz 200mv ripple.
Here are some things I tried:
I added a LM7812 regulator with 47uf input cap and 10uf output cap, as well as a 1uf ceramic cap to the sensor power supply. This fixed the measured voltage droop and slightly improved the jitter at the FPGA.
I joined the two grounds at my board. This alone brought the signal jitter down to about 0.5%. I don't like it though, because it looks like a good way to kill the FPGA due to a ground loop. 24v is supplied to my board via screw terminals; if the + is connected without the ground in place, the capacitors on my board will temporarily raise the negative rail in the FPGA board, which could present negative voltage to the FPGA inputs, which would kill those inputs. Even with a good connector, I cannot guarantee that the ground will be in place before power is supplied. This is why I still plan to use a signal isolator or opto-isolator, along with a 5v regulator for powering the V/F chip.
I still have a 100khz 150mv ripple on my sensor power supply, and a matching ripple at the sensor output. I tried to mitigate it by building a basic capacitor multiplier circuit out of an rc network and an NPN darlington transistor. I must have gotten something wrong because it doesn't do much to attenuate the ripple. It does appear to be working because there is a several-second startup time where the voltage slowly rises after power is supplied. The values I used are 1K resistor, 10uf capacitor and SD2088 transistor, which has a dc current gain of 2000. Any insights as to why it's not working? I followed this schematic:
https://www.electronics-notes.com/articles/analogue_circuits/transistor/capacitance-multiplier-circuit.php
I am new to this so I don't know what I should expect to be able to achieve. I am trying to get the 12v power supply ripple to below 10mv. Is this reasonable?
Comment: "*which I presume comes from the noise at the analog input.*" Why do you have to presume when you can check? Hook it up to a scope and see. As for adding the linear regulators everywhere, you never actually told us what you were using the power supply you were using to power the sensor in the first place. You also never told us what amount of jitter you are seeing and what amount of jitter you would be satisfied with. I see little point in using a digital isolator to carry the signal to the FPGA.
Comment: We just don't have enough info.
Comment: A cap multiplier is not a filter. RC filters have an R for a reason, not just a capacitance. It likely wouldn't work anyways since it suffers from the same reason why using linear regulators to remove switching noise from an SMPS tends not to work: the circuit has to be faster than the noise to react in time to compensate for the noise, but noise is high frequency (i.e. really fast) so passes right through. You need a series component for a filter to drop noise voltage across.
Comment: 100kHz is borderline too fast so you can try adding a low resistance or ferrite bead, but the wrong ferrite bead can amplify noise due to resonance/peaking. If that doesn't work, replace the cap multiplier with just a ceramic capacitor (NP0 since other ceramic dieelectrics are piezo and make noise when deformed.) .
Answer: Analyze the DC voltage signal in with a Spectrum Analyzer and Oscilloscope and determine what other "noise" is present on the DC.  From there, address the undesired signals with filtering.
Voltage regulators are fine, but there are so many places noise is picked up, so a Vreg may not work. Filtering at the input is your best bet.

Differential voltage to frequency


What are the generating elements of a cluster algebra?

Question: I'm trying to get into cluster algebras, and so have been looking at the basic stuff to get the foundations settled. A problem I've run into is that I've come across two (seemingly contradictory) definitions of how the cluster algebra is to be generated.
The first source is Lauren Williams' Cluster Algebras: An Introduction, where she writes:

Definition 2.10 (Patterns). Consider the $n$-regular tree $\mathbb{T}_n$ whose edges are labeled by the numbers $1 , \dots , n$, so that the $n$ edges emanating from each vertex receive different labels. A cluster pattern is an assignment of a labeled seed $\sum_{t} =(\mathbf{x}_t , Q)$ to every vertex $t \in \mathbb{T}_n$, such that the seeds assigned to the endpoints of any edge $t \xrightarrow[]{k} t'$ are obtained from each other by the seed mutation in direction $k$. The components of $\mathbf{x}_t$ are written as $\mathbf{x}_t = (x_{1;t} , \dots , x_{n;t} )$.
[...]
Definition 2.11 (Cluster algebra). Given a cluster pattern, we denote
  \begin{equation*}
\mathcal{X} = \cup_{t \in \mathbb{T}_n} \mathbf{x}_t = \{ x_{i;t} : t \in \mathbb{T}_n , 1 \leq i \leq n \} ,
\end{equation*}
  the union of clusters of all the seeds in the pattern. The elements $x_{i;t} \in \mathcal{X}$ are called cluster variables. The cluster algebra $\mathcal{A}$ associated with a given pattern is the $\mathbb{Z}[c]$- subalgebra of the ambient field $\mathcal{F}$ generated by all cluster variables: $\mathcal{A} = \mathbb{Z}[c][\mathcal{X}]$.

where the $c$ in $\mathbb{Z}[c]$ are the frozen/coefficient variables $\{ x_{n+1} , \dots , x_m \}$.
Wikipedia gives a somewhat different definition:

A cluster algebra is constructed from a seed as follows. If we repeatedly mutate the seed in all possible ways, we get a finite or infinite graph of seeds, where two seeds are joined if one can be obtained by mutating the other. The underlying algebra of the cluster algebra is the algebra generated by all the clusters of all the seeds in this graph. The cluster algebra also comes with the extra structure of the seeds of this graph.

My supervisor and me believe that these are not in fact conflicting definitions, but that they are in fact equivalent, as we have found them to be for the simplest of cases. However, we have hitherto been unable to figure out how one can prove this for the general case.
If anyone knows how to accomplish this proof, or otherwise know of any source or anywhere where this proof can be found, it would be greatly appreciated.
Answer: The fact that the two definitions are equivalent is essentially the observation that a "cluster pattern" is uniquely determined by any seed at any vertex in the tree. This is simply because once you know one seed, all adjacent ones are determined by mutation rules. The wikipedia definition mentions that you get a graph of seeds which are connected if they are related by mutation. This is precisely that $n$-regular tree from the "cluster pattern" definition.


How to make a ShapeDrawable clickable

Question: I'm trying to draw some ShapeDrawable into a View and when long clicking on them they should be editable (the text that they have on it).
I just can't figure out how to detect a touch on the ShapeDrawable.
I tried to make it a Button and draw my Shape in its onDraw function like I found here (How-to create a clickable Button with a ShapeDrawable?) but not even that Button seems to be getting the click event.
How would you solve this problem?
Edit:
@papachan Hm... I tried extending the View class but still no clicks :( My View is getting drawn in the onDraw() of it's superView and it draws a ShapeDrawable with a specific width and height. But I'm never setting the width and heigth in the class containing the View. So may the problem be that it does not know if it got hit by my touch?
Comment: I wonder if you unluckily chose the wrong view to try this. Buttons (in all platforms) tend to eat click events to transform them.
Answer: Only Views can be clickables. Have you tried to extend a View?
Comment: This seems like the correct approach. Make the custom component draw the drawable in the onDraw method but also extend View class. This way you can attach a clickListener to the view.
Comment: Hm... I tried extending the View class but still no clicks :( My View is getting drawn in the onDraw() of it's superView and it draws a ShapeDrawable with a specific width and height. But I'm never setting the width and heigth in the class containing the View. So may the problem be that it does not know if it got hit by my touch?

How to make a ShapeDrawable clickable


Chroot a user in Amazon EC2 instance

Question: I've got an Amazon Linux AMI machine running 2016.09 version. I've recently created a user and I'm able to connect using its credentials (private key).
This user is intended to be used by a third party and I want to restrict its access to its home directory (or subdirectory), so that it can't access any other folder (nor list any other folder/file).
I assume I do need to configure some sort of chroot directory using my sshd_config file, located in /etc/ssh/sshd_config. I've been able to modify its content so that it looks like the following piece of text:
<code>#override default of no subsystems
#Subsystem       sftp    /usr/libexec/openssh/sftp-server
Subsystem      sftp    internal-sftp

Match User myuser
       PasswordAuthentication yes
       ChrootDirectory /home/myuser/ftp_folder
       AllowTCPForwarding no
       X11Forwarding no
       ForceCommand internal-sftp
</code>
Just after saving changes, I restart ssh service by typing sudo service sshd restart.
Unfortunately, I can't login with those changes (either ssh or using ftp):
<code>$ ssh -i 'G:\AWS\ec2_keys\myuser.pem' email@example.com-    1.amazonaws.com -vvv

Authenticated to ec2-XXXXXX-XX.compute-1.amazonaws.com ([YYY.YYY.YYY.YYY]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug3: send packet: type 90
debug1: Requesting firstname.lastname@example.com
debug3: send packet: type 80
debug1: Entering interactive session.
debug1: pledge: network
debug3: send packet: type 1
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t3 r-1 i0/0 o0/0 fd 4/5 cc -1)

Connection to ec2-XXXXXX-XX.compute-1.amazonaws.com closed by remote host.
Connection to ec2-XXXXXX-XX.compute-1.amazonaws.com closed.
Transferred: sent 2328, received 1996 bytes, in 0.0 seconds
Bytes per second: sent 60664.3, received 52012.8
debug1: Exit status -1
</code>
What am I missing in the configuration? Thanks!!
Answer: I solved a similar problem here:
How to chroot accounts for using scp in Amazon Linux?
Some ideas:
 - You might need to have a certain directory structure in the user's home directory, including the <code>/etc/passwd</code> file and some libraries
 - The log files might contain more details

Chroot a user in Amazon EC2 instance


Problem converting endianness

Question: I'm following this tutorial for using OpenAL in C++: http://enigma-dev.org/forums/index.php?topic=730.0
As you can see in the tutorial, they leave a few methods unimplemented, and I am having trouble implementing file_read_int32_le(char*, FILE*) and file_read_int16_le(char*, FILE*). Apparently what it should do is load 4 bytes from the file (or 2 in the case of int16 I guess..), convert it from little-endian to big endian and then return it as an unsigned integer. Here's the code:
static unsigned int file_read_int32_le(char* buffer, FILE* file) {
    size_t bytesRead = fread(buffer, 1, 4, file);
    printf("%x\n",(unsigned int)*buffer);
    unsigned int* newBuffer = (unsigned int*)malloc(4);
    *newBuffer = ((*buffer << 24) & 0xFF000000U) | ((*buffer << 8) & 0x00FF0000U) | ((*buffer >> 8) & 0x0000FF00U) | ((*buffer >> 24) & 0x000000FFU);
    printf("%x\n", *newBuffer);
    return (unsigned int)*newBuffer;
}

When debugging (in XCode) it says that the hexadecimal value of *buffer is 0x72, which is only one byte. When I create newBuffer using malloc(4), I get a 4-byte buffer (*newBuffer is something like 0xC0000003) which then, after the operations, becomes 0x72000000. I assume the result I'm looking for is 0x00000027 (edit: actually 0x00000072), but how would I achieve this? Is it something to do with converting between the char* buffer and the unsigned int* newBuffer?
Comment: Actually, the value would be 0x00000072, not 0x00000027.  Basically, it's swapping byte order, not nybble order.
Comment: Why does the method supply both a buffer and a file pointer?  That's unintuitive.
Comment: I'm not sure. That's how they called it in the tutorial so I stuck with their declaration for the function. I agree it's strange.
Answer: there's a whole range of functions called "htons/htonl/hton" whose sole purpose in life is to convert from "host" to "network" byte order.
http://beej.us/guide/bgnet/output/html/multipage/htonsman.html
Each function has a reciprocal that does the opposite.
Now, these functions won't help you necessarily because they intrinsically convert from your hosts specific byte order, so please just use this answer as a starting point to find what you need. Generally code should never make assumptions about what architecture it's on.
Intel == "Little Endian".
Network == "Big Endian".
Hope this starts you out on the right track.
Answer: I've used the following for integral types.  On some platforms, it's not safe for non-integral types.
template <typename T> T byte_reverse(T in) {
   T out;
   char* in_c = reinterpret_cast<char *>(&in);
   char* out_c = reinterpret_cast<char *>(&out);
   std::reverse_copy(in_c, in_c+sizeof(T), out_c);
   return out;
};

So, to put that in your file reader (why are you passing the buffer in, since it appears that it could be a temporary)
static unsigned int file_read_int32_le(FILE* file) {
    unsigned int int_buffer;
    size_t bytesRead = fread(&int_buffer, 1, sizeof(int_buffer), file);
    /* Error or less than 4 bytes should be checked */
    return byte_reverse(int_buffer);
}

Answer: Yes, *buffer will read in Xcode's debugger as 0x72, because buffer is a pointer to a char.
If the first four bytes in the memory block pointed to by buffer are (hex) 72 00 00 00, then the return value should be 0x00000072, not 0x00000027. The bytes should get swapped, but not the two "nybbles" that make up each byte.
This code leaks the memory you malloc'd, and you don't need to malloc here anyway.
Your byte-swapping is correct on a PowerPC or 68K Mac, but not on an Intel Mac or ARM-based iOS. On those platforms, you don't have to do any byte-swapping because they're natively little-endian.
Core Foundation provides a way to do this all much more easily:
static uint32_t file_read_int32_le(char* buffer, FILE* file) {
    fread(buffer, 1, 4, file);            // Get four bytes from the file
    uint32_t val = *(uint32_t*)buffer;    // Turn them into a 32-bit integer

    // Swap on a big-endian Mac, do nothing on a little-endian Mac or iOS
    return CFSwapInt32LittleToHost(val);
}

Problem converting endianness


lumia 640 xl windows 10 model mobile, sd card no showing issue

Question: In my model Lumia 640 XL files windows 10 mobile app and Whatapp is not working and i am unable to find my SD card. i am unable to turn off my mobile. i have tried to reset the mobile also.has issue with WhatsApp. WhatsApp application crashes after running any video 2, 3 seconds
Comment: Does your mobile has latest update, i.e. 10.0.14393.576?
Comment: yes i have install the latest update
Comment: Whats up is instaled on SD card ?
Answer: First check you sd card in other phone, if it is ok then try hard rest your phone. If the problem persists the i think you have damaged your phone's sd card slot or any internal component is damaged. So if don't have professional knowledge about repairing a phone i will not suggest you doing that yourself. Better take it to service center or any good repairing center.


How do you execute a Javascript function without 'onclick' like "Grippie" in a new post on SOF

Question: How do you execute a JavaScript function without onclick like "Grippie" in a new post on SOF, like the <div class="grippie" style="margin-right: 59px;"/> on Stack Overflow when you post a question or answer? I get a nice CSS cursor which lets me know of the movable edge, but how is the JavaScript which resizes the field finding out I clicked on the 'grippie'?
Edit:
Thank you for the answers which lead to jQuery and describe the handler.
Could I please have a simple use of the handler that determines when the element is clicked, like:
addListener('myElement',performFunction();).onclick;

or however this may work?
Answer: If you look at the generated source with Firefox Web Developer plugin you'll see that it adds a DIV of class "grippie", using the TextAreaResizer mentioned by @grepsedawk.  This DIV has the resize sprite for a background and has a click handler attached to it that performs the resize.
Answer: http://plugins.jquery.com/project/TextAreaResizer
Answer: I have researched a few methods which I will outline. Further comments as to which is best would be appreciated. The goal is to hide the "onClick" listener from the generated source.
document.getElementById('ID').addEventListener('click',function();,false);
//Problems: Has to be terminated and false/true is something tricky I don't understand yet (please see link I post)

document.getElementById('ID').onclick = function();
//Problems: Cannot be terminated directly and heirachy issue where function including 'this' keyword applies to the child divs or something (please again see link I post)

//an iterartion of setInterval(checkFunction,interval);
//Problems: Very very slow and in most cases requires an onClick to check for a change anyway!

So at the end of my research, this website came out on top for explaining very well how eventListeners in Java can be hooked effectively: http://www.howtocreate.co.uk/tutorials/javascript/domevents
Answer: The JavaScript in use on the site listens to click events and looks for the ID of the element being interacted with. The script will then either ignore the event or do something if the element ID is one of the expected objects that requires action.


Solution of equation of binomial random variables

Question: Is it possible to find the probability distribution of the random variable $X$ that solves the following equation?
$$
X = Bin(X, p) + Bin(X, 1-p),
$$
where $Bin(X,p)$ is a random variable distributed according to a binomial distribution with parameters $X$ and $p$, $p \in (0, 1)$, the two random variables on the right side are independent.
Answer:
The solutions do not depend on $p$ in $(0,1)$. These are the Poisson distributions and the Dirac mass at $0$.

To show this, first recall that, for every random variable $Y$ binomial $(n,p)$ and every $|s|\leqslant1$, the generating function of $Y$ is $$E(s^Y)=(ps+q)^n.$$
Considering $g(s)=E(s^X)$, the identity in distribution in the question translates as
$$g(s)=g(ps+q)g(qs+p).
$$
Considering $h(t)=-\log g(1-t)$, one gets
$$h(t)=h(pt)+h(qt).
$$
Iterating this, one gets, for every $n\geqslant1$,
$$
h(t)=\sum_{k=0}^n{n\choose k}h(p^kq^{n-k}t).
$$
Assume that $X$ is integrable with $\lambda=E(X)$, then $g(1-t)=1-\lambda t+o(t)$ when $t\to0$. If $\lambda=0$, $X=0$ with full probability. Otherwise, $h(t)\sim\lambda t$ when $t\to0$.
Fix some $\lambda'\lt\lambda$, then $h(t)\geqslant\lambda' t$ for every $t$ small enough. When $n\to\infty$, $p^kq^{n-k}\to0$ uniformly in $k$, hence, for every $t$ in $(0,1)$, for every $n$ large enough,
$$
h(t)\geqslant\sum_{k=0}^n{n\choose k}\lambda'p^kq^{n-k}t=\lambda' t.
$$
The same iteration shows that, for every $\lambda''\gt\lambda$, $h(t)\leqslant\lambda''t$, thus, $h(t)=\lambda t$ for every $t$ in $(0,1)$, that is, $g(s)=\mathrm e^{-\lambda(1-s)}$ for every $s$ in $(0,1)$, which means that $X$ is Poisson with parameter $\lambda$.
If $X$ is a non integrable solution, then, for every $\lambda$,  $h(t)\geqslant\lambda t$ for every $t$ small enough, and yet again the same reasoning yields $h(t)\geqslant\lambda t$ for every $t$, hence $h(t)$ is infinite, that is, $g(s)=0$, which is absurd.
Comment: It seems to me that the solution (i.e. the parameter $\lambda$ of the poisson distribution) does not depend on $p$, right?
Comment: Correct, for every value of $p$, the set of solutions is the same.
Comment: In case the equation is $X_1=Bin(X_2,p) + Bin(X_3,1−p)$, where $X_1$, $X_2$ and $X_3$ are identically distributed, but $X_2$ and $X_3$ are not independent, nothing can be done to determine the distribution of those variables, right?
Comment: Unless one specifies the dependence of $(X_2,X_3)$ (and even then this is not assured).
Comment: If $X$ is integrable then did you use a Taylor expansion for $g(1-t)$? Don't you have then $o(t^2)$?
Comment: You probably mean $O(t^2)$ (big-O) and no, this is not guaranteed by the integrability of X.


Next steps to supplement home gym routine?

Question: I've now got a three piece home gym... A doorframe mounted pull-up bar, a gymform abxelerate spring loaded sit-up machine, and some makeshift dip bars. My routine has basically become one or two sets of 15-40 sit-ups on the abcelerate, and 1-3 sets of 5-10 dips each, although I ether have to tilt my body backwards as I come down so that my front of torso is slightly facing down rather than fully vertical as it is when I lift myself up, or I have to raise my knees nearly into the fetal position like suspended upward with knees and hips  both bent to the max like a crunch that leaves me in a ball. One of these or the offer is necessary to let me go down all the way. Then whenever I see the doorframe mounted pull-up bar and think of it, I try to do 10 pull-ups, though usually exhaust by about 8. I usually do them with my palms and inner forearms facing back toward me. Occasionally I also hang for a minute, but in all cases it isn't high enough for me to completely dangle my legs to as with the dips I must always bend my knees and lift my feet and lower legs.
Since I got these machines I've stopped doing regular push-ups and tricep dips, but there's no reason why I can't. I've also contemplated getting dumbbells and using the abcelerate as a bench.
But in any case I miss lifting heavy weights and dadlifting barbells in the gym.
What could I do to add some further variety to this routine, and maybe more significantly, what would be the highest priority missing things to supplement it with at the gym if I was to go back in once or twice a week?
Answer: I believe it depends on what are your goals.
For a full body training you're missing:

horizontal / vertical presses (bench press / shoulder press)
horizontal pull (back rows)
legs (squat variations / leg extension + curl)
hip hinge (romanian deadlift)

You could solve those with either barbells + plates or dumbbells, they both have its own advantages and disadvantages.
Either way I'd get at least a flat / adjustable bench for the presses (I got a foldable one to save space when I'm not using it).


How to covert a sbyte[] to BitArray? C#.Net

Question: I'm trying to integrate two systems that deal with images. One system provides an image as a sbyte[] and the other uses a BitArray. I need to take the data from the sbyte[] and convert it into a BitArray. Anyone know how to do this?
Thanks, Paul
Answer: The simplest way would be to convert the sbyte[] to a byte[] and then pass it into the normal BitArray constructor. If you're using .NET 3.5 that's easy with LINQ:
byte[] bytes = sbytes.Select(s => (byte) s).ToArray();
BitArray bitArray = new BitArray(bytes);

This is assuming you're executing in an unchecked context already. Otherwise you might want to make the conversion explicitly unchecked:
byte[] bytes = sbytes.Select(s => unchecked((byte) s)).ToArray();
BitArray bitArray = new BitArray(bytes);

Comment: Cool, so how do I convert sbyte[] to byte[]. Thanks.
Comment: @Paul: Did you read the whole of my answer? It shows you - twice!
Answer: BitArray has a constructor that takes a byte array that you might try:
sbyte[] sbytes = ...
BitArray ba = new BitArray(sbytes.Select(x => (byte)x).ToArray());


Live data sync in Lightning Communities

Question: I have a custom community pages which is showing some content based on Account Status.
I need to update this section in my custom community page based on any server update on the account status field in Salesforce, in the same session without loading the whole page.
I tried platform event and LDS. Emp API is not working in community,so can't subscribe to platform event and LDS doesn't work with server load.
Any other possible workaround?
Answer: Yes, you can use custom LWC  which uses the CometD library from the static resources. It should select the user's sessionId and connect to channel with Streaming API. Create handling events and exceptions similarly to EMP API. It is working in Communities. Check this repository, this example is working fine in Communities!
https://github.com/TheVishnuKumar/lwc-streaming-api

Live data sync in Lightning Communities