What was Hume's specific view with empiricism?

Question: I've stumbled across empiricism and Hume's view on it. It really interests me, but with the sources I've encountered, I still lack a clear understanding of his view on it.
Comment: Stumbled??!!
Comment: Bon voyage. *Pax vobis*
Comment: this is kinda vague, but potentially helpful for others. what do you know so far?
Comment: i am all over the place ha @AgentSmith
Answer: Are you referring to the "problem of induction" which David Hume has famously covered in his 1739-40 "A Treatise on Human Nature" and his 1748 "An Enquiry Concerning Human Understanding"?
If yes, then his perspective is that induction will result in circular reasoning if in terms of probability and if in terms of demonstration, then every demonstration is not able to be False given acceptance of a demonstration as true.
In a very brief summary of his perspective, humans cannot justify induction or cause & effect through reasoning and that we cannot reliably infer what happens in the future based on prior experiences.
Further Reading

https://plato.stanford.edu/entries/induction-problem/
https://en.m.wikipedia.org/wiki/Problem_of_induction

References
Gutenberg has his works or reprints available for reading for free as they are in the public domain.

"A Treatise on Human Nature": https://www.gutenberg.org/ebooks/4705
"An Enquiry Concerning Human Understanding":
https://www.gutenberg.org/cache/epub/9662/pg9662.txt

Or the internet archive
https://archive.org/details/treatiseofhumann01humeuoft
Answer: Empiricism is basically the belief that all knowledge is a posteriori to experience. We're born as a, his words, tabula rasa (blank slate). Experience is what writes on it and that which is written is knowledge, contra Descartes, Spinoza, plus Leibniz, who believed in innate knowledge i.e. knowledge a priori to experience.


Is it legal in the UK to 3D print a firearm design if it is made impossible to fire?

Question: In the UK firearm regulations are very strict, but I would like to learn about them like in the other countries.
Is it okay to print 3D gun designs if I make sure none of the parts can shoot real bullets by using weak plastic that would explode in the hand if fired with a real bullet?
Answer: Is it legal in the UK to 3D print a firearm design if it is made impossible to fire?
Maybe, maybe not
If the result is merely a toy, trinket etc then there is no offence per se.  However it will be unlawful if it meets the definition at s.57 of the Firearms Act 1968 of a firearm, or used as an "imitation firearm" to commit any number of offences in the Act:

