How to assess how much a Ruby/MySQL server can keep up?

Question: We've taken over a legacy system that was implemented between 2007-2009 in Ruby and MySQL and since then has had only maintenance work done on it that was necessary to keep it alive.
As a result, the system is now very fragile in terms of its code base. In fact, since half the code base is in one version of Ruby and the other half is in another (this is what our Ruby guy tells us), we have been having problems making any modifications and deploying to production.
Many of the shortcuts taken have made parts of the system unusable - such as some administration queries taking several minutes to complete, or even times out.
We are currently in the process of rewriting the platform in .NET but we need to assess with as much specificity as possible how much the current setup can hold.
One heuristic that raised a red flag for me is that the current production MySQL database is 15GB at the moment and still phases growth because of automatically scheduled sync jobs that write huge audit logs on the database!
Linux reports (through <code>/proc/cpuinfo</code>) 3xXeon E5420 @ 2.5GHz processors at constant 30-50% load when not running nightly jobs. 6GB of RAM + 2GB swap, out of which only 35MB of mem is free and most of swap is free.
The question is: how can we assess in as much detail as possible how much the current setup will hold? This obviously must be done without doing say, a load test, which could bring the server down for good. What heuristics can use to produce an estimate?
Are MySQL databases known to hold databases as large as 15GB+? Is there a known point where reliability is expected to drop significantly?
Any other insights into the investigation of the problem are welcome.
Answer: I think your question about MySQL scalability is a duplicate of this question:
https://stackoverflow.com/questions/1276/how-big-can-a-mysql-database-get-before-performance-starts-to-degrade
15GB is not large at all for a MySQL database. But that doesn't mean that a poorly written application won't run slowly against that database.  Terabyte sized MySQL databases are not uncommon - the maximum size of an InnoDB table is 64TB
If it's only grown to 15GB in the past 6 years, I  wouldn't expect database growth to be a limiting factor in the time it would take to rewrite the app. The app will probably run about as fast with a 30GB database as it does with a 15GB database
But, to answer your question, if you're running around 30 - 50% load normally,  unless you have any severe I/O bottlenecks (like you probably due during the sync jobs that create a lot of audit logs in the database), I'd guess that you can probably support around twice your normal load. It's really a guess, since it depends highly on what your app is actually doing like how much is it reading/writing to the database, how effcient the database queries are (like, are the right indexes in place),  and how complicated the application logic is.
The low "free" memory is likely nothing to be concerned with - depending on what utility you used to find "free" memory, "free" doesn't always mean "free". Linux buffers disk data in otherwise unused memory and over time, this buffer cache will grow quite large and consume most of the RAM not used by programs. However, this memory is readily available when needed, the kernel can immediately drop a cache page from RAM anytime it's needed by software. For a better sense of how much free memory you have, take the total memory and subtract "used".
If you really did have only 35MB of free memory left, I think you'd be doing some serious swapping and performance would be quite bad. In that case you'd want to do some MySQL and/or web server tuning to reduce the memory demand. But I don't think that's the situation you're in or you'd be reporting more performance problems.
Comment: Thanks. You didn't however make any comments regarding the high mem usage. Is that safe? If I'm not mistaken Linux will consume all RAM before going to swap for active processes but only 50MB free RAM sounds pretty dangerous to me. Thoughts?
Comment: I edited my answer to address the memory question


Javascript - Change/convert image data url to file url in ionic 2

Question: Is possible to change or convert the data url of image to file url ?
For example, I got image from the link but the data was very long such as
data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAABMLAAATCwAAAAAAAAAAAABsiqb/bIqm/2yKpv9siqb/bIqm/2yKpv9siqb/iKC3/2yKpv9siqb/bIqm/2yKpv9siqb/bIqm/2yKpv9siqb/bIqm/2yKpv9siqb/bIqm/2yKpv9siqb/2uLp///////R2uP/dZGs/2yKpv9siqb/bIqm/2yKpv9siqb/bIqm/2yKpv9siqb/bIqm/2yKpv9siqb/bIqm/////////////////+3w9P+IoLf/bIqm/2yKpv9siqb/bIqm/2yKpv9siqb/bIqm/2yKpv9siqb/bIqm/2yKpv///////////+3w9P+tvc3/dZGs/2yKpv9siqb/bIqm/2yKpv9siqb/TZbB/02Wwf9NlsH/TZbB/02Wwf9NlsH////////////0+Pv/erDR/02Wwf9NlsH/TZbB/02Wwf9NlsH/TZbB/02Wwf9NlsH/TZbB/02Wwf9NlsH/TZbB//////////////////////96sNH/TZbB/02Wwf9NlsH/TZbB/02Wwf9NlsH/TZbB/02Wwf9NlsH/TZbB/02Wwf////////////////+Ft9T/TZbB/02Wwf9NlsH/TZbB/02Wwf9NlsH/E4zV/xOM1f8TjNX/E4zV/yKT2P/T6ff/////////////////4fH6/z+i3f8TjNX/E4zV/xOM1f8TjNX/E4zV/xOM1f8TjNX/E4zV/xOM1f+m1O/////////////////////////////w+Pz/IpPY/xOM1f8TjNX/E4zV/xOM1f8TjNX/E4zV/xOM1f8TjNX////////////T6ff/Tqng/6bU7////////////3u/5/8TjNX/E4zV/xOM1f8TjNX/AIv//wCL//8Ai///AIv/////////////gMX//wCL//8gmv////////////+Axf//AIv//wCL//8Ai///AIv//wCL//8Ai///AIv//wCL///v+P///////+/4//+Axf//z+n/////////////YLf//wCL//8Ai///AIv//wCL//8Ai///AIv//wCL//8Ai///gMX/////////////////////////////z+n//wCL//8Ai///AIv//wCL//8Ai///AHr//wB6//8Aev//AHr//wB6//+Avf//7/f/////////////v97//xCC//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AHr//wB6//8Aev//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
So How can convert it to be such as
file:///storage/emulated/..../image1.jpg
Comment: Is the `data URI` at Question the complete?
Comment: open the url in a new tab, then menu > save file as.
Answer: You can replace the MIME type of a valid data URI with "application/octet-stream", set value at .href of  element, set download attribute value to "image1.validExtension", append element to document.body, call .click() on a element
var stream = validDataURI.replace(/[^:][\w/-]+(?=;|,)/, "application/octet-stream");
var a = document.createElement("a");
a.href = stream;
a.download = "image1.validExtension";
document.body.appendChild(a);
a.click();


Java- for loop using << operator

Question: I'm stuying this code and I don't understand what this line does: [(y << 3) + x]
    for (int y = 0; y <= 7; ++y) {
            for (int x = 0; x <= 7; ++x) {
                final String pieceCode = pieceCodes[(y << 3) + x];
                if (pieceCode.length() != 2) throw new IllegalArgumentException();
                if (!pieceCode.equals("--")) {
                    pieces[((7 - y) << 3) + x] = CheckersPiece.valueOf(pieceCode.charAt(0), pieceCode.charAt(1));
                }
            }
        }

