Temporary ticket booking

Question: I am building a e-ticketing site for buses . I am facing a problem here : When the user books tickets with seat number,I have updated the database with their seat numbers . Now I want to know what if he closes the window and selects not to book .Should I expire his session after a interval of time
Answer: I would keep his choices in the session and commit to database only once he confirms the booking.
Answer: This is an issue which often crops up with ticketing and retail sites. The dilemma often experienced by users is that they buy an item (in low stock)  or book a particular seat only to find that the resource is no longer available because another user clicked 'Confirm' before they did...
With an eye to keeping track of resources which are in the process of being purchased it is good practice to implement a temporary 'temp_transaction' database table which your code can consult to determine if a user is in the process of booking, say, a particular seat.
Once payment, vetting and validation on the temporary data has been made then a commit to the main 'transaction' table can be made and the 'resource' (seats) table updated with definitive data.
This approach enables better accounting of concurrent transactions as well as point-in-time auditing of user activity and/or resource status.
Comment: the suggestion to have a grace period by @CodeCaster is a good idea, beacause it allows users to have priority on resources whilst they are booking without tying up resources indefinitely (and thereby losing sales). This could be achieved with a temporary table implementation without any need for cron.
Answer: While the solution of @Gigi is a reasonable one, it's not complete.
You should somehow reserve the seats a visitor chose, otherwise another visitor, visiting at the same time, might reserve the same seats.
You could set a time, for example ten minutes, for which the seats stay reserved to the visitor who reserved them first. During this time, that visitor can complete the reservation (i.e. enter payment and delivery data), at which point you update the appropriate fields to indicate the seats they represent should not be freed again since they now "belong" to that customer.
You could run then run a delete job every now and then (for example on every page view, or prior to every check for available seats, or perhaps through a cron job) that frees seats that have been reserved more than ten minutes ago but whose reservations have not been completed.

Temporary ticket booking


404 Error when building map

Question: My path analyzer doesn't have any data. it is showing me like the image below. Could I know how to redeploy the map and rebuild the historical data?
Answer: Please try going to https://your-domain/sitecore/admin/PathAnalyzer.aspx
On this page you will find an option to perform Historic Map Rebuild.

This process will rebuild all currently deployed maps from historic
data in XDB. Depending on the number of interactions in XDB and the
processing power, this could be a very expensive operation. Important:
This feature is not expected to work in setups where processing server
is separated from the reporting server. Please refer to the Knowledge
Base for more details.

404 Error when building map


How long would the conference be for?

Question: I want to know if this is grammatically correct " How long would the conference be for?".
Comment: It's OK in spoken English or informal writing.
Comment: It may be worth noting that there is a fundamental difference between a question such as "How long would the convention be for?" (where the "for" is superfluous to the sense of the sentence, as you can see by repeating the sentence with the "for" omitted: "How long would the convention be?") and a question such as "What are you in prison for?" (where the "for" is essential to the intended meaning of the sentence, as you can see by comparing it to the "for"-less alternative, "What are you in prison?"). In one case, the inclusion of "for" is unnecessary to sense; in the other, it is crucial.
Comment: Possible duplicate of [Omission of 'for' with various quantified time intervals: influence of verb](https://english.stackexchange.com/questions/193355/omission-of-for-with-various-quantified-time-intervals-influence-of-verb)
Answer: Sounds perfectly grammatically correct to me:
Q: Do you have availability for a conference starting June 21?
A: How long would the conference be for?
What kind of "grammatically correct" are you looking for?
Comment: Was just wondering if this is correct
Answer: I think it's helpful to rephrase to a statement rather than a question...

1: The movie is two hours
   2: The movie is for two hours
   3: The movie lasts two hours
   4: The movie lasts for two hours

I could just about tolerate #1, but #2 is completely unacceptable to me. I've no strong feeling about whether for should be included in the second pair, but certainly in OP's exact example that would be perfectly acceptable once be is changed to last.
Comment: If the context is about booking (a room, a hotel, a conference centre), then "The conference is (booked) for three days" seems normal to me, even if the word "booked" is not stated.
Comment: FWIW, #2 sounds fine to me. It looks slightly odd written down, but spoken, it sounds perfectly normal. "What are your plans tonight?" "Well, the movie is for two hours, then we're having dinner."
Comment: @Steve: I guessed there might be a range of opinions on that one, which is why I said *unacceptable **to me*** above. But do you at least agree that ***for*** is "more acceptable" after ***lasts*** than after ***is***? And by implication, that *How long is the movie?* sounds "better" if you don't tack on ***for***?
Comment: I'm not sure. There are shades of meaning, too. "How long is the movie" could apply generically to a film (it has a published running length of X), whereas "How long is the movie for" is definitely about one particular screening. I probably agree with your proposals. Probably. :)
Answer: It should be, "How long will the conference last?"  "For," in this case, doesn't refer to anything - if you said (for example) "How long do you need me to hold an object for," for would refer to the person asking you to hold the object.  Since the you are not holding the conference for someone, you to do not need to add the word "for" to it.
I don't remember why "be" is the wrong wrong ending as well, someone else can tackle that.
Comment: I'm sorry, but this answer is quite wrong. In "How long do you need me to hold an object for", the "for" has nothing whatever to do with a person, and everything to do with the time.
Comment: @ColinFine Quite so. *Who do you want to hold the event for*, would be another matter.
Comment: I think the "for" is related to a phrasing like "for three days". How long would it be for? It would be for three days.
Comment: I partly agree with you, since I avoid whenever possible, ending sentences and clauses with a preposition. "For how long will it be/last" suits my style of speaking rather better. But I disagree with you in that I see no objection to employing *for*, just its position in the sentence.
Comment: When people talk to one another, they often say for. I'm going to Europe on vacation. Response: And how long will that be for? Perfectly fine, perfectly correct in spoken English or informal written English (emails to friends)

How long would the conference be for?


Altered Patents

Question: In the process of altering an already patented proven chemical process. would someone be able to patent an process in which the outcome may be the same as the already patented process? and if so what would be a way out patented an process thats based from an already patented patent?
Comment: "and if so what would be a way out patented an process thats based from an already patented patent?" I'm afraid I can't parse this sentence. What did you mean?
Comment: What do you mean by saying that " the outcome may be the same"? Same chemical product? Same yield? Same purity? If you alter the process, something, even minor, will be different.
Answer: Would someone be able to patent a process in which the outcome may be the same as an already patented process?
Yes, as long as the new method was novel and non-obvious. In this case, your patent would be limited to the process, and not the product itself (since the product is not novel).
Example
Assume there is a prior art patent, with claims:

Product X.
A method comprising mixing substance A and substance B to obtain product X.

If you discover that you can substitute some substances, and this substitution was not obvious, you could patent:

A method comprising mixing substance A, and substance C to obtain product X.

This is because this method is novel (since it's different from the prior art) and non-obvious (since the substitution is not obvious).
Comment: You might point out that the new process might not allow you to manufacture product X if the product itself is patented.

Altered Patents


Anyone know what this is?

Question: I recently moved into a home and this was lying on a shelf untouched or plugged into anything. Thanks]1
Comment: On the side it looks like it says "control box for submersible motor".  230V 60Hz single-phase...is there a pool or a well with this house?
Comment: Those wire-knockout-looking things on the box, are they intact?  If they are, it would suggest the box has never been installed or connected to the pump.
Comment: ....or they simply kept a spare on hand. (It does have the capacitors in it.)
Comment: No pool, but there is a well pump beside where it was sitting.. wonder if it's required still or left over from something.
Answer: This is a pump control box made by BURCAM and this link is the datasheet.
From your comment about a pump sitting next to it, this looks like the previous owner had a project they either never completed or had to go a different route in completing that required a pump. As others have stated, this unit appears to have never been installed.
Answer: It's purpose is this:
A single phase AC induction motor requires a "capacitor start" routine to make it start spinning in the correct direction, because single phase power has no relative rotation, so without the capacitor starting, the motor would either just vibrate back and forth, or spin in either direction randomly each time you start it. But on a "standard" capacitor start motor, you can see that the capacitor is attached to the motor, that big "lump" on the side of it (some have two, because they need one for running too). That starting capacitor is also not needed once the motor begins spinning, so it is switched out of the circuit with what's called a "centrifugal switch" mounted to one end of the motor, under the bell housing.
But on a submersible pump motor, you need the motor to fit down inside of the well casing pipe, so there is no room for that lump on the side. Plus, the centrifugal switch is a part that wears out and has to be replaced. Replacing parts on a pump motor that is deep under ground becomes expensive. So the solution to both problems is that the starting capacitor is put in that box (the round black cans that you see in there), and the centrifugal switch is replaced by an electronic device called a "potential relay" (the square cube with all the wires coming out of it).

Anyone know what this is?


PHP Check Array with Post

Question: How can a PHP script check if a value is in an array?
I want it to check if a password input is equal to those in an array.
e.g. if $input == "pass1" or "pass2" or "pass3"
Answer: from php manual:

bool in_array ( mixed $needle , array $haystack [, bool $strict =
  FALSE ] ) Searches haystack for needle using loose comparison unless
  strict is set.

if(in_array($input, $somearray)){ .. }

Answer: The PHP function for checking if a variable is in an array is in_array.
Like this:
if (in_array($input, array("pass1", "pass2", "pass3")) {
 // do something
}

Answer: Pretty much copying what Marc B stated in his comment, the example code is
<?php
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Got Irix";
}
if (in_array("mac", $os)) {
echo "Got mac";
}
?>

And in this example the second if would fail because "mac" is not contained in the array.
Answer: There's a couple methods. in_array is one, and foreach is another. I don't know which is faster, but here's how you'd do it with foreach:
foreach ($array as $a) {
 if ($a == "correct password") {
  //do something
 }
}

Comment: Bet on `in_array`. Not sure why you would use `foreach` here.
Answer: Here's another way,
if(count(array_intersect(array($input), array("pass1", "pass2", "pass3"))) > 0){
     //do stuff
}

PHP Check Array with Post


Best way to search through an array and return result

Question: I have an application where you can add peoples firstname, lastname and phonenumber (eg. "new Member('Thomas', 'Jonsson', '0709454543'"). In the application it's possible to show the members on a web page, but now I also want to be able to search for a member with either firstname, lastname or phone nr.
All the Member objects are stored in an array, and in the code below I'm looping through this array and adds the members firstname, lastname and phonenumber in another array, that i'm looping through.
First of all, by some reason I get the following error message in the console ("Uncaught TypeError: Object 0 has no method 'match"). The second thing is that I haven't got a clue how (if I get this to work and get a match if I'm searching) I can refer the search result to the member in the member array. I hope you understand what I mean and I'm thankful for any help.
Yeah, and if you have any tips in better ways for searching, I'm would of course be very happy.
function searchMember(searchWord){
        var searchArray = [];

        for (var i = 0; i < members.length; i++){
        var firstname = members[i].firstname;
        var lastname = members[i].lastname;
        var phonenr = members[i].phonenr;

        searchArray.push(firstname);
        searchArray.push(lastname);
        searchArray.push(phonenr);
        }

        for (var j = 0; j < searchArray.length; j++) {
            if (searchArray[j].match (searchWord)){
                alert("Found member!");
            }
        }
    }
}