(1) "firearm" means-
(a) a lethal barrelled weapon
...
(c) a relevant component part in relation to a lethal barrelled weapon
...
3(1B) In subsection (1)(a), "lethal barrelled weapon" means a barrelled weapon of any description from which a shot, bullet or other missile, with kinetic energy of more than one joule at the muzzle of the weapon, can be discharged.
(4)(b)..."imitation firearm" means any thing which has the appearance of being a firearm ... whether or not it is capable of discharging any shot, bullet or other missile
Comment: It *is* legal to own an immitation firearm in a couple of scenarios which are trivial to achieve for a normal user - if you are a licensed airsoft gamer (find a local airsoft club, attend a few times and register), or if substantial parts of the weapon are bright fluorescent colours (how you can buy an airsoft weapon if you arent a registered airsoft gamer - the seller will spraypaint your weapon for you - mine came with the lower half bright orange).
Comment: Possession of an imitation firearm is not unlawful - it's what one does with it that makes it so. And one doesn't need to go to great lengths to get one either, just pop down to the local greengrocers for a [banana](https://www.google.co.uk/amp/s/www.bbc.co.uk/news/amp/uk-england-dorset-48666853)
Answer: In Germany, there are similar prohibitions against building a firearm or significant parts of a firearm, and also against gadgets which give the appearance of a firearm.
I expect that it would be possible 3D print something which meets neither definition, but doing so is tricky for an amateur. When a German IT publisher printed a gun some years ago, they played it safe and let a licensed gunsmith do it.


how can I include arabxetex to texlive package

Question: I would like to install arabxetex package. I have already installed arabtex with command line sudo apt-get install texlive-lang-arabic. However I can't find a similar command for "arabxetex". Is there a command or a manual way to do this? Thank you.
Answer: I found "arabxetex" is included by "xetex" package. Therefore, we have to install xetex. If you are using debain-ubutu , you just type:

sudo apt-get install texlive-xetex
Answer: The first answer is completely correct. I just want to add that in case you have problems locating the correct package, use apt-cache search, as in apt-cache search arabxetex, which will return you texlive-xetex - TeX Live: XeTeX and packages, after which you can call apt-cache show texlive-xetex to see the list of included packages.


How are degrees of freedom and energy related in classical theory?

Question: How are degrees of freedom and energy related in classical theory? How do we come to know that each quadratic degree of freedom classically contributes a factor of $\frac{k_{B}T}{2}$.
Answer: The short answer is that  $\bar E = -\frac{1}{Z}\frac{\partial Z}{\partial \beta}$ ($\dagger$). $\bar E$ is the average energy of a quadratic degree of freedom in this case and $Z$ is the partition function which sums over all possible values of $E$ associated with your degree of freedom $q$. So it's just how the math works out. There is a short derivation near the bottom of this wikipedia article.
Here is what I consider an intuitive justification of ($\dagger$):
The mean energy of a degree of freedom q is clearly equal to: $\bar E = \Sigma_q p_q E_q$, where $p_q$ is the probability associated with the state $E_q$. (From the principle that entropy is maximized in equilibrium we can derive $p_q$.)
The probability (or weight) is: $$p_q=\frac{e^{-\beta E_q}}{\Sigma_q e^{-\beta E_q}}$$
Now if you look carefully at $\bar E$: $$\bar E = \frac{\Sigma_qE_qe^{-\beta E_q}}{\Sigma_q e^{-\beta E_q}}$$
You will see that it is quivalent to the formula $\bar E = -\frac{1}{Z}\frac{\partial Z}{\partial \beta}$ which yields $\frac{1}{2}k_B T$ in 1D for a quadratic degree of freedom. Here is a hint if you would like to do this calculation yourself: you will have to take the continuum limit and use a Gaussian integral to evaluate the partition function.
Comment: Thanks for the help.
However I can't understand why the canonical ensemble picture was required in this case. I mean that seems something special
( granted in large N limit all ensembles are same). I mean "is there any other method somewhat general ?"
Comment: No problem. You can use whatever ensemble you like to find $p_q$ using lagrange multipliers.
Comment: Here is a link to a decent derivation for the grand canonical ensemble http://xbeams.chem.yale.edu/~batista/vaa/node16.html, this doesn't really address your question though, I was just trying to justify the form of $\dagger$
Answer: The argument goes something like this:
Suppose we have a system in contact with a large reservoir at temperature $T$ with which it can exchange energy. The Boltzmann distribution tells us that the probability of finding the system in some small region of phase space $\mathrm{d}V$ is given by
$$  \rho(q_i,p_i)\,\mathrm{d}{V}= \frac{1}{Z} \exp(-E(q_i,p_i)/k_B T) \,\mathrm{d}{V} \,,$$
where $q_i$ and $p_i$ are the position and momentum variables that define the system, and which the energy $E$ depends on. $Z$ is a normalisation factor. If you're unfamiliar with this equation, derivations can be found on pages concerning 'Maxwell-Boltzmann statistics' and 'the canonical ensemble'. Additionally, if you were unaware, phase space is just the space of position and momentum variables --- that is, a point in phase space just corresponds to some particular values of the $q_i$ and the $p_i$.
$Z$ can be determined from requiring the total probability to be one:
$$ Z = \int_\mathrm{all\ phase\ space} \exp(- E(q_i,p_i)/k_B T) \, \mathrm{d} V \,.$$
Now suppose the energy of the system takes the form
$$ E  = \alpha z^2 + E' \,,$$
where $\alpha$ is some constant, $z$ is some variable, and $E'$ just corresponds to some other terms that don't depend on $z$. In words, suppose that the energy is separable and quadratic in $z$. The probability that $z$ lies between $z$ and $z+\mathrm{d}z$ is obtained by integrating out all other phase space variables besides $z$ in the expression for $\rho(q_i,p_i)$. If we do this, we will find that these integrals cancel with the big integral $Z$, leaving
$$ \rho(z)\,\mathrm{d}z = \exp(-\alpha z^2/k_B T)\,\mathrm{d}z / \int_{\mathrm{all\ }z} \exp(-\alpha z^2/k_B T) \,\mathrm{d}z \,.$$
If we want to find the average value of this term (which I will denote with angle brackets), we can use the result from the theory of continuous probability distributions that
$$ \langle \alpha z^2 \rangle =  \int_{\mathrm{all\ }z} \alpha z^2 \rho(z) \, \mathrm{d}z \,.$$
Evaluating the integrals (which are Gaussian integrals, or related), gives the result
$$ \langle \alpha z^2 \rangle =  \int_{\mathrm{all\ }z} \alpha z^2 \exp(-\alpha z^2/k_B T)\,\mathrm{d}z / \int_{\mathrm{all\ }z} \exp(-\alpha z^2/k_B T) \,\mathrm{d}z = \frac{1}{2}k_B T \,.$$


preposition for tie

Question: is it correct using preposition (on) for the verb (tie)? when it is used with?
And do we use it when we want to use it for ( fastening to another thing)?
For example in this case:
" more and more travels; I tie on my sandals"
Comment: "I tie on my sandals" is not English, no. I'm not sure what it's supposed to mean, even—do you mean that you _put on_ your sandals, or that you _tie_ your sandals _(on)to_ something else, like a backpack?
Comment: You might want to check out [ell.se]. [More here](http://meta.english.stackexchange.com/questions/3722).
Comment: "I tie on my sandals" is valid -- what is it? -- present perfect (?) English.  Doesn't particularly fit with "more and more travels", though.
Answer: That is alright as far as it goes.
But in different contexts tie can take to, with, by, in, from, up and I have no doubt others.
The rope was tied to posts to form a boundary.
The parcel was tied with strong string.
The prisoners were tied by their wrists.
The participants in the three-legged race were tied in pairs
The equipment was tied from the rafters when not in use.
The bundle was tied up securely
Comment: Some naughty person might add _The scores were tied after seven rounds._
Comment: Or "tied as before"!
Answer: Please read http://en.wikipedia.org/wiki/Phrasal_verb.
Transitive use of verbs do not require being coupled to the subject via a preposition.

I killed the bug.
I eat dinner.
I am milking a cow.
I stopped to tie my shoes.

Potentially transitive verbs could of course be used non-transitively.

I am shooting the deer
vs
I am shooting at the deer
She is eating her dog
vs
She is eating with her dog
They like eating chopsticks
vs
They like eating with chopsticks

Do not mistake prepositional phrasal verbs with verb-preposition and verb-adverb phrases.
Words that are used as prepositions can also be used as adverbs. Do not mistake the prepositional use of a word with its adverbial use
Prepositional phrasal verbs

She takes after her father.
=
She behaves or is similar to her father.
Did you eat up all the biscuits?
You need to tie up your shoes.
We shall put on some eye shadow.
We need to go over the notes of the meeting.

Verb-adverb phrases

Please don't bring the matter up.
He has turned the lights off.
When will that kid put her toys away?

Pidginization of verb-adverb phrases

into pseudo prepositional phrasal verbs

Please don't bring up the matter.
He has turned off the lights.
When will that kid put away her toys?

Usual verb-preposition-subject coupling

due to intransitive use of a verb - and can be separated.

She is staying at the hotel.
At which hotel is she staying?
These are the biscuits she has been eating with her dog.
Which dog is she eating the biscuits with?
Where is the meeting, to which I will be going with you?
With whom am I going to the meeting?

Prepositional phrasal verbs-preposition-subject coupling

causing the confusion you are facing.

She is putting up at the hotel.
At which hotel is she putting up?
These are the biscuits she has been eating up with her dog.
With whose dog has she been eating up the biscuits?
Where are the notes of the meeting that I will be going over with you?
With whom should I go over the notes?

preposition for tie


Referring to Gentile Priest as "Father"

Question: Is it permissible to either refer to or address a gentile priest as "Father XXXXXXXXX"?
What alternatives might there be?
Comment: Is there any reason you ask specifically about a gentile priest? Do you think the rule might be different for a _Yisrael m'shumad_ priest?
Comment: Should be no different than calling the Pope, Pope.
Comment: Very similar: http://judaism.stackexchange.com/q/32110
Comment: Christianity perceives baptism as spiritual rebirth, and Christian priests are usually the ones baptizing and preaching (just as parents giving birth to children, and then teaching or educating them).
Answer: Rav Berel Wein seems to feel it would be permitted to call a priest by the honorary title of "father":

One Motzei Shabbos (Saturday night), my Rosh Yeshiva, Rabbi Berel Wein
shlita, was visiting a member of his congregation in the hospital. The
patient was on the top floor and after the visit Rabbi Wein prepared
to take the elevator down. The hospital has two sets of elevators, on
opposite sides of the hall. As Rabbi Wein approached one elevator, he
saw that standing at the opposite elevator was a Roman Catholic priest
in full regalia. He too had just finished visiting one of his own
parishioners and was leaving. The priest had just pushed the button
for his elevator and Rabbi Wein proceeded to push the button for his
elevator. Seeing Rabbi Wein still dressed in his Shabbos regalia, the
priest looked over at him and said, "Good evening, Rabbi". Rabbi Wein
turned and politely replied, "Good evening, Father." And then they
both stood quietly waiting for the elevator to come.    There were a
number of people standing between the two clergymen. As they watched
the proceedings they stood transfixed, as if paralyzed. They felt that
the theological dispute of the centuries was about to be settled right
before their eyes- which spiritual leader could command the first
elevator.    As Rabbi Wein would say, "Contrary to popular belief, G-d
is on the side of Rabbis" and his elevator came first. The door slid
open, Rabbi Wein smiled and magnanimously waved everyone in, including
the priest. As the elevator began its descent, the priest looked at
Rabbi Wein with a sly twinkle in his eye and remarked, "Rabbi, what
would you have said if my elevator had come first?" Rabbi Wein
replied, "Father, you can't prove anything from a descending
elevator."

Referring to Gentile Priest as "Father"


Holomorphic function interpolating $e^{-n}$

Question: Consider the question: does there exist a holomorphic function $f$ on the unit disk in the complex plane such that $f\left({1 \over n}\right) = e^{-n}$ ? I came up with an answer but I'd like to know if there is another argument.
Here's my answer: let $f$ be such a function. $f$ must vanish at $0$ by continuity. Any holomorphic function vanishes at $0$ satisfies the following estimate : $\left| f(z) \right|\sim_{z \to 0} \alpha \,|z|^m$, where $\alpha>0$ and $m$ is a positive integer (this is easily derived from the expression of $f$ as a power series). This contradicts the assumption $f\left({1 \over n}\right) = e^{-n}$.
By curiosity, I would like to know if there is another argument (maybe something about $f(z) - e^{1 \over z}$)?
Comment: Your problem is that $\frac{1}{n} \neq 0$ for all $n$. The domain isn't really the disk, but the punctured disk with zero deleted.
Answer: Your argument is correct. Expressed more formally, it could go as follows: suppose such $f$ exists. Let $k\ge 0$ be the smallest integer such that $f^{(k)}(0)\ne 0$. Then the limit $\lim_{z\to 0}z^{-k}f(z)$ exists and is not zero. But plugging $z=1/n$ here gives $\lim_{n\to\infty } n^k e^{-n} $ which is zero.
Looking at the difference $g(z)=f(z)-e^{1/z}$ is not as helpful because $g$ is not holomorphic at $0$. So, the fact that the zeros of $g$ accumulate at $0$ is not a contradiction.
Comment: Tell me something I don't know...


How can the focal length of a lens be many times greater than the lens's physical length?

Question: I bought a Tamron 16-300.  Question is:  how can it have a focal length 0f 300 mm when it is only about 30 mm long?  Doesn't the lens have to be 300 mm from the sensing element?
Comment: Note: the distance from the sensor to the front of the camera body is about 30mm.  The lens length is quite a bit longer than that.
Comment: Short answer, no.  Multi-element lenses can be designed to be much more compact.  See:
http://photo.stackexchange.com/questions/38192/what-does-it-mean-that-a-lens-is-x-millimeters/38215#38215
Answer: According to a related discussion on dpreview:

A lens can be made physically shorter than its focal length by the use of additional lens elements called a telephoto group.

According to the Wikipedia page for Telephoto lens:

The basic construction of a telephoto lens consists of front lens elements that, as a group, have a positive focus. The focal length of this group is shorter than the effective focal length of the lens. The converging rays from this group are intercepted by the rear lens group, sometimes called the "telephoto group," which has a negative focus.
Comment: Welcome to Photography.SE.  Couldn't help but notice the similarity in username.  Always a pleasure to have another A Henderson around.
Answer: There are several approaches to getting a lens system with a long focal such that it is closer to the media than its focal length. The most common of these is the 'telephoto' lens

From Wikipedia: https://commons.wikimedia.org/wiki/File:Lens_telephoto_1.svg
What this does is it that the outer lens element (at the front of the lens system) has a positse focus and is bending the light more significantly than a simple lens of some focal length would.  Then the second element group (with a negative focus) refocus the light again so that the light appears to have come from a much greater focal length.  This allows for a shorter lens system than the focal length would be otherwise.
Another approach is to 'fold' the lens with mirrors.

This is a 500mm lens that is only 109mm long.
The light path itself does have some glass in it, but it is bounced around a bit:

From Wikipiedia: https://en.wikipedia.org/wiki/File:MinoltaRFRokkorX250f56text.svg
You will note that the light comes in, is adjusted a little bit, bounces off the back (and adjusted), bounces off the front (and adjusted) and then goes through a few more pieces of glass.  The light path is folded through the lens to get a much longer focal length in a smaller distance.
Comment: That Rokkor 250/5.6 was a *lovely* little lens, by the way. About the same size as a conventional 85mm, and easily hand-holdable down to 1/125 unless you were wired on caffeine (which really cut down on the film-swapping; it would be pretty much right on the money at ASA 100 and 1/1000 at high noon, or ASA 400 and 1/500 in daylight woodland shade if you were shooting little critters).
Comment: @user32334 personally, I like the [Nikkor 2000 f/11](http://www.mir.com.my/rb/photography/companies/nikon/nikkoresources/reflex/2000mm.htm) (only 598mm long).  Neat bit on the light path and nature of the doughnut bokeh of reflex lenses at http://www.pierretoscani.com/echo_shortpres.html
Answer: Making a lens shorter than a simple lens is exactly what the term telephoto means.  Telephoto groupings basically act kind of like a magnifying glass, making the field of view close faster than would happen with a simple lens system.
Traditional telephoto lenses still required a fair bit of space and lots of lenses to operate, but newer things like diffractive optics can condense this down even further to make very short telephoto lenses without sacrificing a whole lot in terms of image quality.


non-volatile virtual memory for C++ containers

Question: Is there a virtual memory management process that would allow a program to use the standard container structures and classes, but retain these structures and their data when the program is not running (or being used), for use by the program at a later time?
This should be possible, but can it be done without changing the source code and its (container) declarations?
Is there a standard way of doing this?
Answer: There have been a couple of projects along this line. Neither of those seems to have come into particularly wide use. Stxxl seems to be the most widely used of the projects along this line.


Why do constructors not return values?

Question: Please tell me why the constructor does not return any value. I want a perfect technical reason to explain to my students why the constructor does not have any return type.
Comment: What language is this a question about?
Comment: Because it returns instance of the class. If it returns data type how will you create a new instance.
Comment: @Karan Exactly. Constructors return an instance of a class, so they can't have any other return values.
Answer: What actually happens with the constructor is that the runtime uses type data generated by the compiler to determine how much space is needed to store an object instance in memory, be it on the stack or on the heap.
This space includes all members variables and the vtbl.  After this space is allocated, the constructor is called as an internal part of the instantiation and initialization process to initialize the contents of the fields.
Then, when the constructor exits, the runtime returns the newly-created instance.  So the reason the constructor doesn't return a value is because it's not called directly by your code, it's called by the memory allocation and object initialization code in the runtime.
Its return value (if it actually has one when compiled down to machine code) is opaque to the user - therefore, you can't specify it.
Comment: As much as this is technically detailed and correct, a simple "it wasn't designed to do it" would suffice IMHO. Surely it wouldn't be impossible to design the runtime to return the return value of the constructor instead of the newly-created instance. It just doesn't make much sense and hence wasn't designed to do it. :)
Comment: I'm not so sure about .Net - the above is my understanding of the approach C++ takes.  I'm sure .Net is very similar, except that the metadata generated by the compiler encompasses MUCH more than just the amount of space required to instantiate it (and c++ stores some metadata about type as well, but nothing on the scale supported by .Net).
Comment: At least in C++, it would be impossible for the constructor to return the newly created object. It would have to make a copy, which means calling the copy constructor, and what would _it_ return? However, you could return a reference. Still, return to where exactly?
Comment: Can we assume you are describing .NET?
Comment: Could we say tha same for `__del__`?
Comment: @ Dathan
Is my understanding correct ,if I put your words like this.
"Since a normal function call is associated with an object,.i.e we know what type of value will be returned ,but the same thing is not applicable in case of  a constructor ,the object is still under construction,hence no return type ".
Answer: Well, in a way it returns the instance that has just been constructed.
You even call it like this, for example is Java
 Object o = new Something();

which looks just like calling a "regular" method with a return value
 Object o = someMethod();

Comment: It makes using the constructor much easier if you know the only possible end states are "you have a Something instance" or "an exception is thrown".  (We tried the whole "make the caller check every return value" thing with C.)  Is there a benefit to having two orthogonal error reporting mechanisms the caller has to check each time, or are you proposing doing away with exceptions, too?
Comment: So why shouldn't that method not be allowed to return `null`? I'm not convinced. Not at all.
Comment: @sbi it does return `null` if the constructor has failed to build an instance
Comment: @claudiodfc Not in C++, no.
Answer: How is a constructor supposed to return a return value? The new operator returns the newly created instance. You do not call a ctor, newdoes it.
MyClass instance = new MyClass();

If the ctor would return a value, like so:
public int MyClass()
{
    return 42;
}

Where would you receive the integer?
Comment: But 'this' has to already exist when the constructor starts to run.  If your construction "fails", the 'this' is already allocated, and then what happens?  Do you have a partially-constructed object?  Should the destructor be called on it, or not?  In C++, if you throw in the constructor, you're supposed to save enough state in the zombie object that it can clean up after itself; without an object, how's it do that?  Or do you now have 2 completely independent error mechanisms for constructors?
Comment: "How is a constructor supposed to return a return value?" It could return `this`. Failed construction would be indicated by returning `null`.
Comment: @sbi Since you do not call the ctro directly, it can not return anything. The reference/pointer to the new instance is returned by `new`, not the ctor.
Answer: (I'm biased towards C++, so regarding other languages, take this with a grain of salt.)
Short answer: You don't want to have to explicitly check for success for every single object construction in your code.
Somewhat longer answer: In C++, constructors are called for dynamically as well as for globally and automatically allocated objects. In this code
void f()
{
  std::string s;
}

there is no way for the constructor of s (std::string::string()) to return any value. Either it succeeds - then we can use the object, or it throws an exception - the we never get a chance to try to use it.
IMO, that's the way it should be.
Answer: A constructor is some method automatically called when you initialize a new instance of an object.
This method is there if you need to initialize your object to a given state and run few default methods.
Actually you can imagine the constructor always return the instance of the object created that would be a good image.
Comment: Well, given that you still need to declare *which* constructor has to run (by including the proper arguments) I don't think that really qualifies as "automatically" :-)
Comment: Well, given most OOPL's syntaxes I'd say since you still write the type name, the arguments and in some languages (Delphi, Eiffel) the contructor's name, daying the compiler calls it is akin to saying that the compiler calls a method when you're writing out the method call.
Answer: When you call a constructor the return value is the new object:
Point pt = new Point(1,2);

But within the constructor itself, you're not actually creating and returning the object; it's been created before your code starts, you're just setting up the initial values.
Point::Point(int x, int y) {
  this->x = x;
  this->y = y;
}

The lack of a return type reflects the fact that constructors are used differently than other functions. A return type of null, while technically accurate, doesn't reflect well the fact that the code is used as if it returns an object. However, any other return type would indicate that your code is supposed to return something at the end, which is also incorrect.
Answer: Constructor doesn't return anything not even Void. Though some of the answers have mentioned that Constructor do return reference to the newly created object , which is not true. It's the new operator that returns the object.
So Why constructor doesn't return any value
Because its not supposed to return anything. The whole purpose of constructor is to initialize the current state of the object by setting the initial values.
So Why doesn't it even return Void
This is actually a Design constraint which has been placed to distinguish it from methods. public void className() is perfectly legal in java but it denotes a method and not a constructor. To make the compiler understand that it's a constructor , it requires a way to distinguish it.
Answer: all answers are biased towards C++/Java. there is no reason a constructor does not return a value other than the language design.
look at a constructor in a broader sense: it is a function which constructs a new object. you can write perfectly valid constructors in C:
typedef struct object object;
int object_create( object **this );

this is perfect OOP in C and the constructor returns value (this can also be called a factory, but the name depends on the intention).
however, in order to create an object automatically (to satisfy some type cast, or conversion for example), there have to be some rules defined. in C++, there is an argument-less constructor, which is inferred by the compiler if it is not defined.

the discussion is broader than what we think. Object Oriented Programming is a name which describes a way of thinking about programming. you can have OO in almost any language: all you need is structures and functions. mainstream languages like C++ and Java are so common that we think they define "the way". now look at the OO model in Ada: it is far from the model of C++ but is still OO. i am sure languages like Lisp have some other ways of doing OO.
Comment: How would inheritance work in such a scenario?  If the user-supplied code for a constructor accepts a reference to a presumably-blank `BaseType` object and sets it up as appropriate, such code will have no problem if it's given a `DerivedType` object instead.  If the code returned a `BaseType` object, though, it's less clear how it could be used to produce a `DerivedType` object.
Answer: One point that hasn't yet been discussed is that the constructor of class "foo" must be usable not only when creating instances of foo, but also when creating instances of classes derived from foo.  In the absence of generics (which weren't available when Java, C++, or .net were designed) there would be no way for foo's constructor to return an object of any derived class.  Therefore, what needs to happen is for the derived-class object to be created via some other means and then made available to foo's constructor (which will then be able to use the object in question as a foo when doing its initialization).
Answer: Even though the VM implementation of a constructor isn't to return any value, in practice it kind of does - the new object's reference. It would then be syntactically weird and / or confusing to be able to store one or both of the new object's reference and an additional return value in one statement.
Answer: Constructor is not directly called by the user's code. It's called by the memory allocation and object initialization code in the run time. Its value is not visible to the user.
Answer: When trying to define a "constructor with return parameters", what you will
actually get instead is a method with the class's name.
public class A {

    public int A() {
        System.out.println("hello");
        return 1;
    }

    public static void main(String[] args) {
        A a = new A();
        System.out.println(a.A());
    }

}

This code will print:
hello
1

Instead of printing
hello
hello
1

As you would expect in the case of it being a constructor.
This happens because Java doesn't acknowledge the method as a constructor of A,
such that in reality the constructor that's being called is the no argument one.
Answer: In case of C#, the syntax for declaring object is :
classname objectname= new constructor();

According to this line, if we are using assignment operator(=) then it should return some value. But the main objective of a constructor is to assign values to variables, so when we use a new keyword it creates instance of that class, and constructor assigns values to the variable for that particular instance of object, so constructor returns assigned values for that objects's instance.
Answer: We can not call constructors independently. Instead they are automatically called whenever objects are created.
Ex:
MyDate md = new Mydate(22,12,2012);

In above example new will return a memory location which will be held by md, and programatically we can not return multiple values in single statements.
So constructors can not return anything.
Answer: From what I know about OO design methodologies, I would say the following:
1)By allowing a constructor to return a value, framework developer would allow the program to crash in an instant where the returned value is not handled. To keep the integrity of the program workflow, not allowing a return value from the initialization of an object is a valid decision. Instead, language designer would suggest/force the coders to use getter/setter - access methods.
2)Allowing the object to return a value on initialization also opens possible information leaks. Specially when there are multiple layer or access modifications applied to the variables/methods.
Answer: As you aware that when object is created constructor will be automatically called So now imagine that constructor is returning an int value. So code should like this...
Class ABC
{
     int i;
public:
     int ABC()
     {
        i=0;
        return i;
     }
     .......
};
int main()
{
    int k= ABC abc; //constructor is called so we have to store the value return by it
    ....
}

But as you aware that stament like int k= ABC abc; is not possible in any programming language. Hope you can understand.
Answer: i found it helpful
This confusion arises from the assumption that constructors are just like any other functions/methods defined by the class. NO, they are not.
Constructors are just part of the process of object creation. They are not called like other member functions.
Answer: I would be using Java as my language in the answer.
class SayHelloOnCreation {
     public SayHelloOnCreation() {
         System.out.println("Hello, Thanks For Creating me!");
     }
}

class Test {
     public static void main(String[]args) {
         SayHelloOnCreation thing = new SayHelloOnCreation(); //This line here, produces an output - Hello, Thanks For Creating me!
     }
}

Now let us see what is happening here. in java,  we use the new keyword to create an instance of a class. And as you can see in the code, in the line, SayHelloOnCreation thing = new SayHelloOnCreation();, the expression after the assignment operator runs before assignment is done. So using the keyword new, we call the constructor of that class (SayHelloOnCreation()) and this constructor creates an object on the Java Heap. After the object is created, a reference to that object is assigned to the thing reference of type SayHelloOnCreation.
The point that I am trying to keep here is that if constructors were allowed to have a return type, Firstly the strongly typed nature of the language would be compromised (Remember I am speaking about Java here).
Secondly, an object of class SayHelloOnCreation is created here so by default I guess the constructor returns a reference of the same type, to avoid ClassCastException.
Answer: So the reason the constructor doesn't return a value is because it's not called directly by your code, it's called by the memory allocation and object initialization code in the runtime. Its return value (if it actually has one when compiled down to machine code) is opaque to the user - therefore, you can't specify it.
Answer: A method returns the value to its caller method, when called explicitly. Since, a constructor is not called explicitly, who will it return the value to. The sole purpose of a constructor is to initialize the member variables of a class.
Answer: When we create an object in Java, the constructor is responsible for allocating memory and initializing the object's variables. The constructor is called automatically by the runtime as part of the object creation process.
The constructor doesn't have a return type because it is not directly called by our code. Instead, it is called by the runtime system. The purpose of the constructor is to set up the object's initial state, not to return a value.
So, the reason we can't specify a return value for the constructor is because it is designed to work behind the scenes, handling memory allocation and initialization tasks. Its return value, if any, is not something we can control or access directly in our code.
I use rephase the answer in a simpler form.
Answer: The constructor does not return any values and it does not have any return type. We should call any method explicitly. But in the constructor, it calls automatically when objects are created. For example,
Class Sample{
Sample s=new Sample();//here Sample() is the Constructor
}

Guys! Please note it the constructor and method are not the same.
Constructor is mainly used to initialize the instance variable.

Why do constructors not return values?


Production of acetone from egg shells and vinegar

Question: I learned from these wiki pages that acetone can be produced from calcium acetate, which can be produced by the reaction of eggshells and vinegar. However, I couldn't find the required temperature. Would it be possible to produce acetone vapours by simply heating calcium acetate over a natural gas flame (~1500 degrees C)?
Comment: There was a question about eggshells which seems to have been deleted. Evidently there is a problem with disposing of eggshells and much of the waste eggshell ends up in a dump. This reaction would yield acetone and CaO, but both probably aren't worth the cost of the acetic acid and heat.
Comment: Sorry, didn't mean the cost analysis to be a put down. I thought it was an interesting notion given the eggshell problem. Who knew that getting rid of eggshells would be a problem? The bigger problem with eggshells of course is that there are probably numerous plants generating them. It would cost prohibitive to ship all eggshells to one plant in US for conversion. So you'd need conversion plants near eggshell producers. Interesting problem...
Comment: Did you look in footnotes 3 and 4 for Wikipedia's Calcium Acetate article? https://en.wikipedia.org/wiki/Calcium_acetate#Uses
Comment: I know it's impractical, but I still want to try it because I'm rather interested.
Answer: Calcium acetate decomposes starting at around 160 degrees Celsius, according to Wikipedia. So yes, it is definitely possible to do so in a gas flame.


Earliest and Latest Times for reciting Kabbalat Shabbat?

Question: What are the earliest and latest times for reciting Kabbalas Shabbos? If one was too busy preparing for Shabbos to say it at the normal time, may one recite it at any time after Shabbos starts?
Answer: Earliest time for Kabbalat Shabbat
The earliest time for accepting Shabbat is Plag haMincha - 1¼ Halachic hours (Sha'ah Zemanit) before sunset. (Chabad have an online Halachic time calculator, with Plag and Sha'ah Zemanit for most locations, here.)
Source: Shulchan Aruch, Orach Chaim 267:2

וּבִפְלַג הַמִּנְחָה יָכוֹל לְהַדְלִיק וּלְקַבֵּל שַׁבָּת בִּתְפִלַּת עַרְבִית

So, it has been suggested, that one could start the Kabbalat Shabbat Psalms a few minutes before Plag and get to the "Shabbat Acceptance" moment right at Plag. This "Shabbat Acceptance" moment is generally defined as the last stanza of Lecha Dodi.
Latest time for Kabbalat Shabbat:
Background:
Kabbalat Shabbat has 2 meanings:

The original meaning: To accept upon oneself the sanctity of Shabbat. Even though Shabbat begins (and obligates you in all its Halachot)  automatically at sundown, accepting Shabbat actively is done for two reasons. (1) To accept Shabbat early and fulfill the Mitzvah of Tosefet Shabbat (adding on to Shabbat), and (2) to actively accept the Mitzvah of Shabbat, instead of it happening by itself, and get the reward for keeping Shabbat on purpose.

Obviously, this Kabbalat Shabbat can be done at any point after Shabbat begins, to transform one's Shabbat observance from passive to active.

The newer meaning: The Ari z"l in the 16 century (based on the Gemara in Shabbat 119a) instituted the Kabbalat Shabbat Service starting with certain Psalms and reaching a crescendo with Lecha Dodi followed by the Shabbat Psalms (92 and finally 93). Until then the entire  Kabbalat Shabbat Service consisted of Psalms 92 and 93.

The point was to welcome the Shabbat Queen with a royal ceremony. The ideal time to do this is when the queen is on her way in.
Once that time has passed then the point of the ceremony is lost, but you still can say it, to transform your Shabbat observance from passive to active, since it's simply some Psalms and a poem.
Though welcoming the Shabbat Queen - with the Lecha Dodi poem - long after she's arrived seems rather peculiar.
To answer your question: I cannot find any Poskim who mention this, but I would propose that any time before the Friday night meal would still be somewhat appropriate to say Kaballat Shabbat.
Once you've wined and dined in honor of the Shabbat Queen, it seems silly to then start the Welcoming Ceremony. That said, the OU site write (without sources or explanations):

The latest time to finish saying Kabbalat Shabbat is before daybreak on Saturday morning.
Comment: I don't understand the OU. Why can't you say it even in the morning?
Comment: I don't agree about plag.  It doesn't make sense to say באי כלה when you're not accepting Shabbos, but there's no reason not to start ידיד נפש and לכו נרננה early.  The 6 mizmorim correspond to the 6 weekdays before Shabbos!  You can even say the beginning of לכה דודי too, as long as you time it right so you're not sitting at באי בשלום for 5 minutes feeling stupid.
Comment: @DannySchoemann that depends how much singing the shul does :).  I've been to shuls where it could be 15-20 minutes.  (Of course, they're also typically not the shuls that would _want_ to start early to get people home as early as possible, but you never know.)  I think there's also a value to getting to באי בשלום exactly at plag - it reinforces your excitement for Shabbos and your desire to start it at the earliest possible moment.  It's emotionally (but not halachically) similar to vasikin.  I've never seen a shul do it, but if I were the gabbai I might.
Comment: @Heshy - are you trying to say that one could start Kabbalat Shabbat about 4¼ minutes before Plag, so as to get to באי בשלום at Plag? I guess I could add that into the answer. :-)


