How do you checkmate with a queen?

Question: How do you checkmate with a King and Queen versus King?
Is there a method that is faster than other methods in terms of moves?
Is there a foolproof method if you are in time trouble?
Comment: Treat the queen like a rook, but watch out for stalemates.
Comment: I love this series of questions that you're creating, very informative and covers all the basics, `Is there a fool proof method if you are in time trouble?` is a  great question, btw I didn't know that you had a youtube channel :)
Comment: @Fischer Thanks! :) Yeah, it is important to cover the basics. Yep, I do have a channel, I get 5 views per video, everybody loves it! :)
Comment: @RauanSagit you need to change the title of your videos :) nobody will search for `live g11` and you don't include description in your videos, there's no way to find  it while searching, call it `ruy lopez` or whatever you get many more views :)
Comment: @Fischer Good point. I should do some title editing and add some descriptions. Make it more search friendly! :)
Answer: Grave Danger in King and Queen vs lone King
It's important for the winning side to avoid this common pitfall in this basic endgame.

The winning side should avoid placing their queen on the c2, c7, f2 or f7 squares if the opponent's King is in the nearby corner, because this leads to stalemate.
Below, I include some other types of stalemates that are not as well known.

Basic Idea
The plan is to drive the king to one of the edge ranks or files.

After this is achieved, the checkmating positions are usually like this -

Rectangle Method
This method is the fastest and similar to the rectangle method involving checkmate with a rook. The trick is to confine the opponent's king in the smallest possible rectangle with the queen's first move (if not already confined or can be confined at a later move) and then bring the side's own king closer to the opponent's king.
In the position to the left below, White plays 1. Qc6 as the first move, making the rectangle smaller.

Once this has been achieved, White simply brings the King closer to the Black King to drive it into one of the edge ranks or files. The rook check trick discussed in the rectangle method for the rook applies here with the queen check.
<code>  [FEN "8/8/8/4k3/8/8/8/K6Q w - - 0 1"]

  1. Qc6 Kf5 2. Kb2 Ke5 3. Kc3 Kf5 4. Kd4 Kf4 5. Qf6+ Kg4 6. Ke3 Kh5
  7. Qg7 Kh4 8. Kf4 Kh3 9. Qg3#
</code>
Knight's Square Method
This method is mainly for beginners. Normally, experienced players will do better to use the rectangle method even in time trouble. However, it may at times help to use a  combination of this and the rectangle method.
If you're a in time trouble, this a very fast (in terms of how quickly you can make the moves on the board without thinking much) and foolproof (stalemates are always to be watched out for) way to checkmate the opponent's king.
With this method, you can literally finish playing the move before the opponent's hand even reaches the clock (assuming you're not playing online).
Consider this position where the Black King is on e5.

The King can be checked by a White knight from each of the 8 squares d3, c4, c6, d7, f7, g6, g4 and f3. In the Knight's Square Method, the idea is to move the queen to one of these squares (preferably one away from your king to avoid collisions in time trouble!) and then simply "copy" the opposite king's move.
Thus, in the position below, White first moves the queen to a "knight-square" 1. Qc6!

After that, the White Queen can "copy" the Black King's moves and remain in the knight's square, except, I REPEAT!!, except when the king moves to the corner (a1, a8, h1, or h8). For example, king moves right one square, queen moves right one square; king moves diagonally up one square, queen moves diagonally up one square. Once the Black King is driven to one of edge ranks or files, White brings the King to deliver the checkmate. This is demonstrated below.
<code>  [FEN "8/8/8/8/3k4/8/8/K6Q w - - 0 1"]

  1. Qc6 Ke5 (1... Kd3 2. Qc5 Kd2 3. Qc4 Ke3 4. Qd5 Kf4 5. Qe6 Kf3 6. Qe5 Kg4
  7. Qf6 Kg3 8. Qf5 Kg2 9. Qf4 Kg1 10. Qf3 Kh2 11. Qg4 Kh1 12. Kb2 Kh2 13. Kc2 Kh1
  14. Kd2 Kh2 15. Ke2 Kh1 16. Kf2 Kh2 17. Qg2#) 2. Qd7 Kf6 (2... Kf4 3. Qe6 Kf3
  4. Qe5 Kf2 5. Qe4 Kf1 6. Qe3 Kg2 7. Qf4 Kg1 8. Qf3 Kh2 9. Qg4 Kh1 10. Kb2 Kh2
  11. Kc2 Kh1 12. Kd2 Kh2 13. Ke2 Kh1 14. Kf2 Kh2 15. Qg2#) 3. Qe8 Kg5 (3... Kg7
  4. Qe6 Kf8 5. Qd7 Kg8 6. Kb2 Kf8 7. Kc3 Kg8 8. Kd4 Kf8 9. Ke5 Kg8 10. Kf6 Kf8
  11. Qf7#) 4. Qf7 Kg4 5. Qf6 Kg3 6. Qf5 Kg2 7. Qf4 Kg1 8. Qf3 Kh2 9. Qg4 Kh1 10.
  Kb2 Kh2 11. Kc2 Kh1 12. Kd2 Kh2 13. Ke2 Kh1 14. Kf2 Kh2 15. Qg2#
</code>
Sometimes, one's own King can get in the way of the Queen in this method, as shown below.
<code>     [FEN "8/8/8/2k5/4K3/5Q2/8/8 w - - 0 1"]

     1. Qb3 Kd6 2. Qc4 Ke7 3. Qd5 Kf6
</code>
In such cases, the King can simply be moved away and the same method continues.
<code>     [FEN "8/8/5k2/3Q4/4K3/8/8/8 w - - 0 4"]

     1. Kf4 Kg6 2. Qe5 Kh6 3. Qf5 Kg7 4. Qe6 Kh7 5. Qf6 Kg8 6. Qe7 Kh8
     7. Kg5 Kg8 8. Kg6 Kh8 9. Qg7# *
</code>
As mentioned before, the one pitfall to be avoided in this method is the stalemate that can occur when mistakenly occupying the knight's square when the king is in the corner.
<code>     [FEN "8/8/8/4Q3/8/8/6k1/K7 w - - 0 9"]

     1. Qf4 Kh1 2. Qg3 $4 (2. Qg4 $1)
</code>
Comment: The first diagram only covers half the "dangerous" potential stalemate squares.
Comment: Good, comprehensive answer. My only gripe are the red crosses in the stalemate diagrams; I find them distracting. Why not crop the diagrams instead?
Comment: Thanks Ralph. I'll keep your suggestion in mind for future posts where there are too many diagrams.
Comment: Most beginners cannot resist giving check, and announcing it. Ofter a check just sends the King to a safer spot. Mating with the Queen is a good exercise, but you do need a plan. Which of the mating positions shown here do I want to achieve? Does this move get me closer to it? Does my Queen constrict the other Kings freedom? Does your King get closer to where it needs to be? After that, does this check drive him to a worse situation? Finally, as you get close, will it give stalemate instead? Play this out against a friend using a clock. Practice until both of you can do it in ten seconds.
Answer: Lol, this question is not as silly as it sounds as once I was in time trouble and ended up stalemating my opponent by accident! Most players resign when their opponent is up a queen so such blunders can happen if you occasionally come across a player who is stubborn enough to play till the end. Anyway, after that incident I went back to studying the Queen and King vs. King endgame to avoid such embarrassments in the future!
So, this is how you do it:
1) Remember that stalemates are more easy with Q & K so it is important to check for a possible stalemate before every move.
2) Use your queen to slowly try to corner the opponent king until he is confined to one of the edge row or columns of the board.
<code>[FEN "8/8/8/k2K4/8/1Q6/8/8 w - - 0 1"]
</code>
3) Bring the king in to the position shown in the diagram below:
<code>[FEN "8/2K5/8/k7/8/1Q6/8/8 w - - 0 1"]
</code>
Remember that the king has to be in this position to deliver the checkmate.
4) Slowly nudge the opponent king towards the corner.
<code>[FEN "8/k1K5/8/1Q6/8/8/8/8 w - - 0 1"]
</code>
5) When the opponent king is in this position, deliver the checkmate!
<code>[FEN "8/k1K5/8/Q7/8/8/8/8 w - - 0 1"]
</code>
For eg.:
<code>[FEN "8/8/8/3k4/8/7K/8/5Q2 w - - 0 1"]

1. Qf4 Ke6 2. Kg4 Kd5 3. Kf5 Kc5 4. Qd2 Kc4 5. Ke5 Kb3 6. Qc1 Kb4 7. Qc2    Kb5 8. Qc3 Kb6 9. Qc4 Kb7 10. Qc5 Kb8 11. Qc6 Ka7 12. Qb5 Ka8 13. Kd6 Ka7 14. Kc7 Ka8 15. Qa5# *
</code>
I don't know about the 'faster than other methods' bit, but it works!
Answer: The simplest answer is to restrict the enemy king's movements by "walling off", not attacking, with the queen, move by move, driving it to the edge and then bringing up the king to help administer the mate.  You must remember to always leave the king at least one free square once it's in a corner to avoid stalemate.  This is basically the same method used with the rook and king, although the king and rook must be used together in that case to drive the king to the edge and finally into a corner for the mate. All this may sound confusing in the abstract, but if you try it I'm sure it will become clear quickly enough. I don't think trying to memorize a "formula" beyond what I've just suggested will be of any more benefit.

How do you checkmate with a queen?


How do I display a property in the viewport without using a modal operator?

Question: I want to display a property in the viewport without using a modal operator. is it possible? I found this, but I did not understand how I can use (I started with python).
Answer: Extending the code from Draw and update text in viewport without modal operator in blender
I suggest using a class to handle the handles, and pass context to the callback method.
import bpy
import blf

class DrawingClass:
    def __init__(self, context, prop):
        self.prop = prop
        self.handle = bpy.types.SpaceView3D.draw_handler_add(
                   self.draw_text_callback,(context,),
                   'WINDOW', 'POST_PIXEL')

    def draw_text_callback(self, context):
        font_id = 0  # XXX, need to find out how best to get this.

        # draw some text
        blf.position(font_id, 15, 50, 0)
        blf.size(font_id, 20, 72)
        blf.draw(font_id, "%s %s" % (context.scene.name, self.prop))

    def remove_handle(self):
         bpy.types.SpaceView3D.draw_handler_remove(self.handle, 'WINDOW')

