Can a premium HDMI cable outperform a standard cable?

Question: Assuming two cables both conform to the same standards (e.g. HDMI2.0, high-speed, ...) is it possible that a premium cable will outperform a standard cable when using an objective benchmark that measures the quality of picture/audio? Or what experiment would show that a premium cable has a benefit over an 'ordinary' cable?
Comment: When using a *subjective* measure, almost anything is possible. (-:
Comment: I don't mean to be defensive, but I don't think that this question is about use of electronic devices. Look at the currently leading answer to see how technical and engineering-related this topic is.
Comment: Most HDMI cables work fine for 1080p. However, I have found that when pushing past this (4k 60 fps, higher color depth, etc) you run into a lot of cables that don't. This is even more so the case with Displayport (anecdotal - my experience of dealing with a lot of cables), where I found that unless it is a cable from a reputable brand (and in the case of DP listed on the DP website as being approved), it tends to simply not work for anything above 1080p, or even worse, work intermittently.
Comment: I hope this doesn't get closed. It raises issues related to high-speed cabling in general that also apply to things like eSATA, USB SuperSpeed, Ethernet, PCIe, etc.
Comment: @Chupacabras: See [my answer](https://electronics.stackexchange.com/a/400009/11683). "Standard" cable is built just well enough to meet the given specifications at the given length(s).
Comment: @pipe since my response is short and purely anecdotal, I thought it would not be suited to make a full answer out of it.
Comment: @JorenVaes Still your answer is the first people see after searching for this problem in a search engine. Stack Exchange was designed to get rid of such answers. There's no such thing as a "half-answer" here.
Comment: @RuiFRibeiro Yes... and no. Unless tested it's hard to know what you are getting, which is why "premium" as a keyword, when used with the correct logo, implies that it was tested to the standards.

Many "gold plated premium" cables however will be fraudulent, and over charging, even if they meet the top standard. But until new higher freq standards are released, or tested to a higher bitrate, who knows if the scam cable is actually better then the next top model? it's complicated, which is why the scam works, people with more money that want less risk of time wasted.
Comment: Define "premium cable" and "standard cable". With technical terms.
Comment: @JorenVaes You should answer questions in the section marked _Answers_, not comments.
Comment: Are not high premium HDMI cables a scam, like a 150 Euros gold plated cable in FNAC?
Comment: @DaveTweed Those interfaces are a _lot_ different and use vastly different signal quality requirements, error correction, encoding, etc. What applies for the super short distance PCIe interface (which uses 128b/130b and 128b/132b encoding) will likely not apply to, say, comparatively longer-distance HDMI (which uses 8b/10b). Not to mention, the protocols themselves are different (for example USB will retransmit on error, but does HDMI even _support_ retransmission?).
Comment: @forest: Yes, so ... ? They are all affected one way or another by cabling issues such as ISI, attenuation and external interference (noise). Even if the protocol supports FEC or retransmission, the user will eventually experience a performance decrease.
Answer: You would do a BERT (bit error rate test) on the cable. Better yet, look at the eye diagram at the far end of the cable.
HDMI is a digital format, which means that there's a threshold effect — cable quality does not affect the picture quality at all until it gets so bad that it actually causes bit errors.
"Premium" cable is (supposedly) built to tighter tolerances (reduced ISI), with thicker wire (reduced attenuation) and/or with better shielding (reduced external interference) so that you can have longer runs of it before that starts to happen.
Bit errors flip individual bits, and the visual effect depends on exactly what that bit is used for. A bit error in one of the MSBs of a color channel will cause a pixel to be unexpectedly brighter or darker than it should be — this is commonly called "salt and pepper noise" because in a B&W system, the random white and black pixels look like salt and pepper have been sprinkled on the image.
Comment: That statement should be made stronger: the cable does not affect image quality in any way whatsoever so long as there are no bit errors.  Bit errors will cause "digital snow" on the image.  You will not see any change whatsoever in color, detail, contrast, etc. depending on the cable.  Either you get a perfect picture, a picture with digital snow, or no picture at all.
Comment: Length as a variable should be emphasized more. There are tests that show that there is a difference in error rates at longer lengths (greater than 50 ft).
Comment: Bit errors have a much more drastic effect if the signal has been encrypted with HDCP.
Comment: HDMI uses 8 bits of BCH for error correction for every 64-bit subpacket, so I don't think it's true that a bit error will simply result in a pixel to be simply brighter or darker, especially considering the protocol uses TDMS with compressed and interleaved audio, video, and auxiliary data. So if a bit error is not stopped by 8b/10b encoding _and_ not dealt with or detected by ECC, then an entire packet will be corrupt and the resulting corruption will be more than just a single slightly modified pixel.
Comment: The only time I have seen digital snow was in a dentist's office where they used cheap passive HDMI over dual cat 5 baluns. The screens would even go blank entirely depending on the content. Lowering the resolution helped somewhat. I  recommended replacing the cat 5 with proper long HDMI cables, which solved the problem.
Comment: I can testify that a cheap, long run cable sometimes simply doesn't work. The crosstalk gets too bad, too many bits flip and it fails. But to be fair, there's a difference between "well made" and "high mark up".
Comment: I have seen issues where  long cables are joined with switchs etc in churches.  But have yet to see an issue with cheap cables in a normal home.  (as well as length there are often many cables (PA etc) close by in a church setup.)
Comment: @alex.forencich As an anecdote, the only time I've encountered digital snow when using manufacturer cables was with a cheap HDMI switch. The switch worked in that the input would change based on which device was active, but there was a persistent (albeit minor) digital snow effect across the screen.
Comment: "digital format ⇒ cable quality does not affect...quality at all until it gets so bad that it actually causes bit errors" is not completely true. What can still [fluctuate continuously is _clock sync_](https://en.wikipedia.org/wiki/Jitter) – in digital audio, this jitter could be quite perceptible with old equipment (since the ears are particularly sensitive to timing fluctuations). With video, I don't think this is an issue at all.
Comment: @leftaroundabout: In a video display (especially LCD), the actual display timing is decoupled from the communication timing by various asynchronous FIFOs and/or frame buffers. There is no jitter in the display even if it is present on the cable. (This has also always been true for digital audio, with the possible exception of the very first primitive lab setups.)
Comment: @DaveTweed even when there are buffers (which isn't always the case, even today), digital audio will generally sync the DAC to the master clock. Only consumer or remote protocols go through the cost of completely uncoupling the clocks, at the price of much higher latency.
Comment: I can testify that cheap hdmi cables are garbage for home pc's if you are running high freq, (>60hz) and or high resolution (>1080)
Comment: @forest I think the BCH FEC only applies to audio data and control data, not to the video data. And the line code isn't intended to detect and correct errors.
Comment: @alex.forencich It looks like you're right, BCH ECC does not apply to video packets, at least from reading a few excerpts of the spec.
Answer: HDMI cables are tested at an Authorized Testing Center (ATC) and given a certification based on how much bandwidth they can handle (which is to say, how high of a frequency signal they can transmit without the signal degrading beyond some parameters specified in the standard).
Signals in a cable degrade. The signal that is input to the cable is not precisely the same as the signal that is received, due to various effects which depend chiefly on cable length, the physical properties of the cable stock, and the signal frequency. The longer the cable is, the more distorted the signal will be, and the worse the cable stock is, the more distorted the signal will be per metre of cable that it passes through.
In analog signaling, any amount of distortion changes the image, it's just a question of by how much. If we're transmitting an image across, say, a VGA cable, then you have 3 signal lines, one for each channel of a pixel (red, green, and blue). Each pixel is transmitted in sequence, and the voltage on each line at any given time represents the brightness of one channel of the current pixel. I don't know what the signal voltage of VGA is, but I'm going to pretend it's 1.0 V. Since it's analog, if the signal voltage is 0, that means 0 brightness, if it's 1 V, that means 100% brightness, 0.5 V means 50% brightness, etc. The voltage on the line is analogous to the value being communicated. Of course, if you transmit 0.55 V and, due to distortion, the receiver picks up 0.51 V, the image will come out ever so slightly different than intended. And more distortion means larger inaccuracy in the results.
In digital signaling, nothing changes, except that we only signal 0 V or 1 V. We don't use any of the in-between voltage levels (some digital signals will use several levels, maybe 4 or 5 levels instead of 2, but the point is, we only use a few levels instead of a continuous spread. For simplicity, we'll go ahead with just 2-level digital signaling). Since we are not using any in-between levels, the receiver knows automatically that if it receives a 0.8 V or a 0.9 V signal, that it is really supposed to be a 1 V. So, distortion is corrected by the receiving device. Of course, there is a trade-off, since you can only represent 2 different numbers with each signal instead of dozens or hundreds, you require many additional signal cycles in order to communicate the same amount of information. That's why a 3-channel analog video system like VGA only needs to operate at around 150 MHz on each channel to transmit 1080p 60 Hz, while a comparable digital equivalent like HDMI (which also uses 3-channels, one for each color channel in RGB mode) has to operate at around 1.5 GHz on each channel to transmit 1080p 60 Hz. But anyway...
So distortion in the signal has no effect on the image quality of a digital transmission, because even though the voltages of the signal might be altered slightly during transmission, the system can tell what it was supposed to be, as long as it's even remotely close to the intended value. However, it's important to note that digital signals aren't immune to interference. The only difference is that the effects of the interference are corrected by the receiver.
Because of this ability to correct interference, the quality of an image transmitted over a digital interface like HDMI is not affected by the cable, as long as the distortion is small enough to be correctable. Different HDMI cables do have different amounts of signal distortion, but since the distortion is corrected, it's irrelevant, UNLESS the distortion is so high that the receiver starts interpreting values incorrectly. So how does that happen? Well like I said, the distortion in the cable is affected by the cable length, cable stock quality, and signal frequency. That means:

(Mainly applicable to manufacturers) For a given signal and cable stock, if you make longer and longer cables from that stock, the signal will eventually fail to transmit correctly. In this case, you would need a better quality cable stock if you wanted to make a cable of that length that can handle that signal
(Again mainly a consideration for cable manufacturers) For a given signal and cable length, if you make the cable out of poor enough quality cable stock, it will fail to transmit correctly. However, that cable stock may still work at the desired frequencies for shorter cables, and it will also likely work for lower frequency transmissions, so you can simply label it with a lower rated speed and sell it
(This is applicable to consumers) For a given cable, with a certain length and construction, if you signal at higher and higher frequencies, eventually it will fail to transmit correctly. So a cable that is ok at 10.2 Gbit/s may not work at 18 Gbit/s. To transmit at the higher signal frequency, you would need either a higher quality cable or a shorter cable, or some combination of the two.

If you have a cable and you transmit higher and higher frequencies, you won't get decreased image quality, it will just fail to work once you pass a certain point (or, it will work intermittently, if you are right up against the limits).
In realistic terms, pretty much any HDMI cable can handle 10.2 Gbit/s (1080p 144 Hz or 1440p 75 Hz, or 4K 30 Hz), and even 18 Gbit/s (4K 60 Hz) at shorter lengths, no matter how cheap the cable stock used by the manufacturer. However, when you start combining long cable lengths and high frequencies (i.e. if you want a 15 metre cable for 4K 60 Hz, requiring 18 Gbit/s), you will get failures if the cable is not a high enough quality.
But, it's not really a big deal. Because the creators of the HDMI have certifications for certain thresholds of bandwidth.
Cables that have been tested at an Authorized Testing Center to reliably handle signals with fundamental frequencies of up to 3.4 GHz on each channel (i.e. 10.2 Gbit/s aggregate, or the maximum speed of HDMI 1.3/1.4) are given a High Speed HDMI cable certification.
Cables that have been tested at an ATC to reliably handle signals up to 6.0 GHz per channel on 3 channels (i.e. 18.0 Gbit/s, or maximum speed of HDMI 2.0) are given a Premium High Speed HDMI cable certification.
Cables that have been tested at an ATC to reliably handle signals up to 12.0 GHz per channel on 4 channels (48.0 Gbit/s aggregate, or maximum speed of HDMI 2.1) are given a Ultra High Speed HDMI cable certification.
Please note that version numbers are not a proper or officially recognized way of describing cables, so "HDMI 2.1 cable" has no official meaning and does NOT mean the cable has been certified at an authorized testing center. In fact advertising version numbers on cables has been explicitly banned by the HDMI Licensing Authority and any such cables are automatically considered non-compliant. Genuine certified cables have a special logo which you can read more about on the HDMI website. There are many cables which have not passed certification, and they will advertise terms like "4K certified" or "HDMI 2.0 certified" or whatever, rather than the real title which is "Premium High Speed HDMI cable" and so forth. So watch out for those. Always look for the certification logo.
Anyway, as for the original question... Will a premium cable outperform a standard cable, if they have both passed the same certification? Well, it depends what you mean by "premium cable".
If you mean "a Premium High Speed certified HDMI cable", well if both cables have passed the certification, then they are both premium HDMI cables.
If you just meant "a really good quality HDMI cable vs. a normal quality HDMI cable", well again, if they have both passed the same certification. There will be no difference within the bounds of the certification. If two cables both passed the Premium High Speed HDMI cable certification, then that means they were both tested to reliably handle 18 Gbit/s speeds. If you use them at 18 Gbit/s or below, there will be no difference between them.
How the cables perform at speeds higher than that is a mystery, it's entirely possible that one cable just barely passes the certification, and will stop working at 25 Gbit/s, while the "high quality cable" will continue working up to 50 Gbit/s, you never know. So, you could make an argument for "future-proofing" by buying cables that can handle speeds way beyond what the specification demands today. But I don't think this is very wise, because:

There's no such thing as a "bandwidth meter" that a normal person can buy, so the only way to "check" is by having hardware that can operate at that speed
So, when you buy cables with "future proof extra bandwidth", you won't be able to check that it's true for many years (read: long after your warranty has expired)
Cable vendors have already demonstrated, they don't give a shit about outright lying about the speeds their cables can handle if customers don't have an easy way to check

For further reading, I would suggest this.
Got work to do, so there may be some minor mistakes above, I don't really have time to proofread right now :)
Comment: "HDMI cables are tested at an Authorized Testing Center (ATC) and given a certification based on how much bandwidth they can handle (which is to say, how high of a frequency signal they can transmit without the signal degrading beyond some parameters specified in the standard)." which is all well and good if you only have one cable in the channel, but often you will have three cables source->wallport->wallport->sink. If you want the overall channel to meet the spec then the individual components need to exceed it.
Answer: If the cables actually conform to the standards specified, then there will be no difference between a "premium" or "ordinary" cable, since the signals in question are digital.
However, in reality you may find cables that do not conform to the standard that are advertised otherwise.
Comment: Standards imply a guarantee of minimum performance.  One cable can certainly differ from another at the high end.
Comment: @Chupacabras You're assuming the transmitter and receiver are also meeting standards, which they may not. This is more common than you think; I recall an errata that some SATA ports on a mass-market Intel chipset were identified as marginal fail. Additionally, the user may be doing something violating standards, like daisy chaining cables or using one that is much too long. In all of these cases, cables (and transceivers) which are superior to standards help.
Comment: @ScottSeidman Yes, I absolutely agree. I guess I implicitly made the assumption that the user would be operating the cables within their rated limits, but we both know that's not always the case :)
Comment: I agree with it to, @Chupacabras -- but it doesn't address the question being asked.
Comment: Define "outperform." if both cables have a bit error rate which is zero for all practical purposes when used as per the specification, then arguing that one is "better" than the other is "marketing BS", not "electrical engineering."
Comment: @ScottSeidman even the minimum is enough because it complies the specification and its tolerances.
Comment: @Chupacabras  what was asked was "can one cable outperform another?"  Not "will both cables meet the minimum standard?"
Comment: @ScottSeidman I am not writing about the question. I am writing about Shamtam's answer which I fully agree with.
Comment: @alephzero -- I don't see the words "when used as per the specification" in the question.  One cable might barely meet the spec, and one cable can exceed the spec.  You won't notice until you use the cable in a way that exceeds the spec.
Comment: Premium HDMI cables may be built to a different standard. https://www.hdmi.org/manufacturer/premiumcable/Premium_HDMI_Cable_Certification_Program.aspx
Answer:
Assuming two cables both conform to the same standards (e.g. HDMI2.0, high-speed, ...) is it possible that a premium cable will outperform a standard cable when using an objective benchmark that measures the quality of picture/audio?

No, it's not possible.
A digital transmission line is specified to have zero error rate (to be more specific: an error rate small enough so de-redundancy, error-correction or retransmission routines can correct all of them, thus ultimately achieving error-free transmission). If the cable meets specification, it is the case. The signal at the receiver is perfectly same signal that was sent. There is no room to improve on perfection.

Or what experiment would show that a premium cable has a benefit over an 'ordinary' cable?

If you stay within the spec, there is no benefit. Benefits of a better (signal-wise) cable can materialize if you go beyond the spec. Eg. as Joren mentioned, many old cables specced for 1080p in fact work with 4k. Eg. you can experiment with 4k cables at 8k or 120Hz.
Caveat is that you've asked for a premium cable, not "a cable that has more bandwidth" or "less attenuation". And what constitutes "premium" is debatable and purely subjective. Eg, I consider ultra-thin (about 5mm) cables as "premium", because they offer me extra flexibility. My reasoning is that it takes extra work for the manufacturer to meet same spec in a smaller diameter. On the other hand, there are plenty of cables where "premium" means extra-thick and extra-stiff. In this case, the premium is in supposed greater physical durability of the cable, personal satisfaction from getting physically "more of a cable" and possibly meeting future specs because of the (today) superfluous copper, insulation and shielding.
Comment: However, HDMI has neither error correction nor retransmission.
Comment: @DaveTweed There is TERC4 "with high inherent error avoidance". So, even if it's not called "error correction algorithm", it does the same thing.
Comment: No, it doesn't. And it isn't used on video data anyway, only auxiliary data.
Comment: "Premium" in regards to HDMI is an industry accepted term of art, for the cables that have been through accreditation and passed.
Comment: @Agent_L error avoidance isn't really error correction, though it does help reduce the error rate. At any rate, no error correction is used on HDMI video data. TERC4 and BCH are only used for audio and control data, not video data.
Answer: Low-end cables usually function just fine, in situations with a low noise floor and if you don't mind other cables getting influenced by your HDMI signal. Depending on how low you go in quality they won't even pass EMC compliance tests in modern countries.
A high-end cable has a much better chance of being properly shielded and is usually a bit more resistant to mechanical stress.
For short pieces of cable (say 3 meters) the signal-quality difference isn't enough to cause noticeable effects on whatever is on the other end of the line. However, if you have sensitive electronics near, they might.
Should you benchmark them as explained by Dave's answer, yes, you will find a major difference in quality between cables.
Comment: On my old sat system I used to be able to receive channels depending on how the (cheap) HDMI cable was positioned (I *did* have a very bad reception, sat cable and decoder)...
Answer: Other answers cover testing at a single point in time, typically during production or at point of purchase.
One aspect of better-quality cables though is that they will typically be better constructed, and hence will last longer.  This may relate to:

tolerances or quality of metalwork in the connector housing;
quality of contacts in the connector;
quality of soldering (or other connection method) between the wires and the connector contacts;
quality of strain-relief so that flexing the cable does not snap it at a "weak point" as it enters the connector;
quality of signal wires so that flexing the cable does not break them;
and quality of screen construction so that flexing the cable does not reduce its effectiveness.

Note that I say "better constructed" and not "more expensive".  Typically it does cost more to do this properly, but without disassembling the cable it is impossible to tell whether the basic construction is better or worse for one cable than another.  Unless the "premium" cable manufacturer can tell you how all this was put together, there is no guarantee that your "premium" cable is any better than your "ordinary" one.
Comment: Concur - a damage-resistance will help the cable survive better over the years, which by some definition is out-performing a failed or cut cable.
Answer: Even if both cables have identical signal propagation properties, but

the equipment is sensitive to common-mode currents (conducted EM interference), and
the premium cable has better common-mode suppression chokes (ferrite rings)
or maybe it has better shielding and a good path for dumping the CM current,

then the premium cable is still the winner, because it is a worse antenna for EMI.
Those large coated ferrite beads you see on the ends of good cables are purely for EMC, they are invisible to the signals. They may even be mandatory for meeting FCC requirements, then they will come with the equipment.
This may apply to analog cables (interconnects, speakers) too, because external cables ("antennas") are very significant components in EMC issues. If you live close to a broadcast station then this will matter more. You can also add such CM chokes later, see for example: https://product.tdk.com/info/en/products/emc/emc/clamp/index.html .
Something else: HDMI and DVI (TMDS) receivers contain equalizers that adapt dynamically to the cable length and quality. Early implementations had fixed equalizers that were tuned for an average cable, in that case you should choose a cable that is neither too bad nor too good !
Comment: So a "premium cable" can be better if something else in the system is "broken".
Comment: @IanRingrose: Can be, although I did encounter one setup at my wife's friend's house where for some reason a cheap cable would work and a name-brand one would not for connecting two particular pieces of equipment, though the name-brand cable worked fine for other pieces of equipment.
Answer: YES. But perhaps not in the way you expect.
At standard length, with equipment that conforms to standards, any compliant cable will work exactly the same. No "slight visual quality loss" is possible, since HDMI is a digital standard. If there is any quality loss (e.g. with very poor, nonconforming cable), it would be severe (heavy snow) or simply the devices would not detect that they are connected.
So what could you gain with using higher quality cable? If you push your connection to the limits (using very long cable) then there is possibility that just standard cable will not work properly (signal would be too noisy or attenuated for it to work), but high-quality cable would work. The same holds for patching two cables together (in any case this is not recommended, because of degrading the connection).
So, if you do things you should not, then the better cable has better chances to work than just the "standard" cable. Only in this case there is a difference.
Answer: For a reasonable cable length (say less than a few meters) no difference will be seen, you'll only stress the cable/EQ system when you stretch into several meters.
Answer: Potentially!
If the "premium" branding of the cable, uses the HDMI trade marks / brandings, then unless it is counterfeit or fraudulent, you can be assured that the cable has passed the required testing.

The kicker is your line

Assuming two cables both conform to the same standards (e.g. HDMI2.0, high-speed, ...) is it

Who tested it? Who verified it's true and actually meets standards? If people claim incorrectly that it meets standards, what can be done about it?
Making the claim that your cable passed accreditation, when it didn't, is a much stronger court case then claiming it matched a standard to your own testing.
https://www.hdmi.org/manufacturer/premiumcable/Premium_HDMI_Cable_Certification_Program.aspx


Gate to allow only one player to pass through

Question: On my server I have a quiz which you need to take before you can go to most of the areas, build etc... However, sometimes people try to cheat by going with friends into there. I want some kind of gate/mechanism which only allows one player to pass through and insert some kind of delay or so after this. Is this possible? For the delay I know how to make it, I only need to know if you can build something where only one person can pass through, not multiple at once.
Comment: Command blocks would be the closest thing to provide this functionality.  You would have to teleport the player, but the problem is knowing which player to teleport.
Comment: @Andalur I'm confused.  I don't see how you're going to set permissions on skype/google chat/cell phone IMing/etc.
Comment: @MBraedley You should post that as an answer. It's probably even more solid a solution than mine.
Comment: @MBraedley Well, that doesn't really matters... The one who don't gets teleported simply has to wait until the other one finished.
Comment: What's to prevent people from instant messaging their friends to get the answers?
Comment: To write a good answer, I need much more details about what you want to do. If you want just some barrier with cooldown, I can easily make one. But is that a good solution?
Comment: @John that's pretty simple, just use permissions.
Comment: @BlaXpirit It should only allow one person to pass through, then it should close.
Comment: @John I meant ingame messaging
Answer: I think the answer from MBraedley is correct: the best way to handle this scenario (allowing access to a single player at a time) would be to use Command Blocks to teleport one player into and out of your quiz area. You can program a Command Block to teleport the nearest player to a set of coordinates like so:
<code>/tp @p x y z
</code>
I don't know what would happen if two players somehow managed to be the exact same distance from the command block (i.e. does just one get teleported, or do they both get teleported since there is a tie for the "closest"). This additional argument may be necessary to limit it to only one player:
<code>/tp @p[c=1] x y z
</code>
The next step is to create a circuit whereby clicking an "entry" button will teleport one player into the quiz area, deactivating this button so that it cannot teleport anyone else in until the player exits the quiz area by clicking a second "exit" button, teleporting them out. Here's one such example circuit I just threw together in my survival game:

The blue blocks are buttons that feed their signals into AND gates (green blocks). The outputs of the AND gates will activate Command Blocks (shown here as redstone lamps at the bottom of the image) and will also feed into the input of a T flip-flop circuit (red blocks). The output of the toggle circuit runs behind the red blocks and feeds into an input of each of the AND gates.
When the toggle circuit is in the "off" state (no output, as shown in the image) then the signal from the right button is disabled and the right redstone lamp (i.e. Command Block) cannot be activated. Activating the left button will cause the left redstone lamp to activate and immediately flip the toggle to the "on" state. This will subsequently disable the signal from the left button and reenable the signal from the right button.
This circuit should give you the ability to allow one player at a time to teleport into your quiz area via a button press. Once they reach the end they can then press another button to teleport out and reactivate the entry button for the next player. I'd also suggest enclosing the circuitry and your quiz area in bedrock, so your average player can't mess with any of it.
Comment: The new `testfor` command is probably useful here.  If there is more than 1 person in the test area, teleport them all back to the spawn area.
Answer: You might want to consider using command blocks to teleport players from a spawn area to the quiz area, and then again to the player area.  The reason I'm suggesting teleporting the players into the quiz area is that you only want one player there at a time in order to ensure that the player that finishes the quiz is the player that's teleported to the playing area.  There are a few ways to check if a player is still in the quiz area and hasn't, for instance, logged out.
As for how to actually implement this, I have no idea.  Obviously, you'll need to have at least op powers so you can spawn the command blocks.  Beyond that, I can't give many details.
Comment: You also have to enable command blocks in server.properties - but the line isn't there until you try to use command blocks, which you can give yourself with the /give command. The ID is 137.
Answer: Iron doors with a button will make them impossible to open until the player passes the quiz and steps on a pressure plate, which will then allow the doors to open again.
Comment: Not if the second player has a button/pressure plate/any other door opening device that can open the door.
Answer: You can use a testfor command that is on a clock and from the command block is comparator  that goes to iron door that is closed as if it was opened and if player enters iron door,  it closes and anyone other cannot get in until he/she leave


Do PCs gain experience from a fight that they lost?

Question: If the PCs lose a fight but do not die (e.g. imprisoned), do they gain experience points from the battle?
Comment: Related: [Does a PC who was KO'd earn experience for that combat?](https://rpg.stackexchange.com/q/79979/33707)
Answer: Only from the monsters they defeated.
You gain experience when you defeat a monster (emphasis mine)

When adventurers defeat one or more monsters - typically by killing, routing, or capturing them - they divide the total XP value of the monsters evenly among themselves.
[Dungeon Master's Guide page 260]

Even if you lose a fight, any monster you defeated during the fight would grant experience. The ones you don't defeat (i.e. the ones who imprisoned the party) would not.
The challenge isn't always just combat
Sometimes other factors provide XP, which will also be awarded if the player's defeat that aspect of the encounter.
Some examples are:

Traps and/or hazards that give XP
Encounters where "defeating" the monsters involves escaping rather than beating them in combat (or some other challenge)
Social encounters that qualify as a sufficient challenge
Comment: As the DM you are also allowed to award milestones whenever you want. It is completely RAW to award the players with a milestone for the encounter in lieu of experience for defeating monsters.
Comment: @as.beaulieu Addressed
Comment: Lost battles don't award experience... yet.  Surely the PCs will soon break out of their jail cell and get the chance for a rematch against those that beat them?
Comment: For official rules, the accepted answer is absolutely correct. That said, I offer two thoughts: 1)Experience is what you get when you don't get what you want, and 2) Good judgement comes from experience, but experience comes from bad judgement. That's my wordy argument for awarding milestone experience (instead of combat experience) *if* the lost combat was meaningful to the plot.
Answer: The DM has quite a bit of freedom in the awarding of experience.
First I'd take care of the obvious:

If they subdued or killed any of the opposing group, award experience.

Now, the more subjective awards:

How did they end up imprisoned? Did they talk the opposing group out of killing them? It's a bit of a stretch, but if they took any action that resulted in them not-dying then I would give them something. Not a lot, but a token gesture.
Answer: Personally, I would give them experience for any monsters they killed, but not for the fight itself. If they were overpowered and imprisoned it may because they aren't strong enough for the monsters your throwing at them, and they need more experience to put into leveling up.


App for live blogging from Blackberry to WordPress

Question: I'm looking for an app that will let me post content to single WordPress post, inserting each new "post" either at the top or bottom of the article, with a timestamp. I know there's already an WP app for Blackberry, but I'm looking for something specifically set up for live blogging. Any ideas?
Answer: You might look into the app CoverItLive. They have software that will run on mobile devices and allow you to publish to a variety of mediums.
From what I can see, there isn't a "direct" WordPress integration, but you embed the CoverItLive feed you create into your blog. That way the users have a static location, you can update your content live that goes into the CoverItLive feed, and that way people can still comment in the normal comment section if they so desire.
Basic accounts are free.
Comment: cool, i'll check it out. thanks!
Answer: There is an app Wordpress for Blackberry available from http://blackberry.wordpress.org/


Can I use Apache Software License, Version 2.0 and GNU LGPL 3 licence plugins in my commercial web application?

Question: I have two plug-ins. One has the GNU LGPL 3 license and the other has the Apache Software License, Version 2.0. Can I use them in my commercial app?
And if yes, what precautions should I take?
Comment: Keep in mind that you should NEVER EVER follow the legal advice that you get on the Internet, except if it comes from a lawyer. Preferably one who specializes in the given field, in this case: software licenses. So do take all the answers you get with a grain of salt, because otherwise you may be exposing yourself to lawsuits (since your app is a commercial one).
Answer:
Can I use them in my commercial app?

It depends on what you intend to do with the software that you produce.
Firstly, neither ASL1, GPL or LGPL make any restrictions on what you can use software to do inside your organization.  The restrictions are all on code that is distributed outside of your organization.

For GPL the restriction is that if you incorporate GPL'ed code into your own software, AND you then distribute your software outside of your organization, THEN you must make the source code available under the terms of the GPL or a compatible open source license.
So if you use GPL'ed code in your application and you distribute it, then your application must be open source ... or else you are violating the license.
For LGPL, the restriction (see above) only applies to the source-code of the LGPL'ed library itself; i.e. if you change the library.  If you just use the library, you are not required to make your source code available.
There is also a restriction that the LGPL code in your application must be replaceable by the user of your code.  That means (in effect) that if you distribute your code as binaries only, then you cannot statically link your code against that the library.  You must use dynamic linking.
For ASL, the only significant restriction is that you must say if you have changed anything from the original version the ASL'ed code that you using.

Finally, just to make it clear, neither GPL, LPGL or ASL places any restriction on your purpose in using the software.  And that includes whether your purpose is to make money.  They just constrain the way you can make money ... and in the case of LGPL and ASL, the constraint is pretty minimal.

And if yes, what precautions should I take?

For LGPL and ASL, no precautions are necessary.
IANAL - I am not a lawyer.  If you need to be sure, ask a real, qualified expert; i.e. a lawyer who specializes in software IP law.

1 - For the purposes of this answer, ASL == Apache Software License version 2.
Comment: Does this apply to a web application ? i mean customer will receive only the war file containing the .class and .JAR files. If all is LGPL  still ok ?
Comment: If you are not modifying the LGPL libraries then you can include them with your application code in the WAR file.  But you need to do it in such a way that the person you are distributing your code to can *replace* the LBPL code with another version.  An "uber-JAR" is probably a violation.  Obfuscating the LGPL libraries together with your code is definitely a violation.  (IANAL)
Comment: There is a folder called lib where i place all jar files. So he can relplace any Jar file with its other version. But i dont guarantee it will work always . Is that still ok ?
Comment: Ask your lawyer :-)
Comment: It is just a normal web app running on tomcat. If you can help will be good. Anyway thank for your clarification really helping.
Comment: As I said (or implied) I do not want to be responsible for you making decisions that will get you into legal trouble.  Either read the licenses carefully, apply them to your situation and take responsibility yourself, or consult an expert; i.e. an IT / copyright lawyer.  I have now said that **four times**.  Have you got it yet?
Answer: The Apache License does not place any restrictions on software that links to a plug-in or library that is distributed under the Apache license. The LGPL on the other hand has the requirement that either the LGPL library links dynamically (and can be replaced by a user) or the entire work must be released under a GPL-compatible open-source license.
For the use in a closed-source application, this effectively means that you can use the Apache Licensed plug-in without restriction and that the LGPL licensed plug-in must be linked dynamically.
If you distribute either of the plug-ins along with your application, then you must also either provide the sources for the plug-ins or inform your users where they can obtain those sources.
Comment: @Rachael: "Closed-source" is usually used to refer to software for which the source code isn't distributed. Distribution within an organization is a bit of a special case when it comes to copyright licensing, because providing copies of a software product to people within an organization is not considered distribution for most copyright laws (it *is* considered copying).
Comment: BartvanIngenSchenau what do you mean by "closed-source" application? Do you mean packaged solution (not distributing source code), or do you refer to its distribution within an organization vs something like commercial distribution?
Answer: First of all, this is not legal advise.
GPL software is not allowed to be linked to (including over network), be compiled into, or be shipped with non-GPL software of any form. LGPL loosens this up a little to allow non-GPL third party support, including for commercial products. The important part here is that it must be third-party (so to speak), which creates a small loop-hole.
In short, you link to an existing LGPL library (call this the first party), but the software that makes this link must be made LGPL. Call this this software the second party. Although the second party software must be released as LGPL, as the owner of the second party software you can allow other software to use it outside of the LGPL (as long as the second party software remains available under LGPL as well). In other words, the second party software must be made available as LGPL, but is not required to license it as LGPL under all cases. Every individual user of a software must have license to use said software by law. What I'm saying is that as long as each user has access to the software as LGPL, you can also license it using non viral terms. You can create the third-party software as well, in effect licensing the second-party software to yourself for use by the third party software under non-LGPL terms. I have even heard of people writing themselves a contract and license to use their own software. The law can be strange! The third-party software does not have to be LGPL in any case.
So what you do is create a library to link to the LGPL lib as just a wrapper, and release the wrapper as LGPL. You can then link to this wrapper (your wrapper) in non-LGPL software, as long as your wrapper is avaliable as LGPL.
I can't speak for the Apache Software License because I'm not familur with it.
Comment: That answer is wrong on so many levels. The question is not about GPL, but LGPL. ASL code can be integrated in code under almost any other licence, which means also LGPL or even GPL (even if the opposite is forbidden). You can even use it in closed source software. And, like Stephen C. pointed out, you can do whatever you want as long you don't publish it or make it otherwise available to public.
Comment: *"GPL software is not allowed to be linked to (including over network), be compiled into, or be shipped with non-GPL software of any form."*.  The "or" should be "and".  You CAN use GPL'ed software in non-GPL'ed software provided you don't "ship" it.
Comment: Note that I'm using the term "link" very generically because this doesn't only apply to compiled languages and can also include "including" LGPL software (from local or a network location, such as with PHP or Javascript), or otherwise "linking" to a software over a network such as Java RMI etc.


How can I randomly power one of several wires in Minecraft?

Question: Given 5 wires (possibly more), I want to press a Reset button, and have exactly one of those wires, randomly selected, become active - and remain that way (until the next button press). What is a simple way of doing that?
Comment: @Arafinwe, sure, you might be able use melons as a source of randomness (although it would be a *slow* process). People use a lot of physical items (dispensers, plants, water, etc) to generate randomness. Note that this question was asked in **version 1.5** of Minecraft, and melons are in version 1.8. :)
Comment: I'm checkmarking my answer just to close off the question - but if someone posts a better answer, I'll certainly shift the checkmark to it. :)
Comment: Just a strange thought, but [this question](http://gaming.stackexchange.com/questions/31609/do-melons-prefer-to-grow-in-certain-directions) seems to imply that melon growth is as random as minecraft can get, not just as random as when you hit a button. Thus, your button could maybe use pistons to shunt melon blocks away, and then you wait a while for a melon to grow?
Comment: Ah, sorry. I'm new and so haven't known about what features came out when. Sorry for the irrelevant comment D:
Comment: Not really irrelevant, you probably *can* use melons as a source of randomness (although I do think they'd be fairly slow :) It's also common to update answers as newer versions come out.
Answer: This Q/A is actually related to another Question, my Answer to which, was sufficiently complex (and had so many diagrams), that I decided it was worth a separate post.
Now, there are a lot of random-number generators out there, some very clever (one uses a 13-bit linear feedback shift register - wow). But I wanted something simple, extendable, and easily-understood. There are probably better ones out there :) But I think this one works well enough to be used as part of the circuit in the other Question.
It's basically a 5-clock (using the new repeaters - I love those), connected to some memory flip-flops, with a reset button.
Top-level circuit diagram

5-clock circuit diagram

The arrows are repeaters, set to either 0.3 or 0.2 seconds delay (or none if blank). The 0.2 is to compensate for the length of wire before it, which adds some delay. The clock's entire cycle time is about 1.5 seconds.
333 circuit diagram

How to use it

Clear the 5-clock (repeaters get frozen), on server reboot/game reload. This can usually be done by dropping/removing a torch by the circuit, and/or removing and replacing a section of wire. When all of the repeaters are unpowered, the circuit is clear.

Inject a pulse into the 5-clock. Press the button on the Auto-Pulse Injector, and it will start the clock.

Press the Reset button - exactly one of the five wires, will now become active. If any wires were previously active, they turn off.

The clock cycles through 5 torches in about 1.5 seconds, and when you press the Reset button, whichever wire is next to an active torch, will be locked into an active state.
At this point, someone is no doubt complaining, "you call that random"??? :) Why, yes, I do - unless you walk to the button at deterministic time intervals, it's very random. Some people have designed RNGs that use mobs walking around - I'm using the player. :)
However, if you want to add more randomness to it, use the T.B.D. circuit - basically, that means that you: go to the button, look at the Seconds digit on your wristwatch, and when it hits zero, press the button. This will give a range of 1-10 seconds, averaging 5, in which the clock will cycle, resulting in an unpredictable wire activated.
I realize there are other ways of getting a random event. In fact, I had originally created a rapid-pulsar that burned out, then relit in about 5-15 seconds. I was working on having the relight event trigger a JK flip-flop, sending a pulse to the clock. But it was a) trickier than I thought, and I wanted to get an answer posted :) and b) somewhat redundant. All I was trying to do was wait for a random interval before picking a clock torch - and it's easy enough for the player to just look at his watch for a random interval. :)
Sometimes, the best solution, doesn't require a lot of complex machinery. :)
Also, this design is for a specific application - in the original Question, the person wanted a reset button that changed the wire, which means they were actively choosing when to get a random number. If your application involves disco lights flashing at random, then no, this wouldn't work for that. But there's already plenty of solutions for flashing lights randomly.
The 333 circuit is fairly mundane, I claim no originality - the only reason I gave it a name, is I had to give it some label in the diagram for clarity. :)
Update: Although I originally only used a manually-activated Pulse Injector, it required that the player flip the switch on/off quickly. Just for fun, I decided to add an Auto-Pulse Injector to make it simpler to activate the clock. (The design for which came from the Wiki).
Answer: With the 1.5 update with hoppers and comparators you can make a dispenser face upwards in to a downwards facing hopper and a comparator on the hopper (by the side of it), then place any item that can stack and a item that cant stack in the dispenser, then power the dispenser, a random item will go in to the hopper. If it's a non stacking item it will give out a signal strength of 2 if it's a stackable item it will give out a signal of 1.