Is there a parameter that describes the angle between the spacecraft's position and the sun angle or direction of the Earth's motion?

Question: I am trying to design an Earth flyby for gravity assist in GMAT, and I know from theory that the spacecraft should pass in front of a planet with regard to its heliocentric direction of motion in order to gain delta-v. Is there a parameter or calculation that can describe that? GMAT offers an option to draw the sun vector for a given orbit view with a specific coordinate system, so I can visually see where the spacecraft is compared to the Earth's direction of motion, but I have to manually input the position that satisfies that condition for any given epoch. Instead I would like to design an optimizer that automatically picks what the position vector of the spacecraft would have to be. Is there a way I can do that?
Comment: The keyword would be B plane targetting and GMAT has documentation about it [here.](http://gmat.sourceforge.net/docs/nightly/html/Tut_UsingGMATFunctions.html)
I've put a link to a report that goes into detail as an answer. hope it helps!
Comment: Is the spacecraft in the ecliptic plane? If yes then true anomalies of earth and the spacecraft (Heliocentric) should give you the position information. Or am I misinterpreting your question..
Comment: Yeah it's in the ecliptic plane (inclination of 23.5 degrees). How would I then combine the true anomalies of the spacecraft and Earth to define conditions for a gravity assist?
Answer: This question has some really good answers that explain gravity assists and how they could be conceived.
If you're setting up a simulation, this report probably has everything you need, theory, procedure and its done in GMAT so in principal you could set up the same problem, for earth in your case.
Answer: My answer wasn't just "thank you" Dave Gremlin, I offered an actual solution after those two words. Repeating it here:
As far as a less "official" and temporary solution goes, I created a coordinate system with the Earth as its origin, and the Sun and Earth as its axes references. "Behind" the Earth with regard to the direction of its motion around the Sun is then an inclination of 180 degrees with that coordinate system, and in front of it 0 degrees.


Refresh a page when delete is performed in odoo?

Question: I want to refresh the view page when delete is performed.
I tried unlink() method I see some codes to reload the page.
<code>return { 'type': 'ir.actions.client', 'tag': 'reload', }
</code>
But when I use unlink() method
<code>@api.multi

def unlink(self):

   return models.Model.unlink(self)
</code>
It has to return the unlink() to delete the record so I can not call the return for reload.
I tried this
<code>@api.multi

def unlink(self):

      x={'type': 'ir.actions.client', 'type': 'reload',}

    return models.Model.unlink(self),x
</code>
But its not working.
Any other suggestions to reload/refresh the view page of odoo when delete is performed.
Thanks.
Answer: Try:
<code>@api.multi
def unlink(self):

  return {'type': 'ir.actions.client', 'type': 'reload'}
</code>
It works for me


Purchase Paris Visite pass from Orly airport on a public holiday

Question: Can I buy a Paris Visite pass (zone 1-5, days 1-3) from Orly airport on 8th May 2014? It is a public holiday in France.
Answer: The ticket office at major stations such as the airport will be open even on a holiday. In addition, there are ticket machines that accept credit cards (all of them, since this is an RATP station — on the other hand, SNCF stations such as in Roissy airport have machines that only accept credit cards with chips), and I think the ones in the airport also take banknotes (most of the ones in the city don't).
You can even buy tickets in advance from online resellers. I have no idea about extra costs and delivery times. But I'd just buy the ticket(s) at the airport.
Do check whether Paris Visite is really worth it. For many people, it isn't a good deal, but you need to match the price with what you're doing, and having a pass has the advantage that you don't need to think about cost before hopping onto a train or bus. Paris Visite zones 1–5 (covering the city, both airports and the Versailles Palace) is 48.65€. An Orlybus ticket (I recommend the bus to Denfert-Rochereau over Orlyval, it's simpler and slightly cheaper) is 7.50€ one way. A ticket to Versailles is 3.45€ one way. A book of 10 tickets for travel in the city is 13.70€. 10 trips for 3 days without counting the Versailles and airport runs is a reasonable estimate, which makes Paris Visite worth buying only if you get 13.05€ worth of reductions from Paris Visite, which is doubtful.
Comment: Thanks alot for the prompt reply. As u said that RATP offices are opened also on holidays so i will buy the Paris Visite Pass from the ORLY Airport.
I also read about the Card Machines but some one said that Paris Visite Pass can't be purchased with the machines.
Paris Visite Pass will hopefully worth me, as i have to go to CDG Airport, ORLY airport and Disneyland as well. SO as i have calculated it is a good option for me.
Thanks once again :)
Comment: @rafeymaher Oh, I think you're right: Paris Visite isn't just a ticket, there's also a leaflet and I think coupons for the attractions, so the machines can't hand it out. If you're going to CDG and Disneyland then indeed Paris Visite is a better deal for you than for the average tourist. Though perhaps [Mobilis](http://www.ratp.fr/fr/ratp/c_21148/mobilis/) (day pass) would come out cheaper (not advertised to tourists, I think it's only mentioned on the French part of the website) — then again probably not because Mobilis isn't valid for the airport trips.