context = bpy.context
dc = DrawingClass(context, "Draw This On Screen")

#dc.remove_handle()  # will remove the handle and stop drawing

Comment: to handle the handles, from now on I shall use this on my colleagues :D
Comment: Nice approach, but how we can store the reference to the class in order to remove the handle at later time e.g. based on a scene property enabled or disabled by the user?
Comment: Give it global scope to update method of some scene property, or what I find a bulletproof "hack"  `bpy.app.driver_namespace["foo"] = bar`
Comment: Sorry, wasn't notified @batFINGER. Updating a scene property requires another static variable in the class which ends up in a mess referencing static variables. I really like your idea, in theory it's super nice but in a real scenario for a addon or something, it does not really help IMHO. Maybe I'm too stupid. Anyway thanks for your hacky batTRICK!


Black screen on Nikon 5300 after update

Question: I did an update on my Nikon d5300 and for some reason during the install the camera turned off by itself and the  after that I gave it some minutes and then turn it off from the switch and back on but the screen won't light up, I can't see anything , it focuses! I can move the focus point around ,I can see all my settings on the viewfinder, I can play with the aperture , iso and shoterspeed and it all shows on the viewfinder, even the pop up flash works , and the focus assist light, and when I press the shutter button it takes pictures but it won't saved them to the sd card and every now and then I get the msg error on the view finder and the green light on my camera keeps flashing , I tried connecting my camera to my laptop but it won't be recognized ,
Comment: I avoid updating firmware with a grip attached to the camera. It' s just one more potential point of failure between the battery and the camera. I have had a grip which, after a hard bump, occasionally flexed enough to momentarily lose contact with the power connection just long enough to lose everything in the buffer that was not yet written to the card. If that were to happen during a firmware update, it could brick your camera. That doesn't help you now, though.
Comment: What was the charge state of the camera's battery when you started the update?
Comment: It was fully charged , it had a camera grip on it with 2 fresh fully charged batteries cuz I was about to go for a shoot, do you have any suggestions how to get it working again? It always worked fine I never had issues with it or accidents , i never dropped it or anything I got it new 2 years ago it was just after the update that the screen didn't work.
Comment: Did you try with a different SD card?
Answer: For whatever reason, the update seems to have caused the issue. It's possible the update file was corrupted somewhere in the chain between the server from which it was downloaded, your computer, the memory card to which it was loaded, and the camera's internal memory. Or it is possible the camera had a power glitch during the update that corrupted the firmware as it was written to your camera's flash memory.
Without being able to see the screen, it will be almost impossible to try and run the firmware update again unless you have a working example D5300 to use as a reference as you go through the menu. A well written instruction manual (I think Nikon calls them Reference Manual as the User Manual is much shorter and less detailed) could also guide you through updating the firmware "blind."
If you do try, download the update file again, preferably from a different server than you did before. Use whatever tools you have available to insure the file integrity of the download before and after transferring it to a memory card to be placed in the camera. Remove the grip and place a fully charged battery directly in the camera. Use a different memory card.
If there's an option to update the firmware via a USB connection to a computer rather than via a memory card, you can try that and you should be able to follow the instructions on the computer's screen.
If that doesn't work, you probably need to send it to a Nikon Service Center. They'll probably need to reflash the memory on the camera's motherboard that contains the firmware.

Black screen on Nikon 5300 after update


Resample audio signal with a low factors

Question: Currently, we need to handle a piece of an audio signal. We want to resample it with multiple factor rates (p/q) starting with $1.0002$ down to $0.9998$ with a decrement of $0.000005$. But Matlab functions cannot handle this because of the Integer Limit.
Are there any ways to solve this?
Comment: *big deal.* MATLAB `y = resample(x,p,q);` works fine.  so for whatever ratio $r=\tfrac{p}{q}$ that you want set $$p=\left\lfloor \tfrac{r}{0.000005} \right\rfloor =\left\lfloor 200000 \cdot r \right\rfloor $$ and $$q=\left\lfloor \tfrac{1}{0.000005} \right\rfloor = 200000 $$ and you have your integers for `p` and `q`.
Comment: The general field of study you're looking for is "sample rate conversion".  "Secret Rabbit Code" used to be a nice open-source implementation, but it's been so long since I've had to reference it that I have no clue if it's still a thing.
Comment: Robert there are limits to the factors allowed by resample. resample(1,70000,70001)
Error using upfirdn>validateinput (line 129)
The product of the downsample factor Q and
the upsample factor P must be less than 2^31.
Answer: If you're resampling can be done batch, interp1 using 'spline' as the type works well.
A good article that argues in favor of splines over sinc interpolation is:
Unser, Michael. "Splines: A perfect fit for signal and image processing." IEEE Signal processing magazine 16.6 (1999): 22-38 (PDF).
Answer: You can resample to any, including floating point approximations of irrational rates, using reconstruction by Sinc kernel interpolation (realistically, by using a windowed Sinc interpolator).
Comment: Pseudo code here: http://www.nicholson.com/rhn/dsp.html#3
Answer: Please see my answer to this question : Various size arrays interpolation - resampling
The best method really depends on your application and your requirements. Matlab's resample() is perfectly fine, if you don't care about efficiency, have enough memory, no real time requirement, and reasonably short signals. If's unsuitable for real time sample rate adaption of two different master clocks.
Both sinc kenrnel and splines are different ways to create an interpolation filter, but it's not easy to adapt them to numerical requirements. If you have a requirement like "aliasing, THD and intermod need to be lower than -80dB below 20 kHz" it's better to directly design a low pass filter in a suitably upsampled domain. You an certainly do this by using a sinc kernel but you'll need a lot more filter taps than using a custom low pass filter


Auto-attack behavior relative to ability use

Question: In HotS, how is auto attack triggered or suppressed relative to use of an ability? I have seen posts suggesting that auto attack timers are reset following use of an ability and, importantly, that auto attack occurs when the timer is reset (at time 0). This would suggest that not only do abilities with short cooldowns result in more damage from those abilities, but also increases effective attack speed from auto attacks.
Answer: Auto attack timer is NOT reset following the use of an ability, unless that ability specifically has that capacity.
E.T.C., for instance, had a level 7 talent prior to the May 12, 2015 patch called "Guitar Hero", which expressly stated "After using Guitar Solo, your next Basic Attack strikes immediately". If auto attack timers were reset on ability usage, this would have been 1) redundant information and 2) not actually part of the talent.
Comment: Given this information, does one need to 'wait' for an autoattack to occur before using an ability if auto-attacks are desired or will autoattacks occur regardless of what abilities are being triggered?
Comment: If you want to maximize DPS, yes, waiting to attack, pop an ability, then auto-attack again is the most efficient method.


Does Re-issue of US patent have extended expiry?

Question: The original priority date was in 1994 US5662332 so my assumption was that it had expired, but upon searching Public Pair using the application number (US 08/544,306) it comes up that it's under Re-Issue and still patented. So my question is, is the patent actually expired or does the re-issue extend the term somehow, or is there something else that's extending the term beyond the 20 year window that I'm missing?  Thank you for your time.
Answer: You need to calculate expiry from the US5662332 Re-issue is just publication of information. Here is another answer to calculate the same How do you determine a patent's expiration date?
MPEP 1405    Reissue and Patent Term [R-11.2013]

35 U.S.C. 251 prescribes

the effect of reissue on the patent term by stating that "the Director
    shall… reissue the patent… for the unexpired term of the original
    patent."

The maximum term of the original patent is fixed at the time the
  patent is granted. While the term may be subsequently shortened, e.g.,
  through the filing of a terminal disclaimer, it cannot be extended
  through the filing of a reissue. Accordingly, a deletion in a reissue
  application of an earlier-obtained benefit claim under 35 U.S.C. 120
  will not operate to lengthen the term of the patent to be reissued.


What is the best point-scoring technique?