Double-sided tape residue on painted wall, how did I remove it?

Question: I've tried everything warm water and soap , hairdryer and knife .. etc ... I need something effective . Can someone help ?
Comment: Can you describe the residue? Is it hard, soft, sticky to touch, etc. can you "squeeze" together some of it with your fingers to pull it off? Please "edit" your question to add information.
Answer: Try lighter fluid - apply some to a paper towel and rub at the residue in a circular motion.
You'll want to check the painted surface for color fastness on a suitably hidden spot first to be sure it's not going to damage the paint (although this is unlikely in my experience)
Comment: +1 but peel off as much of the tape as you can first.
Answer: I had a similar problem, but applied on a wooden door frame - I wanted to protect the door frame while painting the walls. I got the problem of glue left on the wood.
At somebody's suggestion, I rubbed the affected area with a cloth dipped in kitchen oil. There was some work, but the glue eventually came off. After that, removing the excess oil was not a big issue.
In your case, you should test your wall first, to see if the oil would damage it. Do the test in a hidden area, to be protected in case of a positive test.
Answer: I used rubbing alcohol before and it seems to do the job. However you need to watch out not to rub the paint off walls. I believe paints that can be removed using water can wash with this. (Now I have small washed stain on my wall).
Answer: I've actually used the same piece of tape to remove the stuck glue. The glue on the tape will usually stick to the glue on the surface really well, then you gently/slowly remove the tape again. Make sure you are touching glue to glue, not bare spot to glue.
Once you have the tape stuck back to the glue spot, you can also try using a circular motion when pulling off the glue. You can also try using the tape to essentially rub it glue off.
Using a mild solvent oil, like WD-40 or Goop, you'll want to keep it from touching a painted surface as much as possible, as it can damage the paint. I suggest using a cloth towel to apply the solvent to, then gently apply the oil to the whole glue spot, then rub the glue spot off gently. Using a circular motion can help. What this does is allow the solvent to get under the glue as well as preventing the glue from sticking to another section of wall as you remove it. You'll need to wash the solvent off very shortly after removing the glue, so it has less time to dissolve the paint.
You can do the same thing with a grease removing soap, like Dawn. Some soaps won't work very well, since they don't work well to dissolve the soap, but they can still help.