Image module for photogaleries

Question: I wanted to download Image module, but I notice that it's not for Drupal 7. Is there some alternative I can use in Drupal 7?
thank you
Answer: The Future of Image in Drupal 7 reports the following text:

Image module is being put into core, but not in its current incarnation. Drupal 7 has already made several major improvements that will make handling images (and files in general) much easier, eliminating a lot of the existing code from image.module.

The Drupal 7 core plan is as follows:

Move ImageAPI into core to provide better support for toolkits such as ImageMagick (done).
Move ImageCache into core to provide thumbnailing abilities as part of image.module (in progress).
Move FileField into core as file.module.
Move ImageField into core as part of image.module.

This means that most of the functionality of those modules are already integrated in Drupal 7.
ImageAPI still contains code that has not been merged with Drupal 7 code; you should install it if you need the ImageMagick toolkit it implements, or the unsharpen mask action.
As gallery modules, you can try:

Galleria
Fast Gallery
Galerie
Answer: There are actually a lot of modules that have been ported to (or are initially written for) Drupal 7. A typical example is Gallery Formatter.
However, if I were you, I would read thoroughly through the following 2 links:
Link 1
Link 2
since there are a lot of different ways to create a photo gallery in Drupal 7. You have to pick the way that is the more convenient for you (e.g. you may want a module that does just this, or you may want to stick to the "lego-logic" of drupal and create the gallery from a cck field).