Question: What is the best technique or strategy for wining a point scoring fight.
Comment: This question is too broad, even restricting it to one specific rule set of one martial art. You can expect hints, thoughts and references; not a full answer.
Comment: It would depend on the rules of the tournament, so no answer is possible.
Comment: Welcome to MartialArts.SE! Your question is a little too broad to reasonably answer, so I have put it on hold. If it can be edited to make it more focused, than it can be easily reopened.
Answer: The funny thing is, this is a great question!
It's a great question, because most people wouldn't ask it. Instead, they'd presume that all this point sparring business is so complex and filled with an infinite number of possible techniques and strategies, so why should there be any particular "best" strategy or technique? And how could anyone possibly determine it?
Well, yes. It's maybe a little silly to talk about "the" best strategy and technique. If there was one, everyone would be doing that. And if everyone was doing that, it wouldn't be long before someone realized they could just do something else to win, because it would have become predictable.
So let's not talk about "the" best strategy and technique. Let's talk about the more general class of "high percentage" strategies and techniques. And by "high percentage", I mean things that have a high ratio of scores over attempts in actual competition sparring. As opposed to "low percentage" techniques and strategies which have a low ratio of scores over attempts.
The question referred to point sparring, but actually this comes up in all kinds of competitive martial arts: Judo, Wrestling, Brazilian Jiujtsu, Karate, Taekwondo, Muay Thai, American Kickboxing, Boxing, Fencing, Escrima, etc. All of these martial arts usually have statistics regarding which techniques were attempted, how many times, and how often it scored.
In Judo, for example, there's this popular 1971 document which attempts to quantify which throws scored the most:
http://www.bestjudo.com/article/0924/frequency-judo-techniques
And so, as you can see from the article, the top 3 throws of 1971 were: Uchimata, Seoinage, and Osotogari. These three throws and a handful of others are used the most. Why? Because they apply in the greatest number of situations, and they seem to be the quickest, easiest, and safest to do.
Of course, time marches on. Rules change. New ideas and discoveries happen and spread like wildfire. The London Olympics of 2014 shows these throws winning the most: Uchimata, Seoinage, Kouchigari, Haraigoshi, Taiotoshi, and Ouchigari. Where did Osotogari go? Hmmm.
Source: http://www.kokakids.co.uk/the-top-scoring-judo-techniques-for-olympic-judo
As a side note, Judo also arranges its throws in a taxonomy known as the "Go Kyo No Waza" (the "5 Levels of Technique"). The first level contains the most widely useful throws in Judo, the ones that can be used in the most number of situations. Level 1 and level 2 includes all of the "most winning" throws mentioned above. The rest of the levels (3 through 5) contain throws that are for very specific situations and don't come up as often. Very logically then, Judo students learn starting with the first level and work their way up to the higher levels. This way, they become proficient in the most useful throws as quickly as possible.
Now as for point sparring, this is going to depend highly on which martial art and which scoring system we're talking about. There are many styles which forbid punches to the face, for example. So of course in those styles, you won't see punches to the face at all. But in boxing, the jab punch is probably the highest percentage technique. It's done the most, and it scores the most.
As a general rule, striking techniques which can be used in the most situations and are fast, direct, and simple to perform will be the highest percentage ones. For hand techniques: jab punch for boxing or reverse punch for karate and Taekwondo. For foot techniques: low/mid-section round kick and front kick. I would also add side kick if you're talking about Taekwondo in particular, but not for most other kicking arts (Taekwondo really likes to use that kick).
These techniques are done the most, because they can be used safely, effectively, quickly, and in the most number of situations. Not coincidentally, that's exactly the same rationale behind why Judo practitioners use the throws that they do.
My advice is to use Google and search for "high percentage Taekwondo techniques" for example. Replace "Taekwondo" with whatever martial art you're interested in.
For Taekwondo, this nice article popped up for me:
http://www.taekwondoscience.com/2014/04/15/discrepancies-in-fighting-strategies-between-taekwondo-medalists-and-non-medalists/
It shows the round kick is by far the leader in terms of wins. Following far behind are: cut kick (like a side kick), push kick (like a front kick), spinning side kick, and side kick. The lowest percentages are for "tricky" techniques such as the 360 degree twisting round kick. And reflecting Taekwondo's preference for foot techniques (because kicks are worth more points than punches are), hand techniques are also low percentage.
Also in that article, you'll read that the best overall winning strategy in Olympic Taekwondo is to be very aggressive. Note that in Olympic Taekwondo, sparring is continuous and just depends on how many points you can get within the time limit. It doesn't stop when you get 3 points as in the "3-point-win" style of sparring. That tends to cause players to forgo defense and become more aggressive to try to get as many points as they can. The more aggressive you are, the more likely you are to score a point, which makes sense for continuous sparring. But in 3-point-win sparring, you'll see a lot more attention devoted to defensive strategy, footwork, decoying, timing, and combos. Getting hit counts a lot more to you in 3-point-win sparring, so you tend to be more defensive.
In conclusion:
Each martial art generally has some statistics available about which techniques and strategies are most winning (the "high percentage" ones). In general the highest percentage techniques and strategies are the ones that can be done safely, effectively, quickly, and in the most number of situations. Differences in rules and scoring will create a bias which can be seen in these statistics.
Hope that helps.
Comment: O soto gari variant and Tai otoshi are another ones with high percentage to go for Ippon.
Answer: The technique that hits the opponent in a valid area of his or her body. Or, the strategy that lets you use those techniques, while keeping you from getting hit.
You know, if we could answer that question, we'd be putting a lot of coaches out of a job.
Train hard. Practice sparring, specifically the games of distance and rhythm. Lose a lot. Learn from your mistakes.
Comment: The other part of your answer should be *don't get hit*. It's easier to win that way :)
Answer: From my exp in karate tournaments, the best point scoring techniques would be the basic 'lunge-punch' or Oizuki. This is very idea for smaller and lighter competitors. I have had successes in scoring points with this.

Be light on your feet, bouncing off your toes, keeping your heel of the ground.
When the opponent moves forward or back, immediately lunge and strike.
after strike quickly lunge backwards to avoid any counters.

The key is to wait for the opponent to move, then enter in as quick as you can and strike the torso.
Answer: The best strategy for winning a points-based fight is to stay far away from your opponent until he makes a mistake, then swoop in, make contact and retreat.
As for the techniques to use, well, whichever one is the shortest, most direct route to your target. In Karate, this is usually a straight punch to the chest (or face if the rules allow). In Taekwondo, it's usually an axe kick, jumping back kick or spinning back kick. In boxing it's a hook or straight punch.
Just be aware that most of the fight is actually maneuvering yourself in such a way that you can create/exploit openings in your opponent's defenses. Taekwondo fights are great examples of this. The two fighters bounce around for excruciating amounts of time, and then just as one of them drops his guard, even if only for an instant, the other lands a devastating kick to the head.


Markdown editor with live formatting

Question: I want to create an online markdown editor that has limited wysiwyg formatting. If you're familiar with iA Writer, I'm trying to create an editor similar to their desktop version. For the most part it's just a simple text editor, but it does a few snazzy things that I'm trying to duplicate.

Automatically underline/bolds thing in *italics*, **bold**, ***bold italics***
Indents ">" blockquotes
Outdents "#" headers and "-" lists so that the text is left aligned, much like on the old three hole punched line paper you could align the text to the red line and put list numbers to the left of it.

I have a few thoughts about how to go about implementing this but I've run into some concerns with each of them.
Editable iFrame

How do I outdent text or apply a css class to it
The formatting happens automatically, so how would I change the selection of the text, reformat it and then go back to the original selection location
I hear that you can load another page into your editable iFrame to do more advanced features, but I'm not too familiar with that - any good resources?

Pure javavascript

