Does the SSL termination happen with the ISP or a mobile service provider?

Question: Is it true that when I connect to a site over HTTPS , my mobile service provider or the ISP gets to snoop in the communication? Can they play MITM?
Comment: What research have you done?  Click on the [tag:man-in-the-middle] tag, or peruse the "Related" questions sidebar, and you'll find dozens of questions here that talk about MITM attacks and what is possible.  Next time, please do more research before asking.
Comment: No, its absolutely not true, but it might be in some rare cases.
Comment: Thanks, @user917279.  No problem: we won't lose Thomas's excellent answer (it'll still be here), and we can even ask the moderators to merge it into that question if this gets closed as a dup (just click "flag" underneath his answer to flag it for moderator attention and ask them to merge his answer into the other one).
Answer: Not, it is not true...
.. Unless the ISP is good at spying on people, and you are gullible. In that case, things are possible.
Explanations: to "snoop" on your communications, the ISP must either break the SSL crypto (fat luck on that) or impersonate the server to power a Man-in-the-Middle attack. From the client's point of view (your Web browser), the server's public key is obtained through the server's certificate. The certificate is validated relatively to the root CA which are embedded in your computer. The ISP will not be able to obtain a fake certificate mimicking that of the server you are trying to talk to.
Spying on you thus requires at least one of the following:

The ISP is in league with a big commercial CA, and can obtain fake certificates. This is highly improbable because such certificates would be so many proofs that the CA is dishonest, thus making the game highly risky, for the paltry gain of simply spying on your data.
You get a big red flashy warning from your browser about the server certificate being invalid in some way, and you click on "I know what I am doing" (which, in this case, would be a quite bad idea).
The ISP could convince you to install some software of theirs on your computer. E.g. a "connection kit". That software, if malicious, could install an extra root CA certificate under control of the ISP, thus allowing the ISP to generate fake server certificates and thus succeed at MitM. (Similarly, the same software could plant some spying tool such as a key logger.)

I am not aware of any actual case of an ISP spying that way on its customers, in supposedly democratic countries (I have heard stories about institutional MitM with rogue root CA in some countries like Iran, though -- but I don't have any confirmation about it).
Without an actual SSL break or rogue CA, the ISP can still see what servers you are trying to talk to, and may try to infer some clues about the contents of the exchanged data based on its size (encryption hides the values of byte, but leaks the message sizes). For an organization who wants to keep track of a lot of people, such metadata already constitutes a lot and is what they will concentrate first, to identify interesting targets.
Comment: I've heard of this done at workplaces, where the employer wants to monitor employees' web usage even over HTTPS, and I've personally seen it done on public WiFi access points. The specific example I remember was on a cruise ferry between Stockholm and Helsinki a few years back, and, for me at least, fell into the "big flashy warning" scenario. (I suppose it might've been intended as the third type, had I been using a more mainstream browser / OS.) I ended up using an SSH tunnel to get around it, since I had no desire to accept their bogus cert, and the proxy wouldn't let me through otherwise.
Answer: HTTPS is end-to-end encryption and when the connection gets established the browser will verify that the sites certificate is signed by a trusted CA. The browser/OS comes with a predefined set of trusted CA and nobody except the owner of a domain should be able to get a certificate from these CAs.
This means in theory, that if the ISP or mobile provider tries SSL interception (i.e. man-in-the-middle) the browser will complain about certificate validation error, because the intercepted connection is now signed by an unknown CA.
But, in reality this might not happen.
If you get the phone from the provider it might come with an additional pre-installed trusted CA issued by the prvider, so that the provider will be able to intercept traffic without warning. Such CA might also be installed for centrally managed phones in companies, so that the company might be able to do SSL interception for security purposes. And finally you might install a browser like Opera Mini, which comes with a pre-installed certificate so that SSL interception and traffic optimization is possible by the browser provider.
Answer: Not directly related to your question, but keep in mind that sadly some apps do a very bad job at verifying the certificate or even use HTTP (without any easy way for you to check) and I've personally seen such a app that used TLS but accepted my self signed certificate without any warnings, so while your browser will correctly verify certificates and display a warning if something is wrong, you should be careful with apps.
Also keep in mind that if your phone is provided by your carrier, I'm pretty sure they can install their own certificate in the trusted certificate store of the phone. The only exception to this is Apple which as far as I know doesn't allow carriers to modify the firmware.
Answer: It's certainly possible.  Here are some ways that could happen:

Your browser trusts certificates from a provider that will provide
illegitimate certificates to your ISP
Your browser is configured to ignore certificate warnings
Sites that you use have shared their certificates with ISPs


Rerouting emails to external account

Question: There was a case when employee A thought he was getting legitimate emails from employee B, as the email address was valid, there were no CC/BCC addresses and just plain text in the body. Some sensitive data was exchanged at the end and an outside email address was revealed for some reason at the end of the chain. Employee B never received and replied to employee A emails. Also, exchange server ended up being down after this incident.
What could have happened?
How can this be prevented?
Comment: Welcome to security.SE. I think that we could help you more if you could explain a bit more about the context of this problem. If it's a homework problem, please say so. If not, please give us more information.
Comment: This is a real incident. What additional info do you need?
Answer: Email was never designed to verify an email actually came from the person it says it came from.  The model is largely one of snail mail, where it's trivial to print an address of President Of The United States as the origin.
The most likely scenario is the header address appeared as employee B, but the reply to: address was set to someone else like email@example.com.  In this case, replies would go to email@example.com instead of employee B.
Comment: looks like you are correct. I only saw the entire email chain with the valid email address in the first few messages. But after I read your comment I checked employee A first incoming email from employee B and it already changed to the rogue email address. I assume IT changed exchange server settings so it displays the real address now. Also, there're probably exchange server and Barracuda settings to reject such emails in the future. I didn't look at this issue firsthand as it's not my job but I'd like to understand if we are doing enough to prevent this from happening again.
Comment: Email is particularly tricky to get right, and there's a wide variety of use cases where the from and reply to can legitimately be different.  One is simply mailing lists.  The "from" should really be from the person who created the message, but the reply-to really has to be the mailing list.  So you could potentially break mailing lists by changing headers, or rejecting email where they don't match.  Also, people don't really pay much attention to the address, but pay attention to the name.  Phishing is just very hard to swat.

Rerouting emails to external account


What is the fastest way to unstage parts of a new file in git?

Question: When I want to split up a new file into several commits I can git add -N <file> and then interactively stage lines using git gui. When I make a mistake while staging, however, git gui won't let me unstage individual lines because it is a new file (which seems like a bug to me). Of course I can always unstage the whole file and start over again, but I am wondering whether there is a more efficient way to do so.
I am using git 1.7.5.

To clarify, this question is specific to new aka untracked files!
Answer: From the command line type:
git reset -p

This will let you selectivelty unstage hunks from the index using the standard command-line interface for managing hunks.. This is the opposite of git add -p.
UPDATE
OK, it would appear that you cannot selectively stage different hunks when the file is new. Given that git-gui and the standard git hunk editor both do not allow this, it probably isn't possible.
Answer: Using fugitive you can easily do so. Just invoke the :Gdiff command and then stage and unstage whatever you want. You can even edit the index file directly. Of course, this solution requires you to be fairly comfortable with vim and vimdiff...
Answer: I just ran into the same issue: I had just committed a new file, and I wanted to unstage some of the lines in that file and have those as a separate commit. The solution I worked out was:

Start on the commit that adds the new file
Remove the lines you wanted to unstage in the source file, stage those changes and git commit -m 'REVERTME'
Create a new commit that reverts that latest commit: git revert HEAD
Use git rebase -i to fixup the first new commit, and optionally reword the revert commit.
Answer: Another easy way to sort this is to cut everything out of the file except for one line that you want in the first commit. Stage it and then add back the rest of the file. From then on you can stage hunks/lines as usual


How do I prevent the user from inserting or updating values for certain columns?

Question: Using SQLAlchemy as the ORM for my PostgreSQL database, I would like to add a constraint (or something similar) in my model definition that prevents a user from:
1) Inserting a value into a column they're not supposed to insert into (e.g. my auto-incrementing primary key or a date_modified that gets automatically set onupdate.)
2) Updating values in the same columns.
Basically - I would like inserts and/or updates to fail if they are attempting to touch specific columns.
EDIT
For clarification: I would like to declare this through my model (which inherit's from SQLAlchemy's Base).
Answer: PostgreSQL supports declarative column security (as well as row security)
Use this template:
GRANT { { SELECT | INSERT | UPDATE | REFERENCES } ( column_name [, ...] )
    [, ...] | ALL [ PRIVILEGES ] ( column_name [, ...] ) }
    ON [ TABLE ] table_name [, ...]
    TO role_specification [, ...] [ WITH GRANT OPTION ]

Example:
GRANT INSERT (colA, colB) ON TABLE foo TO michi;