Image module for photogaleries


In the Skype Meetings App, how can you control your USB/external headset volume?

Question: While connected to the Skype Meetings App, you are given the option to specify specific devices for audio output and input.  However, since this is a selection within the Skype application, normal volume control doesn't seem to function.  Instead, increasing/decreasing volume seems to change the volume settings of the primary audio device.
Answer: This one has both stumped and annoyed me for a while.  I had been unable to find a solution to this online but, eventually, I figured it out so I figured I'd share my discovery.
To modify the volume you need to click on the speaker icon on the Mac menu.

After clicking on the speaker icon, a little menu will show up showing the available audio devices.  Select your headset and then the hot-key volume controls and the volume slider will adjust the volume on your headset.
Once you've modified your volume settings, you can set your primary audio device back to what it previously was.  Your settings on your headset will remain the same, even if you adjust the volume on your primary speakers.
It's pretty simple once you figure out but wasn't immediately obvious.


Can I use brake fluid or steering fluid to stop a fan from squeaking?

Question: Can I use braking fluid or steering fluid on my squeaking table fan? Are they safe? I'm just wondering if I can use anything that's already lying around the house.
Comment: Break fluid is very corrosive!!
Answer: Brake Fluid is not a lubricant, but a glycol based hydraulic fluid designed to have a high boiling point and to absorb water to prevent corrosion (why the brake system should be completely bled out every so often).
Power Steering fluid and Transmission fluid are petroleum based hydraulic fluids, more useful for their ability to transmit pressure, resist heat and work with fluid filled clutches (friction systems) and are not general purpose lubricants, except in the special case of the systems for which they are designed.
You'd almost be better off using engine oil, but its detergent properties are not useful for this type of operation.
Any box store will have 3in1 or turbine oil which are more appropriate for lubricating the shafts on an electric motor.
Comment: They may have the consistency of 10W engine oil, but their lubricating properties leave much to be desired. My years as a heavy equipment mechanic taught me that quite well. You use lubricating oil, not hydraulic fluid if you want the stuff to stay around and actually lubricate moving parts. **Recommending misapplication is very silly.** Use lubricants for lubrication, leave the hydraulic fluid for use in hydraulic systems.
Comment: Motor **Cycle** Chain lube perhaps? This tends to be a grease in a solvent that allows the lubricant to penetrate into the links. While it would make a good lubricant for pivot points and oscillating mechanism shafts due to the grease component, you will want a medium weight oil if you're using it on the fan motor bearings.
Comment: Transmission fluids like Dexron III are lubricants. Don't be silly!
Comment: How about **Motor Chain Lube**?
Answer: No on the brake fluid and no on the steering fluid. If the fan has a fitting to apply oil use a light oil like 3 in 1 home lubricant. If the fan isn't equipped with an oiling port you will have to disassemble the fan to gain access to the bushings or bearings.
Answer: A non-drying oil like Olive oil, or Bacon Grease'll work. A drying oil, like corn or flax oil, will oxidize and form a varnish that glues motor shaft to bushings. That's bad. As mikes implies, a light oil formulated for the purpose is your best choice, and the cost of a small can every decade or two is negligable.
Comment: Rendered sheep fat if you're going natural. Olive oil doesn't belong on metal and all the natural stuff oxidizes and plugs the pores in the Oilite Sintered Bronze bushings typically used in fan motors, leading to a worsening of the problem you're trying to cure.
Comment: I had tried **olive oil** but the squeaking came back after a few days... or am I not applying it correctly?


Linux: using Evernote from Emacs?

Question: I would like to know if there is any software enabling us to use Evernote from Emacs in Linux. I edit my notes with Emacs in a text file that has grown to several MBs over the last 10 years, and I would like to be able to have it syncing with Evernote, and be able to do things like add images to it as well. Any ideas?
Answer: http://code.google.com/p/emacs-evernote-mode/ is working.   I have used it successfully.
Comment: `404. That's an error.`
Answer: Evernote uses HTML behind the scenes, perhaps you could be something similar using dropbox or something similar to provide the syncing?
I realize that was not the answer you were looking for, but short of using the Evernote API and making it work with emacs I do not believe it is possible to edit evernote notes with other editors.

Linux: using Evernote from Emacs?


Will increasing physical RAM help in less virtual memory usage and avoid virtual memory bottlenecks in Linux?

Question: In Linux, for a 8GB RAM server, when could we say virtual memory is actually used more? I.e., what is the number of page faults which says system is using more virtual memory?
Comment: Memory usage (excluding cache/buffers) will of course be exactly the same, as will [virtual memory](https://en.wikipedia.org/wiki/Virtual_memory) usage. Are you perhaps referring to swap?
Answer: Of course yes, Virtual Memory (known as Swap in Linux) will be used less when there is enough memory.
There is a kernel parameter called swappiness that controls how much swap is likely to be used. Tune it to your needs. To see current value (all commands need root):
cat /proc/sys/vm/swappiness

and to set the value
sysctl vm.swappiness=10

and to persist it, open /etc/sysctl.conf and add (or change)
vm.swappiness=10

More information here.
Consider value as percent, and less value means using less swap.
On my laptop with 16GB RAM, using 10 I'm just fine.


Architecture: Notification mechanism

Question: I am just considering several architectural options for a standard software systems. Perhaps you'd like to share your opinions.
System:
We have a business logic component with an underlying database. Until today this logic component was used only by one client and thus UI and Logic and Data layer all have been in one executable. (Tool A)
Now, the program has such cool features that another, already existing tool should use it (Tool B). Tool B shall also use (or at least display) some of the data of Tool A but it also keeps its own data storage. Our solution approach is simple:
We split Tool A. The business logic gets a service interface (probably web services, RESTful or not). Then tool B can access the business logic of Tool A, get data, execute calculations, whatever.
Now, if Tool B shows data of Tool A, it would be nice if it would be notified of data changes in Tool A. Our service interface is nice but a one-way story (if you don't do tricks like keeping asynchronous calls open until an event occurs).
We see several options:

a. Tool B also gets a service interface. When it fires up it registers with Tool A and Tool A will send change events to Tool B.
b. Tool B is polling the service of Tool A for changes.
c. We introduce a middleware where Tool A is publishing events and all clients may subscribe to those events.

We don't like b). Too slow and Tool A would need a means to determine the changes for each client.
c) has the overhead of introducing a new component.
a) Will tightly couple the two tools.
Further information:
We will have a central datastorage (+ our business logic component) on one machine. On other machines may be the clients (up to 20, let's say. Not 100, not 1000, not 10000).
It is a system from one vendor. We don't have to be prepared for lots of third party tools who want to use the events (that would be a strong indicator for solution c)).
Questions:
i) What other options than a)-c) do we have?
ii) Which way would you go and why?
Answer: (i) I can't think of anything off the top of my head.
(ii) Option (c), using something simple like 0mq
Comment: Thanks for the link to zeromq!

Architecture: Notification mechanism


magento2 build image updater service which run through all created products and add missing images to product

Question: I have some products created, but they do not have images when i see them in frontend or backend. I have these missing images in one folder with the format of productSku.png.
I want to build image updater service which run through all created products and add missing images to product
Answer: Quick solution - use the Magento Product Images import functionality:

Write a simple php script which collects all your SKUs from the filenames from your images folder and creates a CSV file with the product SKU on first column, then the base_image, small_image, thumbnail_image, or additional_images on the other columns filled with the image filename.
Move all your images in the <project_root>/var/import/images/ folder.
Use the Magento product images importer guideline to import the CSV file previously created.
Answer: I have done this before with an external bootstrap script. It would also be possible with a custom module cli command.
You need to give consideration to the type of product (simple, configurable, grouped etc), and the image roles you require i.e swatch images. If you have a multi store setup you also need to check if your image role attributes are set to store view or global - i.e. do you want the same images for all store views.
You will need to be able to correlate your images in your folder with your product stock-keeping unit (SKU). This is best achieved by consistently renaming the images. For example if the product sku is ABC-01 and your image is product-image-abc-01.jpg then you will need to determine the image filename from the sku.
To find your missing images load a product collection (all products) and parse each products media gallery data
$_existingMediaGalleryEntries = $_product->getMediaGalleryEntries();
$_imageRoles=array();
foreach ($_existingMediaGalleryEntries as $entry) {
    $_imageRoles[]=$entry->getTypes();
}

if $_imageRoles[] is empty, the product (probably) has no image.
Set your store view
$_store = $this->_storeManagerInterface->getStore($_storeId);
$this->_storeManagerInterface->setCurrentStore($_store);

then loop through the products with missing images, loading them using the product repository
$_product = $this->_productRepository->get($_sku);

Clear and then set the image data depending on the product type and the roles you require. The folder with your images in $_imageImportPath must be relative to the Magento pub/media/import folder.
$_product->setMediaGallery (array('images'=>array (), 'values'=>array ()));
if ($_productType === 'simple')
{
    $_product->addImageToMediaGallery($_imageImportPath, array('swatch_image','image', 'small_image', 'thumbnail'), false, false);
} else {
    $_product->addImageToMediaGallery($_imageImportPath, array('image', 'small_image', 'thumbnail'), false, false);
}

When the image data is set you can save the product.
try {

    $this->_productRepository->save($_product);

    }

    catch(\Exceptionagento\Framework\Exception\NoSuchEntityException $e) {

      // catch NoSuchEntityException

    }


Fubini Tonelli's Theorem, Measure Theory