How do I create a blinking cursor in an area because I don't think I'll be able to do this in a input or textarea...
Possibly make every line a div that converts into an input box when I click on it (similar to how the tags box works on the tags box when you ask a question (though doesn't work for inline formatting)

Any suggestions to how I might go about doing something like this?
Answer: A good start would be to look at Code Mirror (http://codemirror.net/) whom already provides Markdown Editor and a Strong API.
You should be able to add features and live rendering on top of it.

Markdown editor with live formatting


How many G7 chords are there, and when to use which?

Question: Some books say G7 chord is B F G, some say it's G B D F. Are there even more? Does this only happen to G7 or others as well? How will I know which one to use if "G7" is indicated on a sheet music? (mainly for piano)
Answer: With any chord, its root is important - if ony to give it a name!
The third is important to define its majorness or minorness.
The seventh part can use different notes, but with 'G7', that's defined as m7, making it a dominant chord.
The 5th belongs in there, but as the least defining part, can be and sometimes will be omitted. It doesn't bring much to the party, and in any case, that sound is contained in a harmonic of the root, so it's implicit anyway.
So, with the label G7, there'll be G B D and F. As stated, the D can go, leaving G B and F, which does fulfil the criteria.
Dependent on which instrument is being played, anything can go in any order, and anything can be doubled (or tripled). A lot (but not all) of publications use the slash notation to label chord inversions, so G7 would be root, G7/B 1st, G7/D 2nd and G7/F 3rd inversion, but that's not always the case.
Thus, faced with 'G7' on a sheet of music, one could - and usually does, play the given notes, with or without D, in an appropriate order. In fact, in a piece in key C, I often play G7 when a G chord is needed, and particularly if a bass is playing a root, I'll use an inversion, or even just play B and F.
Answer: The G7chord always has G as the lowest bass note. Above G the other three notes can appear in any order BDF , DBF , or FBD. If this is in the key of C , then never double the leading note ( which is B ). Also never double the 7th ( which is F ). Often the 5th ( D) is excluded from the G7 chord to avoid parallel fifths in the voice-leading.So using 4 notes in a Dominant seventh chord such as G7 we are left with 2 main possibilities : GGBFor GBDF This is the case with all Dominant seventh chords. Depending on your instrument I would use whichever 7th chord sounds best and is easiest to play. Play on !
Comment: Whilst you may be technically correct, not all publications use the slash , and G7 *can* be used in any inversion. Whenever I see 'G7', I play whatever I feel is best in that situation - I won't be forced to play it in root position - and I believe most other musos would do the same.And on guitar, open G7 doubles B, and can double F. So what? Voice leading on guitar sometimes can't be helped, and omitting D isn't always the voice leading reason.
Comment: Two "never"-s in the answer. Both of which I've seen "violated" frequently, without any drawbacks. I'm a zero at chord theory, so maybe they make sense from that perspective. That's not to say I'm not aware of intervals. I see all the "never"-s and the "...often excluded 5th..." happen all over the place. Pretty much everywhere actuallly.
Comment: "The G7chord always has G as the lowest bass note" - what about inversions? https://www.musictheory.net/lessons/47
Comment: G7/B = G7 in first inversion ; G7/D = G7 in second inversion ; G7/F = G7 in third inversion. If the chord is simply stated as G7 then it should be in Root position with G as the lowest note. QED !
Answer: The G7 chord has four notes: G B D and F. In root position it has G at the bottom. In first inversion it has the B at the bottom, in second inversion the D, and in third inversion the F.
Those books shouldn't say B F G is G7, but in certain contexts a musician will leave a note out if it sounds better. The 'fifth' (which is what the D is, being a perfect 5th above the root note G) is most commonly discarded, being the least useful in defining the harmony.
Yes, I'm afraid it happens with all other chords.
Answer: Strictly speaking there is one and only one G7 chord and it is (G, B, D, F).
You need to understand a few things about harmony and voicing to fully appreciate the variety displayed in some texts.  First, you are free to double up notes.  So, on a guitar a common "voicing" is (G, D, F, B, D, G) and yet another is (G, B, D, G, B, F).  We can, and often do, sacrifice the 5th of the dom 7 chord as it doesn't move to a chord tone in the I chord as nicely as the half steps 7-->8 and 4-->3, with the 5 being the common tone and not requiring movement.  However this is not necessary.  That explains the three note version as opposed to the 4 note version you are asking about.
A voicing can be chosen so that is has the desired features and is easy to play.  On the guitar there are 3 note voicings use to generate chord scales.  The root definitely defines the chord, the third defines its character as either major or minor, the 7th is useful for resolutions and is typically present in an authentic cadence, V7-->I, but the 5 is often omitted from all 7th chords, not just dom 7.  Since the 7th chord is built of two triads, the Major in the root and the diminished on the third, one sometimes sees the chord substitution vii^o --> I or vii-7(b5) --> I.  Strictly speaking this is NOT the V7 chord but serves the same purpose.


Should an ATM display the balance on-screen after transaction?

Question: If an ATM could prompt users the summary of what they have done onscreen, would it be of any value in saving time, printer and paper?
Comment: This has been done in ATMs in some countries (e.g. South Africa) since the 1980s.
Comment: What is your question exactly? Your title says "balance", picked up in some answers to mean "account balance". Your text: "The summary of what they have done onscreen ...to save time..." suggests info like "you have withdrawn amount x from you account ending on ...xxx" or something.
Answer: Only if that's what they've asked for.
From a usability perspective - There will be people who don't want the balance to be shown on screen. They could be stood their with their wife / girlfriend, and don't want them knowing just how much money they do / don't have.
Also, there may be technical constraints too. To display the balance requires the ATM making a call to the various banking services, which is a cost. There's no need to take this cost if the user hasn't asked for it.
Comment: I think this is correct. Also, displaying balance would give loitering thieves valuable insight into likely targets.
Comment: I agree @JonW , so obvious situation. But what if you don't receive any message from bank related to your account.
Answer: It depends on where you live. If you live in a hyper connected first world country where each customer has a quick access to his/her account information through mobile or web, then they don't need to risk knowing the balance through ATM screen (unless asked for).
But if you live in a country where people don't have mobile phones connected with their bank accounts, then you probably would've no way to know what your account balance (unless you go to the bank with your passbook). Having an on screen balance display helps a lot in that case.
When I was a student, I had my account with a government owned bank, despite of registering my phone number many times with the bank, I never got the message for  my account balance after transactions. I was unqualified for internet banking because of underage. So, that leaves me at the mercy of on screen ATM display. Also, there was less chances of me being mugged than me running out of money.
Answer: I would like to see an quick account summary right after I enter my pin.
"Welcome! You have X $s in your account. Would you like to a) withdraw b) deposit..."
Plus real time calculations as I'm doing my transactions.
And finally an option if I would like to have the full summary displayed, printed, emailed or sent via sms (the bank already has my email and cell phone #). This could be a one-off setup so I don't have to be presented with this screen every time I'm using an ATM.
I see major benefits in time savings for both customers and the bank. Not sure if the paper, print and ink costs amount to much but there are also added waste and maintenance costs that could be reduced.
Answer: I don't think so... Most of the people don't want their balance to be displayed on screen after the transaction as it create threat or embarassing situation for user if someone is looking from back on the screen.
You can do by this way if you like There should be an option "Print Reciept" or "Show Balance on Screen". In case machine is running out of paper then system should ask that it is running out of paper would you like to see balcnce on screen after transaction.
Answer: For what it's worth, ATMs in Australia do exactly this—my bank's ATMs give you three options at the end of your transaction:

Print transaction record (receipt)
Show balance on screen
No balance required
Comment: That isn't the same as what is being asked though. Because with your ATMs the user still has to make a choice. OP is asking if it should just show the balance regardless. Also; is this actually the best option? And why is it good / bad?
Comment: I read the "could" as suggesting the ATMs weren't *able* to initially—based on the other answers, it seems there are many ATMs that can't. I personally think it's better than printing (for cost and environment) but worse for time (because you then have to close it) and so use an app to check my balance, but my point was that whoever is designing the major banks' ATM interfaces over here followed through on introducing it as a feature.
Answer: Isn't this a security risk? Wouldn't you at least feel uncomfortable having your balance displayed on screen where people can look over your shoulder and see how "rich" you are? ATMs are already heavily targeted by scammers, this would just make things easier for them.
Comment: This is why ATMs never do this, unless you explicitly request to see the balance.
Comment: Where I live, up until a year ago it was very common to have an ATM machine that displays balance on screen right after you make a transaction.
Comment: Wow, I got a downvote! Must have been from an ATM scammer :P


Why do males prefer females with blonde hair?

Question: I would like to know why males prefer blonde women.
Comment: I retracted the close vote.
Comment: While the subject of the question has had a lot of research done about it, the one posed here shows absolutely no research. If Yatin has done some, it should be edited in to the question.
Comment: Thanks, Chris. You are right, Matt, but a quick Google search shows that scientific research verifying the male preference for blonde women has been reported in popular media to such an extent as to render this finding common knowledge that does not require initial research.
Answer: Ellis (1974) thought that men prefer rotund features in women and that blonde hair creates such a roundish upper body shape because the blonde hair, which is close in color to (a white woman's) skin, would blend with the skin.
In his famous book, The naked ape, Desmond Morris (1967) documented that men prefer adolescent features. In his opinion blonde hair serves as a secondary sexual characteristic, because skin and hair tends to be lighter in infants than in adults.
One recent study supports this view: Studying Polish men, Sorokowski (2008) found that those men rated blonde women as younger. Since the men also rated younger women as more attractive, Sorokowski concluded that blonde hair may serve as an age cue for men. Consequently, in a second study, Sorokowski found that middle aged women are more likely to die their hair blonde. Younger women already are young, so they don't need that cue to appear attractive. Only middle aged blonde women were rated more attractive than their non-blonde same-age peers. Young women of all hair colors appear equally attractive.
Youth is associated with fertility and health. Ramachandran (1997) proposes a theory that explains how blonde hair can signal health: blonde hair is usually found in women with light skin, and light skin better allows the detection of skin color changes that are symptoms of illness and infestation with parasites. According to Ramachandran, blonde hair simply signals that the man can more easily check if the woman is healthy.
Rowell and Servedio (2009) propose that male preferences help avoid competitive pressure from other males. According to this view it does not matter so much that maybe men prefer blonde women on average. The important finding is that most men fall into groups liking different kinds of women – differentiated not only by hair color but by complex combinations of traits – and therefore do not compete with each other. (Many men here will probably be able to testify that they found women unattractive that a male friend found attractive. In effect they could remain friends, because they liked different women and did not have to compete with each other.)
There is lots more. These are just the first hits from a quick search. An interesting article in the Guardian summarizes some more research: http://www.theguardian.com/science/2010/jun/04/men-blonde-women-attractive

Sources:

Ellis, H. (1974). Man and woman: A study of secondary sexual characteristics. New York: Amo Press.
Morris, D. (1967). The naked ape. New York: Dell.
Ramachandran, V. S. (1997). Why do gentlemen prefer blondes? Medical hypotheses, 48(1), 19-20.
Rowell, J. T., & Servedio, M. R. (2009). Gentlemen prefer blondes: the evolution of mate preference among strategically allocated males. The American Naturalist, 173(1), 12-25. Available online at www.jstor.org/discover/10.1086/593356
Sorokowski, P. (2008). Attractiveness of blonde women in evolutionary perspective: Studies with two Polish samples. Perceptual and motor skills, 106(3), 737-744. Available online at http://www.amsciepub.com/doi/abs/10.2466/pms.106.3.737-744
Comment: All of these theories seem like [just-so stories](http://en.wikipedia.org/wiki/Just-so_story). Are any of these claims actually falsifiable, and if so, are there experiments to test the claims?
Comment: Sorokowski did an experiment, as I wrote. None of the evolutionary hypotheses can be experimentally verified/falsified, of course. There seems to be experimental evidence that men prefer adolescent features (see this question: http://cogsci.stackexchange.com/questions/5509/at-what-age-are-women-perceived-to-be-most-attractive), any explanations or deductions are again hypothetical, of course. How *would* you experimentally find out why men prefer blondes?


Which exchanges still accept USD wire transfers? (Oct 2012)

Question: Are there any exchanges left accepting USD wire transfers? I heard mention of sending to Dwolla and then transferring to Intersango, but only for U.S. citizens.
Answer: Dwolla is only for this in the U.S. and the type of bank transfer they do is ACH, which is specific to banks in the U.S.
As far as exchanges that accept wire transfers directly, there are many, including:

Mt. Gox (Japan)
BitStamp (EU)
BitFloor (U.S.)
BTC-E (Russia)
Bitcoins Direct (U.S.) (bulk sales, minimum $500)

Many various methods here:

http://en.bitcoin.it/wiki/Buying_bitcoins


Why are neutralisations involving weak acids and bases less exothermic than those involving only strong acids and bases.?

Question: I read somewhere that for example the neutralisation reaction between sodium hydroxide and acetic acid is less exothermic than those of sodium hydroxide with hydrochloric and nitric acid because some energy is needed to cause the weak acid (acetic acid) to completely ionise. Is this true?
Comment: *Think carefully*. What is the main reason why a neutralization reaction is exothermic?
Comment: You're on the right track. Acetic acid is a weak acid. It furnishes lesser $\ce{H3O+}$ in solution compared to a typical strong acid. So, less hydronium ions, less combination of hydronium and hydroxide, and less energy released.
Comment: I still don't understand why the fact that a weak acid does not ionise completely is an explanation as to why it is neutralised less exothermically. If we have equimolar solutions of HCl and CH3COOH both of which are monoprotic, won't we still need an equal number of moles of NaOH to neutralise both?
Comment: Correct me if I'm wrong please, but I'd say that most neutralisations simply involve the reaction between a hydronium ion and a hydroxide ion to form two water molecules which is an exothermic process. But, I still don't see what the difference is between the neutralisation of HCl with NaOH than that of CH3COOH with NaOH.
Answer: I think the answer is closer to what was stated in the original question: "some energy is needed to cause the weak acid (acetic acid) to completely ionise". Stated differently, less energy is released from making acetate ion from acetic acid than from making chloride ion from hydrochloric acid (or water from hydronium ion).
Despite the lesser tendency of acetic acid to ionize, the overall stoichiometry of the two reactions is the same--as pointed out in a comment by the OP.


Scheduling when task duration longer than working interval

Question: I'm trying to modify the job shop example for CP-SAT solver. (https://developers.google.com/optimization/scheduling/job_shop)
I'm limited to 8 hours working day,
So I defined a list of NewIntervalVar() to represent non-working 12h everyday and weekend 24h+24h
I add this list to AddNoOverlap() for every machine interval. (Also, is there a better approach? probably I'm already made mistake with this approach)
<code>non_working_intervals = add_non_working_hours(model)
for machine in all_machines:
    model.AddNoOverlap(machine_to_intervals[machine] + non_working_intervals)
</code>
And this works fine if all tasks are less than 8 hours..
Obviously, the model can't fit 15h task in 8h gap and return infeasible..
The question is, how I can redefine the model so it can "automatically" start 15h task on one day and finish it the next day (after 12h). For 15h task it should be like: work 0-8 then gap(no work) 9-24 and then 24-31 (finish last 7h of 15h taks).
The only solution that comes to my mind is to split all tasks into smaller chunks before modeling, but then I should add a mechanism so all parts of a single task must go one by one without interruption (also, I don't know if it's possible to implement)
Answer: You should look at this example:
https://github.com/google/or-tools/blob/stable/ortools/sat/doc/scheduling.md#intervals-spanning-over-breaks-in-the-calendar


Decay estimate of Fourier transform of a compactly supported function

Question: Assume $f(x), x \in \mathbb{R}$ is a function with a compact support such that its Fourier transform $\hat{f}(\xi)$ has a decay rate
$$\hat{f}(\xi) \lesssim \frac{1}{|\xi|^\gamma + 1}$$
for some $\gamma \ge 1$.
Now set $$h(x) = xf(x).$$ Since $f$ has a compact support, $h$ should have similar or better regularity than $f$. Can we now get the following decay estimate of the Fourier transform of $h$ ?
$$\hat{h}(\xi) \lesssim \frac{1}{|\xi|^\gamma + 1}$$
I know now we have $\hat{h}(\xi) = -i\partial_\xi \hat{f}(\xi)$, but it seems hard to only use this relation to get the decay estimate.
Answer: The answer is positive. Since $f$ has compact support, $g:=\hat{f}$ extends to an
entire function of exponential type $\sigma$ with some $\sigma>0$.
Then your estimate on
the real line and the Phragmen - Lindelof theorem imply that
$$\log |g(z)|\leq \sigma |y|-\gamma\log|z|,\quad z=x+iy,$$
which gives that $|g(z)|=O(|z|^{-\gamma}), z\to\infty$ not only on the real line,
but also in a horizontal strip $|y|<2$. Then Cauchy inequality implies that $|g'|$
also satisfies the same estimate on the real line.
Reference for Phragmen-Lindelof theorem: B. Ya. Levin, Lectures on entire functions, lecture 6.
Added. Instead of the above inequality, one can write a more precise one,
which also follows from Phragmen-Lindelof:
$$\log|g(z)|\leq \sigma|y|+\frac{y}{\pi}\int_{-\infty}^\infty\frac{\log|g(t)|}{(x-t)^2+y^2}dt.$$
So to obtain an estimate for complex $z$ from the estimate on the real line, one only need to estimate the Poisson integral in the right. This permits to deal with estimates other than $|x|^{-\gamma}$.
Comment: Many thanks for your answer! It is very helpful! May I ask you one more question? Does the Phragmen-Lindelof theorem hold for more general functions? For example, if $f(z)$ is an entire function of exponential type and $|f(x)| \le log(2+|x|) / (1+|x|^\gamma)$ on the real axis, can we expect $|f(z)| \le Ce^{\sigma |y|}\log(2+|z|)/(1+|z|^\gamma)$? Now the estimate has a log in the numerator, will this affect the answer?
Answer: I came up with an answer that is more real analysis. This method works for any $h(x) = m(x)f(x)$ as long as $m(x)$ is smooth and $f(x)$ is compactly supported.
Without loss of generalization, assume the support of $f(x)$ is $[0, 1]$. Set $$g(x) = m(x)\chi(x).$$ Here $\chi(x)$ is a smooth cutoff function such that $\chi(x) = 1$ on $[0,1]$. Hence $g(x)$ is Schwartz and $h(x) = g(x)f(x)$.
We then have
\begin{equation}
\hat{h}(\xi) = \int_{-\infty}^\infty \hat{f}(\xi-\eta)\hat{g}(\eta)d\eta.
\end{equation}
For $|\xi| \gg 1$, we write
\begin{equation}
\begin{split}
\hat{h}(\xi)
&= ( \int_{|\eta|<|\xi|/2} + \int_{|\xi|/2 < |\eta| < 2|\xi|} + \int_{|\eta|>2|\xi|})\hat{f}(\xi-\eta)\hat{g}(\eta)d\eta \\
&= T_1 + T_2 + T_3.
\end{split}
\end{equation}
For $T_1$, now $\xi - \eta \sim \xi$, we have
$$|T_1| \lesssim \frac{1}{|\xi|^\gamma+1}\int_{|\eta|<|\xi|/2}|\hat{g}(\eta)|d\eta\lesssim \frac{1}{|\xi|^\gamma+1}.$$
For $T_2$, we have
$$|T_2| \lesssim |\hat{g}(\xi)|\int_{|\xi|/2 < |\eta| < 2|\xi|}\frac{1}{1+|\xi-\eta|^\gamma}d\eta \lesssim (1+|\xi|^{1-\gamma})|\hat{g}(\xi)|$$ which decays much faster than $\hat{f}(\xi)$ since  $g$ is Schwartz.
For $T_3$, $|\xi-\eta|\sim |\eta|$, $$|T_3| \lesssim \int_{|\eta|>2|\xi|}|\hat{f}(\eta)||\hat{g}(\eta)|d\eta \lesssim \frac{1}{|\xi|^\gamma+1}.$$
In conclusion, it holds that $|\hat{h}(\xi)| \lesssim \frac{1}{|\xi|^\gamma+1}.$


Why didn't Harry resurrect Dumbledore with the stone?

Question: After reading the title to this question on Movies.SE, my initial reaction was that Harry DID use the resurrection stone, right before he gave himself up to Voldemort.
My question is, why didn't he resurrect Dumbledore? Everyone who meant a lot to Harry in their/his lifetime was resurrected when he rubbed the stone, so why wasn't Dumbledore?
Comment: Do we even know if he had a choice who to "resurrect"?
Comment: @Gallifreyan that is a good point. If not, who chooses who is resurrected?
Answer: At this moment Harry was doubting whether Dumbledore really was the same person he thought he was
He was frustrated with all the cryptic clues Dumbledore left him, instead of telling him exactly what to do concerning the hallows and horcruxes, the Dumbledore he had idolized seemed to be completely different from what he was really like, based on what he heard about him from Rita Skeeter and Aunt Murial. Even his own brother confirmed that Dumbledore was the type of guy who would lie and cheat you to manipulate you into doing what he wants, and set you up to do tasks that you would surely fail in
Also, he was sure he wasn't going to come back out of the forest, based on what he had seen Dumbledore say in Prof. Snape's memory, and the fact that he really did believe Dumbledore might have wanted him to get killed at this point in time, "for the greater good".
Given these facts, I think it is more logical that he would want emotional support from his parents, Lupin and Sirius who fought and fell trying to save him, than someone who just thought of him as a disposable pawn in a bigger war.
Answer: I think this was because Dumbledore had done his job as a guide for Harry. Throughout the books, the trio grows up, and learns to rely more on themselves and less on teacher's advice, which includes Dumbledore's. This may be symbolic of Harry growing up. At this point Harry knows that Dumbledore had died peacefully, and that he very much wanted to die (and what Snape did was in fact mercy killing). Also, at this point there isn't much Harry could ask or learn from Dumbledore - after all, he is going to die himself.
On the other hand, Harry wanted very much to meet his parents since the first book, when he saw them in the Mirror o Erised. It's nothing rational, but simply a wish of child.
Lupin and Sirius were the closest thing he had to role models - Dumbledore was too distant for that (again, by design - he wanted Harry to become independent). Sirius was the closest thing Harry had to a family, blood-relation-wise. Lupin was also his friend (sort of), and someone he respected.
I think this scene is symbolic as Harry grows up to the same level as the people that he resurrected - in a sense, they all dies fighting for the greater good, in order to protect ones close to them.
Comment: Simply put, it would have ruined the following King's Cross station scene that followed. Dumbledore evidently had one more task as Harry's guide to perform.
Answer: To my mind, the answer is that he didn't mean so much to Harry, as you would think. All the resurrected were practically his family, and Dumbledore, well, just his teacher.
Comment: Tonks? I don't remember Tonks being in the Resurrection Stone scene...
Comment: @TeemPorary She wasn't. I've reread it recently and it was only James, Lily, Sirius, and Lupin. Maybe in the movie?
Comment: Lupin and Tonks both came back. Lupin, he was close to, but I didnt get the feeling that Harry was closer to Tonks than to Dumbledore
Comment: But her death, at least, was recent. And about Lupin, well, I guess that Harry felt that Remus was more connected to his parents, and so brought more happy memories, than Dumbledore.


Why are Earth's oceans salty?

Question: As we all know water is $\ce{H2O}$, it does not contain sodium chloride. The ocean is a solution composed of water and a solute which is salt. I was wondering how the massive amounts of $\ce{H2O}$ in our oceans first mixed with salt? I'm sure the water didn't contain salt when it first got to the oceans so how did it get mixed with salt? Thanks.
Comment: duplicate http://earthscience.stackexchange.com/questions/2956/what-is-the-origin-of-the-oceans-salt
Comment: But it is  not in Chemistry Stack Exchange
Answer: Early history of Earth is a question to paleohydrology and paleochemistry. Briefly, water wasn't pure on the early stages of Earth.
Brief history of water on Earth. The planet was hot and seismoactive (lots of vulcanos) in the beginning. Water (as steam) escaped from magma, cooled down and precipitated on the Earth's surface. The surface already had salts on it, so it became saline from the very beginning. A better question is: how come we have fresh water in rivers and saline water in oceans? This separation is due to water cycle on our planet. Rivers bring dissolved salts to the ocean, then evaporates and precipitates over the land. Salts cannot evaporate (at any practical rate), so they stay in the ocean. This is similar to washing dishes. Consider this model: dish gets cleaner - that is a river; drain water gets dirtier - that is an ocean; drain water goes through purification and becomes clean before going to the supply pipe - this is evaporation of water from the surface of an ocean and precipitation over the land in our model.
Answer: The most common answar is-
Water is a good solvent. When it flows, many kind of salts released by rocks dissolves in it. All these salty water goes to oceans and make them salty.
Answer: This reminds me of my school days when we had to watch this movie:
Hemo the magnificant
It's an old movie but worth the time to watch it.
Actually sea water contains traces of all known natural elements including sodium and chlorine ions and our blood is an analog of the sea water of which it evolved.  Salt does not exist in water until the water is evaporated away.
Comment: I'm completely baffled by your last sentence. It seems to contradict itself.
Comment: It's not salt unless it is a solid so evaporation must take place to crystallize to salt. We call it salt water but it is the sodium and chlorine ions that make it "salty".

Why are Earth's oceans salty?


my internal memory is empty but cant add new apps

Question: Not enough storage when loading apps to my phone why is this and my internal memory is empty, also new 4gb memory card is brand new.
Comment: I've just added the `insufficient-memory` tag to your question; please see [its tag-wiki](https://android.stackexchange.com/questions/tagged/insufficient-memory) for some background and first-aid. Trouble in such cases is not storage per se, but *device internal storage*. If that's down, no matter how much free space you've got on your internal/external SD card, you'll get this error.
Answer: Open settings>storage>miscellaneous and delete all the files from here
Also delete cached data(by touching it)It happened with me too but now every thing is fine I found a file named 0 in miscellaneous and on deleting it my phone started working properly
Answer: I think that this has already been answered in this thread
You may have sufficient internal strage space, but not enough space on the /data partition.


How do you print nothing from a Field template? (field--field_name.tpl.php)

Question: I need to show a block if a field has a given state, or print nothing if it has a different state. I can get it to work using a field template with the code below, but printing useless html just to stop it from rendering it's default output seems more than a little hacky.
I've tried setting $element = null; - that didn't work. I tried changing #markup to be empty, that didn't work. Even using print ''; means Drupal kicks it's default rendering back in.
Is there a recommended method for telling a field to do nothing?
<?php if($element['#items'][0]['value'] === 1){
    //This is an archive page - show the block.
    $block = module_invoke('customblocks', 'block_view','archive');
    print render($block['content']);
    } else {
        //nothing to do here - not an archive page
        //The only way to stop Drupal rendering something appears to be to get it to print SOMETHING.
        //So we're going to print an invisible hr.
        print '
';
    }
?>

Answer: This tutorial might be helpful http://akyl.net/how-extract-and-theme-drupal-7-fields-out-renderpagecontent


What is this lump on my goldfishes head?

Question: I just noticed today that my goldfish has a lump on his head that is white around the edge with a red centre. He is eating and behaving normally. He is nine years old and has never had any other problems. The water quality is all came out fine when tested. Does anyone know what this is?
Comment: How quickly is it growing? My goldfish has had a lump on his scales by his dorsal fin almost his whole life (he's 17) which gets bigger as he grows. It's darker than the rest of him, but doesn't look "angry" like this lump.
Comment: Hi Pam! It just suddenly appeared one day, I never noticed it growing! It has decreased dramatically since treating him with a fungal treatment and is now almost completely gone. Hopefully it will go away fully and he will be ok.
Answer: I think your goldfish has a virus infection. This might lead to a tumor forming later.
The only thing you can do about this is to be sure the water quality is as good as possible and to elevate the temperature in your tank to 22 - 24°C and hope your fish can fight this on his own (goldfish are cold water fish so a temperature of 15 - 25°C is ideal for keeping them).
Do not add any type of medication to your water, it will kill the good bacteria and is unlikely to help your fish.
Here is a list of diseases that carp fish can get 17 Goldfish Diseases. It is a scary reading but it might help you and others to diagnose and treat the fish in time.
Answer: Update on the lump:
I consulted some of the notes and websites that one of my lecturers gave me (I am a veterinary medicine student) and decided to treat it with a fungal treatment. It improved almost immediately and now, 4 days later, the lump is almost completely gone! Looks like Billy had a lucky escape!!
Comment: What was the fungal product you used?
Comment: I used the Merck Veterinary Manual


Questions on product recommendations

Question: This question What is the quietest range (cooker) hood? is asking for a product recommendation but it is for an appliance.  I think this type of question is off topic and should be closed.  Recommendations on tools though I think would be on topic.  Just wanted to get other opinions before closing it.
Answer: I think product recommendations should be allowed for things that are installed permanently.  That includes PVC pipe, glue, range hoods, garbage disposals, furnaces, air conditioners, attic fans, sump pumps, electric heaters, locks, walk-in refrigerator parts, and electrical boxes.  Here, choosing the right product often has some technical aspects, and it is part of a bigger home improvement project (e.g., redoing the kitchen, running a new circuit to the garbage disposal, or solving the problem of a wet basement).
I could maybe even be convinced that some questions about "loose" appliances like refrigerators, dishwashers, washing machines, and dryers may be on topic, at least if it's about finding a product for a particular situation with unusual requirements.  Questions about which refrigerator brands are better built are definitely off topic because it's not something DIYers know more about than other homeowners.  I could maybe be convinced that the question asking about quite range hoods falls in this category, but it shouldn't be closed simply because it asks for a product recommendation.
Comment: You make a good point about permanently installed items vs loose.

Questions on product recommendations


Why do I get this anomaly (vertical line) in my TWI raster?

Question: I have derived TWI using SAGA GIS, Have a look on the center of the image, a vertical line goes through it from top to bottom. Anyone else confronted this issue?
Answer: To me it looks like a common error that occurs when multiple DEM tiles are mosaiced. This is particularly common if nearest-neighbour resampling is used for the mosaicing rather than a bilinear or cubic-convolution resampling scheme. Nearest-neighbour resampling is faster than either alternative, but should really only be used in the case of categorical data and not continuous data such as a DEM. Often these mosaicing errors are not apparent in the DEM but are only visible in data derived from the DEM, e.g. slope, aspect, curvature, TWI, etc. The first thing I'd do is check and see if the same line is apparent in an aspect/slope raster. If so, then it's the result of the DEM creation and not the TWI tool.
That said, more troubling to me than the vertical line is the fact that you have extreme discontinuities in TWI, i.e. the contouring effect apparent in the blue-orange transitions in your raster. These are often coincident in your image with what appear to be drainage divides. This shouldn't be the case for TWI. At first, I thought that this was an artifact of your palette, but the fact that the discontinuities occur at divides suggests otherwise. For reference, this is what a typical TWI image should look like:

Notice how it looks like a continuous surface with no localized breaks or discontinuities. The raster should take on similarly low values on either sides of divides/ridges.
The problem with your raster is most likely the result of the contributing area raster (TWI is a combination of slope and contributing area). It's highly probable that the topographic depressions (i.e. sinks) have not been properly removed from the DEM prior to calculating contributing area/TWI.
Comment: @Nasir, Sure, I can write a tutorial on the creation of TWI rasters using Whitebox GAT when I get a free moment. I'll post a link to it here when I'm done.
Comment: Sir this is really great privilege for us. This will help us to 'Do Right thing in Right Way', Especially for me, I tried to get acceptable results in ArcMap too but it didn't help me either. http://gis.stackexchange.com/questions/184998/no-data-values-in-twi-raster Getting TWI is common in many applications, therefore, this will be a great contribution.
Comment: I am thankful for yours insight, it will help me to resolve the issue, I had filled sinks but didn't used resampling technique robust for  continuous datasets. Surely, you have rightly pointed out.  Thanks.
Comment: I have faced problems to derive TWI in various software, many others too. It will be very helpful for all of us if you could refer us to any specific tutorial or do manage to write (Snap) steps preferably in WhiteBox GIS software so everyone could produce acceptable results. It will be a great privilege for all of us.
Comment: I have resolved this problem by modifying above expression as;
Ln(("Flow_acc"+ 1 ) * 30/"Tan_SlopeRad")

There was nothing wrong with the Process Flow Diagram inserted above, however, I removed the 'Sinks' from the flow direction raster using WhiteBox and exported it in ArcGIS and use it to produce Flow Accumulation Raster. Although in ArcGIS, DEM was earlier pre-processed and all depression were removed by 'Filling' these imperfections using 'Fill' tool. However, now there are no anomalies in the derived raster and no cells contain 'No Data' values.


Custom Taxonomies in body class with parent slug

Question: I have tried many answers here on stackoverflow but couldnt find a solution to my problem. I have created a custom post type called ph_products and custom taxonomies with the name ph_category.
Then I created some categories for that custom post type like this:
blue-products
    blue-sub-products
green-products
red-products

I need to have body classes as following:
When on the ph_products-archive page there should be a class with that slug in the body
When on one of the parent categories the respective slug should be in the body class
And when I am on one of the sub category archive pages I need to also have the parent category class
For example I am at the blue-sub-products archive page I want to have blue-products, ph_products-archive, blue-sub-products in the body class
Of course I need all of these classes in the respective single views of the products as well.
I use this piece of code to add the desired classes:
(thanks to https://alexanderdejong.com/wordpress/add-custom-taxonomies-body-class)
function atp_custom_taxonomy_body_class($classes, $class, $ID) {

    $taxonomies_args = array(
        'public' => true,
        '_builtin' => false,
    );

    $taxonomies = get_taxonomies( $taxonomies_args, 'names', 'and' );
    foreach ($taxonomies as $taxonomy) {

        $terms = get_the_terms( (int) $ID, $taxonomy );

        if ( ! empty( $terms ) ) {
            foreach ( (array) $terms as $order => $term ) {
                if ( ! in_array( $term->slug, $classes ) ) {
                    $classes[] = $term->slug;
                }
            }
        }
    }

    return $classes;
}
add_filter( 'body_class', 'atp_custom_taxonomy_body_class', 10, 3 );

But this kinda adds the classes pretty weird for example when I am on the ph_products-archive page I also get the category slugs of the last item posted there so if the last item is in the categories blue-products, blue-sub-products I get these two slugs as classes as well although I am not at these category pages
Or when I am at the blue-products-archive page I also get the blue-sub-products category slug in the body class.
How can I only get the classes desired as described above?
Answer: From the above function you queried all the taxonomies.   Not specific.
I mean it's not only for your custom taxonomy. Working for the whole.
Answer: You will need to use get_term_children( $term, $taxonomy ) and then if has children use child term as class... if not, use taxonomy.
if you really want to be in the child taxonomy archive, try using the taxonomy templates


How to move two anchor points in different directions in sketchapp at once?

Question:

I want to skew the Rect from both left and right in the same time, all i know is to select one anchor point at a time and move it as the two anchors needed to be moved in different directions, how could i do this in the same time in sketch-app?
Comment: possible duplicate of https://graphicdesign.stackexchange.com/questions/95004/how-can-i-drag-2-points-inverted-in-sketch?rq=1
Comment: is it the bottom anchors? what is the final shape you want to obtain? Your question is not very clear.
Comment: The final shape i want to obtain is what you already have seen in the image.

My question is how to move the bottom anchors both in the same time and in different direction after selecting them both to create this shape.

if this still confusing to you.. watch from moment 4:20 here, how to apply this in sketch?
https://www.youtube.com/watch?v=JMxHy_N7-LU
Comment: That would be a nice feature (move towards eachother)
Comment: But i've seen someone already did this in a video tutorial
https://www.youtube.com/watch?v=JMxHy_N7-LU
Answer: Good News!
You can totally do this with the Transform tool.

Three Ways to Transform
Depending if you're the type of person who likes to click into menus, use the keyboard, or use the toolbar, there's a way to do this.
Option 1 and 2
The first way is to go through the Layer in the Menu bar, then Transform > Transform. For the second option, notice it has a shortcut command too

Option 3
The second is through the Toolbar. If it's been removed, it's easy enough to add it back in by right clicking the Toolbar, selection Customize Toolbar… and dragging it where you'd like.


Is this pineapple plant dead?

Question: I planted a pineapple plant. Some leaves died. Tips of others died too. But, as you can see in the picture, most of it is green. It has been this way for months, and no new leaves grow. Is it dead? If not, what should I do to encourage growth?
Answer: It's  not dead at all - but there are some dead areas at the tips of the leaves, and what looks like one completely dead leaf. Trim off the dead areas and the dead leaf,but don't prune. These plants grow from the centre, and if you're in the northern hemisphere, it will now rest and not do very much. Even indoors, though, it needs as much as sun as it can get, but should not be anywhere near a heat source like a radiator or fire. As far as watering goes, only water when the surface of the potting soil feels dry to the touch, and water well, emptying away any excess water in an outer tray or pot after 30 minutes, never leave it sitting in water. Further information here, https://www.todayshomeowner.com/how-to-grow-pineapples-as-houseplants/ - the bit you're interested in is towards the end. You'll note the size of pot required, and the fact that these plants benefit from being outdoors during summer.
I'm rather curious as to the cause of the white lines or what look like scratch marks on some of the central leaves...
Comment: I'm less optimistic, but from photos I can not see much. Pineapples are monocots, so the central buds is very important. If it dies, the plant dies. The dry part in the middle makes me worry. Note: like palms, pineapples and other perennial monocots, have the central bud very protected by "old" leaves (and hairs).
Comment: I'm not entirely sure its dead in the middle, there's one  little area that looks dry and brown, but impossible to say from this picture whether that's the central growth point or not. If it is, you're right,its likely on its way out.  But there might also be evidence of a pup to the left and behind the main growth...
Comment: The central bud doesn't seem very promising at all. On the other hand, the pineapple has been in a more-or-less similar state for a long time. I planted it in mid-April of this year.
Comment: The pup doesn't seem a pineapple. IMO an other pot behind it
Comment: If the central growth point has died, the whole plant will die back in an obvious fashion, so if that happens, its a goner...
Answer: I by far am not an expert, this is more of an opinion than advice. I would prune it back, chop off all the dead. My Aunt says dead leaves sucke the life out of a healthy plant. Maybe do a quick Google search of what type of fertilizer would be good for it, to give it a boost. Good luck.
Comment: Well its an interesting concept, but dead leaves don't 'suck the life out' of a plant, they're not doing anything, they're dead. Best removed so they don't fall and maybe rot on the top of the soil if the plant's in a pot, but otherwise, they're usually removed for aesthetic reasons.
Comment: @Bamboo or to block the spreading of diseases. But this case doesn't seems the case
Answer: The pineapple has recently started growing!
Answer: Update. Here is what it looks like now. It helps that I now keep it outside in a warmer climate.
Answer: The yellowing is from over watering or pests. I cut my plant back because it got severely over water from the hurricane rains we got here in Va. I'm going to check the roots for rot and depot mine. Finger crossed!!!

Is this pineapple plant dead?


A contract that generates another contract

Question: If I want to create a smart contract with an action 'Create Game' and on calling that action a new contract be formed, how is it possible?
Comment: I don't think `setcode` is in the available contract API so I don't think it's possible directly
Answer: You can't create a 'new' contract, but you can call another contract's function and create a new object in that contract to save the state.
You can refer to eosio.token inline functions get_balance/get_supply where both functions are accessible from any other contracts by just initializing eosio.token in your own contract.
edit: It is not possible to create an object in another contract as it will consume ram
Answer: Think of your contract as a factory. You keep a collection of games. Each game is an instance of a struct called game - it has all the state fields of a game. When someone creates a new game you just add one to the collection.


SharePoint column based search

Question: I have some custom columns on my site and I want to search keyword in that columns only. I am using CSOM. Can you please provide me solution for this problem.
cuurent code which searches globally :
KeywordQuery keywordQuery = new KeywordQuery(m_context);
                string Path = string.Empty;
                foreach ( string libraryName in libraryNames )
                    {
                    Path += " Path:" + PluginConfigManager.siteUrl + "/" + System.Web.HttpUtility.UrlPathEncode(libraryName);
                    }
                keywordQuery.QueryText = keyword + Path;
                SearchExecutor searchExecutor = new SearchExecutor(m_context);
                ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);
                Logger.info("Executing ExecuteQuery for Search");
                m_context.ExecuteQuery();

Thanks
Sam
Comment: Which version of SharePoint? Or are you using SPO? Have you tried creating a Result Source for your site so you can add a Result Source attribute (SourceID) to your query?
Comment: I am using SharePoint online, I want results from perticular library and also search should work on only specified columns. So how can i pass coulmns to search query?
Answer: Use KQL. I would use a Result Source to limit the results to the library. In fact, I would use a Content Type on the Library so that makes all of this SO much easier. You can use the Path Managed Property if you aren't going to use a content type. Like Path:"https://tenant.sharepoint.com/sites/site/library"
For the column use the Managed Property you created for the column MyManagedProperty:"My Query"
If you decide to use a Result Source you have to use the ID of the source not the name.
Comment: If I use the managed properties in search then it wont searches in pdfs and documents. I want to search in specified managed propertiers metadata and  in content of pdfs, docuements too.
Comment: Include an OR clause and a free text component to you query and it will do that for you. Alternatively you can try using the Content or Body managed property. (I can't recall which worked for me.)

SharePoint column based search


InfoPath Repeating Table-Add Filtered Data from Secondary List

Question: I have the following scenario that I am trying to get find a solution for.
I have two lists within my SharePoint site called Supplier and Factory. The relationship between the supplier and factory list is one to many, that is for each unique supplier there can be multiple factories that are related to it.
So in the factory list there is a lookup column to the supplier list, a parent-child type relationship between them.
Within InfoPath I am trying to create a form for the Supplier list that will show all of the "child" factories related to that supplier in a repeating table. I have managed to get the repeating table into the supplier form, however the problem I have is that at the moment it includes all of the factories in the list, not just those related to the specific supplier I am looking at.
Is there a way to auto-filter the repeating table so that when the supplier form is opened up, it only displays those factories that have identified themselves as factories of that specific supplier?
I am using SharePoint 365 and InfoPath 2013.
Thanks
Edit
I have added an image below to help better illustrate my scenario.
The image is the view of an item in the supplier list, specifically supplier S2 with ID 2. The table in latter half of the image is the repeating table which is pulling in from the factory list. As you can see it is pulling in everything that exists in that list at the moment, I want it to only pull in those factories which have a matching Supplier ID of the supplier item that is open. So in this case it would be the bottom two factories F5 and F6 (they are the only factories with a matching supplier ID of 2).
Answer: It sounds like you're looking to do cascading drop downs? If so, here's a link to a video that seems very helpful.
Comment: That is along the lines of what I am after, but not quite. I need to apply it to repeating tables, not just fields.


MIT license change own name as copyright holder

Question: If I am the copyright holder of a project licensed under the MIT license, can I change the name in the copyright notice? For example after a name change or changing to/from a pseudonym.
Note that (unlike the other questions that have been posted about this) this is not about someone else's project, but one that is owned exclusively by myself.
Answer: If you are the sole copyright holder, then the answer is very simple: You are not bound by any license, so you are allowed to do anything you want including those things that most licenses forbid.
If you are not the sole copyright holder (e.g. you accepted contributions from others), then things become more complicated but not all is lost.
If there are only a few copyright holders, you can just formally ask for their approval to make those changes to the copyright notices. And some jurisdictions also allow in their copyright laws that factual errors in copyright notices are corrected.
And lastly, copyright notices don't carry that much legal weight nowadays. At best, they are an aid in establishing who owns the copyrights and if you can make a plausible case that you used that name/pseudonym around the time mentioned in the copyright notice, then that should be sufficient to establish you as a copyright holder.
Comment: I agree with @amon: if Bob modified Alice's code, and then Alice merged in Bob's changes, and then she decided to change her own name on her copy of Alice+Bob's work, I cannot imagine a court granting success to Bob if he decides to sue Alice over her changed copyright notice. But I admit I don't have a specific legal basis for this intuition, so perhaps I'm wrong.
Comment: Why would changing your own copyright notices be a problem even if it's MIT-licensed? There's a very literal argument that you have to preserve all notices, but having to preserve your own notices is clearly not in the spirit of the license.
Comment: @amon, I prefer to err on the side of a too strict interpretation of the law. I also don't see a judge ruling against an author modifying their own copyright notices in a work with multiple copyright holders, but it is even better to avoid the whole mess of a lawsuit.


Should I take-off and wear again the ihram when want to perform another umrah

Question: For repeated Umrah, should I take off my first Ahram after completion of first Umrah and wear it again from Meeqat Masjid Aisha, or keep on wearing the same and make Niyyah for next Umrah?
Comment: It is discouraged to do two umrahs in a single journey. Perform tawaf instead
Answer: You can make your repeated Umrah using the same cloth [2] but to catch the sunnah you should take shower [1] and differently you have to take off your cloth. But you don't want to do that so only make Niyyah.

http://fatwa.islamweb.net/fatwa/index.php?page=showfatwa&Option=FatwaId&Id=159221
https://www.binbaz.org.sa/noor/9971

I hope my answer is helpful for you.
Mohammad
Answer: It depends on your initial Niyyah. If you were intended to perform more than one Umrahs with same Ihram i.e. you have a composite Niyyah then its okay but if you intended to perform each Umrah solely then put off the Ihram and re-wear it for the other.
Comment: Please consider adding references to support your claims!


Arpeggio Markings for Chord symbols

Question: Is it common to denote a chord symbol with an arpeggio marking?  How else would you indicate that the chord is to be played arpeggio?
Comment: It occurs to me that I might've totally misinterpreted your question. Are you talking about somehow marking arpeggios on notations like a letter F (for an F major chord) above the staff?
Comment: To put User replete's clarification request into other words, *when you say "chord symbols", do you mean the little symbols* that look like "A7(♭9)"? *Or do you mean the literal notes written into sheet music?*
Answer: The vast majority of chords in piano music are not marked to be played arpeggio, but that still leaves many which are so marked.
Here are typical notations, courtesy of Dolmetsch Online:

Sometimes composers would just write the word arpeggio instead of using these notations. This is to be expected in work from composers who lived before the line notations were introduced. For example, the introductory bars of J. S. Bach's keyboard fugue in A minor BWV 944:

This means that all the chords are to be arpeggiated.
Contrast with this étude by Chopin:

This notation also marks all the chords to be arpeggiated. However, it allows the composer to specify which chords should not be, unlike the general arpeggio term.
These examples are different in another respect. There was great freedom to the performer in how to arpeggiate the chords in Bach's time. As the note durations are long in the example, the performer might play up and down the arpeggio slowly, to fill the entire measure, instead of playing fast from bottom to top only.
At other times, composers took still another approach, writing out the arpeggio directly with grace notes, as in this example from Mozart K. 309:

Here, there can be a difference in intent. If all four notes in this arpeggio were written as a chord with the wavy line notation used, normally the player would continue to hold all the notes. As written with grace notes, however, normally the player would not retain them after playing them.
Comment: And if I am not wrong, the curvy line for the chord in the first image is called *arpeggiando*
Answer: As far as I know, for instruments that use chord symbols (not piano, but guitar maybe), no, this is not common. Chord symbols break down when trying to convey performance text specifically like that in general; how one chooses to convey that arpeggio is up to the transcriber/composer.
However, any well-trained musician in music theory should recognise what your proposed system is trying to say. Even beginners might guess at the meaning, but most intermediate musicians with some music theory training would get it.
I wouldn't advise doing it if you don't think the performers will understand. Of course, if the symbols are for you, then of course write it however you'll remember it!
Answer: For piano music it is common to mark the chord with one of the usual signs. (Look up the other answers.)
But in simple chord accompaniments for guitar in folk -
and pop music it is up to the interpret if he wants to play arpeggio or a strummed chord. This means: There is not a common sign.
(I didn't  understand the question in the sense that you were asking as a songwriter or composer how you could mark a arpeggio for the players.)
Answer: Another commenter explained the arpeggio symbols used in staff notation, but your question is about chord symbols.
The principle behind the chord symbols used in jazz and pop music is to let the instrumentalist follow their own intuition in choosing voicings and textures. If there is a specific arpeggiated pattern you want, it's best to simply write it out note by note, or write out one bar of example notation and then write the word simile over the subsequent measures.
If you don't have a particular arpeggiated pattern in mind, you can simply write the word arpeggio near the chord symbol. Any literate musician will understand this to mean that they should improvise their own arpeggiated pattern.
When you'd like them to stop arpeggiating, you can use the word comp in jazz, or simply end arpeggio or something to that effect.
Another option is to refer to a specific style of arpeggiation, like montuno, Coldplay, or in the style of John Lennon's "Imagine." A pianist experienced with reading jazz and pop charts will know what these things mean.
My larger point is that if there is an accompanying technique that you feel you can describe better in words than in notation, then you should simply use words. Many beginning composers feel pressured to use the "proper" Italian terms and musical symbols to communicate their ideas, but it has long been a staple of notational practice for composers to add instructions in their native languages.

Arpeggio Markings for Chord symbols


Hash comparison tool or script

Question: I need to see if there is a tool out there that can help me with a project I am working on.  I have a remote set of files that we have imported a few TBs, the remote site has sent me a text file that contains a very long list of each filename and its md5 hash.  I need a tool or script that will allow for an automated approach to make sure each file has a match.  I need to take each file name and hash one by one from the list and compare with the imported files for the matching file and hash to validate the data is the same.  If a match is not found I would like to create a report of the file name and hash from the list that are missing a matching imported file.  Any information on the best approach to take either for an existing software tool or script creation is appreciated.
Answer: I was dealing with this issue today as well.  It turns out that the standard *sum utilities in Linux take care of this with their -c option for checking with a filename argument.  Here's an example of going through the whole process with md5sum:
Downloads !104 $ ls *.rpm
rescuetime_current_amd64.rpm  slack-3.3.7-0.1.fc21.x86_64.rpm  zoom_x86_64.rpm
Downloads !105 $ md5sum *.rpm > md5sum.txt
Downloads !105 $ cat md5sum.txt
4abe6d4a8a279d0b0bb45535bb48d566  rescuetime_current_amd64.rpm
68dff7bb9eaafa0df5637f576c54641d  slack-3.3.7-0.1.fc21.x86_64.rpm
da0540c22c46e2264d62eac9deddf8b0  zoom_x86_64.rpm
Downloads !106 $ md5sum -c md5sum.txt
rescuetime_current_amd64.rpm: OK
slack-3.3.7-0.1.fc21.x86_64.rpm: OK
zoom_x86_64.rpm: OK

It might also be worth noting that md5 is deprecated and newer tools are available.  Even if you're not worried about a nefarious attacker it is nice to reduce the remote chance of having a false validation.
Answer: Bash scripts with md5sum will do the trick

Hash comparison tool or script


Accessing page object in C# TBB used in the component template

Question: Is there a way to access page metadata schema value or structure group metadata value holding that page from the C# Code fragment which is used in the component template?
Answer: It is generally considered bad practice to access Page level information from Component templates (Separation of concerns etc.). It is something which was easy in the old days of VBScript templating and sometimes caused a lot of issues.
There are ways to do it though, if you must.
Take a look at Access container page of a component in .net based CT on Stack Overflow
Comment: I will add it to the list of (nonexistent) blog posts to write. Be advised, it's a LONG list ;)
Comment: Oh I love that: "Generally considered bad practice"... "sometimes caused a lot of issues". Sure - I'd prefer to see the PT pass the relevant data to CT scope, but if you're going to be so dogmatic, you owe us a blog on the subject! :-)
Answer: Have a look at the code sample for the third option suggested in the answer here:  https://stackoverflow.com/questions/11182669/how-do-i-pass-arguments-down-to-component-dreamweaver-templates
I believe it's exactly what you're looking for, however, as David suggests in his answer, it's better to avoid reaching to page-level scope from your CT.
Answer: Thanks to David Forster/Jeremy Grand Scrutton for providing option to access the page object from the component template which really works in my scenario & the same solution is provided by one of my colleague.
Page page = engine.PublishingContext.RenderContext.ContextItem as Page;
if (page != null)
{
}
The only limitation with this option is that it is not available during previewing of the page or debug the PT/CT using template builder.


How to get Unique Log on & Log off event in windows

Question: I want to get unique logon & log off event from my pc.
In the event viewer i can see more then one entry for login & log out event.
I check most of the event details but could not found unique event for logged in by user.
http://www.freeimagehosting.net/uploads/bf1f69599d.gif
Answer: Your logon events are unique. You're just not looking at the unique data.
Each event with ID 4624 will contain, in the description, a logon ID (and, if it's a domain logon, a logon GUID), username, and a raft of other detail information.
To correlate a logoff event (event ID 4634) with a logon, you'll need to examine the description of the logoff event and correlate the logon ID there with the logon IDs logged when logon events occur.


SSL Apache site not found

Question: I tried to install web2py on our web server but I have to access the admin panel through SSL because there is no graphical interface on the server itself.
I'm not very familiar with setting up an Apache server so I haven't been able to get this to work. I did run the setup script for web2py which should set the SSL site up, but when I try to connect I just get "This web page is not available". I can connect to the web2py front page with normal HTTP. I have also tried hacking that a bit but I can't even see any errors or access attempts in the apache2 logs.
I did run
openssl s_client -state -nbio -connect localhost:443 2>&1 |grep "^SSL"

With the following results
SSL_connect:before/connect initialization
SSL_connect:SSLv2/v3 write client hello A
SSL_connect:error in SSLv2/v3 read server hello A
SSL_connect:SSLv3 read server hello A
SSL_connect:SSLv3 read server certificate A
SSL_connect:SSLv3 read server key exchange A
SSL_connect:SSLv3 read server done A
SSL_connect:SSLv3 write client key exchange A
SSL_connect:SSLv3 write change cipher spec A
SSL_connect:SSLv3 write finished A
SSL_connect:SSLv3 flush data
SSL_connect:error in SSLv3 read finished A
SSL_connect:error in SSLv3 read finished A
SSL_connect:SSLv3 read finished A
SSL handshake has read 1435 bytes and written 319 bytes
SSL-Session:
SSL3 alert read:warning:close notify
SSL3 alert write:warning:close notify

Site in question is http://www2.olka.fi and my default-ssl looks like this now:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
    ServerAdmin webmaster@localhost
    WSGIProcessGroup web2py
    WSGIPassAuthorization On
    WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py

    <Directory /home/www-data/web2py>
            AllowOverride None
            Order Allow,Deny
            <Files wsgihandler.py>
                    Allow from all
            </Files>
    </Directory>

    AliasMatch ^/([^/]+)/static/(.*) \
            /home/www-data/web2py/applications/$1/static/$2
    <Directory /home/www-data/web2py/applications/*/static>
            Options -Indexes
            ExpiresActive On
            ExpiresDefault "access plus 1 hour"
            Order Allow,Deny
            Allow from all
    </Directory>

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on

    #   A self-signed (snakeoil) certificate can be created by installing
    #   the ssl-cert package. See
    #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
    #   If both key and certificate are stored in the same file, only the
    #   SSLCertificateFile directive is needed.
    SSLCertificateFile    /etc/apache2/ssl/self_signed.cert
    SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
    </Directory>

    BrowserMatch "MSIE [2-6]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
    # MSIE 7 and newer should be able to use keepalive
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

</VirtualHost>
</IfModule>

Answer: OK, the issue was actually the Linux firewall. Adding rules for port 443 fixed my issues. So this question can be closed or deleted.

SSL Apache site not found