Comment: [Bitwise and Shifting operators summary](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/opsummary.html)
Comment: Looks like it's indexing into a 2D array stored in a single array.
Answer: It's an obfuscated way of multiplying by 8. Thus, (y << 3) + x is equal to 8 * y + x.
The reason that y << 3 is equivalent to multiplying by 8 is because << is the left-shift operator: it shifts all the bits of y left by one position. In the same way that if you take a base-10 number and shift left by one position you have multiplication by 10, shifting left in base-2 is equivalent to multiplying by 2. Therefore, shifting left by three positions is equivalent to multiplying by 2 * 2 * 2 = 8. In general, shifting left by n positions is equivalent to multiplying by 2^n (as long as you don't have bits falling off of the left end).
In the olden days, programmers wrote code like this because left shifts are super duper fast, faster than multiplication and so 8 * y was less optimal than y << 3. But these days, compilers are pretty good at figuring out when to replace something like 8 * y with y << 3.
Therefore, I say it's obfuscated because 8 * y more clearly expresses the intent: the intent of (y << 3) + x is to skip by y blocks of 8, and take the xth position in that block. And this is much more clearly expressed by saying 8 * y + x. Remember, we code in high-level languages for humans to read and understand the code. Our code should be written for the humans. The compiler can do its job of making good machine instructions for the machine to understand.
It's done this way because it's trying to pretend that pieceCodes is a 2D array, just mapped into a 1D array.
That is, piecesCode looks like this
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x

but we can pretend it looks like this
x x x x x x x x
x x x x x x x x
x x x x x x x x
x x x x x x x x
x x x x x x x x
x x x x x x x x
x x x x x x x x
x x x x x x x x

See, given (x, y) -> 8y + x we accessing the xth column, yth row of piecesCode. That is, y tells us how many blocks of 8 to skip, and x tells us where to go within that block.
Comment: I'm old enough it's not obfuscated :(
Comment: It's not necessarily obfuscated.
Comment: I say it's not obfuscated because every software engineer should be as comfortable with the binary system as with the decimal system. For example, it will be more natural to resize the array in question by changing `y << 3` to `y << 4` than by changing `8*y` to `16*y`. That's because 8 and 16 are a quite awkward way of writing down two **round** numbers.
Comment: @Ian, I am with you regarding the Go board.
Comment: specifically, `(y << n) + x` is equivalent to `(y * (2^n)) + x`
Comment: Is there anyone that wouldn't understand that `8 * y` means multiply `y` by 8? Are there people that don't understand that `y << 3` means multiply `y` by 8? Yes, obviously. Additionally, `y << 3` doesn't express what's really going on here but `8 * y` does. It does because it says "skip by 8" whereas `y << 3` says "shift left by 3". It's the former that we want to be saying, and we don't need to use a *less* clear mechanism to express that.
Comment: Guys, it's obfuscated whether or not *every* programmer *should* understand this because it doesn't clearly express the intent. I do *not* disagree *every* programmer should know this. But just because some programmers are use to seeing it this way doesn't mean that there aren't clearer ways to express exactly the same thing. It's obfuscated because it's less clear than the alternatives.
Comment: Who is judging, Jason? You? And how do you know "it's less clear". To me, at least, it is **more** clear, as I see, aha, address arithmetic going on, as opposed to some arbitrary numeric calculation.
Comment: @Jason Just as another data point, I also find this notation clearer than (8 * y) + x, but that's partially because I'm old.
Comment: @Ingo: You just *can not* rationally argue that `y << 3` is a *more* clear way of multiplying by 8 than `8 * y`. *Should* every programmer know that they are the same? Yes. But that still doesn't change the fact that the crystal clearest way to multiply by 8 is to say `8 * y`, not `y << 3`.
Comment: But you can't necessarily argue the converse either. And besides, just because one variant may be clearer (in the eyes of some) doesn't necessarily mean that the other is "obfuscated".
Comment: @IanMcLaird 1D-arrays are more memory efficient and it is quite plausible that a "computer player" must instantiate a heavy lot of board positions in order to find the best move.
Comment: I think you confused "obfuscated" and "canonical".
Comment: I think in a language like java with a pretty smart runtime optimizer, it's fair to call this obfuscated.  If the "pretend" array been 5 elements instead of 8, the coder would have had to multiply or shift *and* add which would be even uglier.
Comment: Yes, @IanMcLaird, but some things never change, like the size of a chess board. And obfuscated it is only for the young folk that deem well known clichees of the elder days "unreadable". Hence, canonical.
Comment: Arbitrary numeric calculation? This is *obviously* row-major addressing, get real. And what would you be doing were this array 17 by 17 and not 8 by 8. We're lucky here it's a power of two. `17 * y + x` is going to be a lot more clear than `(y << 4) + y + x`. Come on.
Comment: @Jason I am arguing that I recognize the pattern `(a << k) + b` better than `(a * n) + b`, the latter one being nothing special. Of course, if it's 17, then I'd not write it as `(a << 4) + a + b`. I am also opposing, on principle, the psychologism in our profession - as if "readable" could ever be anything but a **subjective judgement**. Often used to rationalize a **race to the bottom** (aka, we can only use that parts of a programming language the  weakest prospective team member could understand.)
Comment: Is `1e3` an obfuscated way to write `1000`? The argument is exactly the same.
Comment: @Ingo, in principle, I agree with you, but really bitshift operations are for bit-pattern manipulation, not math (yeah, I know it reduces to the same thing -- intent matters).  Had this been a 19 x 19 Go board (since you brought up chess), then we'd be looking at `(y << 4) + (y << 1) + y + x` instead of `19 * y + x`.  Of course, either of these issues could be cleared up by a nice comment on the "funny-looking" code, perhaps even explaining the choice to use a one-dimensional array as though it were two-dimensional.
Comment: @MarkoTopolnik, and that is precisely the sort of comment I was saying should be in the code ;).  I didn't say it was a bad choice, I was saying it's a choice that should have an explanation.  The next person to maintain your code could be a new graduate without a lot of engineering experience.  Help the poor kid get better by explaining your design.
Comment: @IanMcLaird Ah, if the kid can't see *that* on his own, there's just no amount of comment that's going to save the project from his inept hands. But I've realized that using a full array is wasteful in itself: the whole board position fits into just two `long`s! :)
Answer: (y << 3) means bit shifting 3 times to the left. It's the same as multiplying by 2^3 = 8. So, whole expression (y << 3) + x becomes y * 8 + x.
It should be written in the form y * 8 + x, because it's more readable and very probably there is no performance gain. Premature optimization is the root of all evil. It's better to left such micro optimizations to the compiler (or JVM).
Moreover, board size could be stored in a constant, to have it only in one place:
final int SIZE = 8;
// ...
for (int y = 0; y < SIZE; y++) {
    for (int x = 0; x < SIZE; x++) {
        final String pieceCode = pieceCodes[y * SIZE + x];

y * 8 + x is just iterating over a (logically) 2D table with 8 rows and columns, stored as 1D, with 64 cells.
As a final remark, I would like to point out, that in the given code pieceCodes is an array of Strings...
But in fact, it's an array of piece codes. Not just some Strings. Now, "--" works as some magic state and nobody except the programmer knows, what it means. if (pieceCode.length() != 2) also looks bad. So, there should be an object PieceCode and array will be declared as PieceCode[] pieceCodes. In PieceCode we can implement proper equals() method. If PieceCode is only a state, it can be an Enum. For example EMPTY, WHITE_PAWN, WHITE_QUEEN, BLACK_PAWN, BLACK_QUEEN. Comparing Strings is not as fast as comparing Enums. We also have to watch out to write equals(), instead of ==.
Answer: From the spec:
The value of n << s is n left-shifted s bit positions; this is equivalent (even if overflow occurs) to multiplication by two to the power s.
Answer: << and >> are bit shift operators. In this case, it converts y to binary and "shifts" over 3 places, adding new bits to the end as required
For example, if y was 8, it would have the value of 1000
y<<3 would shift to the left 3 bits, resulting in 1000000, or 64
Answer: The code uses an optimization technique that represents a two dimensional array[m][n] as a one dimensional array[m*n]. Both m and n appear to be 8 here (8-queens, chess, maybe?).
The trick is to transpose index tuples (i,j) to indexes for the one dimensional array.
Most of the time, you do this by multiplying i with n and add j.
Since n=8, multiplication can be expressed in this case by shifting 3 bits left. This conveys the message "We are doing adress arithmetic here on some nicely sized (i.e. in terms of power of 2) arrays.", at least to the non-novices.
Comment: I would guess checkers because `CheckersPiece`. Just a hunch.
Comment: I don't see why everyone assumes shifiting is motivated by optimization. In my code I use it for clarity: to emphasize the binary roundness of the numbers in question. `1<<31`, for example is way simpler, more readable, and more obvious than `2147483638`.
Answer: That is called a bitwise and bit shift operator. Also, check out the wiki.
Summary of the documentation

The Java programming language also provides operators that perform bitwise and bit shift operations on integral types. The operators discussed in this section are less commonly used.
The unary bitwise complement operator "~" inverts a bit pattern. The signed left shift operator "<<" shifts a bit pattern to the left, and the signed right shift operator ">>" shifts a bit pattern to the right.
The bitwise & operator performs a bitwise AND operation.
The bitwise ^ operator performs a bitwise exclusive OR operation.
The bitwise | operator performs a bitwise inclusive OR operation.

Example code:
class BitDemo {
    public static void main(String[] args) {
        int bitmask = 0x000F;
        int val = 0x2222;
        // prints "2"
        System.out.println(val & bitmask);
    }
}

So... What is a bitwise and bit shift operator?
In order to save time and space, I'll simply include this article explaining all operators in depth!
Comment: Seems like a wholly unrelated example, and a bunch of words that describe other stuff.
Comment: Yeah, staying on-topic is a dumb idea. Sorry.
Comment: Hey, I'm just trying to help, though.
Comment: Yep, and that's good. My opinion is that a direct explanation of the actual question, and a link to further supporting documentation is the "correct" answer. It's okay to disagree with that.
Comment: Thank you for noting that, looks like it's not needed now since he got his answer.
Answer: Quick answer, it's an efficient way of multiplying a number by 8 (2^3=8)
Comment: Why it is efficient ?
Comment: @DaveNewton Generally, register shifts are much faster than multiplication. However, also (JIT) compiler writers know this and will replace 8*n by the fastest opcode sequence. Maybe something like `load a, n; add a,a; add a,a; add a,a` is even faster. That being said, for us elder ones the notation `(a << n) + b` is very familiar and readable and it tells us that it is most probably an indexing operation going on (rather than some "numeric" computation). It doesn't hurt the greenhorns if they learn this, too.
Comment: @Michael.M My whole point is that it *is* readable, and very much so. You can't say it's not readable only because there are some dozens of millions of adepts in countries like India, etc. who do not understand it. Why should we adapt **downwards**? Can't they learn it? It's not rocket sience, yet if you follow SO closely you find that many "developers" have not the slightest clue about OS, machine architecture, basic handling of a command line, etc. Once their IDE stops working, they're just out of luck. It does not have to be so.
Comment: @Ingo Hate to disappoint you, but there are a lot of non-Indians who are equally clueless--this isn't about country of origin.
Comment: I really doubt that the shifting is in any way faster than the multiplication by 8. Also, it's way less readable.
Comment: It's unlikely to be significantly more efficient, any more. Back in the day the shift-by-two opcode was faster than than the general multiple opcode, i.e., it was faster to multiply by a power of two by shifting and add than to use multiply.
Comment: If its not more efficient in c I don't how it would be in Java unless you are using a old CPU http://stackoverflow.com/questions/6357038/is-multiplication-and-division-using-shift-operators-in-c-actually-faster
Comment: Maybe it's time for grandpa to learn that the compiler takes care of this. The reason we got into programming is to automate away stuff. Should we also learn assembly just because? No offence mate. I would rather write code that is understandable. Another programmer is after all still a "user" at least of my code, and I see more merit in writing user friendly code.
Comment: @Ingo Depends *entirely* on the processor; look at an assortment of modern processor instruction timings and you'll find this is *often* no longer the case at all, and even when it *is* faster might be barely 1-2% improvement. It's incredibly dependent on architecture.
Comment: @DaveNewton I am only disappointed because you misinterpret me. I said "countries like India" qualified by "there are millions of adepts." - I know firsthand that there are very very knowledgeable Indians, as well as extremely dumbfolded .
Comment: @Ingo Apologies for the misinterpretation--IMO it's just best to leave out *any* possibility of racism; I think it's clear that the sentence is easy to read wrong.
Comment: Yes, please replace *countries like India* with *all over the world*.
Comment: Pages like this exist for people who don't understand "<<"; and for everyone of these pages, how many pages are there for people that need to make (2^3=8) faster because their compiler can't do it? In other words using "<<" creates problems while generally solving none.
Answer: y << 3 means "shifted 3 bits left" ... which is, essentially, another way to do "* 8"
If you do a right-shift (y >> 3), that would be integer divide by eight, but is also useful because the bits fall off the end, and you sort of "drain" the bits if you loop.
It used to be (way way back when) that CPU shift was faster than multiplication, so using "x << 1" was faster than "x * 2". However, that's not true anymore.
I used to see expressions in code like "x << 4 + x << 2 + x << 1" ... which is really "x * 16 + x * 4 + x * 2" or "x * 22".
Answer: http://en.wikipedia.org/wiki/Bitwise_operation ... In Java, all integer types are signed, and the "<<" and ">>" operators perform arithmetic shifts. Java adds the operator ">>>" to perform logical right shifts, but because the logical and arithmetic left-shift operations are identical, there is no "<<<" operator in Java.

Java- for loop using << operator


How can I make window zooming respect auto layout constraints?

Question: To keep things simple, let's say I have a window containing a single view, which has auto layout constraints binding all 4 sides to the window container view with offset 0.  And assume that this view also has a constraint setting its aspect ratio to a constant value.  If I resize the window manually, then then window nicely maintains the desired aspect ratio.  But if I click the little green zoom widget, then the window fills up the whole screen, regardless of the aspect ratio, with part of the view being above the top of the screen.  Is there some way I can make zooming resize the window as big as it can be, without violating auto layout constraints?
I couldn't very well detect this problem in the delegate method windowWillResize:toSize:, because that doesn't tell me which screen it's thinking about putting the window on.  I could try to fix the window size in the windowDidResize: delegate method, at which time I do know what screen it's on, but I'm not sure exactly how to do that without reinventing Auto Layout's wheel.

Apparently someone thinks I wasn't explicit enough, so I'll try again.  Steps to reproduce:

In Xcode, create a new macOS App project using XIB interface.
Open MainMenu.xib and select the window.
Reshape the window to be approximately square.
Using the Attribute Inspector, set the Full Screen behavior for the window to Auxiliary Window.
Drag an Image View from the library and drop it in the window.
In the Attributes Inspector, set the image view to show the NSComputer image and scale axes independently.
Expand the image view to fill up the window content area.
With the image view selected, click the button to add new layout constraints.
Add 5 constraints, binding the 4 sides to the container, and setting the aspect ratio.  (see screen shot)
Build and Run.
Observe that if you resize the window by dragging an edge or corner, the aspect ratio remains fixed.
Click the green zoom widget in the title bar of the window, and observe that the window expands without regard for the aspect ratio constraint, cutting off part of the image.
Comment: Well, that seems odd. If I set the aspect ratio to `1:1`, clicking the Zoom button scales the window to full desktop height, but maintains `1:1` ratio for the width. But... If I use the aspect ratio from your project `381:361` -- or any ratio where the width is greater than the height, such as `381:380` -- zooming scales the window to full desktop, ignoring the aspect ratio. `380:381` on the other hand *keeps* the aspect ratio.
Comment: Hmm... I do very little with MacOS apps, but following your steps and setting the Full Screen behavior for the window to Auxiliary Window, it maintains aspect ratio for me. Did you mean when setting it to `Primary Window`?
Comment: @DonMag No, it definitely does not maintain aspect ratio for me, when the window's full screen behavior is set to Auxiliary Window or None.  I tried it on 2 different Macs, both running Monterey.
Comment: Very curious... here's what I get: https://i.stack.imgur.com/4rIA9.png --- could it be that I have some different default setting? Maybe put that basic project up on GitHub and I can make sure I run the exact same thing?
Comment: @DonMag OK, I put the project [on GitHub](https://github.com/jwwalker/ZoomLayout).
Comment: @DonMag That's a good observation about the aspect ratio being greater or less than 1.  I sent Apple a bug report about the issue, and I've now updated it to mention this.
Answer: I just set up a test project exactly as you specified, and when I invoke the window zoom widget, the window expands and retains its aspect ratio i.e. it works as expected. The only thing I can think of that might be causing your issue: maybe your content hugging and content compression resistance priorities are at odds with your constraints? Mind you, I just left them at the default values and it worked fine. Unfortunately Mac/AppKit development (esp. when using IB) is rife with these kind of odd bugs and weird behaviour, probably because Apple has not given it any love in years, so bugs creep in/fester and they are clearly so DONE with developing UI the 'old fashioned way'. (Using SwiftUI to make a Mac app is just as frustrating, in different ways, so I'll stick with what I know). FYI, I used Xcode 13.4.1 to create this test project. Good luck!
Comment: Did you read the comments about how aspect ratio is involved?  If you used an aspect ratio of 1 or less, that could explain why you didn't reproduce the problem.
Comment: Okay, I see what you mean… definitely looks like a macOS bug. I imagine this will likely never get fixed, zoom is a little-used feature which was de-emphasized in the UI years ago. That doesn't make it right, of course—if the feature exists, it should work correctly. I really wish they'd expand the macOS development team resources and spend an entire year 'doing a Snow Leopard'.


Spring Splitter output to multiple channels

Question: I am using the splitter to split the messages and to pass it to the respective other channels for further processing.
But I wanted to send the splitter output to one channel which will write it into another file. Also wanted to send the splitter output to another channel which will perform some task.
I am able to do the same by using the below, but it doesn't seems to be working if failed to process any of the split record in channel2. Its stopping the process and not writing the remaining records in channel1.
    <int:splitter input-channel="inputchannel" ref="splitter" method="doSplit" output-channel="routingChannel"/>

   <int-recipient-list-router id="customRouter" input-channel="routingChannel"
      <int:recipient channel="channel1"/>
      <int:recipient channel="channel2"/>
   </int:reciepient-list-router>

Is there any other way I can pass it to the separate channels independently.
Answer: The recipient-list-router has an option like:
/**
 * Specify whether send failures for one or more of the recipients should be ignored. By default this is
 * false meaning that an Exception will be thrown whenever a send fails. To override this and suppress
 * Exceptions, set the value to true.
 * @param ignoreSendFailures true to ignore send failures.
 */
public void setIgnoreSendFailures(boolean ignoreSendFailures) {

Or if you wish for XML configuration:
<xsd:attribute name="ignore-send-failures">
        <xsd:annotation>
            <xsd:documentation><![CDATA[
                If set to "true", failures to send to a message channel will
                be ignored. If set to "false", a MessageDeliveryException will be
                thrown instead, and if the router resolves more than one channel,
                any subsequent channels will not receive the message.

                Please be aware that when using direct channels (single threaded),
                send-failures can be caused by exceptions thrown by components
                much further down-stream.

                This attribute defaults to false.
            ]]></xsd:documentation>
        </xsd:annotation>
        <xsd:simpleType>
            <xsd:union memberTypes="xsd:boolean xsd:string" />
        </xsd:simpleType>
    </xsd:attribute>

Comment: Thanks Artem for your response. The channel1 is getting completed though any exception occurred in channel2 if we add ignore-send-failures.. But then the control is not going to error channel.. :(
Comment: Ok. You can place `` channel in between `splitter` and `router`. And add `error-channel` to the router's ``. But then `ignore-send-failure` should be switched off. That way , through the queue, you free splitter thread from the exceptions and it will continue to emit
Comment: Thank you very much Artem. I tried with task executor as below and It worked :)  Hope  and  do the same job? `

`


Would it take less time to learn the guitar fretboard if it were tuned to all fourths?

Question: Does it take less time to learn the fretboard when all strings are fourth apart, EADGCF, and then adjust your learning for the standard tuning of EADGBE ... vs... learning in standard tuning from the start?
Comment: I feel like it would take MORE time to learn all fourths because you'd have to teach yourself everything - there are not existing tools to learn all fourths like there are for standard tuning. Also, you couldn't learn most of the common chord shapes with all fourths tuning because they wouldn't work. Frankly, I can't see how learning all fourths would help at all unless one were going to keep playing all fourths for at least many years.
Comment: you would lose the ability to play barre chords easily
Comment: It's an interesting question, but I'm not sure if it's answerable, that is if there are any people who started learning guitar using all fourths. People most often start with either standard tuning, or open tunings, or maybe drop tunings, but all fourths would seem unusual to me. Perhaps some teacher made such experiment on their student?
Comment: Playing single note tunes *may* be easier, but chords 8will* be more difficult - in comparison. And since guitar is one of very few chordal instruments, it's an unsound idea. And to answer your question - learn wrong first, then re-learn? How could that take less time ultimately? It's twice the job !
Comment: One of the main point of this tuning is that the lowest and highest strings are the same note, and tuning all fourth will defeat this. I think it's really more convenient to have those strings the same note than having the same interval between strings.. Or you can still pick a real instrument instead: the bass ;)
Comment: Why might it take less time to learn that way?
Comment: They didn't have to start with fourths. They would've been frustrated with standard tuning.
Comment: I think Stanley Jordan uses 4ths, and has discussed what benefit he feels he gets from it. I think he started on piano. ( https://www.youtube.com/watch?v=WcHid5cucLo ) Not sure he ever thought *to springboard this* into standard tuning though.
Comment: Or if you primarily play leads them for us a far better option.
Comment: What would really be awesome for single-note playing would be a somewhat smaller instrument tuned in tritones, say D Ab D Ab D Ab. It would have to be smaller than a guitar because most people's hands would otherwise have trouble stretching to play a scale. But the advantage would be that every scale pattern would be easily transferrable across the fingerboard and playable in three different octaves at exactly the same position. Bar chords wouldn't work, but you'd be able to play some open voicings that would be impossible on guitar.
Answer: If you learned to play a guitar tuned in all fourths you will not be learning the guitar fretboard. You will be learning how to play an instrument tuned in all fourths, or an alternate tuning of a guitar. Since your question says that the ultimate goal is to play in standard tuning, tuning in fourths will ultimately delay that goal. An instrument tuned in all fourths would be easier to learn to play from a melodic standpoint because of the consistency of intervals and patterns but this would not be helpful in the long run. First, playing simple open chords would be next to impossible and learning other types of chords would have to be either put on the back burner or completely re-learned once standard tuning is implemented. Second, any scale patterns across all 6 strings will also have to be re-learned, as well as playing intervals between the G and B or E strings. The major 3rd between the G and B strings does complicate things in many ways for guitarists but it also allows guitarists to do things that would not be possible on a 6 string instrument with all fourths tuning.
Comment: Absolutely. +1. It can only **slow** the process down, as re-learning has to occur after. After what? After learning badly! And we all know that 'unlearning' takes longer than 'learning'. That G>B string is part of guitar playing. Surely if all 4ths was better, wouldn't guitars tend to be tuned thus?
Comment: We have to admit it works on bass, but chord playing isn't what basses are renowned for...
Comment: "Since your question says that the ultimate goal is to play in standard tuning, tuning in fourths will ultimately delay that goal."
Comment: I was thinking more in terms of - my 6 string bass is all 4ths, and I used to play with a guy who had an 8 string (F#>F) again all 4ths, but no problem as we tend to play single notes mainly, not chords - which as you know, on guitar, don't work well when it's tuned all in 4ths. It's not a well thought out idea - for beginners.
Comment: Taking off some of the strings would be just as effective - quicker initially, slower in the long term.
Comment: @Tim With 4 out of 5 intervals on the guitar being a 4th you naturally learn to play 4ths tuning on the guitar anyway. You just have to learn to navigate the "speed bump" between the 2nd and 3rd strings :)
Comment: @JohnBelzaguy. Exactly. Oh I found it far far faster and learns 2/3 of the fretboard in about an hour and a half. Oh it's not because of court playing either.
Answer: This question is not really answerable as asked.  There aren't many individuals who first learned on an instrument tuned to all fourths and later learned to play on "standard" tuning as if it were an "alternate" tuning.  If they existed and we had a way to survey a lot of them, we could compare the average time it takes to learn one way with the other.
Instead, think about a couple related questions:

Why isn't standard guitar tuning uniform?
Who does tune a 6-string instrument uniformly?

The short answer to 1. is that it is tied to a series of musical traditions where standard tuning makes for accessible fingerings on chords likely to be used.
One answer to 2. is [some] 6-string bass guitar players, who might use B-E-A-D-G-C.  It does make for more uniform fingerings of scales across the whole neck.  In bass guitar context, chords are much less common (and often limited to dyads).
Also, consider another 6-string (or more correctly, 6-course) instrument, the oud.  In some traditions (e.g. Turkish), it is tuned in fourths, where it fits well with tuning systems that are essentially Pythagorean.  In other traditions it may be tuned even more irregularly than standard guitar-- sometimes even in a reentrant tuning.  In any case the tunings are chosen for musical reasons, not for ease of teaching or learning.
As one other answer has pointed out, there are guitarists using all fourths, and although I didn't watch all 50 minutes of video I do gather that these players are not (at their present stage of practice) learning standard tunes from books or the web.  They're also using more complex chords than standard tuning was meant to support.
Answer: I would compare the idea to one of the most famous educational mistakes in modern history - the ITA [Initial Teaching Alphabet] reading system.
The idea was to standardise spellings, like tuning in all 4ths.
Great idea, until you then had to re-train everybody to spell properly.
I was fortunate to be just too old to have had to go through this, but I know people slightly younger than me who still cannot spell 50 years later.
See i.t.a: a great idea but a dismal failure for more background.
Comment: Infamous, for sure… & yup, about as dumb as the traffic transition period;)) I was lucky enough to miss it, but my younger sister got caught up in it all, it was around the same time as they dumped grammar/secondary & went to the abysmal comprehensive system instead. I got away with that one too.
Comment: 'famous' or 'infamous'? I was teaching at that time, and ignored it completely! Rather like the idea of U.K. changing driving from left to right side of road. The plan was to experiment with lorries and buses on right for the first week. If it was successful, all others could change over after...
Comment: This is an interesting digression, but not actually pertinent to the question.
Comment: Oh well it certainly works a lot faster than anything else I have ever tried. So what is the explanation for that.  And no one is being asked to learn anything new. Just a simpler version to get a jumpstart.
Comment: @MarkDominus - it's an exact parallel. Randy - sure, you'll learn one bit, then have to relearn it. You'll also have to learn standard chord voicing over again. It's just not worth it.
Answer: There are professional guitarists that use an "all 4ths" tuning, Tom Quayle being the example that came to mind. Tom Quayle uses EADGCF tuning, which is most frequently used between 4ths guitarists. An alternative is EbAbDbGbBE, tuning down the lower strings to match the higher, used by Ant Law.
The main benefit of 4ths tuning is that it improves improvisation and consistency between strings by maintaining the intervals. This would improve the ability to memorise and navigate the fretboard, and is beneficial for Jazz guitar especially.
It can however limit the amount of music you can play. Guitar music historically has been built around standard tuning primarily, so there will be a number of that you just won't be able to play using an alternate tuning, phrases from popular songs as well as the traditional open and barre chords. This may prevent you being able to perform certain music and styles in the future (as discussed in other answers).
Video Discussing 4ths Tuning in general, including some of the disadvantages.

Video discussing 4ths tuning with Ant Law.
Answer: I have never heard of anything like that - I would not be so arrogant to say it does not exist, but I am pretty sure there is no significant amount of non-subjective data points to look at regarding time to learning the fretboard.
I believe it is safe to say that all except for maybe an incredibly negligible amount of people have learned the fretboard with the regular style of tuning. Alternative tunings are usually a concept for advanced players, used for musical reasons, not as a tool for beginners to learn easier.
Using the standard tuning means you can pull from a plethora of resources on how to learn efficiently; you can learn all the regular chords and scale patterns "mechanically" (without even knowing what the absolute notes are) and work your way of knowing the actual notes. At the beginning everything is fresh anyways; there is some amount of just learning stuff by heart (i.e. the intervals or absolute names of the open strings).
Didactically, for me the most important thing is to have some sort of "mental anchor" (the open string) and then teach the pupil to learn to infer the rest from that. This works of course well with the hand at the basic position (index finger at 1st fret), which the average pupil is probably spending a lot in, in the first few weeks as finger/hand strength develops.
I would see no reason that this would be faster if the tuning were different.     At the very beginning, there's more rote learning anyways; and in an intermediate state, when pupils can really "grok" the interval stuff, they will probably be used to the idiosyncrasies of the fretboard that it doesn't really matter.
Things get "worse" when not playing at 1st fret - as soon as you introduce moving the left hand around, everything is relative anyways. At this state, the intervals between strings don't really matter anymore - it is much more important to intuitively quickly "know" which note is on 8th fret of the D string without thinking too hard. And in the state that you still need to think about it you'll probably simply infer from 0th, 12th or maybe the popular 5th fret, and probably less often from the parallel fret on an adjacent string.
Answer: A six-string guitar tuned in fourths starting with E would be EADGCF, which would have six different string pitches.  Adding a seventh string at the bottom would make it BEADGCF, which would be seven different pitches.  By contrast, the present tuning uses a repeating pattern of five pitches, and even if one were to add a seventh string, BEADGBE would still only have five different string pitches.  If one used a fanned-fret nine-string guitar to accommodate the wide range, GBEADGBEA would still only be five pitches.
The aspect of standard tuning which is slightly tricky is that while it uses a repeating pattern of five pitches tuned in fourths, the "seam" in the pattern occurs between the second and third strings from the top.  If one recognizes the five-string pattern, however, I would think it easier to learn than a straight fourths pattern.
Comment: Why would learning with a seam be faster. With fourths it's one single two or three-string pattern all the way across depending how you count it.

Instead of CAGED there is one single basic chord form. If you're not playing open chords then fourths is far simpler.

The pattern is that every other string changes by a whole note so you can quite quickly map one pattern. I've found it far far faster.

Imagine you're learning checkers or chess and two rows of the board are moved one position to the left. How could that ever be easier than a perfectly symmetrical pattern?


Do neural networks learn a function or a probability density function?

Question: The question might sound a bit strange because I am new to statistical inference and neural networks.
When in classification problems using neural networks we say that we want to learn a function $f^*$ that maps the space of the inputs $x$, to the space of the outputs $y$:
$$f^*(x; \theta) = y$$
Are we fitting the parameters ($\theta$) to model a non-linear function, or to model a probability density function?
I don't really know how to write the question in a better way. I have read several times both things (probability density function, or function just like that) so therefore my confusion.
Answer: Strictly speaking, neural networks are fitting a non-linear function.
They can be interpreted as fitting a probability density function if suitable activation functions are chosen and certain conditions are respected (Values must be positive and $\leq$ 1, etc...). But that is a question of how you choose to interpret their output, not of what they are actually doing. Under the hood, they are still non-linear function estimators, which you are choosing to apply to the specific problem of PDF estimation.
Comment: @sdiabr actually you *wouldn't* use the threshold if you wanted the network to simulate a pdf - since a pdf can have other values besides 1 and 0. With the threshold it becomes a straightforward classifier.
Comment: The proper way to look at this is that the thresholding is a problem *external* to what is learned from the network.  Not respecting this distinction causes lot's of problems in the applications of ML to real world problems.
Comment: You are not, however, learning about the probability distribution of the unknown coefficients, thus you are not learning about the posterior predictive distribution.
Comment: Yeah okey, I understand. So forgetting aabout the thresholding, then I would be modelling a pdf ? I think i got confused with the thresholding because I read something about modelling  a Bernouilli distribution. However, without the threshold, that's already Bernoilli right? In the case we have only one output node with a sigmoid activation function, that would output 0 or 1 with a probability p or (1-p)
Comment: Yes, I got confused again, thanks @CagdasOzgenc. Let's try again: By using a sigmoid function in the output layer we are directly modelling a pdf , right? following whatever distribution it may learn to follow.
Comment: Yah, that's right.  You're using the network to learn the parameters of a distribution (often Bernoulli), usually by maximizing the log-likelihood of that distributional family.
Comment: Okey @Alex, thanks. So if for instance we have a binary classification problem, and the output layer is a sigmoid to which we apply a (0.5) threshold so that the output prediction becomes either 0 or 1, then we would be modelling a probability density function? Something like P( y={0,1} | x )
Comment: What do you mean @BrashEquilibrium ? . As Matthew said, the network is learning the parameteres of a probability distribution over Y (mapping X to Y). I don't understand what do you mean by "you are not learning about the posterior predictive distribution", isn't that the learned probability distribution over Y?
Answer: Generally Neural Networks are not used to model complete probability densities. Their focus is to just model the mean of a distribution (or in a deterministic situation simply a non-linear function). Nevertheless it is very possible to model complete probability densities via Neural Networks.
One easy way to do this is for example for a Gaussian case is to emit the mean from one output and variance from another output of the network and then minimize $-log N(y | x ;\mu,\sigma)$ function as part of the training process instead of the common squared error. This the maximum likelihood procedure for a Neural Network.
Once you train this network everytime you plug an $x$ value as an input it will give you the $\mu$ and the $\sigma$, then you can plug the entire triplet $y,\mu,\sigma$ to the density $f(y|x)\sim N(\mu,\sigma)$ to obtain the density value for any $y$ you like. At this stage you can chose which $y$ value to use based on a real domain loss function. One thing to keep in mind is that for $\mu$ the output activation should be unrestricted so that you can emit $-\inf$ to $+\inf$ while $\sigma$ should be a positive only activation.
In general, unless it is a deterministic function that we are after, the standard squared loss training used in neural networks is pretty much the same procedure I described above. Under the hood a $Gaussian$ distribution is assumed implicitly without caring about the $\sigma$ and if you examine carefully $-log N(y|x;\mu,\sigma)$ gives you an expression for squared loss (The loss function of the Gaussian maximum likelihood estimator). In this scenario, however, instead of a $y$ value to your liking you are stuck with emitting $\mu$ everytime when given a new $x$ value.
For classification the output will be a $Bernoulli$ distribution instead of a $Gaussian$, which has a single parameter to emit. As specified in the other answer this parameter is between $0$ and $1$ so that output activation should be accordingly. It can be a logistic function or something else that achieves the same purpose.
A more sophisticated approach is Bishop's Mixture Density Networks. You can read about it in the frequently referenced paper here:
https://publications.aston.ac.uk/373/1/NCRG_94_004.pdf
Comment: Should change "the entire triplet y,μ,σ" to "the entire triplet x,μ,σ" ?
Comment: @moh no. x is given and will not appear in the density.
Comment: Ouch you beat me to it  I wanted to cite Bishop's MDNs...there is also another way to get Neural Networks to output pdfs, which is of course the Bayesian paradigm. I'll write an answer on that.
Comment: Another fun paper on mixture density networks, used to predict surfing conditions: https://icml.cc/Conferences/2005/proceedings/papers/015_Predicting_CarneyEtAl.pdf
Answer: My dissenting answer is that in most impressive practical applications (those where they get the most coverage in the media, for instance) it's neither the function nor the probabilities. They implement stochastic decision making.
On the surface it looks like NN are just fitting the function, queue the universal approximation reference. In some cases, when certain activation functions and particular assumptions such as Gaussian errors are used or when you read papers on Bayesian networks, it appears that NN can produce the probability distributions.
However, this is all just by the way. What NN are intended to do is to model decision making. When a car is driven by AI, its NN is not trying to calculate the probability that it has an object in front of it, then given that there is an object to calculate the probability that it's a human. Neither it is calculating the mapping of sensor inputs to various kinds of objects. No, NN is supposed to make a decision based on all the input to steer sideways or keep driving through. It's not calculating the probability, it's telling the car what to do.
Comment: This makes it sound like you're talking about reinforcement learning finding the decisions under various circumstances that optimize some criterion (which might be exactly what you intended).


Create User (Bash Script) through Php form

Question: Can anyone help me on this simple thing? I have a php registration form that communicates directly with MySQL database and adds users when someone fulfils the form. The problem starts when I want to also create a home directory for each user (with a bash script) that makes this registration.
What I've done: I created a bash script
#!/bin/bash

sudo useradd -m /home/$1

Whatever parameter I made on this simple script until now didn't work in order to create the user's home directory.
Comment: what kind of 'users' are they who get a home directory on the server?
Comment: Is apache (or `www-data`) a sudoer?
Comment: I hope your users can't input names like `user -g0` or `user -Gsudo` or you'll have surprises! Anyway, my message is: Use More Quotes!
Comment: to accomplish that, you'll probably also need something like `suexec` on your apache server
Answer: Problems:

Explicit home directory: Your command line syntax is wrong.  Try the following instead:
sudo useradd -m username
or
sudo useradd -d /home/username -m username
Is PHP a sudoer? Only certain accounts are able to execute sudo.  Check that the account PHP runs under is listed in the sudoers file.  You can usually easily the file with
visudo
Is PHP chroot-ed? If so, you may not be able to create new linux user accounts from scripts with any reasonable code.

A working test
The following worked for me under Debian (without sudo).
newuser.sh
#!/bin/bash
useradd -d /home/$1 -m $1

newuser.php
<?php
  exec('/bin/bash /var/www-scripts/newuser.sh joe');
?>

test invocation: php newuser.php
If you can perform the same tests (but add sudo as needed), then the only reason it would not work when invoked by your web server is a security problem.  That could either be a chroot environment, or lacking sudoer privilege.
Additional resources
You can see how other people have solved this problem by reviewing the following:

http://www.weberdev.com/get_example.php3?ExampleID=3766
http://www.linuxforums.org/forum/programming-scripting/176031-solved-crafting-php-script-create-unix-user.html
Comment: no nothing again :(
I also used the sudo visudo command

www-data ALL=(ALL) NOPASSWD: /var/www/fredehosting/adduser.sh
Comment: @misthe Have you confirmed that PHP runs under www-data? Sometimes PHP is configured to run under a different account for security reasons -- particularly if serving scripts from multiple users.
Comment: well after looking it more carefully i think that the request might not works correct from my php. form, that's why the bash script not executed  !!!
Comment: @misthe Ok, it sounds like the problem is solved. Hopefully I was at least helpful with the command line stuff. :-)
Comment: to be honest No i type the command from my PhP like this and can create the User. I also try it the shell_exec the same problem ..    exec(" /bin/bash /var/www/fredhosting/adduser.sh $username");
Comment: @misthe It might be that your PHP is being run in a chrooted environment.  See my edited answer which has a lot more detail, and links you will find directly relevant.


How "hard" to read is this rhythm? A rhythmic comparison

Question: I've recently heard a rhythm that sounded like this

It seems slightly tricky to play it perfectly, so I wonder if I could somehow improve this writing to make it more natural and "readable". For example, what if I simply wrote

and added some rubato in the last two notes? Could that mimic the first rhythm? Essentially I want to slow down the second note a slight bit but not lose tempo.
What would be the best approach here?
Edit: Following @endorph's answer, I realised these rhythms are actually identical, making the question slightly pointless. However, if you follow the linked audio, I would gladly hear your opinion on how to transcribe that particular rhythm.
Comment: If you don't want to write straight eight notes, why don't you prefer the rhythm suggested to you already in this answer: https://music.stackexchange.com/a/111935/63781 which seems to be more accurate?
Answer: Minor nitpick: in your first example, the semiquaver should precede the minim. That will improve readability:

Major nitpick: The two rhythms are identical.
A crotchet triplet can be subdivided into 12 semiquavers. We're dividing two beats into 12 equally-sized divisions. The first example splits them into a group of 3 and a group of 9; that is, 1/4 (3/12) and 3/4 (9/12).
The second example also does that, but using quavers.
If you put them into a notation program and play them back, they should sound identical.

Philosophical aside: The point of notation is to communicate.
There are many styles of music where an instrument might play slightly ahead of the beat, or behind the beat. There are many other styles where the tempo itself is very fluid. In these cases, you don't want to notate stylistic choices too precisely. It's too hard to read.
As an example, I'm currently transcribing a choir piece. There's a ridiculous amount of rubato, pauses, and other shenanigans. Almost none of that is in the actual notation, beyond a "rubato" direction at the start. That's sufficient to communicate. Anything more detailed would likely harm the performance.
Notation is designed for a human performer, not a computer. We don't try and notate every nuance of a performance, and we expect the performer to understand the piece sufficiently to reproduce stylistic details that are not explicitly notated.
Comment: @samwolfe as a more general principle, you can keep in mind that dotting a note has the opposite effect of triplet-ing it. So a dotted note in a triplet is the same as the note without either of these modifiers.
Comment: You're right, these are the same! I should have noticed that, I feel embarrassed now haha Thank you so much for the wonderful answer. I agree with you and I like the idea that "overnotation" can harm the performance, I should definitely be careful with it. Btw, if you're curious about the audio source I was basing my writing on, take a look here: https://www.reddit.com/r/Composers/comments/m6ljgn/how_would_you_write_the_section_in_blue_listen/
Comment: The correct  way to notate this is OP's second example. Anything else is not  'overnotating', it's obfuscation.
Comment: @PiedPiper Definitely, in this specific case. I was trying to make the answer slightly more useful in the general case as well.
Answer: I think a dotted quarter followed by an eighth tied to a quarter would be much easier to read. This doesn't break up the basic quarter-note pulse. The performer (as noted by endorph, supra) will add any subtle rhythmic changes, such as rubato, depending on the style of the music (or the performer's mood which always happens.)


How does adding a new value to a set of data affect the standard deviation?

Question: For a given set of $n$ numbers with standard deviation $s$, it is my understanding that adding numbers that are far less than $s$ from the average will always reduce the variance.
1) Does this rule always apply? No edge cases?
2) Is there a formal proof?
Comment: Let's save I have the following set of numbers: {1,3,5} the mean is 3 and the standard deviation is 2. for my understanding, adding another number to the set which is far less than 1 standard deviation from the mean (for example: 4) will decrease the variance. I'm asking whether this rule always applies. And also if there's a formal proof.
Comment: The variance of $(1,3,5)$ is $8/3$, not $2^2=4$.  If you narrow the context beyond what is stated in the questions and add assumptions, such as that these values represent three independent draws from the same distribution, then an *unbiased estimator* of that distribution's variance is $8/2=4$ and its square root is $2$.
Answer: Without any loss of generality we may (by using the mean as the origin and the standard deviation as the unit) choose units of measurement in which the $n$ numbers are $x_1, x_2, \ldots, x_n$ with $\sum x_i = 0$ and $\sum x_i^2 = n$. The variance and standard deviation are both $1$.  Let the new number be $x_0$.  The change in variance is found by subtracting $1$ from the variance of all $n+1$ numbers:
$$\eqalign{
&\frac{1}{n+1}\left(x_0^2 + \sum_{i=1}^n x_i^2\right)  - \left(\frac{1}{n+1}\left(x_0 + \sum_{i=1}^n x_i\right)\right)^2 - 1\\
&=\frac{x_0^2}{n+1} +  \frac{n}{n+1}  - \frac{x_0^2}{(n+1)^2} - 1\\
&=\frac{1}{n+1}\left(-1 + \frac{n}{n+1}x_0^2\right).
}$$
This will be negative if and only if $n x_0^2 \lt n+1$. Its sign does not depend on the units of measurement. Thus, the variance will decrease when $x_0$ is within $\sqrt{1+1/n}$ standard deviations of the mean, it will increase when $x_0$ is further than this from the mean, and will stay the same otherwise.

Note that the variance of $n$ numbers is the mean squared deviation from the mean.  It is not multiplied by $n/(n-1)$ for a bias correction, because nothing is being estimated: these are descriptive statistics.  However, if you do wish to use $\sqrt{(n-1)/n}$ times the standard deviation in the formulas, a little bit of algebra will show that a similar conclusion holds: the threshold between decreasing and increasing the variance is $\sqrt{1+1/n}$ times the "corrected" SD.
Comment: I may be mistaken, but I think the final expression in the last line has an extra factor of $n$ in the numerator.
Comment: @Don You are not mistaken: thank you for catching that.  I will remove the extra $n.$  Fortunately, that does not change any of the subsequent analysis or conclusions.


When to use a new index in Graylog (Elasticsearch)?

Question: I have been searching for days now to find a good explanation on how indices are used by Graylog/Elasticsearch and when to create a new one. There is a lot of info about sharding indices but not much about the indices themselves apart from that they are a set of settings for how much data to retain and how to mange them, but not why. (or so it seems to me)
Background:
We are using Graylog 4.0 with Elasticsearch 7.10 and MongoDB 3.
We try to centralize the logs from 6 warehouse locations (all a few hundred km apart from on another).
Each has 6 to 20 RFID gates which each have a log. Each gate has its on connector middleware to a central controller middleware and all of those have logs.
Then there is the controller of the automated warehouse 'AWMS', WMS server, ERP server and their frontends.
We also consider to collect at least some of the events from the Windows Eventlog of the servers those services run on.
Usually we need to analyse a problem in one subsystem so need to search one of those logs. Occasionally we need to look at the whole flow from RFID gate to AWMS, WMS and ERP.
At the moment I consider having a stream for each of those logs and using the relevant streams in the search. (or is that approach already flawed, if so why?)
Questions:

Is an index set in Graylog just the settings about the retention strategy?
What impact does it have if I have a lot or a few indices?

in Elasticsearch Index Model it sounds like shard sizes and their distribution have the main impact on search performance, and indices are just a framework to manage the shards

How many index sets should I have for my use case?

Multiple per stream?
One per stream?
One per location?
One per subsystem?
One per retention time or size interval?
One global one?
Does it matter from a performance point of view?

Where can I find more information about this stuff, that explains the 'Why', not just the 'How' to mange indices? (I have been looking at both the Graylog index model, Elasticsearch index model, Elasticsearch index templates)
Answer: Is an index set in Graylog just the settings about the retention strategy?
Don't forget that an Index Set has a direct impact on Indices in the underlying ElasticSearch infrastructure, you should take that into account because ElasticSearch is all about Indices and their Shards (data distribution, replica,...).
Data Type and Fields are a thing too: you can't (shouldn't) have the same field with mixed data type in the same Index Set (e.g if the field device exists as Integer because System1 uses a device number but System2 requires the type Text for this field because the device identifier is a string, then you should either store everything as string or create a separate index set to keep both datatypes and their respective benefits under the same field name).
That's typically the reason why you probably don't want to store Windows Logs in the same Index Set that anything else (apply this to your use case, this may be true for your ERP/WMS data sources?...) because they can easily lead to hundreds of differents fields (and it's recommended to avoid exceeding the 1000 fields per index limit).
So, no, it's not just about the retention strategy. As a starting point for your reflection I recommend that you consider grouping various data source types in their Index Set (An Index Set for Windows Log, another one for Linux servers, another one for the firewalls for example, because it makes sense from a datatype point of view).
What impact does it have if I have a lot or a few indices?
It depends on your ElasticSearch infrastructure, and "a lot" is undefined... take a look at Sizing ElasticSearch and Size your shards. Keeping in mind what kind of queries you'll perform and over which time range may help to find the right balance between index size and the number of indices ElasticSearch will have to query to fulfil your request.

Unfortunately, there is no one-size-fits-all sharding strategy. A strategy that works
in one environment may not scale in another. A good sharding strategy
must account for your infrastructure, use case, and performance
expectations.[...]

How many index sets should I have for my use case?
The stream is configured with one index set, you can't set multiple index sets for one stream. Regarding the other points, I already answered above.
However, note that you can configure multiple Streams on the same Index Set, this is very useful if you want to use these streams with the same underlying data and just want to restrict access to a subset of logs for certain users: you can route messages based on the conditions you want between various streams and if those streams all shares the same Index Set you'll not duplicate the messages.


dispatch function event from application to component

Question: I will need to execute a function in a comp1.mxml from main.mxml through event, I found it difficulty to understand and unable to get it work. Suppose,
main.mxml
public function run():void {
//call a function in comp1.mxml
}

and in a comp1.mxml:
public function runComponent():void {

}

Is metadata is need in this case and how to make it work?
Answer: It really depends what you're trying to do, but how it works is that the main app just calls the public function on it's children and not using event.
The other way would be to use an application framework like Parsley, RobotLegs or Swiz so that you can do those kinds of 'connections', but that might not be desirable in this case.
So yeah, I think what you want to do is something like this:
<s:Application creationComplete="comp.runComponent()">
   <comp:Comp1 id="comp" />
</s:Application>

Comment: Wow! thank you, to think it took me 6 hours just to get a simple answer, didn't know about this. How did you know it?
Comment: It's fairly basic.  This is OOP with a view (which is Flash essentially) but done in an xml way (Flex).
Comment: Done a lot XML stuff in Flex too too especially MusicXML
Answer: The main goal of event model is to implement Observer pattern to provide low coupling between components. Lets we have a component called main.mxml which contains comp1.mxml. So main.mxml knows about comp1.mxml and it is normal. main.mxml can call public methods of comp1.mxml without problem.
The event model gives us a possibility for comp1.mxml to not know about main.mxml. main.mxml subscribes to comp1.mxml events and comp1.mxml fires them calling methods of main.mxml without coupling.
According to your question you want to do something opposite. I think it is not a proper way. Do not use events to call methods of comp1.mxml from main.mxml. Just call runComponent() directly the following way:
public function run():void {
    myComp1Instance.runComponent();
}

Comment: Yes, I missed this part. But have you had any experience with as3signal?
Comment: I have no practical experience with it. What about me personally I see no reason to have another event model as far as AS event model is native. Anyway as3signals have the same base conception (implementation of Observer pattern). So my answer is valuable in case of using as3signals.
Comment: I will give a try for DAW workstation, I personally still skeptical of using MVC even when RobotLegs are more popular. If by separate components into different .mxml/.as can do the same?
Comment: Observer (as many other basic design patterns) is applicable to AS-MXML components without any problem.


Erro de sintaxe PostgreSQL usando chaves

Question: Estou com dificuldade para entender o porquê do pgadmin estar apontando erro de sintaxe na minha query.
select
    first_name,
    coalesce(to_char(avg(p.amount),'99.99'), 'nnn') valor_medio
from
{
select
    c.first_name as nome_cliente,
    c.last_name as sobrenome_cliente,
    to_char(avg(p.amount),'99.99') as media_valor,
    s.first_name as nome_funcionario,
    s.last_name as sobrenome_funcionario
from
    payment p
    left join customer c on c.customer_id = p.customer_id
    left join staff s on s.staff_id = p.staff_id
} as
    tmp
    left join staff s on c.staff_id = p.staff_id
    where media_valor > 1

Essa query ainda está em formulação, mas aqui nesse ponto já está dando erro. Na mensagem do erro vem o seguinte:
ERROR:  syntax error at or near "{"
LINE 4: {
        ^
********** Error **********

ERROR: syntax error at or near "{"
SQL state: 42601
Character: 21

Já olhei diversas vezes na linha, mas ainda não consegui identificar o que está errado. Fiz uma questão muito parecida com essa, porém ela não apresentou tal erro. Eu queria saber qual o erro e o porque do mesmo estar sendo apontado.
Comment: De onde você tirou essas chaves?
Comment: cara, sinceramente não acredito.... não sei como as troquei por parenteses. Pior que fiz isso repetidas vezes, e a questão anterior usei parenteses. De fato, muita falta de atenção. Passou despercebido mesmo.
Answer: SQL não possui chaves em sua sintaxe. Use parenteses:
select
    first_name,
    coalesce(to_char(avg(p.amount),'99.99'), 'nnn') valor_medio
from
(
select
    c.first_name as nome_cliente,
    c.last_name as sobrenome_cliente,
    to_char(avg(p.amount),'99.99') as media_valor,
    s.first_name as nome_funcionario,
    s.last_name as sobrenome_funcionario
from
    payment p
    left join customer c on c.customer_id = p.customer_id
    left join staff s on s.staff_id = p.staff_id
) as
    tmp
    left join staff s on c.staff_id = p.staff_id
    where media_valor > 1

Coloquei no GitHub para referência futura.
Comment: Já é a resposta correta, foi muita falta de atenção minha, não tinha reparado que havia trocado os parenteses (incrível isso)


Confusion related to the volume of a solid of revolution

Question: Well, I've done several excercises about calculating the volume of a solid of revolution some time ago and I don't remember how I got the results of some of them.
The first says "Find the volume of the solid generated by rotating the region bounded by $y=x^2 -4x$ and $y=0$ about $x$ axis".
What I've computed here is $V=\pi \int_{a}^{b}R^2 -r^2 dx\ $, where $a=0$, $b=4$, $r=0$ and $R=x^2 -4x$, so I got $\frac{512}{15} \pi$.
But then, there's another problem that says "Find the volume of the solid generated by rotating the region bounded by $y=x^3,$ and $y=4x$ in the third quadrant about $y=8$".
Here, I used the same formula but I wrote $r=8-x^3$, $R=8-4x$, $a=-2$ and $b=0$. And that is what I don't understand. Why $r=8-x^3$ instead of $r=8+x^3$? Because there are 8 units, and then you have to go to $x^3$.
And the same happens with $R=8-4x$ instead of $R=8+4x$.
Or, at least, could I write $R=16-4x$ and $r=16-x^3$? Because there are 16 units minus the functions.
What's the difference with the first activity?
Comment: Note that $x^3$ is *negative* in that quadrant, so $8-x^3$ is adding the distance to the graph of $x^3$.
Comment: @GerryMyerson so what I did in the first activity is wrong?
Comment: $x^2-4x$ is negative for $0<x<4$, so, yes, technically, what you did was wrong; you should have used $R=4x-x^2$. But since $R$ only comes into the volume formula as $R^2$, it made no difference to the answer you get.
Comment: Is this a trick question? The graphs of both $y=x^3$ and $y=4x$ lie entirely in the first and third quadrants. I don't see any area they enclose in the fourth quadrant.
Comment: @David, good point. I took it to mean 3rd quadrant.
Answer: Let's consider a concrete example. Let $x=-1.$ This is midway between your $a$ and $b$ so it's certainly relevant.
For the curve $y=x^3,$ at $x=-1$ you have $y=(-1)^3=-1.$
So you are correct when you say you want to measure the inner radius by going from $8$ to $0$ and then the additional distance from $0$ to $x^3,$ because $x^3=-1.$
In this particular case the radius is $9.$
OK, so let's try $8+x^3$ as the "additional distance" intuition might suggest.
Since $x^3=-1,$ we find that $8+x^3=8+(-1)=7.$
But we already determined graphically that the correct radius is $9.$ So "additional distance $\implies$ use addition" is a faulty intuition.
On the other hand, $8-x^3=8-(-1)=9.$
So subtraction gives the correct answer after all, even when the $y$ values are on opposite sides of the $x$ axis.
The key takeaway for me is: Subtraction always gives the distance.
That's because $p-q$ is precisely how much we have to add to $q$ in order to arrive at $p.$
To be a little more rigorous we should say $p-q$ always gives the distance or the negative of the distance between $p$ and $q,$ because whether you get a positive or negative negative number depends on whether you list the greater number first.
But if you're only going to use the square of the distance then the positive/negative distinction is erased by the squaring.


Create a new link stye in Typo3?

Question: Is there a way to add a new style to the Insert Link dialog in Typo3?
Currently they are "internal-link", "internal-link-new-window", or no style.
I have tried putting various things in the Page tsconfig with no results at all...
I found this on another site which looks like it does what I want but I can't get it to do anything:
RTE.classesAnchor {
  tollerLink1 {
    class = button
    type = page
    titleText = Button
  }
}

RTE.default {
  classesAnchor:=addToList(button)
}

Comment: yes it is... https://docs.typo3.org/typo3cms/extensions/rtehtmlarea/DefaultConfigurations/Typical/Index.html
Comment: @biesior How do you edit/where do you find that part of tsconfig?
Answer: In your TsConfig (Home Page Properties - Resources - Page TSConfig)
RTE.default.buttons {
link.properties.class.allowedClasses := addToList(internal-link-new-window)
}

Comment: Is it possible to do a similar thing but to add a custom Image Position Option?

Create a new link stye in Typo3?


why are errors normal in OLS?

Question: In maximum likleihood, we believe that the y-variable is conditionally normally distributed. So this means that errors are also normally distributed.
In ols regression, things seem to be more algebra/geometry driven. I am trying to fit a line of best fit  between some points. I have done this in high school in my vector algebra class ... and there was never any mention of normal distribution in fitting a line of best fit.
So how come the errors in OLS are needed to be normally distributed?
Comment: Hi: They only need to be normally distributed if you want to do inference and hypothesis testing. You can minimize the sum of the squared errors without the errors being normally distributed and still get a line of best fit.
Comment: They are not (If by OLS you mean optimising a line to minimize the sum of squared residuals)
Comment: Notice that, in the MLE framework, you are maximizing a likelihood so you need a likelihood function. The assumption of normally distributed errors results in the likelihood function. So, the two frameworks give the same coefficient estimates but under different assumptions.
Comment: thx! just to confirm ... ols does not need normal distribution errors?
Comment: can you explain why they need to be normal for hypothesis test and inferences?
Comment: The duplicate asks a same question in a negated form. "Why are errors normal in OLS?" versus "Why aren't errors normal when it is not in OLS?".
Comment: Similar questions/answers exist as well about the issue whether the normal distributed errors are needed for OLS to be used. Answer: normal distributed errors are not needed. So the premise in the question is not right. (example: https://stats.stackexchange.com/questions/509924/)
Comment: No one has quite said this yet, but maximum likelihood is about maximizing whatever likelihood function you postulate. Normal errors are just one example. So the first paragraph of the question confuses a particular if often applied example with a much more general idea.
Comment: @jwolof the usual tests derive the distribution of test statistics under H0 for an assumption of iid normal errors (plus some additional assumptions). This gives exact significance levels. In large samples, significance levels may be pretty close though, even without normality. Even in small samples, you don't *have* to assume normality, you can derive tests under other assumptions. Or there are approximate nonparametric tests.
Comment: Hi: When you  ask "ols does not need normal distribution errors", it depends on what part of OLS. Obtaining the coefficient estimates doesn't require normally distributed errors. But testing any hypothesis or calculating confidence intervals often use  the assumption of normally distributed error terms. So, ols is kind of a vague term.
Comment: nick: what you say is absolutely a good point. But he was referring to minimizing the squared errors of the fitted line versus maximum likelihood with normally distributed error terms so that's why I replied in the manner I did.
Answer: In OLS, the errors do not have to have a normal distribution or even any particular distribution at all.
All OLS does is solve the correspondence:
$$
\hat\beta_{OLS}\in\\
\underset{\beta=\left(
\beta_0,\beta_1,\dots,\beta_p
\right)}{\arg\min}\left\{
\overset{n}{\underset{i=1}{\sum}}\left(
y_i-\left(
\beta_0+\beta_1x_{i1}+\dots\beta_px_{ip}
\right)\right)^2
\right\}
$$
(I say that it is a correspondence instead of an equation because there does not have to be a unique solution $(\arg\min)$, such as if two features add up to a third.)
However, when you assume $iid$ Gaussian errors, the maximum likelihood estimate and OLS solution are equal.
That is the link.
Comment: +1.  Viewing OLS as a gaussian glm is a popular error, but it is very freeing to understand that OLS is much more general than that with **very** desirable properties.
Comment: ok! so errors dont have to be normally distributed in OLS regression? this means i dont need to do all sorts of tests to see if this is true?
Comment: I am still trying to understand .. imagine i do want to check if the errors are normally distributed ... I get the errors from the regression model ... and then see if these errors are normal?
Comment: @jwolof No need to check for normality.  The other assumptions of OLS are more important than the distribution of the errors.
Comment: @jwolof the assumptions about the normal distribution are needed (more as a sufficient condition and not so much as a neccesary condition) for inference about the estimates like computation of p-values or confidence intervals.
Comment: @demetri I presume by *very desirable properties* you are referring to the estimators being BLUE. Thats fine when linear estimators are reasonable - why not use the best of them? But sometimes all linear estimators are poor. I see many people get captivated by the B without considering the suitability  of the L
Answer: As was mentioned by several commentators, ordinary least-squares does not require normal errors. Only when you want to say something about the sampling distribution of the OLS estimator in finite samples, normality needs to be assumed or else the estimates are not necessarily t-distributed.
To some extent, though, we're splitting hairs. The negative log-likelihood, which is being minimized to obtain $\hat{\beta}_{MLE}$, is algebraically identical to the least-squares objective function whose minimization leads to $\hat{\beta}_{OLS}$. If you further don't take the normal likelihood "too literal" but rather understand it as a second-order approximation of the "true" likelihood, you've pretty much eliminated all conceptual differences between OLS and (quasi)-MLE.

why are errors normal in OLS?


Basic tutorial on branches (specific instructions for Mercurial - Windows)

Question: I'm very new to this version control business and slowly learning my way. I've learned how to create a repository and to commit changes to it.  The story right now (for which I think version control is perfect, though I'm not sure the best practice) is this:
I have software A. It is generic.
I need to modify 2 files in the codebase for Company B.  This will make it Software B.
That's the ONLY change I need to do; after that I just want to continue working on A as if Software B had never existed.
What is the best way for doing this?  Just exporting Software A, modifiyng it and sending it to the client?  Working within the repository, committing, and then "backing out"?  I've tried fudging with the close branch and branch but either I'm too dumb to get it to work or its broken (I keep getting "HEAD ALREADY CLOSED" or something).
Any pointers to tutorials about this would be helpful - and I really stress, as annoying as it may be, I'd like help on how to do this from within the tortoise GUI on Win7, NOT the command line please.
Comment: I'm kind of confused... Your title speaks of Mercurial but the question is about SVN, which one is it ?
Comment: sorry, fixed. i was using SVN as a synonym for version control system. ouch.
Comment: using command line, you'll be much more protuctive.
hg branch SoftwareB
hg commit -m "Changes to client B"
hg up default
Comment: You **must** to read Steve Losh articles about different branching strategies - named branches is just one (mostly mentioned) method from 3 total
Answer: OK. You can and have really use Mercurial branches, at least one additional branch per client

Don't close customers branches
Use distinctive names

I need to modify 2 files in the codebase for Company B. This will make it Software B.

Edit files, save changes.

Start commit procedure, i.e in commit pane click on "Branch: default" text (which works like button really) and in this form select 2-nd choice "Open new named branch", select name of branch, press OK. This effectively change branch for this (still unfinished) commit

Enter commit message, press Commit button (see Right-Top on Shot2), confirm creating new branch
After commit workbench window  will show you one more commit, and revision 1 (in my example) is from different branch Cust1 ("Branch" column content and green label in changeset "Description"), revision 0 still in default and we are in active revision 1

When return to mainline is needed - RClick on needed (latest in default branch?) changeset in  changeset-list and "Update" from conext-menu - we change the point, in which our WC mirror repo, to some previous state (checked by file-content verification)

Fix base code, commit without touching options

If we have change customer's version - update to latest cset in his branch

edit and commit
Comment: this is great and the screenshots are perfect. Thanks for the effort!
Comment: Merge Branches in another long story (without me, pls)
Answer: I think the best is to create a named branch for your changes. It will be more flexible if you need to do some later changes for the B client. The following steps should be fine to do this :

Create a new branch on your repository. This SO question should help if needed : How to branch with TortoiseHG
Do the changes you need to do
Commit them in the new named branch
Switch back to the default branch
Forget about the branch you created before (You can also close it if needed)

The following links can help you :

http://blog.caraulean.com/2011/03/09/working-with-named-branches-using-tortoisehg-2-0-illustrated-workflow/
TortoiseHg and multiple branches in one repo
Comment: By "switching back" you mean just make the general changes, then change the branch again to default and click "commit"? there's no reason to "close branch", right?
Comment: You must change the branch to default **after** committing the changes. Have a look a the first link provided, it shows everything with screenshots. And there's no real reason to close the branch, it's only an "aesthetic" thing


Scheduling unpublish too complex for existing modules

Question: I need a specific node type to automatically unpublish 3 months after publishing, but the date of unpublishing needs to remain constant even if the user unpublishes and republishes the node, unless the date is passed in which case it should start again.
Whenever the timer is reset a notice should be sent to the admins, and the date of scheduled unpublishing should be editable by the admins.
Needless to say this is too complex for any current modules, and when I think of writing a module to do it I don't know how to use the drupal api to schedule things with cron, or how to create an administration settings interface to handle the unpublish dates.
Answer: Drupal Scheduler will provide the proper infrastructure. Then in a hook_form_FORM_ID_alter(), you can set the date as follows:
global $user;
$roles = $user->roles;

$plusThreeMonths = date("Y-m-d H:i:s", strtotime("+3 months"));
$form['scheduler_settings']['unpublish_on']['#default_value'] = $plusThreeMonths;
// Disable setting of unpublished date unless admin or user 1
if ($user->uid != 1 && !in_array('administrator', $roles)) {
  $form['scheduler_settings']['unpublish_on']['#disabled'] = TRUE;
  $form['field_package_winning_bid']['#disabled'] = TRUE;
}

Then if you need to update the unpublish date, you can use a function similar to the following:
function _republish_node($nid, $time) {
  $node = node_load($nid);
  // Add time to the publish date
  $unpub = date("Y-m-d H:i:s", strtotime($time));  // pass in a string like "+2 weeks"
  $node->unpublish_on = strtotime($unpub);
  // Set published to true
  $node->status = 1;
  node_save($node);   // Re-save node with updated status
  scheduler_node_update($node); // update publisher fields
  // Add watchdog or other method to alert admins (or use rules)
}

Comment: Ah so I use a custom module to stop the user from messing with the unpublish dates? The lack of permission control on sheduler was the reason I didn't want to use it.
Comment: Actually the module does come with "Schedule content publication" permission, but there's nothing to lock that date down like you want. Actually I found the module to be very solid and would recommend it.
Comment: All right, I'll base my module off what you've shown here, thanks!
Answer: Checkout the module scheduler, This module allows nodes to be published and unpublished on specified dates. If you want to do any other associated tasks related to publishing and un publish of nodes like sending mails etc can achieve by rules


What is the Net Run Rate for a Forfeit Match?

Question: Can you please let us know how the ICC calculates the "Net run rate" for the both teams, when one team decides to forfeit the match by not showing up?
We would like to know what the "Net run rate" awarded to the team that showed up (who are declared as the winners) will be.
Answer: Section 21.10.5 of ICC Cricket World Cup 2015 Playing Conditions covers this situation.

In circumstances where a match (and the points for such match) is awarded to a team as a result of the other team's refusal to play, either by the umpires in accordance with Law 21.3 (a)(ii) or in accordance with the provisions of the relevant event agreements signed by the participating teams, the net run rate of the defaulting team shall be affected in that the full 50 overs of the defaulting team's innings in such forfeited match shall be taken into account in calculating the average runs per over of the defaulting team over the course of the relevant portion of the competition. For the avoidance of doubt the runs scored and overs bowled in such forfeited match will not be taken into account when calculating the net run rate of the team to whom the match was awarded.

In effect, 50 overs are added to the denominator of the loser's "scored" run rate, while their "conceded" run rate is unaffected. The winner's run rate is unaffected. This is easier to understand with an example. Suppose Team A doesn't show up for their game against Team B. Then for purpose of calculating net run rate, following data is considered from this game.
Team A (loser)

Runs Scored: 0 from 50 overs.
Runs Conceded: 0 from 0 overs.

Team B (winner)

Runs Scored: 0 from 0 overs.
Runs Conceded: 0 from 0 overs.

The ICC World Twenty20 2016 Playing Conditions also includes the same rule, the difference being, of course, that instead of 50 overs, 20 overs will be added to the loser's "scored" run rate denominator.
Such forfeiture has occurred a few times in Cricket World Cups:

In the 1996 Cricket World Cup, Australia and West Indies forfeited their league matches against Sri Lanka due to "security concerns".
In the 2003 Cricket World Cup, New Zealand forfeited their match against Kenya due to "security concerns", while England forfeited their match against Zimbabwe due to a certain political controversy.

Note that the above rule wasn't included in the playing conditions for 2003 World Cup and earlier, so in all the above cases, the forfeiting teams conceded "only" the points for the match without affecting their net run rate.


How do you know what beat to emphasize based on the time signature?

Question: In learning the guitar I have run across various time signatures. In each time signature it seems as if you are supposed to emphasize different beats. Is this something that you just have to intuit, is there a formula for this, or is it just convention?
For example:

3/4 you emphasize beat 1
4/4 you emphasize beat 1 and 3
5/4 you emphasize beat 1 and 4
6/8 you emphasize beat 1 and 4 (at least in what I have played so far).
Comment: 6/8 has 2 beats each subdivided into triplets. If the top number is divisible by 3, except for 3 itself, then it is a compound time signature. As far as emphasis is concerned, there is no formula but our brain tends to group things into 2's and 3's. Even quadruple is a form of duple. For some of the newer time signatures there is no set way but 5/4 tends to be 2/4 + 3/4 or reversed. Learn to feel the music and you'll generally group things in a natural and musical way. Music has no set formula(or is so complex only feeling can understand it)
Comment: Not all 4/4 is 1 and 3, plenty of music emphasizes the backbeat (2 and 4), though I don't know enough about the subject to make a concrete answer. From my limited experience it's more about the style of music than the time signature.
Comment: 5/4 can be subdivided into groups of 2 and 3, or even 2, 2, and 1.  Example: "My Wave" by Soundgarden is 2 and 3 rather than 3 and 2.
Comment: Just this past week I ran across a piece of music with a time signature of 3/2. I had an extremely hard time trying to figure out what beat they were emphasizing. It seemed to be the third beat.
Comment: Sometimes, pieces use [hemiola](http://en.m.wikipedia.org/wiki/Hemiola#Rhythm) on some measures to change up rhythmic feel without changing key signature, making things a little more deliciously complicated.
Answer: There is no clear and fast rule. The emphasis is entirely dependent on the rhythm of the tune.  While there are some standard feels for different time signatures, they are broken as often as they are kept. In terms of standard feels, I'd say that all your examples are correct. It's important to note that 5/4 with accents on the 1 and 4 feels just like 3 + 2 (ala Take 5) and 6/8 generally feels like 2/4 with triplets instead of 1/4 notes (like House of the Rising Sun).
But if you listen to anything that really f&*ks with time signatures, these rules will fall apart quickly. Listen to Schism by Tool, for instance. The main riff goes back and forth between 5/8 and 7/8, but it's just a triplet and then 1/8th notes. The accent seems to roll between the beats. And then it changes to 6/8 and 7/8 and the feel of the piece keeps. Eventually the tune ends in 4/4 with one of the most rolling, odd sounding 4/4s I've heard in a while. After 5 minutes in odd signatures, it's almost hard to believe that the end is in the "common" time signature.
So basically, yes, you've got the standard down. But all the interesting stuff happens on the edges by bucking the rules. Even the standard 5/4 piece, Take Five, was revolutionary because no one had really done that before. It's only "standard" now because Brubeck paved the way.
Comment: When talking about 5/4, let's not forget Holst's *Mars, the Bringer of War*.
Comment: Um Brubeck wasn't the first to popularize 5/4. Stravinsky was just one of many that popularized "odd" time signatures, http://en.wikipedia.org/wiki/The_Rite_of_Spring. There were many others and in some cultures such odd time signatures are used more than "even" time signatures(for lack of a better term).
Comment: Yes, but Brubeck brought it to the mass jazz audience...That's why he gets the main Props....
Answer: What are you are referring to is called harmonic stress. It is the metrical stress accorded to a pulse based on its position within a grouping.
It should be noted that, while sometimes musical performers add accentuation to notes or chords occurring on strong harmonic stresses, this is not always the rule. The strength of the beat is actually not a function of amplitude or musical performance, but of the perceived importance of that pulse within a larger grouping.
As you note, the downbeat (the first beat in a measure) is almost always the strongest harmonic stress. Actually, it is not as simple as having just stressed or not-stressed beats. There are degrees.
In common time, the stress is STRONG WEAK strong weak. (1 and 3 are strongest, 2 is weak and 4 is weakest.)
In waltz time, the stress is STRONG WEAK weak.
In cut time the stress is STRONG WEAK.
In odd time meters, the stress is usually just a direct derivative of one of the above. However, I think your idea  about the 5:4 stress is not quite complete. It may be possible to have a measure of 5 that is in the pattern of 4+1 or 1+4 as you mention, but I believe 5:4 is usually either 3+2 or 2+3. This affects both how it is notated and how the harmonic stress is heard. So it's either STRONG WEAK weak STRONG WEAK (as would occur from combining a measure of three with a measure of two) or STRONG WEAK STRONG WEAK weak (as would occur from combining a measure of three and a measure of two.)
7/4 time would be seen as a combination of 4+3 or 3+4, and would inherit the stresses that follow.
11/4 would have to be either 4+4+3, 4+3+4 or 3+4+4, but this is a situation we rarely find ourselves in, isn't it?
As for compound triplet meters such as 6/8, 9/8 and 12/8, they are really just measures of two primary beats, three primary beats, or four primary beats, and would have pretty much the same harmonic stress as a measure of 2, 3 or 4 would in the above.
As for notes not occurring within the pulse, such as the "and of 1", they would have the weakest of any harmonic stress, and would also tend to be perceived as inheriting any of their harmonic stress from the pulse which they are subdivided from. So the "and of 1", if it had any real harmonic stress, would be thought of as having the harmonic stress of 1. Indeed, if the measure began with an eighth note rest, the "and of 1" may possibly be heard as an event on beat 1 that was late to enter. However, worrying about the potential metrical stress of subdivided notes is probably not necessary to have a strong grasp of this idea, so we should probably leave it at the main pulses.
Answer: The time signature has no bearing on whether a beat may be accented or not. Accents on the weak part of the beat can happen regardless of the time signature. This happens often and is called syncopation.
Comment: There's no hard rules, but there certainly are common patterns!
Comment: and some people only accent the first beat in 4/4 time. Beethoven commonly in his orchestral works accents the upbeats(beats that aren't usually accented) without writing an accent symbol.


Change to Username instead of Email Laravel

Question: I'm having some issues with changing Email to Username.
The protected $username = 'username'; Doesn't seem to work for me.
Where can I change the DB Register Query and DB Login Query?
Comment: Can you post your login view?
Comment: This was fixed awhile ago.
Comment: glad to hear that. adding protected username in AuthController should do that job for you. You was correct. :)
Answer: If you want to login by username instead of email use this
$credentials = $request->only('username', 'password');

instead of
$credentials = $request->only('email', 'password');

to check credential here attempt($credentials)
in AuthenticateController.php
Comment: What about registering? I get a DB error cause it's trying to find name, not username.
Comment: you need username there, or change it to name
Comment: Where is AuthenticateController.php
Comment: app/Http/Controllers
Comment: Actually wait no. My username isn't being detected. Whenever I register a new account with a username, it doesn't get inserted into the db. Same with logging in, doesn't want to check my username.


Vaadin filter table containing checkbox components

Question: I have a table component in vaadin 6 , which has check boxes in it. How can I apply filtering to CheckBox component added in the table? I had previously done filtering in vaadin table component which had plain String as data. The CheckBoxes I added to the vaadin table have captions and I want to filter those checkboxes on the basis of their caption. Hopefully you got my point. So, I need help in this regard.
Thanks
Answer: Vaadin 6 has own sorting methods in VScrollTable.java file. It sorts basic classes for example String, Integer, Date etc. Of course you can write your own table which has own sort methods but this can be get lots of time. You can search an addon for this.
May be this works for you: https://vaadin.com/en_GB/directory#addon/filteringtable:vaadin