Question: This is a question from Folland's Book, Suppose $$f(x,y)=(1-xy)^{-a}$$ and $a>0$. Check if the following integrals exist and if they are equal:
$$\int_{[0,1]\times[0,1]}f d(x,y),\int_0^1\int_0^1f(x,y)dxdy,\int_0^1\int_0^1f(x,y)dydx$$
I know it has to deal with Fubini Tonelli's Theorem and this is in the context of Lebesgue Integral.
I know that $$\int_{[0,1]\times[0,1]}fd(x,y)=\sum_{k\ge1}\int a_k\chi_{S_k\cap [0,1]\times[0,1]}d(x,y)$$ Since the function is non negative. It is also continuous except at $(1,1)$, so measurable.
If I could show that the above integral is finite, then I would be done. But no idea how to show the above is finite.
Comment: Changing coordinates to polar coordinates around the corner (1,1) shows that the double integral converges if and only if $\int\limits_0r^{-a}r\mathrm dr$ does, that is, exactly for $a\lt2$.
Comment: @Did Thanks. I did not even think from that perspective, changing coordinates. :(
Answer: Changing coordinates to polar coordinates around the corner $(1,1)$ shows that the double integral converges if and only if $\int\limits_0r^{−a}\,r\mathrm dr$ does, that is, exactly for $a<2$.


rake test not copying development postgres db with sequences

Question: I am trying to develop a rails application on postgresql using a sequence to increment a field instead of a default ruby approach based on validates_uniqueness_of.
This has proved challenging for a number of reasons:
1. This is a migration of an existing table, not a new table or column
2. Using parameter :default => "nextval('seq')" didn't work because it tries to set it in parenthesis
3. Eventually got migration working in 2 steps:
change_column :work_commencement_orders, :wco_number_suffix, :integer, :null => false#, :options => "set default nextval('wco_number_suffix_seq')"

execute %{
  ALTER TABLE work_commencement_orders ALTER COLUMN wco_number_suffix SET DEFAULT nextval('wco_number_suffix_seq');
}

Now this would appear to have done the correct thing in the development database and the schema looks like:
wco_number_suffix      | integer                     | not null default nextval('wco_number_suffix_seq'::regclass)

However, the tests are failing with
PGError: ERROR:  null value in column "wco_number_suffix" violates not-null constraint
: INSERT INTO "work_commencement_orders" ("expense_account_id", "created_at",
"process_id", "vo2_issued_on", "wco_template", "updated_at", "notes", "process_type",
"vo_number", "vo_issued_on", "vo2_number", "wco_type_id", "created_by",
"contractor_id", "old_wco_type", "master_wco_number", "deadline", "updated_by",
"detail", "elective_id", "authorization_batch_id", "delivery_lat", "delivery_long",
"operational", "state", "issued_on", "delivery_detail") VALUES(226, '2010-05-31
07:02:16.764215', 728, NULL, E'Default', '2010-05-31 07:02:16.764215', NULL,
E'Procurement::Process', NULL, NULL, NULL, 226, NULL, 276, NULL, E'MWCO-213',
'2010-06-14 07:02:16.756952', NULL, E'Name 4597', 220, NULL, NULL, NULL, 'f',
E'pending', NULL, E'728 Test Road; Test Town; 1234; Test Land') RETURNING "id"

The explanation can be found when you inspect the schema of the test database:
wco_number_suffix      | integer                     | not null

So what happened to the default?
I tried adding
task:
    template: smmt_ops_development

to the database.yml file which has the effect of issuing
create database smmt_ops_test template = "smmt_ops_development" encoding = 'utf8'

I have verified that if I issue this then it does in fact copy the default nextval. So clearly rails is doing something after that to suppress it again.
Any suggestions as to how to fix this?
Thanks
Robert
Answer: I didn't solve the problem as such but developed the following workaround for the work_commencement_orders model to enable the tests to run.
###########################################################################
###########################################################################
# NOTE this is purely for test, it should have no effect on development or production
# as the field will be marked readonly and prevented from being written to the db so that
# it picks up a default value from its sequence.
public

def before_validation
  if wco_number_suffix.blank?
    maximum = WorkCommencementOrder::Entity.maximum(:wco_number_suffix)
    maximum ||= 0
    self.wco_number_suffix = maximum + 1
  end
end

private

def test?
  @is_test ||= (ENV['RAILS_ENV'] == 'test')
end

# Override default behaviour so that when not in test environment it does not try
# to write readonly attributes during create but instead allows them to be initialised
# by default value.
def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = test?, attribute_names = @attributes.keys)
  super(include_primary_key, include_readonly_attributes, attribute_names)
end

###########################################################################
###########################################################################

Answer: I stumbled into the same issue. For future visitors
Basically put this in your config/environments/development.rb and run your tests.
    config.active_record.schema_format = :sql

For more info -
https://rails.lighthouseapp.com/projects/8994/tickets/5849-rails3-rake-task-dbtestprepare-no-longer-handles-stored-procedures


Convert a list with strings all to lowercase or uppercase

Question: I have a Python list variable that contains strings. Is there a function that can convert all the strings in one pass to lowercase and vice versa, uppercase?
Comment: Why "in one pass"? Do you contemplate the possibility of it taking multiple passes?
Answer: It can be done with list comprehensions
>>> [x.lower() for x in ["A", "B", "C"]]
['a', 'b', 'c']
>>> [x.upper() for x in ["a", "b", "c"]]
['A', 'B', 'C']

or with the map function
>>> list(map(lambda x: x.lower(), ["A", "B", "C"]))
['a', 'b', 'c']
>>> list(map(lambda x: x.upper(), ["a", "b", "c"]))
['A', 'B', 'C']

Comment: Second proposition with **map** is correct but wasteful. There is **no point in making a lambda function**. Just use `map(str.lower, ["A","B","C"])`
Comment: @ThePhi I did a quick check using a small sample I have. Doing a loop on my 20 lists with around 500 items each. The fastest was the former (avg. 0.0011s) vs using map (avg. 0.0022s).
Comment: @mimic A bit late, but for people coming across this, I'm guessing your issue was probably that you were not assigning the result of the list comprehension back to your list. Just doing to the list comprehension returns the value, but does not reassign it to the list variable.
Comment: When I try to print a list after this call nothing changes. Why is that?
Comment: What is the fastest between the two? (list comprehension vs map)
Answer: >>> list(map(str.lower,["A","B","C"]))
['a', 'b', 'c']

Comment: In Python 3 you need to pass the resulting map to the list function to get the desired result, that is, `list(map(str.lower,["A","B","C"]))`.
Comment: obviously `str.upper` to convert to uppercase
Answer: Besides being easier to read (for many people), list comprehensions win the speed race, too:
$ python2.6 -m timeit '[x.lower() for x in ["A","B","C"]]'
1000000 loops, best of 3: 1.03 usec per loop
$ python2.6 -m timeit '[x.upper() for x in ["a","b","c"]]'
1000000 loops, best of 3: 1.04 usec per loop

$ python2.6 -m timeit 'map(str.lower,["A","B","C"])'
1000000 loops, best of 3: 1.44 usec per loop
$ python2.6 -m timeit 'map(str.upper,["a","b","c"])'
1000000 loops, best of 3: 1.44 usec per loop

$ python2.6 -m timeit 'map(lambda x:x.lower(),["A","B","C"])'
1000000 loops, best of 3: 1.87 usec per loop
$ python2.6 -m timeit 'map(lambda x:x.upper(),["a","b","c"])'
1000000 loops, best of 3: 1.87 usec per loop

Comment: It isn't always faster.  Here's an example where it's not: http://stackoverflow.com/questions/1247486/python-list-comprehension-vs-map  But it's not *much* slower in that case.  Using a lambda obviously makes a big difference.  There are more examples of why it's dangerous to trust your intuition on performance issues, especially in Python.
Comment: Do you know the reason behind why a list comprehension is faster than map?
Comment: in python 3, `map` wins the race, but does nothing :)
Comment: @NedDeily `map(str.lower,["A","B","C"])` is fastest is python3.7.5
Comment: @SHIVAMJINDAL because `map` doesn't do anything besides create an object that does the `.lower()` when you *iterate* over it. If you try `list(map())` it's slower. Just as Jean-François said.
Answer: List comprehension is how I'd do it, it's the "Pythonic" way. The following transcript shows how to convert a list to all upper case then back to lower:
pax@paxbox7:~$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> x = ["one", "two", "three"] ; x
['one', 'two', 'three']

>>> x = [element.upper() for element in x] ; x
['ONE', 'TWO', 'THREE']

>>> x = [element.lower() for element in x] ; x
['one', 'two', 'three']

Comment: err, using `list` as a variable name isn't the best choice :)
Comment: yeah, I wasn't criticizing yours (apart from the `list` stuff :)).Where do you think the UV you recently got comes from ? :)
Comment: No but, since the name is of little importance to the method being shown, it's not really relevant. However, I'll change the name in case someone wants to use the code as is.
Comment: the magic of stackoverflow: 250 votes for a python 2-only solution using lambda where it shouldn't!! well 249 now
Comment: @Jean-FrançoisFabre, not sure why you think this is this a Python-2-only solution. As the transcripts shows, it's *clearly* running under Python 3.5.2. In fact, I just checked it *again* for confirmation. ... some time passes while I investigate ... Actually, never mind, it appears you were talking about the current accepted answer rather than this one, so you probably should be commenting *there* rather than here. No doubt an honest mistake. Cheers.
Answer: For this sample the comprehension is fastest

$ python -m timeit -s 's=["one","two","three"]*1000' '[x.upper for x in s]'
1000 loops, best of 3: 809 usec per loop

$ python -m timeit -s 's=["one","two","three"]*1000' 'map(str.upper,s)'
1000 loops, best of 3: 1.12 msec per loop

$ python -m timeit -s 's=["one","two","three"]*1000' 'map(lambda x:x.upper(),s)'
1000 loops, best of 3: 1.77 msec per loop
Answer: a student asking, another student with the same problem answering :))
fruits=['orange', 'grape', 'kiwi', 'apple', 'mango', 'fig', 'lemon']
newList = []
for fruit in fruits:
    newList.append(fruit.upper())
print(newList)

Answer: mylist = ['Mixed Case One', 'Mixed Case Two', 'Mixed Three']
print(list(map(lambda x: x.lower(), mylist)))
print(list(map(lambda x: x.upper(), mylist)))

Answer: A much simpler version of the top answer is given here by @Amorpheuses.
With a list of values in val:
valsLower = [item.lower() for item in vals]

This worked well for me with an f = open() text source.
Answer: If your purpose is to matching with another string by converting in one pass, you can use str.casefold() as well.
This is useful when you have non-ascii characters and matching with ascii versions(eg: maße vs masse).Though str.lower or str.upper fails in such cases, str.casefold() will pass.
This is available in Python 3 and the idea is discussed in detail with the answer https://stackoverflow.com/a/31599276/4848659.
>>>str="Hello World";
>>>print(str.lower());
hello world
>>>print(str.upper());
HELLO WOLRD
>>>print(str.casefold());
hello world

Answer: You could try using:
my_list = ['india', 'america', 'china', 'korea']

def capitalize_list(item):
    return item.upper()

print(list(map(capitalize_list, my_list)))

Answer: Here's another solution to the problem, but I don't recommend using it. Just putting it here for completion of this topic since this solution wasn't added before.
import timeit

def foo1():
    L = ["A", "B", "C", "&"]
    return [x.lower() for x in L]
def foo2():
    L = ["A", "B", "C", "&"]
    return "%".join(L).lower().split("%")

for i in range(10):
    print("foo1", timeit.timeit(foo1, number=100000))
    print("foo2", timeit.timeit(foo2, number=100000), end="\n\n")

foo1 0.0814619
foo2 0.058695300000000006

foo1 0.08401910000000004
foo2 0.06001100000000004

foo1 0.08252670000000001
foo2 0.0601641