Force string into signup form

Question: I am running WP multi-site and BP. The plugin in question is Anti-Splog by WPMUDEV. They have advised they do not support customisations.
Anti-Splog tries to limit spam blogs from appearing on your multi-site network.
I am running a subdomain install. Therefore, on the form where the signup for a subdomain occurs, I want to autofill the value of the form box, and lock it so the user sees the subdomain.
However, even by forcing the $string as the value, it will not continue on to create the new subdomain blog. It says, please enter a value.
This is the random string code:
   $subdomainhash = array_merge(range(0,9),range('a','z'));
   shuffle($subdomainhash);
   $newsubdomain = implode('',array_slice($subdomainhash,0,32));
   echo $newsubdomain;

Now, to force users to use that string on the select subdomain form I have to edit the following code:
    ' . __('Site Domain:') . '';

if ( $errmsg = $errors->get_error_message('blogname') ) { ?>

<?php echo $errmsg ?>

<?php }

if ( !is_subdomain_install() )

    echo '' . $current_site->domain . $current_site->path . '<input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" />';
else
    echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" />.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '';

if ( !is_user_logged_in() ) {
    if ( !is_subdomain_install() )

$site = $current_site->domain . $current_site->path . __( 'sitename' );
    else
        $site = __( 'domain' ) . '.' . $site_domain . $current_site->path;

    echo '
(' . sprintf( __('Your address will be %s.'), $site ) . ') ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '
';
}