Comment: @Michi: This is DB administration, not DB data structure. It's not SQLAlchemy's domain. It's also not supported by every SQL database. (In a high-security environment, I'd have roles with fine-grained grants, and would assign roles to users.) On SQLAlchemy level, you can try to use [events](http://docs.sqlalchemy.org/en/latest/orm/events.html) to _additionally_ check access rights.
Comment: I would like to declare this through SQLAlchemy rather than PostgresQL using my model (that uses SQLAlchemy's Base).
Comment: You could include the required grants as [custom DDL](http://docs.sqlalchemy.org/en/latest/core/ddl.html) along with your models.
Answer: The easiest way I could think of doing this would be to use:
final int (name) = x;

This way the value can't be changed while running.


PowerShell cmdlet licensing

Question: I copied two functions from a cmdlet script distributed with Microsoft PowerShell v5, inside my script that should run on PowerShell v3. Also I slightly modified it. Do I invalid a license or can I get in trouble if I publish this code on let's say Github? I can't find anything relevant to the licence attached to cmdlet scripts distributed with WMF (Windows Management Framework).
Comment: Out of curiosity, which cmdlets? I only ask because I wrote some. If you can't find a license specified in the cmdlet files (unusual) I'm sure there's one for whatever WMF you're using.
Comment: Compress-Archive cmdlet, I based my own custom cmdlet for zipping some files with relative path on that cmdlet.
Answer: You would need to determine which PowerShell Module the Cmdlet in question belongs to. You can use the "Get-Command" Cmdlet to retrieve this information (Obviously, you'll want to Replace  with the Name of the actual Cmdlet).
Get-Command <CmdletName> | Select-Object Name, Module, ModuleName

Once you have the Module Info, you'll want to Locate the Module Manifest File, which can be in one of several locations (depending on your PS Configuration).
Here are Three potential Locations, off the top of my head. The Manifest File should contain a .psd Extension.
C:\Windows\System32\WindowsPowerShell\v1.0\Modules\<ModuleName>

C:\Users\<UserName>\Documents\WindowsPowerShell\Modules\<ModuleName>

C:\Program Files\WindowsPowerShell\Modules\<ModuleName>

Once Located, Open the Manifest File and Locate the "Copyright" Line, as it should list the Name of the Module Author, whom you will want to reach out to regarding your specific Copyright Question(s).
If this is a Microsoft Cmdlet/Module, you may be happy to read that PowerShell is currently Open Source.
Regardless, you will want to review the Copyright Information, which can you can find, via the Link below, as there are particular requirements regarding the re-use of MS Software, Scripts, Modules, Cmdlets, etc.
https://www.microsoft.com/en-us/legal/intellectualproperty/copyright/permissions
In particular, you will want to Expand and Read the "Redistributing software" Section.
For the most part, as long as your PS Script, itself, is also Open Source, you shouldn't have any problems as long as you comply with the "Requirements for allowed uses" Guidelines.
If you would like additional Information, regarding a particular PS Cmdlet, please respond with the Name of the Cmdlet that you are referring to in your Original Post, as I will be happy to dig up the necessary Information, on your behalf.
I hope this is helpful. Feel free to respond with questions. I'll do my best to answer them, as soon as possible.

PowerShell cmdlet licensing


He went to work vs. went to the work

Question:
He went to work.
He went to the work.

Is #2 correct as used differently from #1 (Verb vs. noun)?
Answer: Work is a noun in both sentences.
When saying someone went to the the place they work at, you always say:

X went to work.

When you say,

X went to the work.

I can only think that X went over to a work of art. It would have to be a very specific situation.
Comment: "went to work" can also mean "started working"; "went to the work" suggests "the work" is a location/physical item.
Answer: Number 1 is ambiguous. To work can be either a prepositional phrase or the to-infinitive.
You can use both in one sentence:

He went to work to work.

The first work is a noun (place of employment), the second a verb (to work). You can use in order to instead of to to see that this is a prepositional phrase

He went to work in order to work.

It is usually easy to decide whether to work is a prepositional phrase or the to-infinitive by what follows the two words. But, without more context, each of the following could be read as a noun or verb:

He went to work in Chicago.
He went to work at 9 AM.

One reason this is so is because to go to work can mean both to go to one's  place of employment and to get busy (or to start) doing a task. The same ambiguity can be seen in get to work.

I need to get to work

can mean

I need to get to my place of employment

or

I need to start working (on a task)

As a noun, when we mean the place where we work, we  use to work, without the definite article. We also say to school and to home. If you say to the work it means something else, depending on context.

We went to the work

It could be a work of art or some other object.

He went to work vs. went to the work


How to access REST APIs as guest in Magento 2.1.x

Question: I am building a mobile application for a Magento instance. I can use Token Based Authentication to make the API calls. However I want to enable guest access in my app. The users should be able to browse the categories and products and add to card without signing in, and only need to sign in when they are checking out. Is this possible?
Comment: Did you able to manage guest user browsing ?
Comment: Did the answer below help you? Anything to report?
Answer: I think you can use the anonymous resource for your api method, like:
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
    <route url="/V1/path/to/method" method="POST">
        <service class="Vendor\Module\Api\OwnInterface" method="methodName"/>
        <resources>
            <resource ref="anonymous" />
        </resources>
    </route>
</routes>

Because:

Use the token in a Web API request
Any web API call that accesses a resource that requires a permission
  level higher than anonymous must contain the authentication token in
  the header To do this, specify a HTTP header in the following format:
Authorization: Bearer

Source: Token-based authentication
You can find example here: magento/module-quote/etc/webapi.xml


Linking to own answer in comment of another answer

Question: If you improve on the answer of one person as a separate answer (example), is it considered OK to add a comment to the original answer telling people to look at your answer?
Comment: It is *unacceptable* that your answer did not include a link to Freddy's answer.
Comment: @CodyGray is it _unacceptable_ that you called Franky Freddy? ;)
Comment: If your answer is that similar, I would just leave a comment on the other answer describing how you feel it can be improved.  If such a comment would be too long then maybe the differences merit another answer.
Comment: Hah. Whoops. Darn 5 minute rule. Anyway, if you see other people making this mistake, please edit a link into their answers.
Comment: @CodyGray fair enough (though I see many people make this mistake).
Comment: How can you do that without changing the intent of the original author? If there is a legitimate reason to link to your own answer in someone else's, I don't think this is it.
Answer: Yes, it would be totally acceptable to add a comment to the original answer. You can pretty much leave any comment you like, as long as it is relevant to the post and doesn't contain any personal attacks. A comment pointing to an alternative solution, or even one pointing out a flaw with the answer, is a good comment.
Such a comment should contain a brief description of your proposed modification, accompanied by a link to your answer that contains all the important details.
Speaking of which, if you're going to "riff" off of another person's answer, you need to make sure that you do two things:

Give credit where credit is due: include both the name of the person who originally provided the answer (make sure to get it right!) and include a link to the answer itself. This is required by the license here—you are free to remix and reuse all content contributed by other users, but you must provide attribution to the original author.

Explain the advantage of your alternative. It isn't useful to make a trivial change to the original code and post that version as an answer. Your alternative should actually have a notable advantage over the other version, and you should call that out explicitly at the top. Is yours faster? Less error-prone? Maybe you think it is clearer. Whatever the reason is, this helps people make the best decision about which answer they should choose, depending on their situation and concerns.

If you're asking whether it would be appropriate to edit their answer to include a link to yours, well, probably not. This is ultimately a judgment call, and although I can imagine certain cases where it would be appropriate, many will disagree with me (some users think edits should only be used for presentational issues, but I think that's overly restrictive). If you do decide to do this, tread very lightly, taking into consideration how you would be affecting that person's answer and what appears to be their recommendation. They would be well within their rights to roll back your edit if they disagreed.
Also note that if you simply leave a comment, the user might decide to edit a link to your answer into theirs. I probably would, if you actually provided something of value.


Remove anchor from URL MVC3

Question: So, I have a form on PageA that attaches an anchor so that the page jumps to errors shown on PageA.  But, when there are no errors, I am trying to use
<code>return RedirectToAction("PageB", new { id = ID });
</code>
But, for some reason, even though I am redirecting to a different action, the anchor is being attached.  So, on error it would be going to www.domain.com/Controller/PageA#errors, it goes to www.domain.com/Controller/PageB?id=5#errors.  This causes an issue because there is an anchor errors on PageB also.  How can I remove the anchor on the redirect?
Answer: You can remove it manually, by using Url.RouteUrl (which will create a string with your exact URL).

Remove anchor from URL MVC3


Is there a way to generalize programming language syntax

Question: I'm hoping to develop language independent tool for code analyzing. in order to do that i need  to find a way to generalize programming languages syntax. I thought of develop a layer between source code and analyzer so that it can understand the source code independent of the language.
I need to know is there a special research area for this problem? Any suggestions?
Comment: afaik there is no standard for pseudo-code, the problem is that programming languages differ way to strong (functional, oop, ...) which makes it practically impossible to create a pseudo language that can represent all of them
Comment: Extended Backus Naur Form?
Comment: Generalizing *syntax* is easy, it's called Grammar Recognition/Generation.  Generalizing language ***semantics*** is incredibly hard (maybe impossible).  And syntax is meaningless without the semantics to go along with it.
Answer: It really depends on the kind of analysis you're going to do. If you want to analyze the "intent" of the code in a manner that is explainable in the context of the source language, the problem is likely impossible unless you restrict yourself to a particular language family (e.g. Java, C#, and C++, but even that is limited).  You can gain more flexibility if you're only interested in basic analysis, e.g. building a model of defined types and methods/functions.
If you're interested in analyzing low-level behavior, your best bet may well be to analyze the output of early stages of the compiler. For example, there are many useful types of analysis, such as data flow analysis, that can be done on Java bytecode, irrespective of the language that generated it. Similar analyses can be done on LLVM intermediate code or GCC's intermediate language (in fact, these compilers both do a lot of their optimizations on the intermediate code or assembly code level and are thereby able to do a lot of the same optimizations no matter what language is being compiled).
Answer: In my research group, people have been working on an software analysis platform called Moose. They thus developped the Famix model to abstract over the syntax of specific languages. There are various importers from specific languages to the language-independent model.
There are common constructs that you find in many object-oriented programming languages with different syntaxes, e.g. inheritance, etc. It is however impossible to have a unique model that captures the semantics of all construct of all language--the model captures the semantics of common constructs shared by many languages.
Answer: For static analysis you'll need "generalised" operational semantics, which has absolutely nothing to do with syntax. You're lucky - it does exist, because each and every practically useful language out there ends up being translated into semantics of the actual hardware.
Therefore, assembler of your CPU is exactly your "generalised semantics". Operational semantics of CPUs is a well-research topic, you'll find a wealth of papers if you dig deeper.
LLVM is low level enough to cover most of such semantics while being more compact and easier to analyse than the real hardware, so you may consider using a similar intermediate representation. SSA form can simplify the analysis significantly.
But do not get too excited - it is exceptionally hard to do any useful global analysis on such a low level - a generic memory model will require too much resources, rendering any analysis unrealistic on a contemporary hardware.
If you're ready to limit your choice of source languages severely, you can go up a level, and employ more analysable semantics. You may find K framework interesting if you want to go this way.


How is the print time of an object to be printed estimated?

Question: I am curious about the algorithm/principles behind the estimates that the slicing softwares provide. Is there a standard technique behind this and how accurate is it ?
Comment: And let's not forget the psychological part: the beginning of a print always seems to take forever, partly because there's little in the way of recognizable shapes.  The last 25% or so of the layers , not only is the shape quite visible, but typically these layers cover much less area than the base, so the time per layer does decrease.
Answer: Much of the software used in 3D printing is open-source, and so are some slicers. Cura, for instance, does (or did, this source code is from an older branch) its print time estimation in gcodeInterpreter.py.
The relevant portion of the source code is (simplified and with many lines removed for clarity):
<code>    totalMoveTimeMinute = 0.0
    pos = util3d.Vector3()

    for line in gcodeFile:
        G = self.getCodeInt(line, 'G')
        if G is not None:
            if G == 0 or G == 1:    #Move
                x = self.getCodeFloat(line, 'X')
                y = self.getCodeFloat(line, 'Y')
                z = self.getCodeFloat(line, 'Z')
                e = self.getCodeFloat(line, 'E')
                f = self.getCodeFloat(line, 'F')
                oldPos = pos.copy()
                pos.x = x
                pos.y = y
                pos.z = z
                feedrate = f
                currentE = e

                totalMoveTimeMinute += (oldPos - pos).vsize() / feedRate
</code>
As you can see, (this version of) Cura simply:

Loops over all the G-code instructions,
Computes the length of each move (in X/Y/Z) and divides that by the feedrate to get the time that move will take,
Sums this up over all the moves.

and does not take into account:

Acceleration or deceleration. It assumes the printer is always operating at the maximum feedrate,
The length of filament extruded. The feedrate is the speed for the move in (X,Y,Z,E), but Cura only looks at (X,Y,Z).
The time it takes to heat up the print bed/hotend or homing/autoleveling,
The effects of the printer slowing down if moves can not be read (from USB/SD-card) sufficiently fast (though this would be rather hard to include in any estimate).

The accuracy of this estimate can be arbitrarily bad if the feedrate is set to some unrealistic value.
Newer versions of Cura use a much more advanced time estimate method, and it can be found in timeEstimate.cpp.  It is much more complicated, and actually takes jerk/acceleration/deceleration into account. It is much more accurate.
We know exactly how 3D (open source) 3D printer firmwares work, so estimating print time is as easy as simulating execution of the G-code by your given firmware. There is no reason you can't get a really good estimation (if you take into account all of the intricacies of your given firmware's acceleration/deceleration techniques) but writing the code for it is rather involved.
Answer: Generally speaking, the typical algorithm takes into account the slicer's speed settings for specific features of the build, such as infill, perimeters, top/bottom layers, etc. The distance traveled by the nozzle at a specific speed for each feature is also part of the equations involved. There are some rather vague portions of the nozzle movement based on acceleration and other factors which makes the calculations less accurate.

How accurate is it?

Not too accurate. My experience with three different slicers is that it's never been within better than ten percent. I believe the various combinations of features of a build are not going to be identical from one model to the next, preventing even a ballpark figure to be created from previous builds.
Comment: Can you provide a reference where one could see how these calculations are made ? Like a piece of code or the algorithm itself.
Comment: Tom van der Zanden's answer is a bit more convoluted than I can follow, not being a code person, but is a good start. I've found a number of web sites containing basic descriptions of calculations, including http://forums.reprap.org/read.php?2,647001 but all of them appear to be missing various factors. In most of the sites, the acceleration is ignored or approximated. As a result, the build times are approximations. I suppose if one were applying orbital dynamics mathematics to 3D printing, one could get more accurate results.
Comment: Unless you're dealing with multi-day prints, I'd say 10% is more than adequate accuracy.


How to preserve shape keys with decimate modifier?

Question: I want to use the decimate modifier to make some LODs of a mesh, and this mesh has a very huge number of shapekeys which I must preserve.
I can't apply the decimate modifier with a mesh with shapekeys.
Comment: This might not be possible as shapekeys depend on the actual geometry, which is partially "deleted" with the Decimate modifier.
Comment: Also, the decimate modifier will change the vertex order.
Answer: For this you must re-create all shape keys for each LOD-version of your mesh. You can try to do this. First making LOD-version by applying Decimate modifier to copy of your high-poly mesh with all shape keys deleted.
Then, sequentially turn on each shape key on your original high-poly mesh and apply Shrinkwrap modifier to previously made LOD-version as a shape key targeting that high-poly mesh with shape key turned on.
That is, add Shrinkwrap modifier to low-poly ('decimated') mesh. In your high-poly mesh turn on particular shape key by set it value to 1. Select your high-poly mesh as a target in Shrinkwrap modifier. Click 'Apply as Shape Key' on Shrinkwrap modifier. If all went good you would had particular shape key transferred from high-poly to low-poly model.
Comment: still relevant in 2024
Answer: You can use the decimate command instead of modifier.

You can set up the same amount of decimation and symmetry option as in the modifier.
To get better result, select one of the shape keys before decimate (not the basic one). I don't know why, but it works better.
Comment: Thank you! This approach really works better than the Modifier, go figure why. The other opinions that it's impossible to keep the shape-keys are plain wrong. Of course, you won't be able to approach the original form on 100%, but depending on the decimation, Blender should be able to keep quite good approximation - that operator, proves it.
Comment: It's not an opinion, it's a simple fact sliding into disuse. Thanks to literally decades of algorithm evolutions, yes, you are less likely to completely break your shapekeys, UVs, skinning, vertex groups/colors at the slightest vertex addition/removal. But this used to be very different years ago. But there was a day when doing any of the above was dangerous. Not just for your work actually, some operations were famous to often crash the software, sometimes even the computer itself!
Comment: So softwares back in those days would try to prevent you from doing that at many costs. And to this day, some operations are still risky, and not allowed (or somewhat limited) by some tools/softwares for extra caution. And anyone who have known these days or have been taught by those who did: they kept some knowledge and habits out of this.
Answer: What you want to do is not possible. Shapekeys require the geometry of a object, and modify it; However when a Decimate modifier is added, some vertices are decimated, and just stop doing the general existing thing; Also, the vertex order is modified.
Think of it like this: you have a list which stores the position a vertex, associated with an index, for each vertex; Imagine you are trying to define some specific info about the mesh, by referring to the vertices by their index, what would happen if suddenly one vertex was deleted and the following indexes where shifted in order to maintain continuity? You'd end up trying to refer to the wrong vertex, so it was removed altogether.
Comment: I don't see how this is an issue, if you remove vertex you can also remove data for that vertex inside shapekey.
Comment: Then why can't the decimate modifier adjust the shape keys such that each new vertex uses its closest old vertex? Also, why does using the decimate modifier on one body part break shape keys that only exist to change other body parts?


ASP.NET file browser get filepath

Question: I'm using an <input type="file" /> as a file browser dialog in MVC. I don't actually want to  upload the file though, I am using it to select a template on a shared drive. I only want to get the full filepath in my action method. The server will then process the file and force download to the client. I have got hold of the HttpPostedFileBase object, but I don't see a filepath property. Is this possible? Or if not, what other options are available?
Answer: You will never be able to get the full path of a file from a file upload box because it is a security issue.  No browser will pass you the full path, only the filename.
Additionally, the file upload box will always upload the file.  Unfortunately, much like with the security issue of the full path, there is no way to show a file dialog and have the user pick a file without initiating an upload.
Answer: You could try something like adding an onchange javascript event on the input and write the value to a hidden field. Then just read in the value from the hidden field. It will contain everything that's in the text box part of the input field.
<input type="file" name="fileUploader" id="fileUploader" onchange="filePath.value = fileUploader.value;" />
<input type="hidden" name="filePath" id="filePath" />

I haven't looked at it with MVC but in ASP.Net I'm able to read that value from the code behind after using the input field.
Hope this helps.

ASP.NET file browser get filepath


Find $\lim\limits_{x \to 0}\frac {1}{x^3}\int_0^x \frac{t\ln (1+t)}{t^4+4}\mathrm{d}t $ without using L'hopital's rule

Question: Find $$\lim\limits_{x \to 0}\frac {1}{x^3}\int_0^x \frac{t\ln (1+t)}{t^4+4}\mathrm{d}t $$ without using L'hopital's rule. Using the rule, I got it as 1/12. What's a way to do it without L'hopital?
Comment: See also: [Finding the value of $\lim_{x\to 0} \frac{1}{x^3} \int_0^x\frac{t\ln(1+t)}{t^4+4}dt$](https://math.stackexchange.com/q/2219619)
Answer: A possibility would be to make the change of variable $t=ux$. Then the limit you are looking for is :
$$l=\lim_{x \rightarrow 0} \int_0^1 \dfrac{u}{u^4x^4+4} \dfrac{\log(1+ux)}{x} \, du $$
Then, using the dominated convergence theorem, you get the limit inside the integral :
$$\begin{array}{rcl}
l & = & \displaystyle \int_0^1 \lim_{x \rightarrow 0} \dfrac{u}{u^4x^4+4} \dfrac{\log(1+ux)}{x} \, du\\
  & = & \displaystyle  \int_0^1 \dfrac{u^2}{4} \, du \\
  & = & \dfrac{1}{12}
\end{array}$$
Edit : a little bit more of details for the dominated convergence theorem, you can use :
$$\dfrac{u}{u^4x^4+4} \dfrac{\log(1+ux)}{x} \leq \frac{u^2}{4}$$
using the classical $\log(1+t) \leq t$.
Comment: Well I used the fact that $\log(1+t)/t$ tends to $1$ when $t$ goes to 0, and this comes only from the fact that $\log'(1)=1$.
Comment: I assume you used l'Hospital to compute the limit with the log over $x$, but still this answer is different in flavor than the obvious option :) +1!
Comment: That's precisely what I meant, but as I said in the other answer, L'Hospital's rule, Taylor expansion, $o(x^n)$-approximations, they're all one and the same. But the idea at the beginning here is different.
Answer: Integration by parts is a reasonable choice. Since:
$$ \int \frac{t}{t^4+4}\,dt = \frac{1}{4}\arctan\left(\frac{t^2}{2}\right)\tag{1}$$
we have:
$$ \int_{0}^{x}\frac{t\log(1+t)}{t^4+4}=\frac{\log(1+x)}{4}\arctan\left(\frac{x^2}{2}\right)-\frac{1}{4}\int_{0}^{x}\frac{\arctan\frac{t^2}{2}}{1+t}\,dt \tag{2}$$
and by considering the Taylor series of $\log(1+x)$ and $\arctan\left(\frac{x^2}{2}\right)$ in a neighbourhood of the origin we easily get:
$$\lim_{x\to 0}\frac{1}{x^3} \int_{0}^{x}\frac{t\log(1+t)}{t^4+4}=\frac{1}{4}\cdot\frac{1}{2}-\frac{1}{4}\cdot\frac{1}{6}=\color{red}{\frac{1}{12}}\tag{3}$$
as wanted.
As pointed by Patrick Da Silva in the comments, we can also skip the integration-by-parts step, since we are just integrating $\frac{t^2}{4}+o(t^2)$ between $0$ and $x$, hence we trivially have $\frac{x^3}{12}+o(x^3)$.
Comment: @PatrickDaSilva :Of course. Nice. Thanks!
Comment: I think it's just easier to look at the Taylor expansion of $\log(1+x)$ around the origin without integrating by parts and do the exact same trick. It almost amounts to using l'Hospital's rule, but that's because anything which uses the derivatives amounts to the same trick : Hospital, Taylor expansions, $o(x^n)$-approximations...
Comment: @Chilango : You can expand $1/(t^4 + 4)$ using a geometric series argument and expand $\log(1+t)$ using the classical trick, there's no issue there.
Comment: @PatrickDaSilva: yes, you're right, we are just integrating $\frac{t^2}{4}+o(t^2)$ so it is not difficult to compute the limit also without integration by parts. Good point.
Comment: @PatrickDaSilva: but you are not integrating $t\ln (t+1)$ rather $\frac{t\ln (1+t)}{t^4+4}$ so when you expand the logarithm you still have to integrate by parts several times I think.
Answer: Let's first analyze the limit when $x \to 0^{+}$. If $0 < t < 1$ then we know that $$t - t^{2} = t(1 - t) < \frac{t}{1 + t} < \log(1 + t) < t$$ Multiplying by $t$ we get $$t^{2} - t^{3} < t\log(1 + t) < t^{2}\tag{1}$$ Also we can easily see that $$\frac{1}{4}\left(1 - \frac{t}{4}\right) < \frac{1}{t + 4} < \frac{1}{t^{4} + 4} < \frac{1}{4}\tag{2}$$ If $0 < t < 1$ then all the terms involved in the inequalities $(1)$ and $(2)$ are positive and hence we can multiply them together to get $$\left(t^{2} - t^{3}\right)\left(\frac{1}{4} - \frac{t}{16}\right) < \frac{t\log(1 + t)}{t^{4} + 4} < \frac{t^{2}}{4}$$ or $$\frac{t^{2}}{4} + o(t^{2}) < \frac{t\log(1 + t)}{t^{4} + 4} < \frac{t^{2}}{4}$$ Integrating the above between $0$ and $x$ where $0 < x < 1$ we get $$\frac{x^{3}}{12} + o(x^{3}) < \int_{0}^{x}\frac{t\log(1 + t)}{t^{4} + 4}\,dt < \frac{x^{3}}{12}$$ and dividing by $x^{3}$ we get $$\frac{1}{12} + o(1) < \frac{1}{x^{3}}\int_{0}^{x}\frac{t\log(1 + t)}{t^{4} + 4}\,dt < \frac{1}{12}$$ and thus by Squeeze theorem we get $$\lim_{x \to 0^{+}}\frac{1}{x^{3}}\int_{0}^{x}\frac{t\log(1 + t)}{t^{4} + 4}\,dt = \frac{1}{12}$$ A similar argument can be made for the case when $x \to 0^{-}$.
We don't need to use any advanced tools like Taylor series or L'Hospital's Rule and job is done via very simple inequalities and Squeeze theorem.
Answer: $$\lim\limits_{x \to 0}\frac {1}{x^3}\int_0^x \frac{t^2}{t^2+4}\cdot \underbrace{\frac{\ln (1+t)}{t}}_{\text{approaches 1 when $x\to0$}}\cdot \underbrace{\frac{t^2+4}{t^4+4}}_{\text{approaches 1 when $x\to0$}}\mathrm{d}t$$
$$=\lim_{x\to 0} \frac{x-2 \tan ^{-1}\left(x/2\right)}{x^3}=\lim_{x\to0} 1/12 - x^2/80+\mathcal{O}(x^4)=1/12.$$


is Client Puzzle a challenge-response variant of Proof-of-work?

Question: is Client Puzzle a challenge-response variant of Proof-of-work? I am kind of new to crypto, sorry if the question is kind of dumb. If it's not can you give examples of algorithms that implement the idea of a challenge-response variant of proof of work? And can you explain why the Client Puzzle is not challenge-response, please?
Answer: Yes, client puzzles as outlined by Joel's and Brainard are an example of a challenge-and-response proof-of-work protocol. A difference from proof-of-work usage in distributed ledger updates is that client puzzles are not competitive: a separate challenge is set to each user. Another difference is that the challenge has a known solution, which puts an absolute bound on the required work rather than having the work follow an exponential distribution. Otherwise, the idea is very similar to modern cryptocurrency usage.


Photoshop generate: Possible to generate larger than document size?

Question: I have files where some of the graphics are larger than the document. Is it possible to use "generate" for a layer where some content is outside of the document view? (so I'll have a png/jpg that is larger than the document itself?) I presume 'no', but thought I might give it a shot here.
Answer: No.
From Adobe's Help Docs on this topic:

Assets are clipped to the document boundaries. If an image does not fall within the document boundaries, Generator does not create the associated image assets.

I think that ties that one up with a  bow.


Multiple Update Panels

Question: When you have multiple UpdatePanels on a page, is there a way, in the code behind, find out which Update Panel triggerred the postback? It appears that the Request["__EVENTTARGET"] is not a reliable way of doing this.
Answer: An UpdatePanel doesn't trigger PostBacks, it intercepts them. The originator of the PostBack would be something like a button. If you have event handlers for all your interactive elements, you naturally know which one fired by which event handler runs.
Comment: Yes, I should have said "control in an Update Panel triggerred the postback". I have multiple instances of the same user control that has an updatepanel within it.
Comment: @unknown so the event handler in the correct instance of the user control should fire. It might be easier to help if we know what you're trying to accomplish.
Answer: you can get the id of the postback element on the client with the following
function pageLoad(sender, args) {

// add function to the PageRequestManager to be executed on async postback initialize
var prm = Sys.WebForms.PageRequestManager.getInstance();
      prm.add_initializeRequest(InitializeRequest);
}

function InitializeRequest(sender, args) {
    if(args._postBackElement.id === 'id_of_element_in_question' {
        // do whatever
    }
}

to get it on the server, presumably you'll know which control/event raised the postback as it will be handled in the relevant event handler in the code-behind.

Multiple Update Panels


motd displayed twice

Question: So here's the deal. I've created /etc/motd.tail as suggested by Ubuntu documentation which should append STATIC content to /etc/motd . However as well as this work, it displays the MOTD TWICE when I log on to the server via ssh.
W00t ?! Is there any way to fix this ? This does seem like a bug to me.
Thanks
Answer: For me it was two places causing motd to be displayed twice:

pam.d
sshd

1
~> cd /etc/pam.d
~> grep -i motd *
and then editing /etc/pam.d/sshd to hash out these two lines:
session    optional     pam_motd.so  motd=/run/motd.dynamic
session    optional     pam_motd.so noupdate
(May differ from version to version so confirm with grep output.)
2
My /etc/ssh/sshd_config also had #PrintMotd=yes (default is yes so it was active even if it was #'d out)

In the end I set /etc/ssh/sshd_config MOTD option to PrintMotd=no (not removed the # and set to no to replace the default) and enabled the /etc/pam.d/sshd motd lines so the /etc/ssh/sshd_config option printlastlog=yes will print the last login information after the pam.d motd is displayed.
Pam will also use the options in /etc/update-motd.d/ to customise the /etc/motd as well which sshd will not do as it will simply display what is already there.
Answer: Bug, no...
It sounds like you have something wrong in your ~/.bashrc file. Look and see if there are any lines which add motd.tail. Maybe look for motd*?
If that doesn't work, just append directly to MOTD. Command:
sudo -i
cat /etc/motd.tail >> /etc/motd

Then, you can (if you want), rm /etc/motd.tail.
Get out of root by exiting.
Just remember to directly edit the motd file as a workaround.
Comment: Its a fresh install. So, if there is something weird with the bashrc files it certainly hasn't been updated by us :(
Updating motd directly defies the point of motd.tail - isn't that going to be overridden. My understanding is that motd is DYNAMICALLY created whilst motd.file should contain just static content.

motd displayed twice


Use Investment Bank Report as Reference?

Question: I'm writing a thesis on a financial topic and some important arguments for my research can only be found in reports from investment banks, not scholarly sources. I think it's because the topic is very new but right now I'm not sure how 'respected' a bank report reference is. I'm talking UBS, Citibank,... The topic concerns QE causing distortions in the stock market. Is it considered acceptable to use a bank report as a source in a thesis?
Comment: This seems like a question for an expert in your field, and would probably depend on what information you're using and in what context.  For instance, if you want to discuss Citibank's profits in some year, a Citibank report would be an excellent source for that.
Answer: Citing grey literature, such as investment bank reports, isn't unheard of.
There are a few caveats.

Discuss it with your supervisors early on: they will know the whens and hows of acceptable grey-literature citations.
It may not be easy to find useful citation metadata such as named authors.
Your reviewers / examiners may not be able to accesss the report, and that would be problematic for them, and thus for you.
You should not build arguments that are grounded only in grey literature. Corroborate with peer-reviewed literature wherever possible, even if it's just corroborating one aspect of the points you're taking from the grey literature.
Business reports often have some wacky form of encryption that hinders text searching, which can make including them in your literature review somewhat hazardous.
Answer: Using a bank report is acceptable unless it appears as though there is some bias present. QE and its impacts are a hot topic so you are likely to find it written quite heavily about in bank reports and the like. However, you must be on guard that what is being written is not really sales literature.
If the statements is "You would be reckless with your finances to ignore the impact of QE so come and let us make your money work for you!" then you might want to avoid it.
Just follow common sense about critical reading and how to evaluate your source reading material. If the source seems credible and the content seems unbiased then there should be no problem citing it.
As EnergyNumbers wrote, it is always better if others have access to the report but even if others do not, that should not stop you from including relevant information. Use the best source material you have, wherever you can find it.


Did Dumbledore have a plan for killing Voldemort?

Question: Chapter 33 of Deathly Hallows tells us all that we really need to know about Dumbledore's plan to make sure that once Voldemort dies, he stays dead. However, I can't find anywhere in the series that tells us how Dumbledore planned to have Voldemort killed in the first place. We already know from chapter 35 of Deathly Hallows that what we see happen with the Elder Wand wasn't a part of Dumbledore's plan and I can't think of anyone who would've had a good shot at beating him fair and square, so what was the plan?
Comment: Sure, but at least your enemy isn't *immortal*
Comment: @Valorum And going by the last war, I guess that it'll take about a decade to solve that problem?
Comment: Once his horcruxes are destroyed, he's merely a powerful wizard.
Answer: Yes, he had a plan, but it was not always the same plan.
Dumbledore's first goal was always to eliminate Voldemort's Horcruxes, since he was well aware that, once these were destroyed, anyone could kill Voldemort, at least in theory. A Dark Lord who can be downed by a stray spell from an Auror is far less dangerous than one who can resurrected by his followers as many times as necessary. It is true that Voldemort and his Death Eaters fought the entire Ministry of Magic in the first war, and were winning,  but the fact that Voldemort escaped unscathed from most of those battles was, if not really coincidence, certainly not an inevitability. We saw that three skilled magic-users could give him quite a hard time in Deathly Hallows. Dumbledore was, of course, aware of the diifficulty:

"Yes, I think so," said Dumbledore. "Without his Horcruxes, Voldemort
will be a mortal man with a maimed and diminished soul. Never forget,
though, that while his soul may be damaged beyond repair, his brain
and his magical powers remain intact. It will take uncommon skill and
power to kill a wizard like Voldemort even without his Horcruxes."
Harry Potter and the Half-Blood Prince

I have no doubt that initially, he planned to try to kill Voldemort himself, once all the Horcruxes were eliminated.

'You do not seek to kill me, Dumbledore?' called Voldemort, his
scarlet eyes narrowed over the top of the shield. 'Above such
brutality, are you?'
'We both know that there are other ways of destroying a man, Tom,'
Dumbledore said calmly, continuing to walk towards Voldemort as though
he had not a fear in the world, as though nothing had happened to
interrupt his stroll up the hall. 'Merely taking your life would not
satisfy me, I admit –'
Harry Potter and the Order of the Phoenix

Merely taking his life would not satisfy him, because he needs to destroy the Horcruxes first. However, whatever Voldemort says with regard to the nonlethal spell that Dumbledore used there, the latter is clearly not making much of an effort to avoid killing the former in the battle: he tries to suffocate him under a mass of water, wrap him in a rope of flame, and more. Besides, when Snape first betrayed Voldemort to Dumbledore, he was afraid that he would kill him, suggesting that he had been willing to use lethal force against the Death Eaters in the first war.
Dying was not on Dumbledore's to-do-list until near the beginning of the sixth book, when his carelessness with the Resurrection Stone left him with a debilitating and inevitably fatal curse. Naturally, Dumbledore himself, with the appropriate backup, would have had by far the best chance of defeating Voldemort once the Horcruxes were destroyed.
After Dumbledore contracted the curse, his original plan became untenable, so he moved onto another one. Perhaps the querent thought Dumbledore did not plan for Harry to survive, but that is incorrect. He did not plan for Harry to get the Elder Wand, but Harry's survival would have been assured by Voldemort having taken his blood:

"Precisely!" said Dumbledore. "He took your blood and rebuilt his
living body with it! Your blood in his veins, Harry, Lily's protection
inside both of you! He tethered you to life while he lives!"
Harry Potter and the Deathly Hallows

Dumbledore had known, or strongly suspected this, since the fourth book: that is why he had a "look of triumph" in his eyes when Harry explained to him that Voldemort had taken his blood.
Now, Dumbledore knew that Harry would survive, and he did believe that Harry had the power to take on Voldemort. Right after the first quote that I mentioned, Dumbledore says that Harry does have uncommon skill and power, particularly insofar as his ability to love provides him with a strong weapon against Voldemort—in fact, based on the way Dumbledore described his protection, it is possible that Voldemort or anyone else would have been incapable of killing him permanently as long as Voldemort was alive.
In addition, love is the basis of many other types of powerful magic, but even setting that aside, Harry is rather skilled at Defense Against the Dark Arts, by which I mean that he appears to be the best witch or wizard of his generation in that regard: he got an Outstanding when Hermione received an Exceeds Expectations, and his ability to produce a corporeal Patronus at 13 was little short of extraordinary. With more practice, he could have been a formidable opponent on the basis of skill alone.
In the end, though, I think there was some degree of desperation or hope in Dumbledore's plans near the end. He did not know for certain that anyone could kill Voldemort, not to mention defeat his Death Eaters, once all of his Horcruxes were destroyed, but he knew that they would at least have a chance. Eliminating Voldemort's immortality was the top priority.
Comment: "his carelessness with Slytherin's locket" - Don't you mean the ring?
Comment: Killing Voldemort permanently requires the destruction of the Horcruxes, so killing him would have satisfied Dumbledore, but was not possible at that time. Don't assume that what he says to an enemy during a fight is true. Even if Voldemort can't kill Harry, he could capture him and leave him to rot in Azkaban, besides it is not sure that Harry would survive a second killing curse. I think the formulation "there was desperation or hope in his plans" is too kind as a description for his actions. He didn't even make sure Harry got the sword.
Comment: "We saw that three skilled magic-users could give him quite a hard time in Deathly Hallows." - Doubtful, they were under the protection from Harry's sacrifice.
Answer: There isn't any indication in the books that Dumbledore really had a plan about Voldemort.
There is an indication that Dumbledore had a plan about the elder wand, and that plan didn't work (fortunately).

"I admit that was my intention," said Dumbledore, "but it did not work as I intended, did it?"

What we know is that that Dumbledore wanted Harry raised like a pig for slaughter. When Snape mentions that, Dumbledore doesn't deny, he just changes the topic.

"I have spied for you and lied for you, put myself in mortal danger for you. Everything was supposed to be to keep Lily Potter's son safe. Now you tell me you have been raising him like a pig for slaughter —"

That is consistent with how Dumbledore had Harry raised, and he admits that he knew that, even before he placed Harry with his relatives:

"You had suffered. I knew you would when I left you on your aunt and uncle's doorstep. I knew I was condemning you to ten dark and difficult years."

Why Dumbledore thinks this is a good idea is not explained. He has a prophecy that states

The one with the power to vanquish the Dark Lord approaches.

But his plan is that the one with the power to vanquish shall not use that power, but he shall let himself be killed.
In a comment, Valorum argues that after the horcruxes are destroyed, he can be killed. But with Dumbledore and Harry gone, and the ministry under his control, he is most likely to die of old age. And Harry would be dead, if not for the ownership of the wand.
We see that Umbridge uses the opportunity to send all muggleborn and halfbloods to Azkaban.

"No, no, I'm half-blood, I'm half-blood, I tell you! My father was a wizard, he was, look him up, Arkie Alderton, he's a well-known broomstick designer, look him up, I tell you" ...
"Take him away," said Umbridge.

So it seems Dumbledore had no problem with this development. By the time Voldemort would die, the muggle-born would be all dead, the pure-bloods in charge and the half-bloods would be servants. And after Voldemort's death, there would be no change, because that is exactly what Malfoy and his friends want, and they don't need Voldemort for that.
Comment: "So it seems Dumbledore had no problem with this development." Actually, there is a lot to indicate that Dumbledore was rather opposed to things like Umbridge and Voldemort running the Ministry of Magic, not least that he dedicated years of his life to avoiding it. He was not exactly chummy with the Malfoys, either. As a side note, where did you get "the half-bloods would be servants"? That is not what happened when Voldemort took over.
Comment: Also I do not think Voldemort can die of old age....
Comment: @Adamant Voldemort may or may not die of old age, especially of the only one who can kill him is already dead, but it is the best case scenario of what Dumbledore planned for. Dumbledore may be opposed, but that's what his plans lead to. He was also the one to bring Umbridge back from the centaurs. Halfbloods in Azkaban or as servants, because the pure-bloods need some people to actually work.
Comment: No they don't, because they can wave their wand and make chores get done, and in any case they enslave house-elves to do precisely that.
Comment: @Adamant Whether the half-bloods end up in Azkaban or some other lace is really just a minor point. The point is that Voldemort and the pure-bloods would have won the war if everything had gone according to Dumbledore's plan or lack of planning.
Comment: Well, only if you ignore the details indicated in my answer about the plan that Dumbledore actually had.  Also, how carefully have you read the series? Half-bloods were at little risk from Voldemort's regime: while Voldemort exalts blood purity, he simply cannot (and perhaps would not) propose any measure against half-bloods, who are quite possibly a plurality of the magical community. Don't forget, most of the Death Eaters are actually half-bloods, as is Voldemort himself. Only Muggle-borns and opponents of the regime were subject to arbitrary imprisonment or execution.
Comment: @Adamant I did read the books, and I did read your answer. I didn't find a reference to a plausible plan in your answer, and you write "there was desperation or hope in Dumbledore's plans", which is a kind way to say he had no plan and hoped for the best. Maybe Harry can't die while Voldemort survives, although the prophecy says "neither can live", but that doesn't mean he would win. And although I mentioned Umbridge sending also a half-blood to Azkaban, that is really just a minor point of the answer.
Comment: Bearing in mind the rather large number of half-bloods whom they did not lock up, such as a number of students at Hogwarts, I assumed that was one of two things: most likely, a lie, since they were about to send him to Azkaban and he would have said anything to prevent it; or, contrariwise, he had been accused of being Muggle-born due to his being inconvenient for the regime.
Answer: To me it is clear that, because he insisted that it is essential that Voldemort kills Harry, he expected that when Voldemort did manage to kill Harry, then because of the fact that Voldemort used Harry's blood, Voldemort himself would also die at the same time.  Of course, what actually happened is that, since Harry didn't die, Voldemort survived as well.
Comment: I'm not sure this necessarily has to be true. Doesn't he want Voldemort to "kill" Harry to destroy the Not Horcrux and fulfill the prophecy rather than because he thinks they'll both die?


Is Durarara SH a sequel to Durarara x2?

Question: Is Durarara SH a sequel to Durarara X2? do I need to read Durarara X2 to understand it?
Answer: Yes, Durarara SH is set 1.5 years after the end of Durarara!! A majority of the main cast returns. You probably do /have/ to have read all of Durarara to understand it, but I'd recommend it.

Is Durarara SH a sequel to Durarara x2?


Listing files in a directory including contents of subfolders with sorting

Question: I'm looking to list the entire contents of a directory, including the contents of subfolders but sorted by filesize.
Thus far I've managed to get as far as listing and sorting whilst still being recursive with ls -lhSR(the h is nice to have but definitely not essential for me, as long as I can get file sizes).
I am likely overlooking something obvious, or asking the impossible, but any advice here would be greatly appreciated.
Answer:
You can use find:
find . -type f -printf "%s %P\n" | sort -n

Optional: To convert byte values to human-readable format, add this:
| numfmt --to=iec-i --field=1

Explanation:
 find in current directory (.) all files (-type f)

 -printf: suppress normal output and print the following:
     %s - size in bytes
     %P - path to file
     \n - new line

 | sort -n: sort the result (-n = numeric)

Comment: I'm glad my answer helped you. Please consider clicking the checkmark on the left side to mark the answer accepted. Thanks.
Comment: @RoVo it would also be nice to upvote the question since, given that you've answered it, you probably found it interesting and useful.
Comment: Oh perfect! Thank you so much, this did exactly what I needed!
Comment: This is indeed true and I did this now ;-)
Comment: @toms It's OK to wait a while (maybe a day or so) to accept the answer, even when it's as good as this one.  Once the answer is accepted, there's no way for another answer to turn out to be even better. And because of that, a lot of people won't bother to submit any other answers, so we don't get a chance to see them to find out if one's better.
Comment: @MontyHarder OP is actually able to change the accepted answer, but you're right of course. I added my answer below. :)
Comment: Why `-type f` instead of `-not -type d`?  The OP didn't ask for it to be restricted to regular files.
Comment: What other [type](https://www.gnu.org/software/findutils/manual/html_mono/find.html#Type) do you think of?  I'd say regular file is the only type that makes sense.
Answer:
Since you didn't specify a particular shell, here's an alternative using zsh's glob qualifiers with
setopt extendedglob

for the recursion. Then for example:

recursively list plain files:
printf '%s\n' **/*(.)

recursively list plain files, ordered by increasing Length (i.e. size):
printf '%s\n' **/*(.oL)

recursively list plain files, Ordered by decreasing size:
printf '%s\n' **/*(.OL)

recursively list plain files, ordered by decreasing size, and select the top 3 results:
printf '%s\n' **/*(.OL[1,3])

If you want the file sizes as well, then you could use
du -hb **/*(.OL[1,3])

Answer:
With the globstar shell option set you can use shell globbing:
shopt -s globstar         # don't match hidden files
shopt -s globstar dotglob # match hidden files
stat -c"%s %n" **/* | sort -n

If you try that with too many files, you'll get an "Argument list too long" error. To work around that, you can use printf and xargs:
printf "%s\0" **/* | xargs -0 stat -c"%s %n" | sort -n

I just realized this prints the directories (with a size of 4096 bytes) as well – if you don't want that, use this instead:
stat -c"%A %s %n" **/* | sed '/^d/d;s/\S* //' | sort -n
printf "%s\0" **/* | xargs -0 stat -c"%A %s %n" | sed '/^d/d;s/\S* //' | sort -n

Example run
$ tree
.
├── edits.png
├── makescript
├── new
│   └── edits.png
└── test
    └── 1.png

2 directories, 4 files
$ stat -c"%s %n" **/* | sort -n
0 test/1.png
43 makescript
2160 edits.png
2160 new/edits.png
4096 new
4096 test
$ stat -c"%A %s %n" **/* | sed '/^d/d;s/\S* //' | sort -n
0 test/1.png
43 makescript
2160 edits.png
2160 new/edits.png

Comment: Nice solution. Compared to find, it doesn't include hidden files, how to achieve that?
Comment: @RoVo Always forget about these – you just need to set the `dotglob` shell option, see my updated answer.
Comment: Instead of stripping directories after the fact with sed, you could consider something like `printf "%s\0" **/* | xargs -0 sh -c 'for f; do [ -d "$f" ] || stat -c "%s %n" "$f"; done' sh | sort -n`
Comment: You can use `ls -lhSd **/*` if you don't mind having the directories as part of the list.  Or if none of your directory names have `.` in them, and all the files you want *do*, you can `ll -hS **/*.*`, or similar.
Comment: turned that into [an answer](https://askubuntu.com/questions/1046563/listing-files-in-a-directory-including-contents-of-subfolders-with-sorting/1046865#1046865)
Comment: @steeldriver Good idea, but that's 20 times slower than the approach with `sed` in my tests, so I'll leave the answer as it is.
Answer: If you don't have zsh, you can still use du + sort:

Human-readable sizes, including cumulative sizes of directories:
du --apparent-size -ah0 . | sort -zh | xargs -0L1

Only files (using find):
find . -type f -print0 |
  du --files0-from=- --apparent-size -ah0 |
  sort -zh |
  xargs -0L1

In both cases, I have opted to use null-terminated lines (-0, -z, -print0 options), to be safe against all valid filenames.
Answer: For quick interactive use on directory trees that aren't too huge, shopt -s globstar is really nice.  A glob can't filter out directories based on type, but if you use it with ls -d then ls will just print the directory name, instead of the contents.
Assuming your ll alias includes -lh:
  # with  shopt -s globstar   in your .bashrc
ll -rSd **/*

will give you output like this (from my code-golf directory), but with colour highlighting (so it's easier to see the directories).  Note that sorting by filesize happened across subdirectories.
drwxr-xr-x 1 peter peter   70 Jun  8 07:56 casexchg
...
drwxr-xr-x 1 peter peter  342 Mar 13 18:47 parity-party
-rw-r--r-- 1 peter peter  387 Jul 29  2017 likely.cpp
-rw-r--r-- 1 peter peter  416 Aug 31  2017 true-binary.asm~
-rw-r--r-- 1 peter peter  447 Feb 23 20:14 weight-of-zero.asm
...
-rw-r--r-- 1 peter peter 6.4K Jun  1  2017 string-exponential.asm
-rwxr-xr-x 1 peter peter 6.7K Aug 31  2017 true-binary
-rwxr-xr-x 1 peter peter 6.8K Sep 17  2017 dizzy-integer
-rw-r--r-- 1 peter peter 7.5K Jul 24  2017 fibonacci/fibonacci-1G.v3-working-32b-stack-except-output.asm
-rw-r--r-- 1 peter peter 8.4K Jul 25  2017 fibonacci/perf.32bit-pop-114limb.sub-cmc.1G~
-rw-r--r-- 1 peter peter 8.4K Jul 25  2017 fibonacci/perf.32bit-pop-114limb.sub-cmc.1G
-rwxr-xr-x 1 peter peter 8.4K May 19 04:29 a.out
-rw-r--r-- 1 peter peter 8.9K Jul 25  2017 fibonacci/perf.python-xnor-2n
-rw-r--r-- 1 peter peter 9.5K Jul 26  2017 fibonacci/fibonacci-1G-performance.asm
-rwxr-xr-x 1 peter peter 9.6K Apr 12 23:25 empty-args
-rw-r--r-- 1 peter peter 9.7K Dec 18 17:00 bubblesort.asm
-rwxr-xr-x 1 peter peter 9.9K Feb  6 23:34 parity-party/a.out
-rw-r--r-- 1 peter peter 9.9K Jul 25  2017 fibonacci/fibonacci-1G-performance.asm~
...

You could filter out the directories by piping through grep -v '^d'
You can sometimes use a glob that matches only files and not directories, if your filenames have a pattern.  e.g. ll -rSd **/*.jpg, or even **/*.* works if none of your directory names have . in them, and all the files you want do.
(For people with a DOS background: there's nothing magical about *.* on Unix.  It just matches any directory entry that contains a literal dot.  But other than executables and sometimes text files, it's common to give extensions to filenames.)
@dessert points out you would need shopt -s dotglob for it to match all files.

With GNU find
If there aren't too many files to fit on one ls command line, find -exec ls {} + will put them all on on command line where ls can sort them.
find -not -type d -exec ls --color -lrSh {} +

Using -not -type d instead of -type f avoids ignoring symlinks, named pipes, sockets, device files, and whatever else you have kicking around in your directories.

With du:
du -ach | sort -h
....
4.0K    x86-modedetect-polyglot.o
8.0K    ascii-compress-base.asm
8.0K    dizzy-integer
8.0K    stopwatch-rdtsc.asm
8.0K    string-exponential.asm
8.0K    true-binary
12K     a.out
12K     bubblesort.asm
12K     casexchg
12K     empty-args
100K    parity-party
220K    fibonacci
628K    total

Now directory names are sorted into the list with to sum total of all their contents, but individual files are still included.
sort -h, aka --human-numeric-sort, sorts numbers with size suffixes like du -h prints.  It's perfect for use with du.
I often use du -sch * | sort -h, or */ to get only directories.
du -sch **/* | sort -h would give you the above output, if you forget that du has a -a option.
(I only took the time to look it up because I'm posting an answer.  For interactive use, I probably would have just used du -sch **/*.


Why would I want to import finished goods?

Question: I get that importing raw materials for manufacturing is a great way to make money. I can also see why importing food might be necessary.
However, I also see trade routes for Rum, Weapons, Cigars, and other finished goods, often at a markup. Whhy would I spend money and trade routes on those things? Will Tropicans actually use them and, if so, what are the benefits?
Answer: You never ever want to import finished goods aside from these 2 conditions.

Unless your map doesn't allow you to gather raw materials and it's required for a mission. For example, stealing a wonder and you want to complete it quickly.
You're so rich and your goal is to raise happiness for your Island to the highest level.

Otherwise finished goods are extremely expensive and can make you go broke quickly.
Your citizens will absolutely use some of the finished goods that can be sold in the Grocery or Shopping Mall.
If memory serves me correctly these are the finished goods that can be consumed:

Rum
Chocolate
Cheese (Creamery)
Cigars
Juicery
Cannery

Unsure about: Furniture, Jewelry, Clothes
Answer: To my understanding, Tropicans will use them and it will contribute to fun and food satisfaction (diversity of available products is a positive factor for fun and food quality).
You can also imports only to export later at a higher price (if you have good relations for instance). And sometimes you have to import something to fulfill a request, this is the main reason (if not the only) I found myself importing goods to be honest.


How can I print recipient mail address in webform email handler body with twig?

Question: In the webform e-mail handler configuration I can see that webform twig variable is available. I looked to the context with xDebug and it looks like I should be able to print e-mail address of the recipient with in the mail body. But it doesn't work, the body is empty. Do you know why and how can I fix this?
{{ webform.handlers.e_mail.settings.to_mail }}

Edit: I also tried to use token like this:
{{ webform_token('[webform:handler:e_mail:settings:to_mail]', webform_submission, [], options) }}

,but the token didn't get replaced.
Answer: The module maintainer says it's by design: https://www.drupal.org/project/webform/issues/3231110


Friends blocks not showing up

Question: My friend and I are playing Minecraft PE on two different devices both on the newest version of Minecraft and whenever he places a block its always the same. For example if he tries to place a diamond block it shows up as cobblestone.
Answer: That happens to me to whenever I play with my brother. The block or the object you want to put down has to be on the first GUI to get it working. I had the same trouble.

Friends blocks not showing up


How to make CTRL+L lock screen in ubuntu 14.04 without gnome-settings-daemon

Question: I use IceWM without gnome-settings-daemon. How to make CTRL+L combination to work as in native ubuntu environment?
Comment: This question would be better if you indicated *how* Ctrl+L works in the "native Ubuntu environment", since that would allow anyone with knowledge of IceWM to answer. As it currently stands, only people familiar with *both* Ubuntu *and* IceWM would likely be able to offer an answer, severely limiting your possible respondent base.
Answer: Add
<code>key "Ctrl+l" xlock
</code>
to ~/.icewm/keys.  Restart IceWM.  Of course, you'll need xlock installed for this to work.


In statistical mechanics, why do we consider number of states of a system in energy interval?

Question: In statistical mechanics,when we go for calculating the no. of accessible micro states of a system, I notice that we always calculate the no. of micro states of that system in some energy interval say between $E$ and $E+dE$ instead of calculating the no. of micro states at particular energy $E$. Even,in micro canonical ensemble,in order to calculate the entropy of a system we use the renowned formula $$S=k \ln W$$
where $W$ is the number of accessible micro states of the system in energy interval between $E$ and $E+dE$ but not the micro states at energy $E$. So my question is why we always calculate micro states in enery range $dE$, but not at a particular energy $E$ of the system?
Comment: Please don't shout at us.
Comment: If I randomly pick a number between 0 and 1, what is the probability that it will be, say, 0.5?
Answer: Disclaimer
I prefer the notation $E+\Delta E$, because I want it to be clear that we are talking about a finite quantity (i.e. nowhere we will take the limit $dE \to 0$ or such things).
Theoretical point of view
You can surely consider the states with energy precisely equal to $E$ and define the microcanonical probability density as
$$\rho(p,q) = C \cdot \delta(H-E)$$
where $C$ is a constant and $H=H(p,q)$ is the Hamiltonian. This is for example what Landau does in his book.
However, it can be shown that for large $N$ this definition is equivalent to
$$\rho(p,q)=C' \cdot \int_{E<H<E+\Delta E}d^{3N}pd^{3N}q$$
for a suitable constant $C'$ and for some constant $\Delta E$, which doesn't even necessarily be "small" (see for example my answer here, or Tuckerman's book).
Experimental point of view
There will always be some uncertainty on the measurements you can effectuate of the system's energy. If you want, this $\Delta E$ represents this uncertainty.
Therefore, while from a mathematical point of view it makes perfect sense to take $\delta(H-E)$ as your probability density, form an experimental point of view it makes much more sense to consider energies in some finite interval.
Addendum about entropy
If all you want is to calculate the entropy, things get even "easier". Indeed, the high dimensionality ($6N$) of phase spaces makes it so that you can equivalently define the entropy as
$$S = k_B \log \int_{E<H<E+\Delta E}d^{3N}pd^{3N}q$$
$$S = k_B \log \int_{H<E}d^{3N}pd^{3N}q$$
or even
$$S = k_B \log \left( \partial_E \int_{H<E}d^{3N}pd^{3N}q\right)$$
where $\partial_E$ is the partial derivative with respect to $E$.
The difference between these definitions will be a constant of order $\log N$ or smaller, irrelevant since $S$ is of order $N$ (see Huang, Statistical Mechanics).
Comment: @pragyanpratimbordoloi If this answer solved your doubt, you can consider accepting it.


How can i fix sweating Duct work in my unconditioned garage?

Question: I had a water stain appear in my garage right near where the main AC trunk comes up the center of the house.  Of course at the time I did not know this I thought i had a leaking pipe.  After I opened up the ceiling I found that it was a duct that was leaking.  The insulation was completely soaked.  I took off the insulation and the duct was rusting away.  I guess this has been a problem since I bough the house.  The builder said its because they did not spray foam around the joints where the duct cuts through the joints.  I took down the dry wall to inspect the rest of the ducts and looks like there are several places where they did not tape it well and there are small gaps where hot air can get to the duct.  What should I do to fix this?  The insulation is R8.3 fiberglass.  Should I take all that out and wrap the duct in a better type of insulation?  The rust did not eat through the duct so I hope I don't have to replace any of it.  Any guidance you could provide on the best course of action would be greatly appreciated.  The house is out of warranty and my insurance considers this a maintenance issue so I am on my own to pay for this fix.enter image description here
Answer: Air seal with air duct sealant (a gray goo that hardens after it's brushed on or applied with a putty knife), not duct tape, and insulate, preferably a LOT better than R8 (your heating/cooling cost is hugely affected by poorly insulated & leaky ducts in unconditioned space.)
You can reinforce the duct sealant by embedding fiberglass mesh drywall tape in it. I don't suggest using duct tape because it has a habit of falling off after a few years.
Answer: If accessible and on a flat surface area( the rust and corrosion) Home Depot has what is called self leveling cement. Mix a batch and coat worn areas with it and this will be what the industry calls " a restoration" which may last 10+ yrs.
Hope this helps!


Labelled dataset for NLP regression

Question: I am looking for a dataset, where I could use NLP techniques to estimate target value using regression. For example, I could be give a few sentences that describe an accident, and the target value would be the cost of an accident. Kaggle has quite a few datasets for NLP, but they  all, as far as I can see, for classification.
Answer: I know of a good few NLP regression tasks, but these are usually not about a predicting an extrinsic value from the semantic description, but rather predict some numerical property of the text itself:

MT quality estimation: predict the quality of a translated sentence, usually as a score. Data available at the WMT QE Shared Task series. There are probably other similar datasets about predicting the quality of a sentence in general.
Author profiling: predicting the age of the author of a text. Some datasets exist in particular through the PAN workshop series.
Predicting a rating based on a comment - there's data everywhere on social media, Amazon etc. You could even use StackExchange posts and predict votes :)

I'm not aware of any data similar to your example (btw it would be a very challenging task). I know that there are some works on detecting fraud from the text of an insurance claim, so maybe there are datasets that you could use in this area.

Labelled dataset for NLP regression


What's a good way to insert Latex math onto this site?

Question: I understand LaTeX math is not supported.  I'm looking for a recommendation on how to take math expressions, render them, and insert them into an answer on this site.
Answer: There are external editors like Codecogs
which convert a LaTeX(-like) expression into an image, which you can then embed in your post (either directly or by uploading the image with the built-in image uploader).
Answer: You can use a function found here to actually view TeX in the site. Click on the first link to do so.
As said in the site, drag it to your bookmarks so you can reuse whenever you want.


Is there any rule in recursion?

Question: recursion is the ability to place one component inside another component, so is it only for the same kind such as NP with NP, PP with PP, and etc?
Comment: What theory are you interested in? See these question for some information: [What's the difference between recursion and embedding?](http://linguistics.stackexchange.com/questions/5875/whats-the-difference-between-recursion-and-embedding), [What is recursion?](http://linguistics.stackexchange.com/questions/3252/what-is-recursion?lq=1)
Comment: A dominating A is pretty much the definition of recursion.
Answer: A recursive phrase structure rule is one with the same symbol occurring in the string on the right hand side of the arrow and on the left of the arrow.  For instance "N -> N and N".  A recursive set of phrase structure rules is one which permits a phrase structure derivation in which a symbol can be rewritten as a string containing that same symbol.  For instance "NP -> Det N, Det -> NP 's", which permits the psg derivation:
<code>NP
Det N
NP 's N
</code>
whose last line has "NP" recurring in the string "NP 's N".
In order to generate an infinite number of sentences, a psg has to be a recursive set of rules.
A tree which has a symbol dominating itself could only be generated by a recursive psg.  However, trees are often cited which are supposed to have some source other than a psg, so just because you see a tree with a recursive symbol, that doesn't necessarily have any interesting grammatical consequences.

Is there any rule in recursion?


My SSD doesn't have enough space to upgrade to windows 8

Question: I am trying to update my Windows 7 PC to Windows 8 and am having problems with the space on my C: drive.  I have two drives in my computer, one 64 GB SSD (my C:) which has my windows 7 on it and a 1 Tb HDD (my E:) that I use for all my big programs and games.  When I go to upgrade there is only 6 GB of space on my SSD and it needs 20 GB.  Whats the best way to free up space on my C: drive without reinstalling all of my programs? Or can i install Windows onto my E: and somehow transfer it over to my C:?
Answer: Why bother upgrading? Programs installed in Windows 7 will probably require a reinstall, so unless you have personal files in C drive, you can format it and do a full reinstall.
As far as I have tried, promotional Windows 8 Pro allows installing even if there is no Windows 7 on the computer, although the promotion requires that you have bought Windows 7.
Answer: Well, C: and E: are different partitions. So, upgrade means that Win 8 has to come in C: drive.
And you have 64 GB almost filled up, so sadly you have to uninstall some software and free up space in your SSD.
And as said above. programs installed in Win 7 might need to be reinstalled to work with Win 8
Answer: Run Disk Clean up. Uninstall programs that your not using. Otherwise format the C drive and install Windows 8 Fresh on the SSD


Maximum input argument length limit for uint256 array

Question: I have a public function which takes in a uint256[] memory input argument. I tried passing it an array of ~1000 elements in an array and it constantly failed with failing gas estimation. But, it works with ~150 elements - i'm continuing to test with higher length arrays but was wondering if there's a limit specified somewhere?
Answer: I don't think there's an explicit limit for an array size in a parameter. But the limit is caused by hitting the a gas limit.
You need to pay gas for each byte of data you input in your transaction, and per every operation the transaction triggers. If the combination of these two is too high, the transaction is reverted because it runs out of gas. Your wallet is also smart enough that it detects this failure and doesn't even let you execute the transaction.
If you have defined an explicit gas limit for transactions, you can make that higher. Otherwise you're simply hitting the network's block gas limit, which depends on the used network.
Furthermore, there's the possibility that your code simply reverts for some code-related reason.
Comment: For the same of completeness I'd add that there's a draft EIP that would impose a hard limit on the size or `calldata`: [EIP-1985](https://eips.ethereum.org/EIPS/eip-1985). The limit would still be pretty high though (~4GB) so you are not likely to hit it before you run out of gas.


Is it better to wire power to your switches or your fixtures first?

Question: Given the option, is it better to bring power to your switches first, then run wires to your lights? Or is it better to bring the power to your lights first, then run wires to your switches? Or does it matter?
Comment: No.   I'm quite serious: if you're even considering this question, please hire a professional before you kill yourself by putting power where it shouldn't be.
Comment: If you run hot to the lights first, then they are hot even if the switch is off. If you do any sort of work on the wiring without turning off the breaker, you stand a good chance of ending your existence.
Comment: @CarlWitthoft I just finished talking with a journeyman electrician about how to rewire a job that was previously done poorly. He threw out some suggestions that didn't seem to be the most economical, and I'm not sure if that has anything to do with him being near retirement and maintaining some older practices, or if there's more to it than that.
Comment: If the line comes into the box of the light fixture, there would obviously be hot wiring in the box, but the light fixture itself would not be hot if the switch is off. The hot of the fixture is wired to the switch in the wall and if this is off, then one can work on the fixture without turning off the breaker. Personally, I like to have the line in the switch box, but my experience is so limited that I probably don't realize that in some cases other considerations make it convenient or even necessary to have the line in the box for the fixture.
Comment: @BillOertell even in that case, the always-hot wires from source and to switch-loop will be pushed up into the back of the box.  The wires you disturb to change the fixture will be de-energized if the switch switches hot and it's off.  Nonetheless, the vast majority of users here will shut off the breaker when doing such work.
Answer: For new installations, the important thing is really getting neutral to the switch location.

NEC requires it (in most cases) as of the 2014 edition

Chapter 4 Equipment for General Use
Article 404 Switches
404.2 Switch Connections.
(C) Switches Controlling Lighting Loads. The grounded circuit conductor for the controlled lighting circuit shall be provided at the location where switches control lighting loads that are supplied by a grounded general-purpose branch circuit for other than the following [...]

It allows you to use more advanced switches (timers, motion sensor, lighted, and/or 'smart' switches)

To get a neutral to the switch you generally either need to:

Run power to the switch first
Run a 3-conductor (eg 14/3) between the switch and power location (carrying neutral, hot, and switched-hot).

Given 14/3 is more expensive than 14/2, in most cases, I'd say run power to the switch first unless it's substantially father away from the power source than the lights (eg: the power-supplying wire passes your lights, then you have to double back with power to the lights).
If you only have a couple situations where you need this, it may not be worth it to buy a spool or some bulk 14/3, so it's ultimately a judgement call.
Answer: Since neutrals are now required at switch locations, it's theoretically "better" to bring the circuit to the switch first. However, it likely depends on the cost difference, and ease of installation between the two methods. Without more detail, it's impossible to say for sure.
Comment: @ShemSeger You should ask a new question for that specific scenario
Comment: So it depends sometimes on individual situations? I have one switch at the top of a set of stairs that someone wired to the lights, switches, and receptacles in two rooms in my basement. If you flick the switch, the power goes dead to both rooms. I want to rewire it so the receptacles still have power when the lights go out, and so you can turn the lights on in each room independently, as well as wire in a 3-way switch at top and bottom of stairs.
Comment: Right now the power goes to the light in the one room,  then to a receptacle, then to the switch in the second room, and finally to the light in the second room. My plan was to install a new 3-way switch at the bottom of the stairs, and wire it directly to a 3-way switch at the top of the stairs with 3-wire cable, then rewire the power downstairs so the receptacle always has power, and you can turn on the light in the second room without having the light on in the first.
Comment: @mmathis I'll draw up a wiring diagram then post it as a new question.
Answer: The question of "is it better" was actually determined by what the NEC code says. In a nutshell... the hot or supply wire needs to run into the switch box WITH its mated neutral wire first. The reasoning is that many of the new switches have circuitry in them that require a neutral and "end running" the switch doesn't provide that. Technically, and for liability purposes, if you touch it, it MUST be brought to code. However, in the scenario you brought up, all of that will be determined by exactly where that  circuit is fed from. If you are doing a 3 way switch, and following code, it has to be in one of the switch boxes. The outlet for that circuit can be tapped out of the box that has the hot but that hot won't be in a light fixture box.
Comment: You can provide a neutral on a switch loop, no problem -- just requires putting in a cable that's one wire fatter than you're used to.


How to identify the correct pronunciation for letter "g" before "i" or "e"

Question: It's really confusing when to be sure if the letter g is to be pronounced like giraffe or like girl. Both are followed by i. So how can we know the difference? On the other hand, we have gender and general. So is there a rule?
Comment: the question is broad. there's no one rule you'll have to practise it by reading words that begin with 'g'.
Comment: @MaulikV. As usual in English there are lots of exceptions, but there are some broad rules concerning the pronunciation of the letter g  and the question is very interesting to deal with. A shame it should be closed.
Answer: There are two ways to pronounce the letter "g" at the beginning of a syllable.
The hard g /g/
is the most common pronunciation. It comes:

before a consonant (great)
before a back vowel (go, garden, get)
before a front vowel in most words of Germanic origin (girl, gift,...)
at the end of a word (frog)

The soft g /ʒ/

It is extremely rare at the beginning of a syllable. The only words I can think of at the moment are

genre [ʒɒnrə].
bourgeois [ˈbʊəʒwɑː]

which are both loan words from French that have kept the French sound /ʒ/.
/ʒ/ is a little more common at the end of a word, but there again we only find it in loan words from French (rouge, garage)

/ʒ/ is more frequent in combination with /d/ in /dʒ/
It is the usual pronunciation if "g" is before the letters 'e', 'i' or 'y'.

giraffe [dʒɪ'rɑːf]
gin [dʒɪn]

This is only a general framework to start with and you will find exceptions of course. When you are not sure you can consult a dictionary, even online dictionary will give the IPA phonetic notation.
I've just found this online article Why are there two pronunciations for the letter 'G'? with a little humoristic touch on the pronunciation of GIF.
Comment: I think it's not very common to call /ʒ/ the "soft g" sound in English. Usually, that term would refer to the affricate [dʒ]. The sound /ʒ/ is only associated with "g" in recent loanwords. Maybe you could flip around the order in which you discuss those two sounds? Otherwise everything in this answer looks good to me.
Comment: @sumelic I don't quite understand what you are saying (I'm not a professional phonetician), do you mean you would not refer to the /ʒ/ sound (as in *beige* for example)  as a "soft g", but you would not say it is pronounced with a "hard g", would you? I know there would be a lot more to say about the pronunciation of the letter "g" but I suppose at the time I wanted to give a quick answer before the close suggestion became effective. I went from the most common sound to the least common, why do you think would the reverse order would be better?
Comment: Well, in English, the most common sound is /dʒ/ rather than /ʒ/. That's why I think it would make more sense to start with /dʒ/. I wouldn't say "beige" is pronounced with hard g, but it's not pronounced with a usual English soft g sound either. It's pronounced with a French soft g sound.
Comment: Is e a back vowel in 'get'?


How to automatically transfer cells from multiple sheets to one master worksheet in Excel

Question: I have a workbook with one master sheet, which lists all combined assets, and several sub-sheets (listing tangible assets, securities, etc.). For the sake of simplicity, assume the master sheet includes two columns: Name and Value. The sub-sheets include additional columns that don't need to be transferred to the master sheet (e.g., acquisition date, basis, etc.). For each new entry on an individual sub-sheet, I would like to insert a new row on the master sheet and add the relevant data to the cells.
Securities Worksheet:
Name      Value    Acquisition Date    Basis
AAPL      $450     1/8/2010            $211
GE        $2,500   11/1/2011           $1,500

Tangible Assets Worksheet
Name      Value    Insured
Jewelry   $6,000   Yes
China     $1,200   No

Master Worksheet - List of Combined Assets:
Name      Value
AAPL      $450
GE        $2,500
Jewelry   $6,000
China     $1,200

Can this be accomplished with an Excel formula, or will VBA be required?
Any suggestions on the best way to approach this would be much-appreciated.
Thank you.
Answer: This can be achieved using Get External Data (note, in spite of the name, this can be used to self-reference in a workbook)
This answer is based on Excel 2010.  If you are using a different version it's still possible, but menu's to access these features may be different.
Steps:

In the Master worksheet, from Data tab, select Get External Data / From Other Sources
Select From Microsoft Query
From the Select Data Source dialog, select Excel Files*
From the Select Workbook diaog, select the file you are working in
Microsoft Query should now be open, displaying the Add Tables dialog
Add Securities and Tangible Assets sheets
From Tangible Assets, double click Name and Value to add them to the query
Select SQL from the menu bar
Edit the displayed query to this, and accept:
(SELECT `'Tangible Assets$'`.Name, `'Tangible Assets$'`.Value
FROM `Securities$` `Securities$`, `'Tangible Assets$'` `'Tangible Assets$'`)
UNION
(SELECT `Securities$`.Name, `Securities$`.Value
FROM `Securities$` `Securities$`, `'Tangible Assets$'` `'Tangible Assets$'`)

You will get a warning, SQL query can't be displayed graphically. Select OK
Select Return Data to Excel from File menu.
Select where to place the query
It's Done!

Now, whenever your source data sheets are updated, refresh the Master query to get the latest data.
Comment: This looks like a nice, simple solution. Unfortunately, it doesn't seem to work on the Mac because Excel requires the use of a 3rd party ODBC manager.
Comment: I haven't tested it yet but it looks elegant!  I'll keep it in mind. I didn't know you could self-reference using _Get External Data_.