foo1 0.08721100000000004
foo2 0.06254229999999994

foo1 0.08776279999999992
foo2 0.05946070000000003

foo1 0.08383590000000007
foo2 0.05982449999999995

foo1 0.08354679999999992
foo2 0.05930219999999997

foo1 0.08526650000000013
foo2 0.060690699999999875

foo1 0.09940110000000013
foo2 0.08484609999999981

foo1 0.09921800000000003
foo2 0.06182889999999985

Answer: Solution:
>>> s = []
>>> p = ['This', 'That', 'There', 'is', 'apple']
>>> [s.append(i.lower()) if not i.islower() else s.append(i) for i in p]
>>> s
>>> ['this', 'that', 'there', 'is','apple']

This solution will create a separate list containing the lowercase items, regardless of their original case. If the original case is upper then the list s will contain lowercase of the respective item in list p. If the original case of the list item is already lowercase in list p then the list s will retain the item's case and keep it in lowercase. Now you can use list s instead of list p.
Answer: If you are trying to convert all string to lowercase in the list, You can use pandas :
import pandas as pd

data = ['Study', 'Insights']

pd_d = list(pd.Series(data).str.lower())

output:
['study', 'insights']


Drag & Drop: How to prevent folders in my Dock to pop up as windows?

Question: I have a folder in my dock where I want to drop files. When hovering over the icon, the folder always pops up as new Finder window. I want it to be a stack or a list. Is there a way to achieve this?
Comment: You can control-click on the folder and choose stack or list but that affects how it is shown when you click on it. I think you're talking about spring-loading and the control-click settings do not seem to affect this.
Comment: Yes, I know and tried all three of these settings, they seem to have no effect for drag and drop.
Comment: Might it, by any chance be a smart folder? If so then there is no way around this.
Comment: No, it's not a smart folder, so I keep my hopes up.
Answer: In Finder preferences (⌘ cmd + , from Finder itself), unchecking "Spring-loaded folders and windows" will prevent a window from opening up when dragging files to a folder.
Comment: AFAIK this has no affect on **dock** folders, and the Finder window that appears when adding a file to such a folder.
Comment: This prevents the folders in my Dock from popping up at all. So I could only copy/move into the parent folder. I need to drop files into the child folders.


Retrieving user login time in SDL Tridion 2011

Question: I need to write a script that generates a report of users that have not logged into Tridion for 1 year. I know we can retrieve the modified dates and the users of all the files, but how would we track the login date of users who don't make any modifications, i.e. only read-only access?
Comment: Hi Wilson, thanks for joining SO and posting about SDL Tridion. would you consider committing to the Area 51 proposal for Tridion questions at http://area51.stackexchange.com/proposals/38335/tridion?referrer=eo63snjNlUWNn9xqeeO2NA2
Answer: Look at the IIS logs for the Tridion 2011 application.  In there you should see requests for all the pages in Tridion by various users.  Some of the entries will look like this:
2012-09-20 00:48:53 ::1 GET /WebUI/Editors/CME/Views/TridionDashboard/TridionDashboard.aspx - 81 TRIDION\Administrator ::1 Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/537.1+(KHTML,+like+Gecko)+Chrome/21.0.1180.89+Safari/537.1 200 0 0 48