It doesn't seem to matter if I force $blogname or $site to be $newsubdomain.
It does not fill the value of the form, or replace the above strings. I can't get it working?
The subdomain box needs to be the random subdomain string above on a new site registration.
Can any php guru could help please?
Thanks in advance,
Johnny
Answer: Not sure where you are placing the code as you don't say - but you will need to edit the WordPress signup code / file and add your random string code in there and then hide the input for the sub-domain or set it to disabled and set it's value to the random string.
You'll then also need to encode the same random string in the form and check that the encoding is correct when the form is submitted so that you know it hasn't been changed (it would be easy to change the random code in the HTML using something like firebug).
Once you get past the processing then the blog creation will be the same and antisplog will work as before.
Comment: Thanks caffeinated, the code is in the ust-wp-signup.php which is the second code paste above. The two  tags. I will try firebug, as I was manually editing the php file, then creating a new blog. However I got the error above. I think it is an encoding issue. Will let you know. Thanks
Comment: That was painful. All fixed now.   :)
Comment: Well, done - but you don't have any checks in there to ensure that your user doesn't use firebug to edit the string you set - which is very easy to do.
Answer: ' . __('Site Domain:') . '';

if ( $errmsg = $errors->get_error_message('blogname') ) { ?>

<?php echo $errmsg ?>

<?php }

   $subdomainhash = array_merge(range(0,9),range('a','z'));
   shuffle($subdomainhash);
   $newsubdomain = implode('',array_slice($subdomainhash,0,32));