Answer: You don't need to create a search array, you can iterate over the original array as follows:
function searchMember(searchWord) {
    var props = ['firstname', 'lastname', 'phonenr'], j, prop;
    for (var i = 0; i < members.length; i++) {
        for (j = 0; j < props.length; j++) {
            prop = members[i][props[j]];
            if (prop.match && prop.match(searchWord)) {
                alert("Found at index " + i + " and object: " + members[i]);
            }
        }
    }
}

Answer: Not necessarily the best solution but you could use
function searchMember(searchWord){
    var str;
    for(i = 0; i< this.length;i++){
        str = this[i].firstname + this[i].secondname + this[i].phonenr;
        if(str.match(searchWord)
            return true;
    }
}

Answer: Your TypeError must be coming from your actual data - is everything really a string?
For the searching - you don't need to do two loops; you can check when iterating the first time already. To get the result, you can return the member in the function. What a function returns is replaced when a function is called.
function searchMember(searchWord) {
    for (var i = 0; i < members.length; i++) {
        var firstname = members[i].firstname;
        var lastname  = members[i].lastname;
        var phonenr   = members[i].phonenr;

        if (firstname.match(searchWord)  // firstname matches
         || lastname.match(searchWord)   // or lastname matches
         || phonenr.match(searchWord)) { // or phonenr matches
            return members[i]; // if either of the three, return this member
        }
    }
}

Then you can do:
var someMember = searchMember("D"); // search for "D"

alert(someMember.phonenr); // alert phonenr of found member

http://jsfiddle.net/Fu7ED/


Do old trophies carry over to new games?

Question: If you start a new game of Lego Harry Potter Years 1-4 will you keep the trophies you have earned on the first play through and only need to achieve the ones the won't unlock? Animagus is the only trophy that won't unlock for me.
Comment: I am not sure if I follow. Trophies can't be unearned. This is one of the most basic charasteristics of trophies. This applies to every game that has trophies. What drives you to think this game somehow is different?
Comment: If, however, you were wondering whether starting a new playthrough would reset the *progress* towards a trophy, then the answer is yes for this game.
Comment: I assume you are referring to the PS3 version? I don't know for sure, but pretty sure you can't unlock a trophy twice, so yes, you'd be left with collecting just the last one I believe.
Answer: If you begin a new game, you will retain all previously collected trophies. In your case, Animagus will still be the only locked trophy.
Often, you'll find mutually exclusive trophies i.e. two you can't get in the same play through. An example of this would be Dishonoured's no-kill achievement and the kill-using-all-gadgets achievement.
Additionally, as per Robotnik's comment, you will often only get one opportunity to achieve a trophy, meaning you might need to make multiple playthroughs to try and get them.
Comment: Adding to this, a lot of games have trophies that can only be earned once in a playthrough, forcing you to play the game again in order to try and achieve them
Comment: Don't you mean, "locked trophy"?  Sounds weird if the only unlocked trophy is the one he needs.
Comment: @fbueckert no idea what you mean... >.>
Answer: Trophies are linked to your PSN account. Provided that you're using the same PSN account when you start a new game, then they will carry over. Many games have trophies that you can't get unless you play them more than once and make different choices.


The difference between "Delete" and "Recommend Deletion"

Question: Until reaching the threshold of 20000 reputation points, during the review process I was presented with the option to "Recommend Deletion". Now that I have reached it, this has turned into "Delete". Furthermore, after reaching the 10000 threshold I got access to the "review > Tools" page, where again I was able to cast delete votes. How do these three delete options differ from each other?
Answer: There are two ways how the community can delete answers (well, actually, it can also via spam flags etc. but this is orthogonal):

Users with 20k+ can vote to delete an answer (provided its score is negative). This can be done on the answer directly using the link below it. Three such votes will delete the answer. Technically, this is very similar to voting to delete a question (which is a 10k+ privilege).
In the Low Quality review users can suggest to delete an answer. For users below 20k (or, as Daniel pointed out, users above 20k that are out of delete-votes for the day) this will be recorded as "recommend deletion" for 20k+ users an actual delete vote will be cast, too. Six such suggestions (recommendation or actual vote) will delete the answer.

That there is a difference in the LQ queue depending on below or above 20k explains the change you saw.
The "tools" page just aggregates information related to the first type of delete-voting, showing the current actual delete votes. It can be used as a gateway to posts one might want to cast a delete-vote on, yet one never literally votes from the tools page.
The deletions via votes and from review are slightly different (which type it was is also marked on the post).

A deletion from review can be undone by OP voting to undelete. To undo a deletion by votes by contrast needs three votes (that can include OP).
The criteria for which answers are eligible for deletion are slightly different. For review it is non-positive score, for votes it is negative score.

To put it somewhat differently, a users can recommend deletion in LQ review and six such recommendations delete, a user with 20k+ can vote to delete answers and three votes delete. And, for a 20k+ user doing the former the system will automatically do the latter (except if they are out of votes).
Comment: Perhaps worth adding: If a 20k user has run out of delete votes for the day but hasn't reached the review limit yet, they can still "Recommend Deletion" in the queue.
Comment: It might be worthwhile to note that deletions via "recommend deletion" votes are weak in the sense that the OP can "unilaterally" undelete the post, which is not the case with deletions via "delete" votes.
Comment: @AlexM. Or a combination. If a post gets $n < 3$ delete votes in the review queue, and $6 - n$ recommendations, it's deleted. I'm not quite sure, but I think delete votes from the question page itself don't combine with recommendations from the queue.
Comment: Thanks for the addition. I did not know that.
Comment: So should I understand that deletion occurs when either of the following 2 events happen: either 6 delete recommendations, or 3 delete votes (either in the review queue, or in the Tools page, or on the very page of the post)?
Comment: @AlexM. Not quite. It's (six recs or votes in review) or three votes anywhere. (As I see Daniel already said.) Maybe votes from outside the queue  also count towards the six, but I am not sure about this off-hand and I rather doubt it.  [The "tools page" technically plays no role at all, as you cannot really vote there. It just gives a link to the post.] I am also not sure how the thing regarding 'undel by OP' is handled exactly. But I guess it is in place unless it is three actual delete votes.
Comment: @DanielFischer: See also [this feature-req on meta.SO](http://meta.stackoverflow.com/questions/316010/stop-using-delete-votes-in-the-lqprq), which asks for reviews not to eat into the daily delete vote quota; I posted a quick and dirty [user script](https://gist.github.com/vyznev/58747ec3eb4a02bf19c2) there that (hopefully) makes "Delete" actions in review behave the same as "Recommend Deletion".
Comment: Test: $\renewcommand{cos}{sin}$   $\cos$ $\sin$.
Comment: @quid: Repent, sinner!
Comment: @AlexM. there I forgot to cover my traces... oh well.


How to show that it holds $|z|<2\max_{0\le k<n}|a_k|^{\frac{1}{n-k}}$ for any root of $X^n+\sum_{k=0}^{n-1}a_kX^k$?

Question: Let $z\in\mathbb{C}$ be a root of the complex polynomial $$f=X^n+\sum_{k=0}^{n-1}a_kX^k$$
I want to show that it holds $$|z|<2\max_{0\le k<n}|a_k|^{\frac{1}{n-k}}$$
Proof: For $s>1$, consider $$f_s:=\frac{1}{s^n}f(sX)=X^n+\sum_{k=0}^{n-1}\frac{a_k}{s^{n-k}}X^k$$ Evaluation of $f_s$ at $z$ yields
\begin{equation}
\begin{split}
f_s(z) &= \sum_{k=0}^{n-1}\frac{a_k}{s^{n-k}}z^k-\sum_{k=0}^{n-1}a_kz^k \\
&=\sum_{k=0}^{n-1}\left(\frac{1}{s^{n-k}}-1\right)a_kz^k
\end{split}
\end{equation}
Since $\sqrt[n-k]{2}\in (1,2]$ and $s>1$ it holds $$\frac{1}{\sqrt[n-k]{2}}<s\;\;\;\Leftrightarrow\;\;\;\frac{1}{2}<s^{n-k}\;\;\;\Leftrightarrow\;\;\;\frac{1}{s^{n-k}}-1<1$$
Thus,
\begin{equation}
\begin{split}
|f_s(z)| &\le \sum_{k=0}^{n-1}\left|\frac{1}{s^{n-k}}-1\right||a_k||z|^k \\
&\le \sum_{k=0}^{n-1}|a_k||z|^k \\
&< \sum_{k=0}^{n-1}|a_k|M^k
\end{split}
\end{equation}
where $$M:=1+\max_{0\le k<n}|a_k|$$ is an upper bound for the length of any root of $f$ by Cauchy's theorem. Now there comes the point where I'm unsure how I should proceed. I would be really thankful if someone could help me out.
Answer: By the triangle inequality we have
$$
|f(z)| \geq |z|^n - \sum_{k=0}^{n-1} |a_k| |z|^k,
$$
so if $z$ is a root of $f$ then $|z| \leq r$, where $r$ is the unique positive root of the equation
$$
x^n - \sum_{k=0}^{n-1} |a_k| x^k = 0.
$$
(Note that Descartes' rule of signs implies that the equation does indeed have a unique positive root.)  Let
$$
M := 2 \max_{0 \le k < n} |a_k|^{1/(n-k)}.
$$
For all $k$ we have
$$
2^{n-k} |a_k| \leq M^{n-k},
$$
so
$$
\sum_{k=0}^{n-1} |a_k| M^k \leq M^n \sum_{k=0}^{n-1} 2^{k-n} = M^n (1-2^{-n}) < M^n.
$$
Thus $M > r$, from which the result follows.
Comment: The essence of this argument is drawn from the proof of Theorem 30,2 of Marden's *Geometry of Polynomials*.
Comment: Thanks for your detailed answer. But shouldn't it be $$M^n(1-2^{-n})$$ in the last equation? In addition, I think the triangle inequality yields $$|f|\ge \left||X|^n-\sum_{k=0}^{n-1}|a_k||X|^k\right\|$$ However, I'm unsure if you argue with the knowledge that $z$ is a root of $f$ (cause $z$ was introduced in the question as a root of $f$) or you placed $z$ as an arbitrary variable.
Comment: Whoops, you're right, it should be $2^{-n}$, thanks for spotting that.  And $$\left||z|^n - \sum_{k=0}^{n-1}|a_k||z|^k\right| \geq |z|^n - \sum_{k=0}^{n-1}|a_k||z|^k,$$ no?
Comment: You're right, you've used the triangle inequality in the right way. My mistake.


Create categories, inherance or delegate?

Question: I am having a little problem. My scenario is: I will build a project with a lot of target. I want have the "public code" (for all target) and "specific code". The problem is: In "public code", I NEED call function at "specific code".
My first try was using categories. I create "public.h" then "public+specific.h" codes using categories. The class that will use this class will need to:
<code>#import "public+specific.h"
...
public *myClass = [[public alloc] init];
[myclass doSomething];
</code>
To use another specific class, i only need to change the #import and nothing more. The unique problem is that in "public class" i will need create a false function, like.
<code>//public.h
@interface public : NSObject {}
...
- (void) doSomething {return };

//public+specific.h
@interface public (specific)
...
 - (void) doSomething { //do what it really have to do };
</code>
The other problems is intrinsic to categories: I can't create local class variable, all will have to be declared in "public.h". I want have all specific things IN specific class...
Ok, so I try in another way: use Inheritance with delegates. In the classes "public.h" and "public+specific.h" it work very well, no need to use fake function, all was fine. BUT, (aways a but), I always will have to alloc the specific class, and if I don't want this, I can create a fake function only to call the delegate, so I have the same problem above. This is a sample:
<code>  //In public.h
  @protocol publicDelegate
    -(void)doSomething;
  @end
  @interface public : NSObject {
      id <publicDelegate> myDelegate;
   }
   -(id)initWithDelegate (id <publicDelegate>)initDelegate{
       myDelegate = initDelegate;
       [myDelegate doSomehing];
   }

   //public+specific.h   //The '+' isn't correct here :P
   #include public.h
   @interface public_specific : public <publicDelegate> {}
   - (id)init{
        return [super initWithDelegate:self];
   }
   - (void) doSomething { //do what it really have to do };
</code>
Like I say, the problem here is how I create this object
<code>   #import "public+specific.h"
   ...
   public_specific *myClass = [[public_specific alloc] init];
   [myClass doSomething];
</code>
With this, I will have to create a lot of #if defined , #elif defined... every time that I need to create a object call. With categories, I only need to do this with the "#include".
To solve this problem, I can have things like this:
<code>    //in "public.h"
    - (void) doSomething {
         return [myDelegate doSomehing]
    };
</code>
Another time I will create fake function. And worst, for every new function in "public+specific.h" I will have to create another fake function.. zzz.. (in categories, i have to do this only with function with "public.h" call in "public+specific.h")
So, anyone have another idea to this problem?? It's a little problem, but I want to make my code good, easy to develop and clean...
Answer: in many cases, composition would serve you well.
Comment: I didn't see how this can help-me. This is only create another class with some data or function. I think is look like create the specific class. But thanks for the tips.
Comment: Rodrigo, i don't see what problem (from your original post) it cannot solve.


Nexus 5 with zero-length partitions

Question: So something is wrong with either the partition or the eMMC. TWRP is unable to erase/reformat/repair any partition (console lists partitions that fail to mount: /data, /data/media, /system, /cache) and e2fsck -pcfv /dev/block/mmcblk0p27 says it is zero-length partition. In fact, under TWRP, the partition sizes are System(0MB), Data(0MB), Cache(12MB), Boot(22MB), EFS(6MB). Any help?
Comment: Have you double-checked if the info shown by TWRP is correct by checking with [DiskInfo](https://play.google.com/store/apps/details?id=me.kuder.diskinfo)?
Answer: Probably your best shot at this point is to flash a factory image. Complete instructions are at the top of that page, but the general gist is:

Download and extract the factory image (you'll probably want the latest one - MRA58K)
Boot your device into fastboot mode (in TWRP go to reboot -> bootloader, or run adb reboot bootloader)
Run the flash-all script (make sure that fastboot from the SDK is in your PATH - set PATH=<path-to-fastboot-folder>;%PATH% in windows, and export PATH=<path-to-fastboot-folder>:$PATH in OSX/Linux)
Your device should work again! You'll have to flash TWRP again, though.

Nexus 5 with zero-length partitions


Entropy and reversible paths

Question: I'm a little bit confused about calculating entropy changes along irreversible paths by integrating over a reversible path. When using the central equation I can understand the argument, entropy and all the quantities we use to calculate the entropy change are state functions that have well defined end points. So the process between these two states doesn't matter, we will get the same entropy change. I find it difficult to grasp how we can use dS=dQ/T to calculate entropy changes in irreversible processes. Since Q is path dependent I don't see how the original argument applies. We can take the free expansion as an example, if we try to use dS=dQ/T we will get zero entropy change as no heat flows into the system. But using the central equation where all quantities are state functions we get a entropy change which is larger that zero as expected.
Comment: i suggest you read up on the concept of integrating factor: https://en.wikipedia.org/wiki/Integrating_factor
Comment: I know the concept of integrating factor but fail to see how it has anything to do with my question.
Comment: $\delta Q$ is process dependent but in a reversible process the ratio $\frac {\delta Q}{T} $ is now *state* dependent not just process dependent. Now if you connect any two states with an irreversible process then to calculate the entropy change between them can be had by connecting the two states via a *reversible* process, if there is one, and there you can use the integrating factor. A state is a state irrespective of what process was used to reach it. The integration of $\frac {\delta Q}{T} $ to calculate the entropy change is only done over a reversible path.
Answer: As you rightly say, all the quantities in the fundamental relation are functions of state, and so the change calculated using it along any 2 paths with the same end points will be the same.
When we use the fundamental relation to compute the change for an irreversible process, what we generally do is find a different path, a reversible path with the same endpoints, where we can use our nicer equations for reversible processes, such as $dS = \frac{dQ}{T}$, and integrate along that instead. Since heat and work are path dependent quantities, the amount of heat transferred and work done will generally be different along this new path to what they were on the true/actual path, but that is fine provided we have enough information to compute our integrals and end up in the right place.
How do we know we got to the correct end state if we were integrating along a totally different path? Well, our original path will have been defined by some set of constraints; to take your example, a free expansion is defined by the condition that $dU=0$. We will also have some conditions on where along that path we stopped, e.g. the final volume $V_f$. Now the original path was a 1d line in the state space of our system and our end condition gives us where on that line we finish, so the constrains and the end condition must be enough to tell us where the end point is; it is the point where all the constrains and the end condition are satisfied. So now to find whatever other thermodynamic quantities, not already specified, that we desire, we find a reversible path where all these conditions are true somewhere and integrate to that point.
So in the example of a free expansion, we know that between our start and end point $\Delta U=0$, so we will look for a reversible path where this is true. The easiest way to do this is to use the same constraint as the true path
$$
dU = 0 \quad\Rightarrow \quad  dQ = -dW
$$
Now, since we are requiring our new path to be reversible, we can use the formulae we have for work and heat in that case.
$$
TdS = pdV
$$
So in order to calculate the change in entropy, we simply integrate along this new path until we reach our end point condition where $V = V_f$. Notice that along this new path heat was transferred, but it was compensated for by work being done, so the internal energy remained the same.
Comment: It's becoming a bit more clear for me, but I had another example in my head while writing my question which still confuses me. Say you drop an object from a height which then falls onto the ground. The first law says that $Q=0$, since $\Delta U=W=mgh$. If we want to calculate the entropy change for this object along a reversible path we would get zero since $dQ=0$, how do I know that this corresponds to the actual entropy change in this case. Is $\Delta U=mgh $ and $\Delta V=0$ the necessary constraints? This approach feels similar to the faulty reasoning I gave for the free expansion.
Comment: It doesn't make really make sense to talk about the volume of your ball as a variable, instead your macroscopic variables will be $T$, $S$, $h$ and $mg$. In this case the fundamental relation reads $dU = TdS + mgdh$ your constraint is that no heat was transferred and your final conditions are that you did $\Delta W$ and $h$ has gone form $h_0$ to $h_1$. From the first law $\Delta U = \Delta W$. You then have that along a reversible path $\int_{S_0}^{S^1} TdS = \Delta U - \int_{h_0}^{h^1} mg \,dh$
Comment: The right hand side you can compute since $mg$ is a constant (this is the equivalent to equation of state) The left hand side you might be able to do something with if you know the heat capacity of the ball. What this equation is saying is any work that didn't go into increasing the height of the ball went into increasing the internal energy through friction, which is, of course, irreversible. In the happy case that the work done equals $mg\Delta h$ then no energy was lost to friction the process was reversible, and no entropy produced or heat transferred  as you would expect.
Comment: Okay, I think I finally get it. Thanks, this has been bugging me for a while.
Comment: @BySymmetry In the fundamental relation using Euler's theorem we get (ignoring chemical potential): $$U=TS - PV$$ All variables are state functions but why do we say that $U=U(S,V)$. I mean for different $P,T$ the function will have different values for the same $S,V$. Thanks in advance.
Answer: For an irreversible path, the integral of dQ/T is not equal to $\Delta S$.  To get the change in entropy between the two end points of an irreversible path, you need to devise a reversible path between the same two end points, and calculate the integral for that path.  It doesn't matter what reversible path you choose; they will all give the same value for $\Delta S$.  For more details on this, see the following link:
https://www.physicsforums.com/insights/grandpa-chets-entropy-recipe/
This link contains contains a simple recipe for determining the entropy change for any arbitrary irreversible process, and presents several typical examples of irreversible processes encountered in thermodynamics courses, and how to apply the recipe to determine the change in entropy for each.
Answer: There is an implicit but crucial assumption in thermodynamics (your calculations are based on it): Any irreversible process can be closed by a reversible process to become a cycle. If it is false, thermodynamics would collapse:
http://philsci-archive.pitt.edu/archive/00000313/
 Jos Uffink, Bluff your Way in the Second Law of Thermodynamics, p. 39: "A more important objection, it seems to me, is that Clausius bases his conclusion that the entropy increases in a nicht umkehrbar [irreversible] process on the assumption that such a process can be closed by an umkehrbar [reversible] process to become a cycle. This is essential for the definition of the entropy difference between the initial and final states. But the assumption is far from obvious for a system more complex than an ideal gas, or for states far from equilibrium, or for processes other than the simple exchange of heat and work. Thus, the generalisation to all transformations occurring in Nature is somewhat rash."

Entropy and reversible paths


space time contraction

Question: What could be the reason that space and time contraction increases almost exponentially at the last decimals places close to the speed of light or close to singularity gravitational fields. Does this hint like a "sound barrier"
transistion wich is shown by the imposibility of mass particles to reach that speed and where massless particles navigate at this speeds. Would this imply that negative mass particles would be able to navigate at greater speeds than that of light.
Answer: The space-time distortion gets greatly amplified near the limit because thats a mathematical property of the lorentz factor or the swcharzschild factor. Physically it means that it becomes progressively difficult to reach or surpass that limit. The concept of negative mass to me should accompany its own concepts of velocity and kinetic energy which implies that they could possibly have a different speed limit.

space time contraction


Is my money insured against bank failures during a wire transfer?

Question: Suppose I am sending money by international wire transfer from my FDIC-insured bank account in the US to my CDIC-insured bank account in Canada. Suppose one of the banks become insolvent during the wiring process. What happens to the money I sent? Is the money insured while in transit?
Answer: The simple answer is that the wire transfer process has handshakes which guarantee that the transfer either happens or doesn't; if incomplete it is cancelled.
I don't know whether that protects only bank to bank or fully account to account.
But I think you're at more risk from a bank's servers blowing up in mid-transaction than you are from bank failure; the latter will be an organized shutdown of a system designed to handle that robustly.


What are some ways of thinking about exponentiation, other than repeated multiplication?

Question: For instance, we can think of exponentials as solutions to differential equations. Are there any other interesting ways of describing exponents without iteration of multiplication?
Answer: Using the exponential function (with different characterisations) $e^x$ and the natural logarithm:
For every $a, b \in \mathbb R$, we can write $a = e^{ln(a)}$ (suppose for now $a>0$) which implies
$$a^b = (e^{ln(a)})^b = e^{b\cdot ln(a)}$$
See these great answers for more detail.
In fact, this allows to expand the concept of exponentials to the complex plane:
Given $z, w \in \mathbb C$, we define
$z^w = e^{w\cdot ln(z)}$ (where $ln(z)$ is the complex logarithm), and use the fact that for $w = a + i\cdot b$:
$$e^w = e^{a+ib}=e^a\cdot e^{ib} = e^a(cos(b)+i\cdot sin(b))$$
since $exp(x+y)= exp(x)\cdot exp(y)$ and $e^{ib} = cos(b)+i\cdot sin(b)$.
However, note that this is a multi-valued function unless a branch of the complex logarithm is chosen (otherwise $(e^{ln(z)})^w \neq e^{w\cdot ln(z)}$).
Answer: If a function's growth rate is proportional to its value then it's an exponential function.
i.e.  $b^x$ is growing at the rate $c_b*b^x$ for some constant $c_b$.  $b^x$ is the one function where that can be true.
Which allows for the "how can you multiply something by itself 1/2 a time to get $b^{1/2}$" question to be "how much do you have at 1/2 if the instantaneous grate of growth always proportional to the current ammount?"  Of course, that's a pretty hard question to answer without circular reasoning, but it does make non-integer and even non rational exponents meaningful.
Comment: I like this different answer. $\color{white}{+1}$
Answer: From the category theory point of view, you can adress a lot of exponentials.
For example, in the category of Sets, an exponent of two sets is the set of functions from one to another

( A hint to see why it makes sense: how many functions exists from a set $A$ to a set $B$?
  Answer:

 $|B|^{|A|}$ where $|X|$ is the cardnality of a set $X$

)

https://en.wikipedia.org/wiki/Exponential_object
Answer: If you go one step beyond multiplication...
$$a^b=\underbrace{a\times a\times a\times\cdots\times a}_b$$
$$a\times b=\underbrace{a+a+a+\dots+a}_b$$
And combine these to turn exponentiation into addition.
$$\color{white}{\text{Way too many additions, so I left it out.}}$$
Take these farther steps, and you'll create the hyperoperation sequence.


Where can I find system call source code?

Question: In Linux where can I find the source code for all system calls given that I have the source tree? Also if I were to want to look up the source code and assembly for a particular system call is there something that I can type in terminal like  my_system_call?
Answer: You'll need the Linux kernel sources in order to see the actual source of the system calls. Manual pages, if installed on your local system, only contain the documentation of the calls and not their source itself.
Unfortunately for you, system calls aren't stored in just one particular location in the whole kernel tree. This is because various system calls can refer to different parts of the system (process management, filesystem management, etc.) and therefore it would be infeasible to store them apart from the part of the tree related to that particular part of the system.
The best thing you can do is look for the SYSCALL_DEFINE[0-6] macro. It is used (obviously) to define the given block of code as a system call. For example, fs/ioctl.c has the following code :
SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
{
/* do freaky ioctl stuff */
}

Such a definition means that the ioctl syscall is declared and takes three arguments. The number next to the SYSCALL_DEFINE means the number of arguments. For example, in the case of getpid(void), declared in kernel/timer.c, we have the following code :
SYSCALL_DEFINE0(getpid)
{
        return task_tgid_vnr(current);
}

Hope that clears things up a little.
Answer: From an application's point of view, a system call is an elementary and atomic operation done by the kernel.
The Assembly Howto explains what is happening, in terms of machine instruction.
Of course, the kernel is doing a lot of things when handling a syscall.
Actually, you almost could believe that the entire kernel code is devoted to handle all system calls (this is not entirely true, but almost; from applications' point of view, the kernel is only visible thru system calls). The other answer by Daniel Kamil Kozar is explaining what kernel function is starting the handling of some system call (but very often, many other parts of the kernel indirectly participate to system calls; for example, the scheduler participates indirectly into implementing  fork because it manages the child process created by a successful fork syscall).
Answer: I know it's old, but I was searching for the source for _system_call() too and found this tidbit

Actual code for system_call entry point can be found in /usr/src/linux/kernel/sys_call.S Actual code for many of the system calls can be found in /usr/src/linux/kernel/sys.c, and the rest are found elsewhere. find is your friend.

I assume this is dated, because I don't even have that file. However, grep found ENTRY(system_call) in arch/x86/kernel/entry_64.S and seems to be the thing that calls the individual system calls. I'm not up on my intel-syntax x86 asm right now, so you'll have to look and see if this is what you wanted.
Comment: `entry_64.S` no longer exists in mainline 4.8.
Comment: @sherrellbc You are wrong ```entry_64.S``` is still present to this day here is the source code ```https://elixir.bootlin.com/linux/v5.16.7/source/arch/x86/entry/entry_64.S``` although I'm having difficult time to find where are the system calls functions present.


How to register debian uefi file with my motherboard?

Question: I moved the disk with my debian installation to another computer, and it wouldn't boot. Using systemrescuecd I mounted my uefi partition (512 MB, vfat filesystem, has EFI directory) and did cd /mnt/sda1 && mkdir BOOT && cp debian/grubx64.efi BOOT/bootx64.efi, and it booted fine. (got the advice at Askubuntu) Now how do I register debian/grubx64.efi file with my system so that I can get rid of BOOT/bootx64.efi?
Answer: You can list and manipulate the EFI boot entries with efibootmgr on Linux.
Once you've successfully booted the system manually, make sure that efibootmgr is installed:
apt-get install efibootmgr

Then make sure the efivars pseudo-filesystem is mounted RW:
mount -o remount,rw -t efivarfs efivarfs /sys/firmware/efi/efivars

If that command fails, or if running efibootmgr results in a message like EFI variables are not supported on this system. then you did not boot in EFI mode.  Reboot and try again.
Finally, add debian/grubx64.efi to the EFI boot list and make it the default:
efibootmgr -c -p 1 -d /dev/sda -L "GRUB" -l '\efi\debian\grubx64.efi'

The -p 1 and -d /dev/sda options specify the partition and block device containing the EFI system partition where you created the BOOT sub-directory.  -L is a label for the entry being created, and -l is the path to the boot-loader.
You can delete entries you don't want with efibootmgr -b <boot-entry> -B.
You can get a detailed list of the current EFI boot entries with efibootmgr -v.
See man efibootmgr for details.  I recommend reading it thoroughly and googling or asking here for clarification before running any of the above commands.
Comment: note: this is how to do it manually.  Running `grub-install` or `update-grub` should do much of the above automatically if you have `grub-efi-amd64` (or `grub-efi-ia32` on a 32-bit x86 machine) installed. You may need to manually mount the EFI partition user /boot manually, I can't recall exactly.
Comment: `grub-install` with appropriate options did it
Comment: Could be just `grub-install` in a chroot with /dev, /proc and maybe /sys (bind)mounted.
Answer: After having read https://wiki.archlinux.org/index.php/GRUB#UEFI_systems and man grub-install I did sudo grub-install --efi-directory $MY_ESP_MOUNTPOINT --target=x86_64-efi and now I have a "debian" boot target listed and working.
Answer: I'd suggest the command
sudo grub-install --efi-directory $MY_ESP_MOUNTPOINT --force-extra-removable --recheck

With --force-extra-removable Debian will (as Redhat does) create the BOOT directory in the EFI directory just along with the Debian directory. Most BIOS (like HP BIOS for example and I feel recent Dell BIOS) use this BOOT directory to find the file BOOTX64.EFI and automatically create the Boot entry making the UEFI boot automatically.
The --target option is not mandatory as you Debian will automatically set the right value if you run the grub-install from the same binary type as the system you want to boot
--recheck is here just to recreate the UEFI table and clear old boot entries no longer relevant as you could do with -B option in efibootmgr.


STP Priority field and 4 bits in multiples of 4096

Question: For the STP Priority Field, how do you get "multiples of 4096" out of 4 bits?
Comment: 0-15 (your 4 bits) * 4096. I didn't write the spec; that's just how it works.
Comment: Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer.
Answer: I think you are confusing a couple of things about the 802.1Q tag. The tag is 32 bits, the first 16 bits of which are the TPID (0x8100) field. The last 16 bits are the TCI that consists of three fields:

The PCP is three bits for priority
The DEI is one bit usually used along with the PCP to create a
four-bit priority
The VLAN ID is 12 bits

Since the VLAN ID is 12 bits, it can have 4096 different values. It is the low-order 12 bits of the TCI, the four higher order bits together are multiples of 4096. Taken by themselves, the four bits only have 16 possible values, but they are actually part of the TCI, which has 65,536 different values for all the fields combined.
Looking at it in binary makes it obvious (the priority starts on bit 13):
Bit   |   16|   15|   14|   13|   12|   11|   10|    9|    8|    7|    6|    5|    4|    3|    2|    1|
Value |32768|16384| 8192| 4096| 2048| 1024|  512|  256|  128|   64|   32|   16|    8|    4|    2|    1|

Typically, you take the 4096-based priority and add it to the VLAN ID to come up with the TCI.
Comment: I'm trying to study for the CCNA Exam. In Wendell Odom's ICND2 (2016) book, on page 73, it states the Spanning-Tree Protocol's "Priority Field" has 4 bits and is multiples of 4096. I cannot fathom how you can get 32,768 out of 4 bits. :(
Comment: 802.1d, 802.1w, and 802.1s -- all the things predating the consolidation in 802.1q-2014. Blame 802.1t... the "priority" is the 4 MSBs of the 16bit priority field, with the remaining 12 being the extended system id.
Comment: @LeonardBoone, look at the values of the bit number of the 16-bit field. The bit 13 value (where the priority starts) is 4096. The four most significant bits must be a multiple of 4096.
Answer: Using bridge priority increments of 4,096 is a means to keep compatibility with classic STP where the priority was a 16-bit field. In RSTP/MSTP that field was reduced to 4 bits, so there are 12 lower, "virtual", all-zero bits. This creates unambiguous priority mapping between STP and RSTP/MSTP priorities.
IEEE 802.1D-2004 reads:

The stated ranges and granularities for Bridge Priority and Port
Priority differ from the equivalent text and table in IEEE Std 802.1D,
1998 Edition and earlier versions of this standard as explained in
9.2.5 and 9.2.7. Expressing these values in steps of 4096 and 16 (rather than, for example, as a 4-bit value with a range of 0 to 15)
allows consistent management across old and new implementations of
this standard; the steps chosen ensure that bits that have been
reassigned are not modified, but priority values can be directly
compared with those based on previous versions of the standard.

As a side effect, those 12 "virtual" bits allow for simpler interoperability with R/PVST+ (where required) which can use the individual VLAN ID in those usually zero bits (PVST has one bridge instance in each VLAN as opposed to IEEE STP with a single default instance for a bridge).
For MSTP, the 12 repurposed bits in the BPDU hold the system ID extension that distinctly identifies the multiple spanning tree instance (MSTI) that the bridge operates in.
See IEEE 802.1Q clause 14.2.5 Encoding of Bridge Identifiers for details.
Answer: The example bellow helped me to understand the meaning of these 4 bits + what the extended bits are used for.
The Bridge Priority value and the Extended System ID extension together make up a 16 bit (2-byte) value. The Bridge Priority making up the left most bits, is a value of 0 to 61440. The Extended System ID is a value of 1 to 4095 corresponding to the respective VLAN participating in STP. The Bridge Priority increments in blocks of 4096 to allow the System ID Extension to squeeze in between each increment. This is clearly shown in the below analysis:

source: firewall.cx


Approximating a discrete probability distribution with a standard normal distribution

Question: Let us approximate a discrete distribution by a standard normal distribution, without using a continuity correction factor. Let $X$ be a random variable with discrete distribution, and $Y$ be a random variable with standard normal distribution. Since we did not use a continuity correction factor, can we say that the $P(X \geq x)$ is always greater than or equal to its approximated probability by the standard normal distribution?
Comment: **Yes,** for normal approximations to binomial. Details and an example in my Answer below.
Comment: **No** (did you intend *less than or equal*?) - take the simple example of tossing two fair coins and letting $X$ be the number of heads.  Then $P(X \gt 1) = \frac14$ for two heads, while the normal approximation at the expectation of $1$ would suggest $\frac12$
Answer: If the discrete random variable $X$ takes integer values, then
$$P(X > x)= P(X \ge x+1) = P(X \ge x+.5)$$
The continuity correction would use the third expression when using
a continuous distribution as an approximation.
Ordinarily, the approximating continuous distribution would have
positive probability in the interval $[x, x+.5].$ In that case using
the continuity correction will give you a smaller approximated value.
Example: Suppose $X \sim \mathsf{Binom}(n = 64, p = 1/2)$ and
you seek $P(X > 30).$ The exact value is $P(X > 30) = 1 - P(X \le 30) =  0.6460096.$
1 - pbinom(30, 64, .5)
##  0.6460096

If you use $P(X^\prime > 30) = 1 - P(X^\prime \le 30)$ as an approximation,
where $X^\prime \sim \mathsf{Norm}(\mu = 32, \sigma=4),$ you will get
$P(X > 300) \approx 0.6914625.$
1 - pnorm(30, 32, 4)
## 0.6914625

But if you use the continuity correction, you will use
$P(X^\prime > 30.5) = 1 - P(X^\prime \le 30.5) =  0.6461698.$
Hence, your approximation will be $P(X > 30) \approx  0.6461698.$
This is smaller than the value 0.6914625 without the continuity correction.
It is also closer to the exact binomial probability.
1 - pnorm(30.5, 32, 4)
##  0.6461698

Usually in textbook examples you can expect about two decimal places of accuracy from
a continuity-corrected normal approximation to a binomial distribution.
To four decimal places, the exact value in this example is 0.6460 and the continuity-corrected normal approximation is 0.6462. (Here we get three-place
accuracy; approximations are often best when $p \approx 1/2.$)
The figure below shows relevant binomial probabilities (vertical bars) and
the approximating normal density curve. Notice that be binomial probability $P(X = 31)$ is approximated by the area under the normal curve above the interval
$[30.5, 31.5].$ The uncorrected approximation wrongly
includes the vertical strip between $x = 30.0$ and $x=30.5$ under the
normal curve.

Note: The values I have shown are from R statistical software. If your
normal approximations are obtained by standardization and using a printed
normal table, then results will be slightly different because of the
rounding entailed in the use of the table.
Comment: Thank you. So you mean that we can't say for sure that P(X>=n) is greater than its approximated value by normal distribution?
Comment: I checked P(X>=n) and normal distribution always gives the smaller value. Is there any intuition or proof behind that?
Comment: I'm agreeing with you. The difference in my example is the area under the normal curve above the interval $[30.0, 30.5],$ as mentioned just before the figure. To four places, compare _normal_ probabilities $P(X^\prime > 30) = 0.6915$ without continuity correction with $P(X^\prime > 30.5) = 0.6462$ with continuity correction. For intuition, start with obvious fact that $P(X^\prime > 30) > P(X^\prime > 30.5).$ (Maybe shade in the two areas under the normal curve.)
Comment: Thank you. I mean the probability value when we don't use continuity correction factor is always less than the "true probability value" for P(X >= x). In fact, without using correction factor we are underestimating the true probabilities.
Comment: Now you've _changed_ it to $P(X \ge x),$ which is a slightly different situation. I have tried to set the principles out clearly in my answer, and I'll leave the variations to you.
Answer: Hint:
Consider a binomial distribution with parameters $n, p$.

What is $P(X \gt n)$ for the actual binomial distribution?
Is the normal approximation less than or equal to this?


Can I use fat-free milk in béchamel?

Question: Can I use a fat free milk to make the sauce? Should I add more butter to the roux if I do so?
Comment: @papin this seems to be already an answer. We prefer people to add answers in answers, not in comments, because 1) they are more likely to be read where they belong, 2) comments are ephemeral and can be deleted at any time with no reason or warning, and 3) the voting system doesn't work with comments. Don't be afraid to post a very short answer as an answer. If it's sufficient, it's even better than a wordy one.
Comment: I know I've done it with 1% and 2% ... I've likely done it with skim, but I've been off milk for years and can't remember for sure if I've done it.
Comment: related : http://cooking.stackexchange.com/q/9300/67
Answer: Yes. The important fat is the one the starch first goes into. The higher temperature reached by fats (as compared to water or milk) helps cook the flour, creating flavors.  The liquid added later dilutes the mixture into a sauce. The liquid's fats are not as crucial for the sauce's thickness as the liquid's proteins.
I think of the cooked butter-flour mixture  as a thickner that can be added to milk, broths, and even a saucy dish.  The roux thickens way better than just a slurry of flour and a cold liquid.
Jack Lang has written a long post on Béchamel and Hollandaise and the science is summarized in chapter 4 of Vaclavik and Christian Essentials of Food Science

Can I use fat-free milk in béchamel?


Spring JmsTemplate and Apache ActiveMQ, why so many connections?

Question: I have a web application that runs text processing jobs in the background once a message is received on an ActiveMQ which is listened to by a Spring MessageListener....the problem I"m encountering is that once I process around 30 background jobs, ActiveMQ stops processing any messages, Spring message listener loses its JMS connection, and sometimes I get an error in the ActiveMQ log saying that there are too many open files.
I ran the 'lsof' (list open file) command on Linux against the ActiveMQ process and noticed that for almost each message queued/published/received by JmsTemplate, a new connection is opened. Is this normal?
here's my configuration:
<code><bean id="connectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
    <constructor-arg ref="amqConnectionFactory" />
    <property name="exceptionListener" ref="jmsExceptionListener" />
    <property name="sessionCacheSize" value="100" />
</bean>
</code>
Answer: You need to use the PooledConnectionFactory provided by ActiveMQ, you can see full configuration here. Make sure you read the JmsTemplate Gotchas as well.


Mac cannot use external hard drive after Ubuntu installation?

Question: Please help. I wanted to install Ubuntu so I follow this guide: http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx I used my external hard drive to do this but then after I finished everything, when I plugged in my external hard drive I get "The disk you inserted was not readable by this computer" and I cannot see my external hard drive in Finder, but I could see it in the Disk Utility. Does this mean all my data was erased? How do I get my external hard drive back? I don't want to delete everything on my external drive because I have about 300gb of data on it. Thank you.
Answer: First of all test your external HDD on your installed Ubuntu system. There is a chance that Ubuntu can still read it. If so, backup all your data from it (to have a copy at least), and go back to Mac and using the Disk Utility:
You will have 2 options:

If you succeded with making a copy: format your external HDD, and copy back all your data from the location where you made the backup.
If it failed: ask a professional to help you. Don't try to use "magic" softwares to recover your data, because it is a huge chance that you will destroy for good your data.
Comment: Hi. Thank you for answering. So I tried plugging in my external HDD on Ubuntu and I was able to read it but it only has Ubuntu stuffs on it like install, boot, etc.. Did I just wipe all my data? How can I recover it back?
Comment: Well, probably that you formatted the drive by mistake when you made the install media. You have a small chance by using `photorec` to take back some of un-overwritten files like documents, pictures, etc. Remember, that you will loose all your filenames! As a personal opinion: how I would do this? first make a disk image copy with `dd` and try to recover from that image (just to have an untouched copy on your original HDD). Never work or try to do modification on the corrupted media itself! If you are not familiar with these tools, better take the HDD to a professional.


searching for text for studying representation theory

Question: I'm a graduate student studying algebraic geometry.
Recently, When I studying Hodge theory, I saw sl2-representation is used in Hodge theory.
So I think that studying representation theory may be helpful for me.
Can you recommand me some good text for studying representation theory, focused on materials helpful for algebraic geometry, and not so difficult to read.
Comment: http://mathoverflow.net/questions/13/learning-about-lie-groups/ related
Comment: This question http://mathoverflow.net/questions/2755 is not exactly identical with yours, but the answers posted there could just as well be posted here.
Answer: Recently, Pavel Etingof published a book about his course on representation theory with his students. This is a description of the book:
"The goal of this book is to give a "holistic" introduction to representation theory, presenting it as a unified subject which studies representations of associative algebras and treating the representation theories of groups, Lie algebras, and quivers as special cases. Using this approach, the book covers a number of standard topics in the representation theories of these structures. Theoretical material in the book is supplemented by many problems and exercises which touch upon a lot of additional topics; the more difficult exercises are provided with hints.
The book is designed as a textbook for advanced undergraduate and beginning graduate students. It should be accessible to students with a strong background in linear algebra and a basic knowledge of abstract algebra."
This is a very enjoyable book to read. A version can be found here: link text. You get a bonus buying the book, where some nice historical remarks are added.
Comment: The bonus also contains two short digression-style chapters on homological algebra (although I think they won't surprise an algebraic geometer).
Answer: A nice good book has been written by Fulton and Harris, of course there are many others
Comment: That's a good collection of examples and exercises, but a pretty bad text for reading. Flawed proofs, lots of missing details, lack of separation between results and proofs make learning much harder than it should be.
Comment: Indeed Fulton and Harris is very appropriate for someone focusing
on algebraic geometry.
Answer: I'd also recommend
Erdmann, Karin; Wildon, Mark J. Introduction to Lie algebras.
Comment: I taught a 1-semester class for seniors/1st year grad students out of this book and they all really enjoyed it. It should be very suitable for self study as well.
Answer: I would recommend Introduction to Lie Algebras and Representation Theory by Humphreys.
It covers all the basics of Lie algebras and their representations, though mostly in characteristic 0 and over an algebraically closed field.
But then, going into any depth with the theory without these assumptions requires a lot of additional work anyway, and knowing the theory for this nice case is a good start.
Answer: If you are particularly interested in sl2-representation theory, there is the book by Mazorchuk: Lectures on $\mathfrak{sl}_2(\mathbb{C})$ - modules.


"Hurry, give me anything that will hold water!" What verb tense is this?

Question: In the following sentence, "Hurry, give me anything that will hold water!"  What verb tense is "will hold" ?  Not future simple, I presume.
Comment: Today's English has no "future" tense. There are two primary tenses: present, past. Your verb "will" is present tense.
Comment: Consider: "will hold" versus "would hold". The verb "will" is present tense, the verb "would" is past tense. If you're interested in how today's English references the future, then this Language Log article may interest you: http://itre.cis.upenn.edu/%7Emyl/languagelog/archives/005471.html
Answer: It is future simple.
An alternative construction would be

Hurry, give me anything that holds water!

This would make sense and would be a simple present. Something that holds water now will also hold water in the foreseeable future.
Because the holding has not yet occurred, but will occur once the vessel is put into service,

Something will hold water [soon].
Answer: You have only two possibilities:
a)  future simple - will as auxiliary verb
b) will as modal verb such as can
As future tense makes no sense  at all it can only be possibility b) and then the tense is present tense of "will".
The meaning is nothing but
1 something that holds water
or
2 something that can hold water.
Due to the ambiguity of will + infinitive the use of "will" as a modal verb is somewhat limited, mostly to negative forms
as in

I tried but the door would not open. The door is jammed.

As to your sentence above this use of "will" looks like the language of an earlier time or
like individual or regional habit of speech.
As to your sentence above this use of "will" looks like language of an earlier time or an individual habit of speech
or a regional variant of speech.
Comment: When I was a  medical student I saw this use of "will", more than once, in Textbooks of Physiology. In sentences such as: ...during exercise the right ventricle will pump more blood into the pulmonar artery." which I understand means "can pump" or "pumps".


Is G-bundle over 1-skeleton trivial

Question: Let $G$ be a connected Lie group, and $P \rightarrow M$ a principal G-bundle. Is $P$ trivial over the 1-skeleton of $M$. If yes, what is a reference? More generally, over the $n$-skeleton, $G$-bundles are classified by $\pi_{n-1}(G)$. How does one see this, or is there a good reference?
Comment: The statement about the classification of $G$ bundles by $\pi_{n-1}(G)$ is wrong...
Comment: Did you look in Steenrod's "The topology of fibre bundles"?
Comment: You need two facts: 1-skeleton is homotopy equivalent to a wedge of circles, and principal $G$-bundles over $S^n$ are classified by $\pi_{n−1}(G)$. Since $G$ is connected, $π_0(G)$ is trivial so any pricipal $G$-bundle over a circle is trivial, and hence the same holds for 1-skeleton. This argument fails for n-skeleton because it is generally not homotopy equivalent to the wedge of n-spheres: consider e.g. 2-skeleton of the 2-torus.
Answer: This can be seen using obstruction theory. Therefore consider the Whitehead tower of BG:
$$ EG \to ... \to BG\langle3\rangle\to BG\langle2\rangle \to BG\langle1\rangle \to BG $$
Now a $G$ bundle over $M$ is classified by a map $f: M \to BG$. The bundle is trivial iff we can lift $f$ to a map $M \to EG$. Since the fibres in the Whitehead tower are Eilenberg-MacLane spaces we can write down the obstruction to lift $f$ successively through the $BG\langle n\rangle$'s:
-Obstruction against lift to $BG\langle 1\rangle$ lies in $H^1(M,\pi_0(G))$
-Obstruction against lift to $BG\langle2\rangle$ then lies in $H^2(M,\pi_1(G))$
-Obstruction against lift to $BG\langle3\rangle$ then lies in $H^3(M,\pi_2(G))$, etc...
In your case $\pi_0(G) = 0$ and therefore the first obstruction vanishes. On the 1-skeleton all the higher obstructions vanish for dimensional reasons, thus all bundles are trivial.
If you moreover assume that $G$ is simply connected and finite dimensional (e.g. SU$(n)$, Spin$(n)$,...) then also $\pi_2(G) =0$. Hence there are no non-trivial $G$-bundles over manifolds or cell complexes of dimension $\leq 3$.
Comment: Oh, I was very confused by the second sentence of your last paragraph.  What you mean is that all high-enough obstructions vanish.  Certainly $H^2(M,\pi_1(G))$ does not vanish in general.
Comment: I hope it is less confusing now...
Answer: Hi,
I don't know your background knowledge, so I'll try to post an elementary explanation to your question, which is also the way I understand it. I am not 100% reliable, and there might be more or less serious mistakes in what follows, but I think the main ideas are there.
You know that a principal $G$ bundle is trivial $\mathrm{iff}$ it admits a section. So suppose you have a (locally finite) cell complex $X$, put $X_n$ the $n$-squeleton of $X$ and let $P$ be a principal $G$-bundle over $X$. We'll also call $P_n$ the restriction of $P$ to $X_n$, which is still a princial $G$ bundle. You want to know why $P_1$ is trivial, and how (non) triviality of the $P_n$ is related to the fundamental groups of $G$.
Well, what is $P_0$? It is nothing more than a discrete collection of (homeomorphic) copies of $G$, one above each vertex of $X_0$. Now, for each vertex $x\in X_0$, chose a point $g_x\in G$. This gives you a trivialisation of $P_0$ (the (continuous) map $X_0\rightarrow P_0,~x\mapsto (x,g_x)$), and $P_0$ is trivial.
Similarly what is $P_1$? It is a graph with, along each line, tightly packed (homeomorphic) copies of $G$. To show it is trivial we need only construct a section of $P_1$. Let's start with the section of $P_0$ we already constructed. This was nothing more than a collection of pretty random points in the fibres over the vertives of $X$. What would it mean to extend this (very partial) section of $P_1$ (only defined on the zero squeleton $X_0$) to the whole of $X_1$? It means constructing, for each edge $e$ with endpoints $x$ and $y$ a continuous map from $e$ (which is basically $[-1,+1]$) to $P_1$ that takes on the values $g_x$ at $x$ and $g_y$ at $y$ (that is with values imposed on $\lbrace -1,+1\rbrace=\partial [-1,+1]$. This is, a priori, possible $\mathrm{iff}$ $g_x$ and $g_y$ lie in the same path component of $G$, but such will always be the case [EDIT: actually, it's not, consider the $\lbrace -1,+1\rbrace$ principal fibre bundle over the circle which is trivial on the circle minus $-1$ and on the circle minus $+1$, and has a cocycle that is $-1$ on the left and $+1$ on the right (this is also $\mathbb{S}^1\rightarrow\mathbb{S}^1,~z\mapsto z^2$): it is not trivial].
You can, for instance cut the edge $e$ into many little closed intervals that each trivialize the (induced) bundle [Edit: and only overlap at their extremities], and glue sections together, imposing the first and final value of the section, and working your way from $-1$ to $+1$. [EDIT: What may happen now is that the final two values you have to link within $G$ may not lie in the same path component, and so there is a dependence on $\pi_0 (G)$] Now we have a map from the $1$-squeleton $X_1$ to $P_1$ that is a section of the bundle, and is continuous along each edge, and prolongs the first section we constructed earlier on. But because $X$ is locally finite, this map is continuous. (Actually I'm pretty sure that condition is unnecessary, because you can impose your sections to be 'locally constant around the vertices')
So $P_1$ is trivial,always, regardless of any restrction. This technique can be carried on. Suppose you have shown $P_n$ to be trivial, let $s_n$ be a global section. Can you extend $s_n$ to a global section $s_{n+1}$ of $P_{n+1}$? Consider a $(n+1)$-face $F$ and its border $\partial F$. The desired section is already defined along the border $\partial F$ (it's the restriction of $s_n$ to $\partial F$), so you have what is essentially a (continuous) map $c_{\partial F}$ from $\mathbb{S}^n$ (the border $\partial F$) to $G$, and you want to extend it to a map from the euclidean $(n+1)$-unit ball $\mathbb{B}^{n+1}$ (which would be $F$) to $G$. This problem is equivalent to nulhomotopy of the map $c_{\partial F}$, and you thus find that $P_{n+1}$ is trivial $\mathrm{iff}$ all such maps are nullhomotopic. In particular, if $\pi_n (G)$ is trivial, the above problem is always solvable.
You might want to have a look at Homotopy groups of Lie groups if you are unfamiliar with the fact that the second fundamental group of a Lie group is trivial. This fact implies, as Thomas Nikolaus has already pointed out, that a principal $G$ bundle over a surface or $3$ manifold with simply connected $G$ is always trivial. Another good reference is Milnor and Stasheff's excellent book "Characteristic Classes", where everything I list is explained in better and shorter form.

Is G-bundle over 1-skeleton trivial


Hermitian, hollow matrix and invertibility

Question: I have an $(n+m)$x$(n+m)$ block, symmetric, real matrix with all non-negative entries and all zeroes in the main diagonal, with $m<n$. The first block is a $n$x$n$ invertible matrix, and the other diagonal block is a $m$x$m$ matrix of zeroes. The off-diagonal blocks are a $m$x$n$ matrix of rank $m$ and its transpose. Can I guarantee that the matrix is invertible? Can I do it if I also know that the matrix is negative semidefinite? Thanks!
Comment: Do you mean that the dimensions of the entire matrix are $(n+m)\times(n+m)$?
Comment: Hint: Schur complement
Comment: Yes, sorry, Greg: dimension is $(n+m)$x$(n+m)$.
Comment: Yes, user251257, my question could be phrased differently as: do we know that the Schur complement of the first matrix (the $n$x$n$ non-singular matrix) is non-singular?
Comment: @Rob use the definitness and rank condition
Answer: So, here is my attempt to an answer. Is it correct?
The first $n$x$n$ diagonal block $D$ is negative semidefinite, so its inverse is negative semidefinite as well, and the negative of that inverse is positive semidefinite. Then there exists a permutation matrix $P$ such that $-P'D^{-1}P$ has a unique Cholesky decomposition $R'R$, where $R$ is an upper triangular matrix. Since $D^{-1}$ is invertible, $R$ has all diagonal elements positive. Then, if we let $A$, $A'$ be the skew diagonal elements of the block matrix, $-A'D^{-1}A=-A'PP'D^{-1}PP'A=-BR'RB'$, where $B=A'P$. Note that $B$ has full rank ($m$), since $A$ has. That is, its rows are linearly independent. Therefore, $BR'$ has rank $m$, and so has $BR'RB'$. Therefore, we conclude that the Schur complement of $D$ has full rank, and so the block matrix is indeed, invertible.


My macbook pro is getting some current while connecting to external monitor

Question: My macbook is getting some current or can be said as vibrating when i connect it to Thunderbolt to VGA adapter to external monitor.
and then when i connect macbook to magsafe connector for charging , the vibration effect has gone.
please help me.
Comment: That is normal and nothing to worry about.
Comment: how do you see or test the current/vibration? is it when you gently touch it with the back of your hand ?
Comment: Yes, when i touch the aluminium i get vibration/current in my hand.
Answer: I get this too, a vibrating sensation when I touch the metal casing of the MacBook, when my external Samsung monitor is connected to my MacBook Pro via HDMI. Like you, it goes away when I plug in the MagSafe cable. The vibrating only occurs when my MBP is on battery AND when the external monitor is connected.
It is NOT normal.
My belief is that current from the monitor is being passed into the MBP because the monitor is not earthed. I'm using a 2 prong plug on the monitor, while my MBP is using a 3 prong plug. I'm going to try and buy a new cable for my monitor with a 3 prong plug to solve this because I'm worried it's doing my MBP no good. (Currently I leave my MBP plugged into the mains when I use the external monitor, something which doesn't do the MBP battery any good either!)
UPDATE
Well, I bought a new cable for my external monitor with an earthed plug (or so the shopkeeper said) but it's had no effect. Still get the vibrating!


Two logs files for a single database

Question: Is there any reason or performance benefit in having two log files for a single database and on different drives?
Answer: Logs are written to sequentially, so only one would ever be used at a time.  So, no, there is no benefit from having two on the same database.
EDIT: I looked over the part about different drives.  I suppose there could be a need in having two log files if you are working with limited drive space and your original log file would outgrow it's drive and you cannot move it to a larger drive for whatever reason.
Answer: Not as normal state, no. In an emergency, perhaps. But really that should only ever happen 0 or 1 times, because if it happens once, you should never let it happen again. – Aaron Bertrand
Multiple log files and why they're bad by Paul Randal. – Kin
Answer:
You don't always need a pair.

By default, SQL Server starts each database with one transaction log file.  The transaction file is used sequentially, not serially, and there's no performance benefit to having multiple log files.  SQL Server just starts working at the beginning of the first log file, works through to the end of it, and then starts with the next log file.
Read the complete blog of Brent Ozar from here.

Two logs files for a single database


Reducing a 100Km OS Map to usable size

Question: I have downloaded a 100Km map from OS, but the problem is that it is far larger than I need and hence takes a long time to load every refresh in QGIS. Is there a way to cut down the size of the accompanying shape files to a more manageable size of, say, 10Km square?
Answer: The data is VectorMap District vectors I guess? If you are happy about working from a command line or in a terminal you can clip a shapefile to a precise 10 km square using a command like this:
<code>ogr2ogr -spat 460000 190000 470000 200000 -f "ESRI Shapefile" SU_Road_clipped.shp SU_Road.shp
</code>
where "460000 190000" forms the coordinate of the bottom left-hand corner of a rectangle and "470000 200000" forms the coordinate of the top right-hand corner of the same rectangle. The original shapefile will be clipped to a subset having the extents specified by the rectangle (the output will be a new shapefile, the original will not be harmed in any way).
Nick.
Comment: I've downloaded ogr2ogr from FWTools (Is that the best place as it's given me 100s of new files!!!), tired it and it works, brilliant thanks. Better than the Sextante option
Comment: FWTools is great, but in fact if you have QGIS you already have GDAL/OGR installed :) N.
Comment: I thought I had but could not work out how to use it!!!
Comment: I should have mentioned that I could not find an ogr2ogr executable on my PC which was why I installed FWTools
Comment: It should be in C:\Programs (x86)\Quantum GIS Lisboa\bin if you installed by standalone installer, else C:\Osgeo4w\bin.
Answer: Use the GRASS v.generalize tool, you can use it with the qgis/grass plugin or now also with the sextante plugin (the last option is easier as you don't need to get deep into the grass data model).
Comment: most probably the op wants to clip/extract the 100 km² data to parts of 10Km² each..
Comment: That's right. I have not used Sextante or Grass as it was not needed for my purposes. Grass does not seem to fit the bill, but would Sextante?
Comment: OK, I have just installed Sextante and I think it will do the trick, so thanks Giovanni

Reducing a 100Km OS Map to usable size


Why can data be recovered after formatting?

Question: If a quick format just marks bits as writable, and a normal format writes 0s to the entire disk, why do people bother with DBAN, and why are multiple passes ever required?
Answer: It used to be possible by reading the residual magnetism left by the previous bit. This isn't so much of an issue now that the tracks and bits that hard drives write are so small. It is almost impossible to recover any meaningful data off of a zeroed drive with modern disks.
EDIT: This next section is only true for XP. Psycogeek pointed out that Vista and up does zero out the drive if you do a full format.
That being said, your definition of quick format and normal format is off. A normal format doesn't zero out the disk, that would take too long. The difference between the two is that the normal format looks for bad sectors on a drive, while the quick does not.
So it's best to use a tool like DBAN to at least do one pass if you want to make sure data isn't recoverable. And if you're doing one, why not a few more for fun!
Comment: depends on the OS, it is said that later versions of windows systems do zero out the drive when running a full format, which does take forever. http://superuser.com/questions/393912/does-long-format-in-windows-zero-write-the-hard-drive
Comment: thanks. had no idea about format scanning for bad sectors.
Comment: No problem! Did this answer your question?
Comment: Incidentally, checking for bad sectors in software is anachronistic at this point.  Drive controllers do it automatically in hardware as the drive operates, so unless you're using an extremely old drive, there's no need to force that check; it just takes extra time.
Comment: these days with bits scrambled and using more complex encoding zero is not really flat magnetism so residual data is more hidden
Answer:
If a quick format just marks bits as writable, and a normal format
  writes 0s to the entire disk, why do people bother with DBAN,

On older setups a format indeed wrote a pattern to the whole disk (e.g. all zero's though any pattern would have done). A single pass of this is enough to wipe all data for regular users.
I mention regular users because with sensitive enough equipment it was possible to recover some of the old data. This means data was not save the NSA or any similar group which can afford some very expensive equipment. Overwriting the data several times with different patterns however made the information on the disk really unrecoverable.
This point is probably moot for modern platters since the magnetized particles have become much smaller.

and why are multiple passes ever required?

A single pass is enough to make a disk controller read the newly written data.
However consider the following simplified example:
  A magnetic north (say 100% intersity north) represents a 1
  A magnetic south (say 100% intersity south) represents a 0
Now what happens when we encounter a 85% north?
The disk controller will interpreted it as a 1.
No big deal, values do not need to be perfect.
Now to wiping a disk.  I have 100% charge N, I wipe it with all zero's, ideally setting it too 100% S.  But what happens is that it might end up 90% S.   Now I heave a disk with 100% S parts (which originally were 0's) and with 90% S (which originally were 1's).  So if I scan carefully enough I can reconstruc the old data.
And once more, that example is not technically correct. It is very much simplified.
Overwriting the data with multiple passes with different data makes enoguh of a mess out of it that it becomes unrecoverable. Add a few more passes and you get goverment standards for wiping. This is why some tools offer multiple passes.

Moving on to DBAN:
DBAN can send the 'secure erase' command to a disk. If the disk supports this it should erase itself without any further activity from the computers.  That can yield significant speed gain. (e.g. when you connect the drive over a slow bus like USB).
And on SSD's this is often very quick because some of them always encrypt their data. A secure erase just deletes the key to that data and generates a new one. That makes safely wiping the SSD a matter of roughly 0 seconds.
< hat type="tinfoil">Assuming there is no backdoor in the firmware </hat>. :)
Answer: 1) EDIT: This next section is only true for XP. Psycogeek pointed out that Vista and up does zero out the drive if you do a full format.
2) That being said, your definition of quick format and normal format is off. A normal format doesn't zero out the disk, that would take too long. The difference between the two is that the normal format looks for bad sectors on a drive, while the quick does not.
In 1. u say if you do full format the disk is zeroed, and in 2. u say normal fomrat (full u mean i guess) does NOT zero the disk
Well does a full format zero the disk or not? thnx
Answer: Look at it this way...
When you throw things away at your house, you can take that trash to the dump. On a computer, all the data is on the drive. Period. There is nowhere else for it to go. Recovering data from formatted drives is much like the ability to recover files that were deleted from a recycle bin. In each case, the data still exists but is no longer put together. Recovery programs know how to locate the data and reconstruct it.
The reason for multiple passes is to make it more difficult to recover/restore data in an effective way. It is a matter of data security. The more sensitive the data, the more passes you want. The Department of Defense recommends 7 passes. This is what they consider to be a sufficient deterrent and, perhaps, making it theoretically impossible to recover anything.
Answer: If a quick format just marks bits as writable, and a normal format writes 0s to the entire disk, why do people bother with DBAN, and why are multiple passes ever required?
The use of DBAN and equivalent stems from a combination of older technology, paranoia and a misunderstanding of "The Gutmann method".   (The Gutman method was looked at as a definitive method of ensuring data was wiped from pretty much any type of disk using 35 different passes, a long time ago)  People misunderstood it to be what was required to ensure data was unrecoverable, when in fact only 1 or 2 passes were required.  Similar specifications were designed by militaries, and so the idea of lots of overwriting passes were cemented in management belief and policy.
Other considerations -  old drives had the data scattered across the disks with less density, and, crucially, higher tolerance of write heads.  On an old disk that was overwritten with "all zeros", it would be possible to replace the heads (or sometimes just the circuitry) and amplify the signals coming off the heads as a 0 which was previously a 1 would still read slightly higher then a true 0, thus making it possible to recover data.  Writing random data / other patterns negates/largely negates the ability to recover data this way.
Programs like DBAN will also try to write over sectors which have been marked bad by media - formats would not "get to" this data so its more recoverable.


Change parent theme file function in child themes functions.php

Question: im trying to understand how Action Hooks and Filters work and have this example i want to edit
This function is in a parent theme framework php file:
public function formatArticleCat01( $show_category = false, $shorten_text_chars = 300, $show_date = true, $show_comments = false, $show_author = false, $show_views = false ) {
$sFigure = ( $this->article_thumb != '' ) ? '
'. $this->getReviewScore() .'' .$this->getFigureSmall() .'

' : '
';
return '

                '. $sFigure .'

                        '. ( $show_category ? $this->getCategoryLabelSpan() : '' ) .'

                            article_link) .'">'. $this->article_title .'

                            '. ( $show_date ? $this->getPostDateMeta() : '' ) .'
                            '. ( $show_author ? $this->getAuthorMeta() : '' ) .'
                            '. ( $show_comments ? $this->getCommentCountMeta() : '' ).'
                            '. ( $show_views  ? $this->getViewsLabelSpan() : '' ) .'

                            '. MipThemeFramework_Util::ShortenText($this->article_content, $shorten_text_chars) .'

                        '. $this->getStarRatingLabelSpan() .'

';
}

So lets say i want to add another class to that div just in this line
$sFigure = ( $this->article_thumb != '' ) ? '
'. $this->getReviewScore() .'' .$this->getFigureSmall() .'

' : '
';

It should work with a filter hook right? Can someone help me to understand the functionality of filter hooks and make this example work
I have no clue what to add in my child theme functions.php file to prevent the loss of the changes when i update the theme.
Hope someone can help me
Thanks
Answer: Filters are for modifying the data, but actions are like bus stops where you can attach your functions to theme and they will be run when the script reaches an specific state.
To use any of the above, they must be first declared somewhere. Let's take a look at this example from the codex page of apply_filters:
// Function that modifies the data
function example_callback( $string, $arg1, $arg2 ) {
    // (maybe) modify $string
    return $string;
}
// The filter used by user
add_filter( 'example_filter', 'example_callback', 10, 3 );

// Declaration of the filter by the person who
$value = apply_filters( 'example_filter', 'filter me', $arg1, $arg2 );

Now as you can see, the filter is declared and given a name by using $data = apply_filters( ... ). Then, somewhere else in the code it is called by using add_filter( ... ). So, if you have no filter declared attached to that data, there is no way you can filter that piece of data.
Now about your code. It seems like you grabbed that piece of code from a class. Most decent developers use pluggable functions when they write their code. It means, they define their classes and functions as follows:
if ( ! class_exists( 'some_class' ) {
    class some_class {
        // Class code here
    }
}

This allows the user to override that specific class or function, by simply defining it himself. Take a look at your code. If it's following the same practice, then you can copy the class to your child theme's functions.php file, and modify the parts of it you wish.
Comment: Hey, thanks for the answer. You were right. The function was inside `if ( ! class_exists( 'MipThemeFramework_Article' ) ) {`and in parents functions.php there was this line `require_once(get_template_directory() . '/framework/class-article.php');`. I understand the functionallity a bit more but i still have no clue how to change it in my child themes function.php. Any ideas?
Comment: if i do that i get a fatal error message:
`Fatal error: Call to undefined method MipThemeFramework_Article::formatArticleForMegaMenu() in .../framework/extend-menus.php on line 592`
Comment: a few lines before line 592: `$post_article = new MipThemeFramework_Article();`
line 592:
`$menu_list .= ''. $post_article->formatArticleForMegaMenu() .'';`
Answer: In layman's term Filters are used to modify or change an existing data such as content of a post, or any other defined value. Actions on the hand do something when a particular thing is run.
For both actions and filter you have to declare them first, i.e in case of filters you must define what can be changed using a filter, and for actions hooks what will cause the action to run.
Note:
In your above example, there is no mention of any filter, therefore the only way for you to modify that function is to copy it in your child theme's function.php file and add a class manually.
Now to Understand how filters work, lets look at an example,
Lets' say you want to print an author's name, then you can apply a filter to it, so that in case you want to change the author's name you can do so without modifying the original function.
/*
 * - 'change_author_name_filter' is the filter hook $tag
 * - 'Digvijayad' is the value being filtered
$author_name = apply_filter('change_author_name_filter', 'Digvijayad');

Now if you use $author_name then it will use 'Digvijayad' as the default author name. However if you add a filter like the following.
// filter call_back
function change_author_name( $author_name ){
    //here you can do whatever you want to author name;
    // you can modify it or replace it altogether.

    // To print 'Digvijayad & Jack Johansson' you can do the following.
    // $author_name .= ' & Jack Johansson';

    // or you can replace it altogether.
    $author_name = 'Jack Johansson';

    return $author_name;
}
add_filter('change_author_name_filter', 'change_author_name', 10, 1);

Now if you use $author_name it will be replaced by 'Jack Johansson'
As for Actions, they trigger a response when something is done. lets take Alarm as analogy. First you set a time for an alarm, and when the time is reached, the alarm clock plays a sound to tell you that it is time.
Now with actions, you can tell the alarm clock to do other things such as 'call a friend' too when the time is reached. Now lets put this in code.
Let's assume you have already set the time, now you set an do_action hook that will do something, when the time is up.
//code when time is checked
// and now time is up
do_action('time_is_up'); //basically it will perform this action when ever the time is up

now you can add more actions to this particular event. From the analogy, you can now tell it to call a friend when 'time_is_up' actions is run.
// Now Whenever 'time_is_up' runs this function will run as well
function call_friend(){
    //code for calling a friend;
    echo 'calling friend';
}
add_action('time_is_up', 'call_friend', 10);

You can similarly add more actions to the same 'time_is_up' action hook.
For example, maybe you also want to call your family member
function call_my_family(){
   //code to call my family
   echo 'calling family';
}
add_action('time_is_up', 'call_my_family', 10);

Hopefully this simple explanation clears out your confusion about actions and filters.
For more reading, you can read Tom McFralin's article on Actions and Filters.
Comment: Hey thanks for the explaination, appreciate it.

i watched the code of the parent theme again and saw that the function is inside a class:

`if ( ! class_exists( 'MipThemeFramework_Article' ) ) {`

The other thing i found is in parent theme functions.php:

`require_once(get_template_directory() . '/framework/class-article.php');`

You said in your post
>therefore the only way for you to modify that function is to copy it in your >child theme's function.php file and add a class manually.

With the new informations is there a way to change it without to completely overwrite it?
Comment: From my knowledge and as mentioned by Jack, that is the only way it will work if you go through it using `PHP`. However, if you just want to add a new class, you can always use `JavaScript` or `jQuery` to do that.


I have the Samyang FE 14mm lens which has a nondetachable lens hood - is it possible to still use a ring adaptor on this so that I can use a filter?

Question: And how would I know which size adaptor I need? There are no markings on my lens. I'm looking into buying a square filter holder to try help with this. Thanks.
Answer: Back in 2014 Samyang introduced the SFH-14 filter holder specifically made for their 14mm lenses. Cokin made three special filters that fit the holder, which uses an odd size larger than even "standard" 150mm filters: 161 x 139 x 3 mm.

The filters were:

ND8 (three stop) neutral density
ND4 (two stop) neutral density
Half Blue (two stop) blue graduated neutral density

Due to the limited availability of suitable filters, it seems to have never really caught on. Four years later in 2018 a few of the holders can still be found for sale, but good luck finding the 161mm filters to fit it! They're sometimes marketed as 'Samyang 160 filters'.

A number of third party holders made to fit the 14mm Samyang lenses for 150mm filters are available from makers such as Nisi, Haida, and Lee (three piece ring system + Lee 150mm holder). The slightly smaller 150mm filters require the holder to be closer to the lens than the 161mm filters that fit the Samyang holder. One must be careful to avoid scratching the filters with the front of the built-in lens hood on the lens. The advantage of using a 150mm holder is that there are many more options in terms of what kind of filters are available in that size.
Comment: Hi there. Thank you very much for this information - it's been very helpful. Quick question as I'm super new to filters and holders and whatnot: could you briefly explain what the millimetres mean please? Would I HAVE to have a 161mm or 150mm filter holder/filters? And if I were to purchase one, could I still use it on my smaller lens, providing I have a suitably-sized adaptor ring? Also, does it matter whether the holder is advertised as being for a auto or manual lens at all? I have an autofocus. Thank you again for all of the help.
Comment: @Man - filters are made either circular (and come in many diff sizes to thread onto the front of the lens, or square. I personally use a 100mm kit and love it. Michael's answer indicates to me that your best option is to choose a 150mmX150mm filter system, that way you can have a holder for your Samyang but also be able to use the filters with other lenses as well. If you have more q's about filter systems, ask as a new question!
Comment: @Corey awesome - thank you very much, and will do :)
Comment: Most, if not all, of those other questions have already been asked/answered here.
Answer: You will probably have to go with something like this:

Lenses with no front threads might have a filter slot nearer the rear of the lens, but the Samyang you've got is not among those.
So, the semi-janky >_< filter above is probably your best bet.
Answer: You already have many choices of makers to get the filter holder for the new ultra-wide lenses and the correct filter size, if you like the Lee filters, they have an online tool to choose the right components for your lenses and camera make: Lee Sytem Match.