From the item above you can see that the TridionDashboard page, i.e. the first page you get after logging in, was accessed by the TRIDION\Administrator user (yes, my Tridion VM is called "TRIDION" and I logon to it using the Administrator account).
So, what you need to do is make sure that the logs don't get overwritten once they fill up and get archived to a location where you can grab them and parse them.
The only info you require is the user name.  Simply throw it into some kind of a HashSet  data structure (that stores only unique keys) such that key is username and value is the timestamp.  I bet you can do all the parsing with a couple lines of code using Powershell (or if you use Cygwin a one liner using the grep command will also do the trick).
The logs are typically in %SystemDrive%\inetpub\logs\LogFiles, but check your system to ensure that location hasn't been modified.
Answer: I have never written Something like this, the only way I can think of achieving this is to create a GUI extension which adds AppData indicating login time to the User Object whenever they open the CME.
I don't believe there is an event triggered when the login occurs, otherwise I would suggest creating an even system.
You might consider reading this article by Nuno (http://www.tridiondeveloper.com/inheriting-metadata-on-organizational-items), it describes executing an action which is triggered by a user opening an item. My guess is that it would be triggered even when the user only has readonly access (but you would need to check this). If it is triggered on all read actions, you could update the user AppData whenever a user opens any IdentifiableObject in the CME. This would tell you when the user last viewed any item in the CME.
Hope that helps
Chris
Comment: I have written something like that, following the approach that Chris mentions (write something on Load). Just be careful that Load events fire _a lot_ and you have to make sure you're not killing the system with the overhead of writing this data somewhere.
Answer: Mihai blogged about this a while ago, here is the link, it has some code examples too: http://yatb.mitza.net/2012/03/capturing-users-last-login-date-into.html
Answer: You could implement the Load event. This is called by pretty much every action in the GUI. As soon as anyone uses Tridion, the event is certainly called.
But be careful: you have to write super efficient code because otherwise it will slow down the system.
Comment: Mihai blogged about this a while ago, here is the link, it has some code examples too: http://yatb.mitza.net/2012/03/capturing-users-last-login-date-into.html
Comment: I think Mihai's blog is the answer! Will you change your comment into an answer so it can be accepted? Or let Mihai do it himself, of course..
Answer: Tridion doesn't keep track of a "last modification made by this user", so you'll have to roll something yourself.
The first thing that pops to my mind is to write a handler for the Save event of IdentifiableObject. In that handler you can update an Application Data property on the user. The script can then simply loop over all users, get your AppData and determine which users have been inactive for more than a year.
Comment: I think you have missed the point - It IS possible to get a list of items that a user has modified, and from that it IS possible to get a date of the last time a user modified an item in the CMS. User1684360 is asking how he might tackle the challenge of logging when a user last logged into the CME, as several of the users only have read access to the CMS, and as such never edit any items. I don't believe there is an event associated with a user logging into the CMS, or  am I wrong?
Comment: You're right, I misread and then started over-engineering. :-) There indeed is no LogOn event, so a GUI extension would be the only thing I can think of for that. Or a ReadEvent on the User object. I never looked at the exact happenings of such an event, but fear it may fire too often. For example when somebody starts iterating all users.


Disable keyboard shortcuts on GitHub?

Question: I'm especially interested in disabling "T" button.
Comment: What page are you on for T?
Comment: @EightDaysofMalaise At least on every "repository" page. For example here: https://github.com/qbittorrent/qBittorrent . I haven't noticed before, it's shortcut for "file finder"
Comment: I use search-as-you-type to find things in my editors and on github pages, it's really annoying when it jumps me off the page i'm on and onto the "find a file" screen because i pressed 't'.
Comment: [In Firefox it looks like this'll work.](http://superuser.com/questions/399352/how-do-i-prevent-pages-i-visit-from-overriding-selected-firefox-shortcut-keys)
Comment: @TomWoodward thx, looks like it will work everywhere
Answer: Basically copying answer from superuser.com linked by Tom Woodward in comments. I've only changed keycode and url.
It's Greasemonkey script which disables "T" shortcut. Supported by major browsers (extension like Greasemonkey for Firefox/Tampermonkey for Chrome may be needed/useful).
// Your code here...

// ==UserScript==
// @name           Disable keyboard shortcuts
// @description    Stop websites from highjacking keyboard shortcuts
//
// @run-at         document-start
// @include        *github.com*
// @grant          none
// ==/UserScript==

keycodes = [84] // Keycode for 'T', add more keycodes to disable other key captures

document.addEventListener('keydown', function(e) {
//    alert(e.keyCode); //uncomment to find out the keycode for any given key
    if (keycodes.indexOf(e.keyCode) != -1)
    {
        e.cancelBubble = true;
        e.stopImmediatePropagation();
    }
    return false;
});

Comment: This answer is outdated, there is now an easier way to do this through GitHub Accessibility settings, I've added a new answer.
Answer: To simplify janot's answer (I can't add comments) use e.key instead of e.keyCode, then you don't need to figure out keycodes at all and instead can just list your keys = ['t'].
Answer: You can disable keyboard shortcuts that don't use a modifier key (Ctrl or Cmd) in the GitHub Accessibility settings
Comment: I thought this answer was a totally different approach to the accepted answer so would not be suitable to edit it. Can you link me to where the forum policy states link-only answers are bad?
Comment: [edit] "your" answer, not the accepted answer.  See [answer]:  *"Links to other websites should always be helpful, but avoid making it necessary to click on them as much as possible."*. [This Meta Stack Exchange post](https://meta.stackexchange.com/q/8231/) also has some related content
Comment: SE sites are not forums. Even as an experienced SE user, if you never have, it would be valuable on each  site to take the [Tour] and review [ask] and [answer].  While I expect the "link only" issue is pretty common, other guidelines will vary. You are automatically given 100 reputation when you join new sites based on your SE "experience".  In turn you should be familiar with how the sites work, and willing to access readily available documentation like [answer].
Answer: The shortcut feature related code is in this JavaScript file:
https://github.githubassets.com/assets/environment-bootstrap-63ce95f0.js
You can use a browser ad block extension and disable this URL:
https://github.githubassets.com/assets/environment-bootstrap*
This will completely disable the shortcut feature.

Disable keyboard shortcuts on GitHub?


What is the difference between grape and cherry tomatoes?

Question: What is the flavor difference between grape and cherry tomatoes? The store had both and they looked rather similar.
Answer: The difference in their name is - not surprisingly - because of their form. Cherry tomatoes are round, while grape tomatoes are more oblong. Wikipedia mentions that grape tomatoes are 'sweet as cherry tomatoes', so not much difference in flavour according to this. Perhaps grape tomatoes are more similar to small plum tomatoes.
This site claims grape tomatoes to be sweeter, having a thicker skin and a lower water content than cherry tomatoes. Interestingly, it also says that grape tomatoes are a cross between cherry tomatoes and other tomatoes.
The claims of the second site are in agreement with this site ("grape tomatoes have thicker skin, lower water content and intense sweetness"). It also states "a grape tomato is half the size of a cherry tomato", so perhaps they are smaller. Due to the lower water content, grape tomatoes have less chance of 'squirting' when being bitten into.
Comment: Grape and cherry refer to the shape more than anything else.  With so many different varieties you can get different characteristics from one type of cherry to another.  Also how ripe they are will cause huge differences as well.  As a general rule though...grape tomoatoes are the Roma's compared to the cherry's being the field type.  Roma being slightly more fleshy and less pulp is what I'm getting at.
Comment: I find grape tomatoes are the better choice as in general they have more tomato flavor, the cherry tomatoes are good if you want to stuff them with salad for a small bite.
Answer: If there is a difference, I think it's smaller than all of the normal variations in supermarket tomatoes. Buying either kind, I've gotten plump/juicy ones, drier/mealy ones, sweet ones, bland ones. I think this is mostly attributable to the wide variation in quality of storebought tomatoes, notably seasonal variation and how unripe they were when picked. Some may actually be different types of tomatoes, too: I know there are a few reasonably widespread cultivars sold as cherry tomatoes.
I think the primary reason for the "grape" name is just the shape; cherries are more spherical and grapes are oblong. Both grape and cherry tomatoes should usually be sweeter than larger tomatoes.
If you're a gardener or are lucky enough to know someone who can supply you, I think you'll find much more variety in flavor among all the types of little tomatoes that people grow at home. I've had some that were so sweet I felt like I was eating delicious tomato candy off a vine, and I've had others with a full tomato flavor but not so much sweetness. Unfortunately I don't know names of varieties here, but I'm sure if you sought out that sort of thing, you could discover the ones you like most!
Answer: Cherry Tomatoes depending on variety are usually more tangy than sweet.
A popular variety sold in Australia is Genio (unsure spelling) has a long shelf life with tangy flavor.  Suitable for salads as a replacement for tomatoes.  They also tend to hold their shape better during cooking compared to the run of the mill variety of grape tomatoes.
Whilst grape tomatoes generally have a sweeter flavor over their cherry counterparts.  These usually have a shorter shelf life but ripen quicker as a result.  In terms of cooking, grape tomatoes usually have a stronger flavor and may over power other ingredients.
Lastly another issue is when the fruit is harvested.  For commercial production cherry and grape tomatoes are typically harvested when they are light orange in colour.  With cherry tomatoes some varieties will be sugary sweet if left on the vine until full colour.
Overall, the main issue is identifying which variety is being sold.
General terms
Cherry = Tangy
Grape = Sweet
Comment: It's interesting because in Canada the Cherry tomatoes are far more sweet than the Grape. Here Cherry tomatoes are basically perfectly round, and grape are oblong.
Answer: Not so much difference between these two varieties of tomatoes. Cherry tomatoes are good for cooking and grape tomatoes are good for dressings. That's all in my point of view.
Answer: Renaming was inevitable once 'cherry' size became golfballs...
Round or oblong 'grape' tomato? I tried a nice golden egg-shaped wee one; more a texture difference than flavor: crispy juicy rather than mealy squishy.
Blessedly more variety these days in tomatoes.
How about pulling aside your supermarket green-grocer and asking for a sample? Not possible with prepackaged punnets but why shop where you can't touch and smell, hmmm?
Comment: I'm not sure how useful this is; I still see cherry-sized cherry tomtoes, and I've had mealy and juicy tomatoes of both names.
Comment: -1 for the totally irrelevant and condescending 3rd paragraph.
Comment: sorry to have offended. poster mentioned they looked similar but hadn't tasted... never had a grocer turn me down for tasting while most of us are not bold enough to ask.
Answer: Labeling. The only difference is what you call them.


Company in administration in Portugal

Question: If a company is being run in administration are contacts/agreements still valid ? For example, a service legal agreement.
Answer: Yes, they remain valid
However, the vast majority of contracts allow the innocent party to terminate them if the other party commits an 'insolvency event' like appointing an administrator. This is typically an active step that the innocent party must take; it doesn't automatically flow from the insolvency event.
In addition, a company in administration is likely to have breached the agreement by, for example, not paying their bills. This will also have consequences under the contract which may allow the innocent party to terminate.

Company in administration in Portugal


Drywall over doorway

Question: I know the correct option is to hang a single drywall board horizontally over the doorway, and then cut out the door. But just how terrible would it be to hang horizontal boards on either side, and then a single thin piece over the top? The sides would be small butt joints. Would it really be the end of the world as some forums are making it sound?
Answer: Every building settles. A common place where drywall cracks due to settlement is at the top of doors. Minimizing joints at top of doors is highly recommended.
Comment: The house was built in 1995 and this half bath was never finished. Does that make a difference re: settling?
Comment: I'm also not entirely sure how best to cut out the drywall if I do hang a piece horizontally over the door, since the door frame is already partially installed. I don't feel like buying a RotiZip.
Answer: A razor knife is a great tool for cutting sheetrock. I would guess any major settling has already happened. Reducing joints over doors will reduce cracking of a joint but with severe settling the sheetrock can crack or pull through the screws I don't think you are risk with your home.
Answer: Small but joints above each corner of the door ( properly taped )are not going to be to difficult to feather out and make less noticeable. You could choose to put one but joint somewhere over the door so you only have one to deal with and it will not affect the installation of trim at the corners.
More importantly It appears your door is not hung properly. In the photo it looks like the jamb  (door frame) is set flush with the wall framing so that you do not have anything to butt the Sheetrock to. The jamb should sticking out past the framing (stud) by the thickness of the Sheetrock so that when you put trim around the door it sits on the Sheetrock and overlaps onto the jamb.
Comment: Thanks. I shimmed the jamb siding in too much. I'll get that fixed. It was correct when I found it, the original builders had casing on the jamb (which I removed for this project) which had small pieces of 1/2 inch drywall for proper spacing. Oops!

Drywall over doorway


"WITH REPLACE" Restore failing with same logical filenames

Question: Does using WITH REPLACE when the logical filenames match (to avoid using WITH MOVE) fail when the backup is from a different version of SQL?  I have a backup from SQL 2008 but when I attempted to restore it using WITH REPLACE on a SQL 2012 folder, despite the Logical filenames matching on the database backup and the database I'm replacing, it's failing giving me the 'directory lookup' error.
Comment: Please add the actual error message, and the actual `RESTORE` command, etc.  Always err on the side of giving too much detail!
Answer: This is the answer I've found for why the file autolocation doesn't work in SQL 2012 for me.  I don't believe it has anything to do with the backup being from SQL 2008.

In SQL Server 2012, during the restore of a full backup without MOVE clauses that indicate the target physical location of each file, on top of an existing database, the file autolocation algorithm requires: not only a logical name match between the file declared in the backupset and any given file in the existing database, but also their file GUID, file ID, and create LSN must match. If any of those attributes don't match, the physical location used for that logical file is the one stored in the backupset. This additional requirement was implemented to fix this last scenario I just exposed which was considered a defect.

This was taken from this MSDN article: Link
Answer: WITH REPLACE refers to the database, not its files (though the net effect would be the same I guess).
If you have file names that match an existing database and you try to restore it as a different database, you will need to use WITH MOVE to prevent SQL Server from trying to overwrite the existing files (which it won't be able to do).
What's happening in your case, though, almost certainly, is that your database backup from 2008 has its data files in a path like:
C:\...\MSSQL.100\...\Data\

But on the SQL Server 2012 machine, that folder doesn't exist; it is going to be:
C:\...\MSSQL.110\...\Data\

(The differences may be even more pronounced if either is a named instance.)
So you have two options at this point:

Determine the folder(s) the backup expects, using RESTORE FILELISTONLY, and create those folders, making sure that the SQL Server service account has read/write/modify permissions.
Use WITH MOVE and put the files in a valid location.

A third, extremely silly option that I only mention for completeness is that you could go back to the 2008 server, move the database to a folder that matches a folder that exists on the new server, take a new backup, and then restore. Don't do this. Just stop trying to avoid typing WITH MOVE...
Comment: Aaron, thank you for the comments. I thought that if the logical filenames (not the physical filenames) matched on the database you were replacing that SQL server would automatically put the files into the same paths as the existing database (not the paths stored in the backup file).  I've successfully done this before (going from SQL 2008 backup to SQL 2008 server) but now I'm not sure if the physical filenames matched as well as the logical names.  My automated restore SPROC does look at FILELISTONLY and attempt to determine if a WITH MOVE statement is required.  I may need to tweak it.
Comment: I found this article which explains my situation entirely: http://blogs.msdn.com/b/ialonso/archive/2012/06/08/sql-server-changes-behavior-in-cases-where-file-autolocation-is-invoked-during-the-planning-phase-of-a-full-restore-with-replace-clause.aspx  Thoughts?


How to merge pdf file so that each file starts with file name?

Question: I have around 500+ files and I know how to merge them. But the problem is I would like to merge them in such a way that every file starts with the file neme in its first page.
For example I have 3 files (fila1,file2,file3) and each file has 10,20 and 30 pages. I need the merged file in such a way first page would be FILENAME that is file1 then the complete first file , then name of second file in one page followed by the file and so on....
How could I do so?
Comment: It sounds like you need to find a way to take a string of text and turn it into a new, one-page pdf - then merge all of those with all the original files, in the correct order.  What creates the original pdfs, and what command do you plan to use to merge them?
Answer: There are many ways to generate a banner page pdf. Here's one using groff:
declare -a files del
i=1
for file in file1.pdf file2.pdf file3.pdf
do  echo -e '.ft H\n.ps 30\n.vs 35\n.sp 10c\n.ce\n'"$file" |
    groff -Tps |
    ps2pdf - - >/tmp/title$i.pdf
    files+=(/tmp/title$i.pdf "$file")
    del+=(/tmp/title$i.pdf)
    let i=i+1
done
pdfconcat -o /tmp/out.pdf "${files[@]}"
rm ${del[@]}

It creates a tmp title pdf for each file and collects the filenames in bash array files and the names to delete in array del. The groff input is standard troff commands to set the font to Helvetica, the point size to 30 points, the line spacing slightly bigger, and to space 10 centimetres down the page for the text which is centered.
Comment: I tried as you mentioned and receive the following error message
Comment: declare -a files del; i= 1; for file in *.pdf; do echo -e '.ft H\n.ps 30\n.vs 35\n.sp 10c\n.ce\n'"
$file" |groff -Tps |ps2pdf - - >/tmp/title$i.pdf ; files+=(/tmp/title$i.pdf "$file") ; del+=(/tmp/title$i.pdf) ; let i=i+1; done; pdfconcat -o /tmp/out.pdf "${files[@]}"; rm ${del[@]}
1: command not found
pdfconcat: open /tmp/title.pdf: No such file or directory
rm: cannot remove '/tmp/title.pdf': No such file or directory
rm: cannot remove '/tmp/title1.pdf': No such file or directory
rm: cannot remove '/tmp/title2.pdf': No such file or directory
Comment: Could you please have a look what I did wrong?
Comment: The reason for the error `1: command not found` is because you left a space when setting `i`. It should be `i=1`. I dont know why you have the other errors. Make sure you are using `bash`. Add `set -x` to the start to see what each command is doing, and perhaps it will become clear what the problem is. Add any further debug output to your original question, where it will be easier to read, and just mention it in a comment to my answer.