if ( !is_subdomain_install() )

    echo '' . $current_site->domain . $current_site->path . '<input name="blogname" type="text" id="blogname" value="'. $newsubdomain .'" readonly="readonly" maxlength="60" />
';
else
    echo '<input name="blogname" type="text" id="blogname" value="'.$newsubdomain.'" maxlength="60" readonly="readonly" />.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '
';

Force string into signup form


i am stuck on how to weight paint my human character using the rigify add-on

Question: i am trying to weightpaint my character. I have used the riify add-on to rig it. I do not know what the relationship between the rigify rig and weight painting is. Do i paint on the human meta rig? I am trying to make it so that i can control my character using the rigify rig. I know how to weightpaint the human meta rig but i am unsure how to approach it with rigify. Help would be really appreciated as i am desperate to get animating after making this character for so long! Thanks!
Answer: The metarig is only used to lay out the bones on the mesh. I recommend a tutorial if you're not familiar with Rigify.
Place the character model so that it stands on the "ground" (soles of the feet at z=0). Make sure you have applied All Transformations (scale, location, rotation) to the mesh with Ctrl+A (in Object mode) before you start. The bones of the elbows and knees should be bent slightly.
When you're happy with the layout, apply All Transformations to the metarig, then press the Generate Rig button. You can use this button more than once. Rigify can override the generated rig. See section button Advanced Options.
The Generate Rig button creates the actual rig. It's just named "rig" and has all the control bones and deform bones (layer 30) on different layers.
After you have created the generated rig you can parent it to the mesh with Automatic Weights and test it in Pose mode.
There might be some issues that need to be fixed.

The fingers might need some corrections. To make the fingers "grab" you need to scale the red handle. If it doesn't work proper have a look here: Rigify finger controls rotation not moving correctly

The eye lids you might have to weight paint manually. And you need to parent the eyeballs to a bone of the rig to make them follow the control. Video: Fixing the Metarig - The SECRETS of RIGIFY: Part 3 and Weight Painting - The SECRETS of RIGIFY: Part 4! - [Blender 2.8]

The teeth and tongue might need some weight painting
Comment: Thanks! I am really grateful for your advice and it has helped a lot!
Answer: The main things you should understand are:

The meta rig is just a way to build the Generated rig. You always parent and weight paint with the Generated rig.
The Deformation bones of the Generated rig are on layer 29 which is hidden by default. So you weight paint Rigify like any other rig but you have to unhide layer 29 first.


Touchpad scrolling not working, all set correctly in dconf editor, acer aspire V3 771G, Ubuntu 13.04

Question: I've been through all the other similar posts I can find on this, and they suggest creating/editing files that seem to make no difference, sorry.
I have a new computer (Acer Aspire V3 771G) running Ubuntu 13.04, but touchpad scrolling won't work.
I've tried enabling everything touchpad related in the dconf editor, and even installed the unity tweak tool and bodged settings around in there, but nothing seems to work.
Can anyone offer me any advice as to what I should try next?
Thanks,
   Doug.
Comment: Could you post the output of `synclient`?
Comment: Sure thing:

> $ synclient

> Couldn't find synaptics properties. No synaptics driver loaded?

And thanks for looking at this,
  Doug.
Comment: a quick "me too" comment. same output. any ideas? thanks
Comment: Nothing yet, sorry.
Answer: I found the answer at http://nwoki.wordpress.com/2012/10/02/multitouch-fix-for-alps-touchpad/ for my Acer Aspire V3 771G.
The version I've downloaded was 1.3, so replace every instance of psmouse-alps-dst-0.x with psmouse-alps.1.3 (so, without the dst). Also, I did not change the alps.c file as mentioned on the website.
After ending every step I can (finally) use my touchpad. I only have to get used to spreading my fingers a little wider than I am used to with a synaptics touchpad.


Can any other devil fruit users use gears besides Luffy?

Question: In One Piece, Luffy can use gears 2-4 (I know from a little bit of spoilers, I'm on the Water 7 arc and he has already used gear 2), but so far I haven't seen another devil fruit user use gear like Luffy's. Is there any devil fruit user that uses gears?
Answer: You're asking the wrong question. Gears is just the name given by Luffy to the extra usage of his unique paramecia body, hence technically only he can use Gears.
Gear 2

 Luffy uses his Elastic Heart and Blood Vessels to increase his bloodflow, this allows him to increase the limit of his body. He can move very fast and increased strength. It however decreases his endurance as he experiences more fatigue

Gear 3

 Luffy pumps air into his bones, which also being of rubber expands and allow him to increase the size and momentum of his moves

Gear 4

 Here Luffy pumps air into his muscles. This allows him to use Haki, while remaining elastic enough to dodge/bounce back attacks

Other users have their own special moves.
For Example:

1. Magellan - Covering his body with a stronger poison (Venom Demon: Hell's Judgment)
2. Robin - Using Thousands of Hands to create larger body parts including Wings. (Gigantous Mano or something)
3. Mr.3's Wax Suit (Champion Form)

If they call their special moves something else instead of Gear N, it doesn't change the fact that they are using there fruits' ability in a new way :)
NOTE: All Credit to Luffy for thinking outside the box, though I doubt he considers the impacts of those actions before doing something, usually he does it because its COOL! :D
source : http://onepiece.wikia.com/wiki/Paramecia; Anime/manga
Edit: added more examples.
Edit 2: With the introduction of awakening, it makes sense to add that each fruits awakening will also be unique. Thus Luffy's version of awakening and how he uses it or even accommodates it into his Gears will be upto his ingenuity. (Personally, I want him to use a Staff (Like young Goku), which can extend due to his Rubber powers!)
Answer: Luffy is the creator of Gears, and so far in both the manga and the anime, he is the only known user to use it. In the One Piece wiki, the only person who can use Gears is Luffy, and the only reason he can even use gears is because of his Devil Fruit, the Gomu Gomu Fruit. Wiki quotes:

By taking advantage of the unique physical abilities granted by his Devil Fruit, Luffy has invented techniques that augment his speed and strength in different ways, though each one also has corresponding physical drawbacks. He refers to these techniques as Gears.

The way Gears work (you will see quite soon because they explain it in the CP9 event during the fights) is that Luffy pumps his blood a lot faster than normal, and his veins don't explode because he can stretch any part of his body, whereas if a non-stretchy person tried this, their veins would explode causing instant death. Therefore, no one besides Luffy can theoretically learn Gears.
Answer: Gears is just a name to his techniques. They are called gears basically since he is forcing his body or devil to its current full potential. If we go with that thinking then we can say that logia devil fruit user also use "gears" when transforming to liquid (well not liquid but when they turn to light or sand or fire etc). The one thing that all devil fruit users do have is awakening. But since you are in Water 7 arc I'll just stop here.


Exporting from Corel for word?

Question: I'm developing a number of maps within arcMap which are then exported to Corel for final annotation. In the past i have exported as a .png, to insert into my word doc. The maps i'm currently working on however export in poor quality, from corel. Unlike others they have text in from arcmap, but they look perfect in corel. I've tried "export for word" and also tried .bmp and .jpeg options. Any other work arounds?
Comment: What settings are you using to export from CorelDraw? that might make a difference. Also adding some of the images to your question would help.
Comment: I've added the typical setting available to me. Any suggestion based on that?
Comment: The first image came from arcMap? Despite the huge size, the quality is already quite poor. Also I see that your image size is in mm, but I wonder what is the resolution (DPI)? That also has an effect on the final image quality.
Comment: the first image is the .png exported from corel. i'll play with resolution.
Comment: Definitely the first one is not a png, it is a jpg with a lot of compression.
Answer: Definitely the first one is not a PNG, it is a jpg with a lot of compression.
It is also already resampled (probably 200%-300%) after you generated the original image.
Now.
You should not "play" with the resolution n_n. You should find the correct setting.
1) Make sure your original texts and bullets and stars are in vectors inside Corel.
2) Export as PNG and, if in the map you have the real phisical dimensions (in cm or in) export one version at 300 ppi, one at 200, one at 150.
If you really need that inside Word, go ahead, if you need that for print, you should not use word for that.

There is a chance you make a marmalade of the image before inserting it inside Corel. That happened probably before you inserted the elements inside it.
In the example, the poor text was born as 72ppi.
If you export the image at 72 ppi he is still a happy text.

But if you push the resolution, the poor text can not live with the expectations. 150 ppi

Poor text. 300 ppi.

That is what happened with your top image

The problem was not the export, was the import, in which case, you need to review your process.
Answer: Open coreldraw file > Select All (Ctrl+A)
Press ctrl+E

A pop > Enter the file name > save type format to JPEG >select only tick on
click on export

A pop > Keep the resolution to 300 dpi and color mode > RGB and rest of the setting as shown and click ok
Now open MS word
Go to Insert tab or click insert

click on Picture > a pop and navigate your file where u have exported the coreldraw JPEG
Comment: Why first select all and then check "Selected only"?
Answer: The problem is simply that you're almost always going to lose clarity once you export to a raster format.  Fortunately, you have two vector-based options when saving/exporting from Corel for use in Word: .emf and .wmf.  Either of these formats can be inserted into your Word document using the Insert Picture function (just like you would a jpeg/png).
Click File > Export for Office, then for "Graphic should be best suited for:", select Editing.  This will allow you to export your graphic in the .emf format.

Alternatively (and the option I prefer), you can click File > Save As and choose WMF - Windows Metafile.

One other thing I should note:  Sometimes (most times probably) the graphic will look "not so great" when you're looking at it in Word.  But fear not, it is just a result of Word not being very good at rendering graphics on-screen.  Upon PDF/printing of your document, the graphics should look as crisp as they did in Corel.
Hope this helps.

Exporting from Corel for word?


Indexing pages with few text (like tags with just one article) is penalizing for the SEO?

Question: Have you done any experiment or read of any case study to check if too many tags are really damaging the SEO of a website?
Answer: The main issue with having too many tags is that CMS such as Wordpress or Blogger will create tag pages similar to category pages which can result to many similar thin content duplicate template pages which can negatively affect your SEO.
However if you are looking to insert many tags to improve the User experience then you can nofollow and noindex the tags pages which will not cause any SEO issues.
TIP: If you use wordpress there are plugins such as All in One SEO & Yoast which options to noindex these type of pages automatically.
Answer: According to the Google's Panda Update - Website must have quality content.
Websites with low & thin quality content is getting low authority. It says:

Google's Panda Update is a search filter introduced in February 2011 meant to stop sites with poor quality content from working their way into Google's top search results. Panda is updated from time-to-time. When this happens, sites previously hit may escape, if they've made the right changes. Panda may also catch sites that escaped before. A refresh also means "false positives" might get released.

The following tags are important in SEO:

Title Tags
Meta Description Tags
Heading Tags (H1-H6)
Italic/Bold Tags
Meta Keywords Tags
Image Alt Attributes
Nofollow Attributes
Robots Meta Tag
Rel="canonical" Link Tag
Schema Markup
Social Media Meta Tags
Viewport Meta Tag

Tags will help Search Engine to understand more about website & helps in improving the visibility of website.
Meanwhile unique H1 tag must be used in a page. We can use H2-H6 tags wherever necessary using secondary targeted keywords.
Comment: Your list of tags that are "important" for SEO is a load of hooey.  Some of them aren't tags (the attributes).   Some of them are completely ignored by search engines (meta keywords, social media tags).   Some of them can be replaced with CSS and have the same SEO effects (bold, italic, headings).   Some of them have the ability to change how your site looks in the search results but have no effect on rankings (meta description, schema).  I'm not sure how that list helps answer the question anyway.  Your first part seems relevant, but not the tag list.


Remote desktop from Mac to Ubuntu without logging in first?

Question: this has been asked before but I dont see a response just yet. I was wondering if there is a way to remote desktop from my mac to Ubuntu 11.04 without logging in first? My ubuntu is set up as my media server, and occasionally I need to screen share. So far I am able to do it successfully from Apple Screen share IF my ubuntu user is logged in. However, if ubuntu is at the screen prompting username and password to login, screen share will not connect. I am able to login via terminal after I ssh, but it wont work unless the user is actually logged in. Any help would be appreciated, its annoying to keep connecting a monitor just to log in.
Answer: I would probably install X2Go if what you really want is a remote desktop solution. This is a terminal server that will enable you to log onto the system whether or not the user is logged in. You will also be able to run a single application from the other machine. And it's much faster than VNC. http://www.x2go.org.
However, if your Ubuntu machine has a screen and you just want to control it using a laptop as a mouse and keyboard for it, then you want to use Synergy. This is available for Ubuntu, Windows and OS X and then the other computer simply acts as an external screen to the laptop.
Answer: You need to make sure vino is loaded at startup, not just when your user logs in.  Take a look at these instructions: http://jakeyoon.com/2008/11/19/enable-vino-vnc-server-for-login-manager-gdm-in-ubuntu/


How can I install a pendant light fixture on a cathedral ceiling with no attic space?

Question: My house has an integrated ceiling/roof with exposed rafters... the ceiling/roof is sloped and surfaced with V-edged 2" redwood boards over 4x6 rafters 4' on center.  I want to hang a pendant light over the dining room area (unfortunately right in between two rafters).  Do I need to mount raceway to a surfaced-mounted junction box? What type of junction box exisst for this implementation (that doesn't look like a rough piece of hardware)?
Comment: A picture might be useful.
Answer: Here is a link to lots of images of a variety of surface wiring hardware.  There are several manufacturers of good looking surface boxes and raceways. One of the popular high quality makers is Wiremold.
Comment: thanks so much... great ideas... sara Tester101 shirlock homes... special thanks to @HerrBag for all the images - very helpful... Since the previous owners painted the ceilings, I'll be repainting. It should be relatively easy to embed the wiring up to the J box and caulk/paint to hide it.
Answer: I think a redwood cove molding

(like a crown, its a sprung molding, installed at a 45, with open space behind) to hide the wire running up from the wall, installed on the side of the 4x6 rafter.  Then reate a minibeam (Attach a top piece across the whole joist bay, then add a 3 sided box that slides over the top piece) that has unequal legs, to create a level spot to attach the pendant hardware.  The angled beam would run from side to side.  Encase a junction box sitting on an angled block that matches the slope of the ceiling.
If you can rout out enough space for the cable in the ceiling boards, a flush mount fixture might work.

If you don't do this yourself, you'll need both and electrician and a finish carpenter.
Answer: Have a channel plunge-routed up the side of the beam/rafter. Run the Romex through the channel. Cover with a matching piece of flat redwood the width of the beam, a quarter inch or half inch thick sister board is all you need, it's just to cover the channel and wire. Also route out a shallow pancake J-box space at the nearest point to where the drop will be for the light fixture. A hole drilled in the sister board where the wire comes out of the J-box will remove the need for an unsightly box cover. The sister boards should be installed with small screws or finishing nails which will allow you to gently pry up the board to service the wiring if needed. Use a chain and hook to loop the cord over and down to the location you desire. If the chain annoys you you can cover it with a fabric sleeve, ruched up over the chain and wire. I have done installations like this in a number of arts and crafts homes and it has worked well and looked really nice.


Is HTTP status code 500 acceptable to be shown to a user?

Question: Are there any cases when error 500 is acceptable to be returned? Or should we always try to handle all server-side exceptions and return another code with a user-friendly informative error message?
Answer: From the question I'm understanding that you are asking if it is okay to allow the default white page with critical information of probably the page and line number of the code where the error occurred to display in the front-end/production environment/user side.
Simplest and most appropriate answer (as per my understanding) is NO.
The reason being this discloses critical data which malicious users (hackers) like to exploit. Instead of this have a custom error page for error status codes like 500, 503, 404, 403 and any other error status and wherever such an error occurs redirect users to the respective custom error page which will display a custom and more user friendly error message.
Answer: No. If you ask a normal person (i.e. a non geek) they will most likely think that they have done something wrong. You should always try and be as user friendly as possible. Also the stack trace should never be visible in a production system as that is exactly what hackers are looking for.
One thing we used to do was in a test environment was to surface the stack trace in the HTML source as comments so the test automation can easily access it.
Also I have seen white text on white background to display the text in production, so you only needed to highlight the white section to see it, but this is a bad idea as most hackers will use their own client side source, not yours.
Comment: Any of the 5xx error code will result in the page content to be displayed normaly. So while the page content should display user friendly content, it is good practice to use the proper http status code. If you return a faked 200 status code, search engine such as Google will update their index with the error message, overwriting the real content. /// Proper advise is to return the correct http error status code with a user friendly message.
Answer: The wording of the question and the answers seem to miss a subtlety in what you're asking. To not break HTTP, you should always return as a 500. You never redirect to an error page (and give a 200 OK if something bad happened).
Now, whether or not you're bubbling up the stack trace, or just giving a simple "something bad happened" - that's another story. Web and app server trickery can be used to mask the specifics while still returning the proper HTTP status code. So the simple answer is yes return 500, but yes swallow the exception details before delivering the page to the end user.
Comment: Indeed it's important that your HTTP response code != what you display to user. (Anecdote: Once my friend was pissed off because a client was idling with payment, and what he did is he made response codes of all site pages to be 402 'Payment Required' instead of 200. Since page content wasn't changed, the site looked normal, so it was kind of ineffective… but fun =))
Answer: In production, our web application shows a friendly message.  While manual testing, we set a test flag that allows a stack trace to appear in the browser.  When we are penetration testing or stress testing, we surface the HTTP 500.
Comment: It is generally more user friendly to return a friendly error message - however it isn't really harmful to return a vanilla 500 error and allow the browser to display their default error page for that exception.  It goes without saying that you should never return the detailed 500 errors with stack trace info as that could compromise your site's security.  A hacker who has access to detailed exception info and stack traces can use that to their advantage.
Comment: Agreed.  When we manually test, we use a QA system with different credentials, not the production system.
Answer: Our applications display a user-friendly message to the user with an error code in brackets beside it to avoid the "Error hiding" design anti-pattern. In the particular case of a server timeout I use (500) beside the friendly text message that "There was a problem completing your request please try again later.", etc.. This is a friendly message to the user but also allows a technician to know what type of failure occurred if the user contacts us about it.


Running time of sparse matrix multiplication

Question: Given a sparse matrix $M \in \mathbb{R}^{n \times m}$ with $n \ll m$ and $\mathsf{nnz}$ being the number of non-zero-components. What is the running time of computing $M M^T$?
Comment: What do you think?
Comment: What have you tried? Where did you get stuck? We do not want to just hand you the solution; we want you to gain understanding. However, as it is we do not know what your underlying problem is, so we can not begin to help. See [here](http://meta.cs.stackexchange.com/q/1284/98) for tips on asking questions about exercise problems. If you are uncertain how to improve your question, why not ask around in [chat]?
Answer: The question doesn't make any sense. It doesn't make sense to ask for the running time of a computation, unless you specify an algorithm for that computation. So how would you calculate this product? That's the first thing you need to do: Specify an algorithm how you calculate the product.
The next step: Assuming that many array elements are zero, can you reduce the amount of work that this algorithm would be doing? For example, if you know that x = 0, then it's pointless to multiply xy because you know the result is 0. And it's pointless to add xy to z, because that doesn't change z. So how can you take advantage of many array elements being zero? What's the runtime if you do that?
The next step: Assuming that many array elements are zero, can you reduct the amount of work further? Would you need some clever data structures? If yes, which ones?


SDR (RTL-SDR v3) USB audio much less than LSB

Question: Why does USB have so much less audio output than LSB? I've checked all settings and they are correctly set or not used, like AGC etc. Using same band pass on both modes.
Comment: It would help if you explained how you came to this conclusion.
Answer: Not knowing your level of experience with the various amateur radio modes, be aware that for a given SSB (single side band) signal, only one of the side bands (upper or lower) is transmitted. The carrier and the other side band are significantly suppressed in the transmitted signal.
Since USB (upper side band) tends to be used on the higher frequency bands, you may simply be experiencing the difference in gain of your DSP or your antenna system on these higher frequencies. Normally, a properly configured AGC block will minimize this variation but it cannot completely eliminate it.
Comment: Thanks for the responses. No. I'm quite experienced in receiver design being an applications engineer type and many decades as a ham. SDR is my first exposure to the A/D type approach though. The difference in level of audio out between LSB and USB has me wondering why. It has to be something about filtering or slope of response. I will keep at it to figure it out.
Answer: Figured out the audio level difference between USB and LSB. With USB the AGC selection became active then using LSB it turned off. Settings are not permanent but need checking for each frequency selected! 73, Jim K5BTV


How to describe guns to someone who has never seen them before

Question: In my story, a mysterious visitor presents the characters with a new weapon: guns. These people have never seen anything like it, as gunpowder has been discovered but not really used to its full potential. So they know what gunpowder is, as well as metal. However, they do not know about things like bullets or triggers or barrels. So how would these characters describe these gun if they have no knowledge of them if I also want to give clues to the reader knows what they are before the character does? Note that I am writing in thrid person and in the present tense.
Comment: @FFN Now that I think about it, that is fine. Thanks, maybe just copy and paste it as an answer so I can check it as accepted.
Comment: "a small metal object, looking like the hilt of a sword, with a small lever which produced a loud bang when pressed" is enough? Add something about magical small metal arrows if you will.
Comment: @FFN But how would they identify it at first sight, if it did not go off yet. Also, this is a smaller revolver type pistol.
Comment: so you want your characters to identify a gun and it's inherent danger without having ever seen one? I don't think it's possible, but you could say something about how intimidating the weapon looks and that it fills the characters with unexplainable fear. Is it really necessary that they identify the gun before someone uses it?
Answer: You should try to draw comparisons between the gun and the things your characters already know. Try decomposing the gun to its most essential parts and describing those.
My solution to this specif case (a revolver type pistol) would be something on the lines of "a small metal object, looking like the hilt of a sword, with a lever which produced a loud bang when pressed". If you want, describe how this object shoots "magical small metal arrows" and uses "black smelly earth" to function.
Comment: If they know gunpowder they can describe the smell as "like fireworks".
Answer: You write that gunpowder and metalworking have been discovered. So the people of that world know that gunpowder explodes (and that explosions create a force that propells stuff) and they know objects made from metal such as tubes (and if they don't, they know tubes made from other materials such as clay or wood).
Given this knowledge, I do not understand the difficulty in describing a gun and why you would accept an answer that compares a gun to a sword hilt.
If the information given in your question is complete enough for us to answer your question, then the following description of a gun should be appropriate:

A handle attached to a metal tube, through which a metal ball is propelled by exploding black powder.

Note that instead of "gunpowder" – a term derived from a word for an object that does not exist in your world – I use the synonym "black powder".
Answer: The description depends on the point-of-view character, the actions of the gun-wielder, and the current weapon systems available.
If your POV character is observant, quick-witted and capable of making inferences you get a different description than if they are arrogant with a sense of cultural superiority.
The physical description is couched in terms of what is familiar to the POV.

The strange men hastily formed an outward-facing circle. Each quickly drew a short, hollow cylinder from open pouches at their hips. They raised one in each hand towards the warriors, shifting the target of their flute-like devices to the warrior closest to each of them.

The action of forming a defensive circle and raising something is a clue to your readers.
You can also describe the way they sight down the barrel, or they way they move the barrel between targets like a bow and arrow.

The chief understood the strangers believed their devices should keep the warriors at bay. These were obviously weapons of a sort. But were they actually dangerous or merely a superstitious device to send evil spirits towards the warriors?

Once the gun is fired you can describe the sound, small and sight of the gunshot plus the effect of the weapon on the target. You can also describe the changed demeanour of the gun-slinger. But that's getting beyond your question.
Human males generally posture and scream before resorting to violence, if this is a first contact type story.


Why class weight is outperforming oversampling?

Question: I am applying both class_weight and oversampling (SMOTE) techniques on a multiclass classification problem and getting better results when using the class_weight technique. Could someone please explain what could be the cause of this difference?
Comment: You should check out this question: https://datascience.stackexchange.com/questions/44755/why-doesnt-class-weight-resolve-the-imbalanced-classification-problem/44760#44760
Answer: You should not expect class_weight parameters and SMOTE to give the exact same results because they are different methods.
Class weights directly modify the loss function by giving more (or less) penalty to the classes with more (or less) weight. In effect, one is basically sacrificing some ability to predict the lower weight class (the majority class for unbalanced datasets) by purposely biasing the model to favor more accurate predictions of the higher weighted class (the minority class).
Oversampling and undersampling methods essentially give more weight to particular classes as well (duplicating observations duplicates the penalty for those particular observations, giving them more influence in the model fit), but due to data splitting that typically takes place in training this will yield slightly different results as well.
SMOTE creates new observations of the minority class by randomly sampling from a set of "similar" minority class observations. Synthesized observations are computed based off adding a random percentage of the difference between two randomly chosen "similar" observations, for each coordinate (i.e. column). Similar observations are defined typically using the k most closest neighbours to a particular observation of the minority class. This means that, depending on the value of k chosen, as well as numerous other factors such as how similar your observations are in general, the distance measure, etc. SMOTE may or may not be useful for your particular problem.
Methods that deal with class imbalance do not all work the same and is a large area of study. It appears you have noticed that the class weight method is more effective, which is why any sort of method chosen in addressing any potential class imbalance problem needs to be wrapped within a model validation scheme to see if the particular method (or really, using any method at all) yields any benefit.
Comment: Thank you for the detailed explanation. I have a follow-up question: when I compare the iba (Index of Balanced Accuracy) index of these two techniques, SMOTE outperforms class_weight. The recall of the minority class in **class_weight** is much less than the SMOTE approach. I thought we may need to involve **iba** in our decision-making process. May I have your thoughts on this?
Comment: ...the model is going to be used.
Comment: I am not too familiar with iba because I almost never use evaluation metrics that aren't proper scoring rules. Corrections can be made to metrics such as log loss (such as finding the relative improvement of the model's log loss vs the log loss of a simple, naive model such as one that always predicts the majority class with probability equal to the proportion in the training set). That being said, iba appears to be the average accuracy score observed within each class? If you value better predictions of the minority class (more true positives) at the expense of more false positives then...
Comment: SMOTE might be the better option based off what you have observed. But this depends on the context of what you are trying to do, namely the costs of false positives/false negatives. Rarely does anything come for free. In your case, the model's overall accuracy is dropping (I assume so, anyway) in exchange for predicting the minority class better. Seemingly, this is because your model is more likely to predict the minority class through the use of SMOTE, for better (more true positives) and for worse (more false positives). Whether this is desirable depends solely on the context of how...
Answer: Probably not the answer you're looking for, but don't go crazy! Different class weight strategies give different results.
The follwing drove me almost crazy! The following should give the same results, but it doesn't.
class_weight = "balanced"
class_weight={0:0.85, 1:0.15}
I learned to live with it ...
Comment: Thank you @FrancoSwiss, the example is very intuitive.


Uniform sampling with constraints

Question: Suppose one wants to uniformly sample a string $w$ of a given length over a finite alphabet, such $w$ satisfies a set of structural constraints (such as - "the third character has to be equal to the first character and the last character has to be equal to the second one").
The obvious method is to uniformly sample $w$, check if the constraints hold and return it if so. However, I am dealing with the case where there are many constraints, and the probability of random string to satisfy them is extremely low. Is there a way to sample uniformly from the set of all strings satisfying the set of constraints?
Comment: These equality constraints are trivial to implement (just copy the equal characters).
Comment: Maybe too broad. I don't think there is a general solution.
Comment: If the equality constraints do not depend on character values, @YvesDaoust's suggestion results in a uniform distribution.  OTOH if you can have value-dependent constraints like "If the third character is A then the fifth must be B, otherwise it can be any character", uniformity will in general be lost.  (Example: Every character at an even position is forced to be A if the first character is A and free to vary otherwise; strings with As in even positions will be heavily overrepresented if the first character is chosen uniformly.)
Comment: https://cs.stackexchange.com/a/115520/755
Answer: If your constraints can be described using a small DFA, then you can use sampling-by-counting, which works in the following way. For each $\sigma \in \Sigma$, count the number of legal strings starting with $\sigma$ (as explained below), and use this to sample the first character, say $\sigma_1$. Then, count the number of legal strings starting with $\sigma_1 \sigma$ for all $\sigma \in \Sigma$, and use this to sample the second character; and so on.
It remains to explain how to count the number of strings of length $n$ with prefix $x$ accepted by a given DFA. Let me start with the case $x = \epsilon$. The idea is to use the transfer matrix method: construct a matrix $A$ in which $A(q_1,q_2)$ is the number of edges from $q_1$ to $q_2$ in the DFA (that is, the number of symbols $\sigma$ such that $\delta(q_1,\sigma) = q_2$). It is not hard to check that $A^n(q_1,q_2)$ is the number of words of length $n$ which carry the DFA from $q_1$ to $q_2$. Taking $q_1$ as the initial states and summing over all final states for $q_2$, we obtain the number of words of length $n$ accepted by the DFA.
Given a prefix $x$, we do exactly the same, only counting words of length $n-|x|$ that are accepted by the DFA when started at state $\delta(q_0,x)$.

As a simple example, you can use this technique to sample a word of length $2n$ over $\{a,b\}$ having an equal number of $a$ and $b$. Although the corresponding infinite language isn't regular, you can construct a DFA for this language which has $O(n)$ states, making the above approach feasible. In this particular case there are also known closed formulas for the number of words of length $n$ with prefix $x$.

With some work, you can probably extend this approach to context-free grammars. One thing to try would be to extend the CYK algorithm so that it counts the number of words of given length with a given prefix.

Uniform sampling with constraints


Who named the chapters of the Quran?

Question: Every chapter of the Quran has a name.
So, were these names given by Muhammad(saww) or was he told before the revelation that this is for chapter so-and-so?
If not, then who named these chapters?
Comment: Oops, you asked a nice question. Actually I wondering who named them too. but I think they have named by the mean of Allah, then Allah inform the Prophet to name them like their current names.
Answer: There is two main theory about it:
Some scholars believe that the names of Suras of Quran are

"Towghifi" which means they have been chosen by the Prophet. For example Ayatollah Mohammad Hadi Marefat claims this theory and says:

each Sura of quran has been named by the Prophet because when one ayah descended from Allah, the Prophet said to put it, in which Sura.

named because of being widely used by people with these names. Ayatollah Javadi Amoli believes it and says:

there is no reason that these Suras are named by infallible and also there are Suras which has a great meaning but their names are not so, for example Al-Baghara (cow) and Al-Naml(ant) ,...
Answer: The names are given by the people of that time. These are no given by Allah himself. According to arabic traditions, the names does not necessarily represent the main topic of the chapter.
Answer: Scholars hold a variety of opinions on this. Some scholars believe that the naming of the chapters was all divine, that is, Allah informed the Prophet as to what the names of the different chapters are. Ayatollah Haadi Ma'rifat espouses this view in his al-tamheed.
Others believe that some chapters of the Quran were named by Allah whilst others came to be named due to other reasons such as popular usage. Ayatollah Javadi is of this opinion. For example, he believes that Surah al-Baqrah was not divinely named because firstly it is not fitting for such an important surah to be named after an animal and secondly there are some narrations which warn against referring to the Surah as al-Baqrah. Some of our scholars have thus referred to it as "The Surah in which the Cow is mentioned"... Ayatollah Javadi believes that Surahs such as Yaa-seen, Fatiha etc were named by Allah whilst others like Ankaboot, Naml, Baqrah came to be named by the people.
I read an interesting discussion which provides references for some of the views on the following page...
https://lightofthefurqan.wordpress.com/2016/01/10/ayatollah-javadi-naming-the-chapters-of-the-quran/

Who named the chapters of the Quran?