What is cognate miRNA?

Question: I understand what miRNA are, but I'm unsure of what cognate means. Looking at this post, it seems that a cognate miRNA is a known miRNA vs. a recently discovered/possible miRNA. Is this thinking on the right track?
Answer: The use of the word cognate in molecular biology reflects adjectival definition 2 from Lexico:
2 formal Related; connected.
'cognate subjects such as physics and chemistry'
The example given shows that this can be used in the most general sense of related, so that there is no requirement for some common antecedent as a surrogate for a human mother or ancestor.
Specifically there is no implication of the involvement of a common DNA sequence, as in the answer from @Dirigible, nor that of a common origin as invoked in an earlier answer on this topic.
This is quite clear if one considers the much earlier usage of cognate in molecular biology in relation to an mRNA codon and the tRNA anticodons that can recognize it, or a tRNA and an aminoacyl tRNA synthetase that can aminoacylate it.
As far as the usage with microRNAs is concerned, a cognate mRNA is one with which the miRNA can interact by base-pairing — no more, no less.

What is cognate miRNA?


What is the largest inductance value ever attained (in Henries)?

Question: For example, are there inductors with values in terms of kH or even MH? 1 H inductors are not all that easy to find.
Comment: A quick google came up with an MRI magnet being only 6H, I'm surprised it's as small as that! This isn't really a physics question, it's an economics question. With a large coil of very fine wire, you could make a record-breaking inductance, that was totally useless through having very low SRF or high resistance, just to break a record.
Comment: @Mr X .Would it be interesting to know what the highest Q inductor is ?
Comment: I have seen some large values attained using gyrators (I cannot recall  the exact values but certainly in hundreds of Henries and perhaps more).
Comment: I think gyrators are cheating. They are inductor simulators, not real inductors. If gyrators count, then an open circuit also has infinite inductance.
Comment: Whenever you find it, put two in series.
Answer: The largest inductor ever known to me was Fermi National Accelerator Lab's Tevatron magnet.  If memory serves it was 1000 Henries running continuously at 1400 DC Amperes.  Energy storage must have been right around 1 GigaJoule.  They had a "quench resistor" designed to burn off the energy in case the magnet would develop an open circuit.  The resistor (designed by my boss!) could be seen from space on Google Maps until not long ago.
Comment: BTW, do you have any links to the huge "quench resistor" used?
Comment: Thanks for the answer! That's pretty much exactly what I was looking for.
Comment: Designing such a resistor was a question from my time as an undergraduate.
Comment: I recall calculating similar numbers for the specs of the magnets in ITER.  That was quite a long time ago; ooh, I wonder if they have actual test data now?!
Answer:
What is the largest inductance value ever attained(in Henry's)?

The magnetic permeability of free space is 1.2566370614…×10−6 henries per metre and the universe is pretty big. "What" you might possibly say and I would say that radio waves (and light) are carried vast distances between far-away galaxies so this "inductance" is being used to convey energy we can see and detect therefore it exists.
Between earth and the sun (93 Million miles or 150,000,000 km) I estimate the inductance to be 188,000 henries.
Comment: Interesting.  The Solar system is only 150 times more inductive than a ABB transformer?
Comment: @PaulUszak given that inductance is proportional to turns squared, that should not be surprising !!
Comment: I wonder what the capacitance and resonant frequency is?  ?365.25 days≠  (not ;)
Answer: I can't compete with the Universe (that's cheating anyway), but it's fairly easy to buy 25H inductors for power supply smoothing.  The audiophile guys do this all the time for their valve amps.
Inductance is a way to transfer power from one bit of metal to another.  So look at transformers.  Clearly power rating is closely related to inductance.  I can't find concrete evidence of anything bigger than 1200 MVA, but see this Wiki page.  It lists the largest inductance at ~1300H for a 3000MW transformer.  ABB do some large ones.
So we need another question: What's the biggest single transformer, and what's the power /inductance equation?
Comment: Instead of CRC rectified-ripple filters, use CLC. The very oldest radios used the L to also provide the flux field for the loudspeaker instead of expensive ALNICO material.
Comment: I've never heard of [large] inductors for PSU smoothing (unless it's a constant current one). Why/how would it be used instead of a large capacitor?
Comment: @Jodes  They're better than just large capacitors, and certainly were in the heyday of valve technology.  It's a sentimental throwback but works.  See http://www.angelfire.com/electronic/funwithtubes/3_Simple_Power.html , http://www.valvewizard.co.uk/smoothing.html , and http://www.ebay.co.uk/itm/SET-OF-3-INDUCTORS-CHOKES-25H-50mA-5H-70mA-FOR-VALVE-PREAMP-POWER-SUPPLY-NEW-/252871125352?hash=item3ae04b2968:g:1sAAAOSwhvFZB04I if you want to buy one.
Comment: @analogsystemsrf  i remember those... I wonder if anyone tried to make a 100kFarad LiPo Battery into a 100kHenry inductor with a power TIA. (transvestite amplifier)
Answer: Not sure about those but I just measured the inductance of a Tesla Model S rear drive AC inductance motor and it's somewhere between 20H and 25H across one phase. I got 23H but it was a really rough measurement. This means it would be around 70H for the 3 phases.
It's not the largest admittedly, but it's interesting to me so I thought I'd add it as a real world thing.
Comment: But the three phases aren't one inductor unless they're in delta and you open the loop. You might be interested in my answer to https://electronics.stackexchange.com/a/487353/73158.
Comment: @diegogmx: Good question. I would only have to consider it from the point of view of power factor correction. For PFC we quote the capacitors in kVAr per phase so I imagine a motor would be specified in the same way using the P-N voltage and phase single phase current.
Comment: Tesla Model S rear drive AC inductance motor is delta format
Comment: @Transistor how do you exactly define the motor inductance? the inductance seen across 2 connections, the coil inductance of a single phase or some way i didn't think of?
Answer: I had a small signal step-up transformer made once (~3 cm diameter) that had about 250 H secondary inductance.
That goes to show that you can achieve ridiculously large inductances by just winding many turn on high permeability cores. These inductors won't be able to handle a lot of current before saturating, so they are mostly useful for low frequency signal transformers.
Consider a slightly larger core with 1 mH permeance. Then you wind 100,000 turns on it. Its inductance will be 10 MH. I suppose it would be approx. the size of a large cooking pot (~30 cm). The reason this isn't done, is that there are no use cases for such inductors.
Answer: Signal transformers can go quite high, thanks to the extreme permeability of certain materials: permalloys and some nanocrystalline types being the most important today.  The catch: you don't get much flux, so the signal level and magnetizing current are both very low.
Offhand, I have a UTC (United Transformer) O-1, an audio transformer specifying 50kΩ secondary, 30-20KC (it's old enough to predate Hz, that's "kilocycles"), max level 8dBm.  It's packaged in a metal can (cylinder) about 2.2 x 3 cm (D x H).  With a 100kΩ source impedance, I measure -3dB (implying equal reactance) at about 5.3Hz, or L ~= 3000H.
If we make some assumptions about the core, say Bsat ~ 1T, Ae = 30 mm^2, then the signal level of 8dBm corresponds to 17.8Vrms into 50kΩ, and this voltage at 30Hz requires about 4.4k turns \$\left( N = \frac{V_\textrm{rms}}{4.44 B_\textrm{sat} A_e F} \right) \$.  (It's quite fine wire I'm sure; DC resistance is 3.7kΩ, probably in the range of 44-46AWG?)
(Aha, which is not at all a bad guess: I measure saturation at almost exactly the specified level. They said 8dBm and they meant it!)
Note this means an inductivity (AL) around 150µH/t2, no small feat for a spool of magnetic strip.
There are probably some (custom / boutique) audiophile transformers, or inductors* even, that have been made with similar or higher values.  I recall Turner Audio specifying some 150H chokes in one design, or maybe they were even more; I wouldn't be surprised to find an additional order of magnitude or two somewhere else.
*Inductors being the more impressive, as they have to tolerate some DC bias, so can't draw advantage from high-μ materials, and real (considerable) energy storage is in play.  Note my transformer saturates at a mere 30µA.
Also worth a look: anything with high voltages.  Neon sign transformer; power line sensing (potential transformer); historical examples perhaps (25Hz, 16.67Hz used to be used for power, and still are in some places!); etc.
Also, if you don't mind that it requires an external power source to operate, arbitrarily large inductances can of course be synthesized by active circuits.


Change file types from rows data to log

Question: I am looking for small advice. My database has 12 log files and x_log11 is showing file type as Rows data instead of Log and file group as primary. I am using SQL 2014.
I need to change it from rows data to log as it is log file?
will there be any impact if I will keep like this.
If I am trying to shrink(for other purpose) log files x_log11 is showing in data files.
will this settings impact on file growth of log files?
Comment: Why on earth do you want to have more than one log file at all? Please read [this](http://www.sqlskills.com/blogs/paul/multiple-log-files-and-why-theyre-bad/)...
Comment: I don't want.It's already there in my environment. So just trying to understand what can I do in this situation.
Comment: Rather than try to change a data file to a log file (which is not possible), what you should do is remove the 10 additional log files (and possibly rename this one, though that is solely cosmetic).
Comment: I guess you classify your files by the suffix of your database file names. Well, if that's the case, just rename your files.
Answer: A Rows file stores data and is where your data and meta-data lives.
A Log file stores changes to that data.
You can't change one to the other.
Comment: But my log file 11 is in rows data rather than log. can't change this? will it impact on growth of log files.
Comment: You can change the NAME of the file, but not the TYPE (rows vs logs) of file.
Comment: In theory, you can REMOVE a file, and create a new one that has the same name and is the other type. But removing ROW files means you're going to lose data. And removing LOG files may risk your system as well, unless you do so carefully.

Change file types from rows data to log


Facebook likes Influence SEO ranking

Question: I have seen some data that shows strong correlation between number of Facebook shares and Google ranking position. It makes sense. But I am wondering how does Google know number of Facebook shares. Viewing my html page source doesn't show it because the number is printed with javascript. Do I need to make any other step or is enough to just put like button?
Answer: My personal take -
Do not forget that liking something / sharing something is often visible elsewhere -- eg a public timeline, or a social widget on the blog of the user who shared / liked some of your pages.
Such would create a backlink to a specific page, which is a well known metric used by search engines (albeit not as much as it used to be). A single reference this way probably won't create any measurable effect, but if your numbers are large enough, you get the picture.
Answer: I liked this question, and could not wait to get an answer on this. So I did what any normal surfer would do ... Googled it.
This matter was widely discussed some time back with contributions from Rand Fishkin from SEOMoz, Matt Cutts from Google and the folks at Seoroundtable. Finally, the data scientist at SEOMoz published a slightly technical albeit extremely clarifying post which you need to read here.
In short - No. FB Likes do not influence SERPs.
There is correlation between higher SERPs and more likes, but correlation is not causation.
Comment: It's important to note that you should always have an open mind when reading things from Matt Cutts, hes often vague on purpose... Fact is they don't want us knowing everything about their rankings procedures otherwise people could get the rankings they want with little effort. I believe that Google uses social interaction as a trust factor, so they may not directly improve your rankings, but indirectly do by giving you 'trust'.
Answer:
Viewing my html page source doesn't show it because the number is printed with javascript
  Google reads JS very well, so this is no the reason.

Do I need to make any other step or is enough to just put like button?
Its only your own vision based on your visitors' needs. If the content stimulate users to like and share, you should do it.
Facebook likes don't influence SEO ranking. Matt Cutts said they (FB likes) can only show Google this content is interesting, but it doesn't influence ranking directly.

Facebook likes Influence SEO ranking


Nested Summation

Question: I have the following nested sum :
$$\sum_{i=1}^{n}\sum_{j=1}^{i}\sum_{k=1}^{j}x = x+1$$
I don't have a clue how to solve this one, can somebody help me?
Thanks in advance.
${}{}$
Comment: I"m confused. Is it really supposed to be an $x$ on both sides here?
Comment: This can't be correct. The right-hand side must depend on $n$, it seems to me.
Answer: I will use the rules found on this page.
First, note that $x$ is not in the base or limit of any of the sums, so it can be "pulled out":
$$x\sum_{i=1}^n\sum_{j=1}^i\sum_{k=1}^j 1= x+1$$
Work from inside to outside, simplifying the sum:
$$\sum_{k=1}^j 1 = j$$
$$\sum_{j=1}^ij = \frac{i(i+1)}{2}=\frac{1}{2}\cdot\left(i^2 + i\right)$$
$$\sum_{i=1}^n\frac{1}{2}\cdot\left(i^2 + i\right) = \frac{1}{2}\left(\sum_{i=1}^ni^2+\sum_{i=1}^ni\right) = \frac{1}{2}\left(\frac{n(n+1)(2n+1)}{6} + \frac{n(n+1)}{2}\right)$$
Now we're done, and can plug back in:
$$\frac{x}{2}\left(\frac{n(n+1)(2n+1)}{6} + \frac{n(n+1)}{2}\right)=x+1$$
Now, solving for $x$:
$$x\left(\frac{n(n+1)(2n+1)}{12} + \frac{n(n+1)}{4} - 1\right)=1$$
$$
\begin{align*}
x &= \frac{1}{\left(\frac{n(n+1)(2n+1)}{12} + \frac{n(n+1)}{4} - 1\right)} \\
  &= \frac{6}{n^3 + 3 n^2 + 2 n - 6}
\end{align*}
$$
Answer: After a little rearrangement we have
$$\begin{align*}
1+\frac1x&=\sum_{i=1}^n\sum_{j=1}^i\sum_{k=1}^j1\\
&=\sum_{i=1}^n\sum_{j=1}^ij\\
&=\sum_{1=1}^n\frac{i(i+1)}2\\
&=\frac12\left(\sum_{i=1}^ni^2+\sum_{i=1}^ni\right)\\
&=\frac12\left(\frac{n(n+1)(2n+1)}6+\frac{n(n+1)}2\right)\\
&=\frac1{12}\Big(n(n+1)(2n+1)+3n(n+1)\Big)\\
&=\frac{n(n+1)}{12}(2n+4)\\
&=\frac16n(n+1)(n+2)\\
&=\binom{n+2}3\;,
\end{align*}$$
so
$$\begin{align*}
x&=\frac1{\binom{n+2}3-1}\\
&=\frac6{n(n+1)(n+2)-6}\\
&=\frac6{n^3+3n^2+2n-6}\\
&=\frac6{(n-1)(n^2+4n+6)}\;.
\end{align*}$$
Comment: Can't this be done combinatorially?
Comment: @Ishan: Conceivably, but I don't at the moment see such an argument.
Answer: This question can be solved in a different way.
Your equation is equivalent to $1+\frac1x=\sum_{(i,j,k)\in A}1=|A|$
Where $A={(i,j,k)| 1\leq k  \leq j\leq i\leq n }$
So,$|A|= ^nC_3 +2^nC_2+^nC_1$
This is because, we can choose 3 distinct i,j,k or distinct i with the same j and k, or distinct k with the same i and j, or i=j=k.
So we get $1+\frac1x=^nC_3 +2^nC_2+^nC_1=^{n+2}C_3$

Nested Summation


Can we reduce infinitely linearly dependent spanning set to an independent set while keeping spanning?

Question: I'm quite unfamilar to infinite-dimensional case. Let $V$ be an infinite-dimensional vector space, and let $S$ be a subset of $V$. If $S$ spans $V$ and $S$ is linearly dependent, can we know that $S$ can be reduced to a linearly independent spanning set? If so, how to prove it? Does it require AC?
Comment: Probably a maximal linearly independent subset of $S$ will still span $V$.
Answer: This statement is in fact stronger than the claim that every vector space has a basis, which requires the full axiom of choice. So the answer is yes, but only with choice.
Comment: There are some weaker forms of choice, generally involving the ability to "choose" on some particular set. You can see the axiom of countable choice, or the axiom of dependent choice. However, in ZF, the assertion that every vector space has a basis is exactly equivalent to the (full-strength) axiom of choice. So not only will you need "something like" choice to prove your claim, but your claim would in turn *imply* the axiom of choice.
Comment: I'd look for a proof of every vector space having a basis. I imagine you'll have to change maybe five words to turn it into a proof of your claim.
Comment: What is the full axiom of choice mean?
Comment: Thanks. Very very clear. Learned a lot from your answer! By the way, do you know where can I find the proof of my claim? I think there are few linear algebra books have these.


Prove the irrationality of $e=\exp(1)$ with $\exp $ defined as solution of ODE

Question: I am writing math lessons as I will teach soon on my freetime.
In my course,
I defined $\exp(x)$ as the solution to the O.D.E :
 $$f'(x)=f(x),\qquad f(0)=1$$
Is there a way to prove, maybe by contradiction, that $e$ is irrational without using series?
Comment: You can always prove that the solution is $f(x)=\sum_{n=0}^\infty \frac{x^n}{n!}$, and then prove $f(1)$ is irrational. You usually prove irrationality of $e$ by an infinite sum, so it's the most straight up approach.
Comment: Seems to me you could just use the normal proof. Just avoid defining $e$ as a sum and use Taylor's theorem centered at $0$ extrapolated to $1$ directly.
Answer: I don't think there is; I think you'll have to prove $e=\sum_{k\ge 0}\frac{1}{k!}$ first. However, there's an easy way to do that using the ODE. We make repeated use of $f(1)=1+\int_0^1 f(t) dt$: $$f(1)=1+\int_0^1 (1+\int_0^t f(t') dt')dt+\cdots$$So $$f(1)=1+\int_0^1 dt+\int_0^1 dt\int_0^t dt' t'+\cdots=\sum_{k\ge 0}\frac{1}{k!}.$$
Comment: @T.D. Here's the simplest way to understand it. The $k$th term after the $1$ is a $k$-tuple integral with ordered integration variables $\in [0,\,1]$, so a random point in the unit hypercube has a $1/k!$ probability of "counting". So instead of the integrand, which is equal to the constant $1$, integrating to the hypercube's volume $1$, it's only $1/k!$.
Comment: Could you explain a bit the last line ? I don't see where the factorial comes from. Thanks


Practicing acoustic guitar silently

Question: I want to practice acoustic guitar without disturbing anyone else. I want to be the only person who can hear it. But how can I do that? Would it be okay if I buy an amplifier with a headset? Will this solve my problem?
Comment: Could we get you to further elaborate on your question? It is sort of sparse as it is.
Comment: Do you mean an acoustic guitar, or an electric?  If you do mean an acoustic, how do you expect an amplifier to change how loud the acoustic guitar is on its own?
Answer: There are a number of silent guitars on the market. These are quite similar in principle to electric violins - a solid non-resonant body and fitted with piezoelectric pickups at the bridge.  In addition headphones and possibly an amplifier will be required for silent practice.
Some are available as nylon-strung versions for classical-style guitar, as well as steel strung.
(Yamaha's range is marketed as the Silent Guitar, but other manufacturers probably make something similar; I'm not making any recommendations.)
Comment: they claim 80% quieter than an ordinary acoustic or 90% quieter than a classical...do they compare to any electric guitars that are not plugged in?
Comment: Heh, I haven't tried one. I would expect that they are **not** completely silent. I guess the steel strung versions may be as loud as an unplugged electric as Mr. Boy suggests in his answer. The nylon strung versions will probably be a bit quieter.
Answer: The point of an acoustic guitar is that it can be heard without need for any amplification. To have an instrument that cannot be heard by others, a solid guitar is a better option. That can then be connected to a small amp, etc., and headphones. What are the reasons you don't want to be heard? They may give other options.
Answer: I think this is a bit of a silly answer, but you could get a cheap/old acoustic guitar and rip the back off. This would kill all the acoustic resonance and you'd get hardly any noise.
But as others have said, an electric guitar is a better option unless you need an acoustic for specific reasons (which you should add to your question). However, even an unplugged electric guitar makes a reasonable amount of noise... not enough to wake your neighbours but enough to be annoying to other people in the same room.
Comment: Not a silly answer at all in my opinion. Could remove the back and possibly glue extra timber inside the soundboard to reinforce the line from the neck to the bridge. This would effectively be building a low cost, DIY semi-solid guitar.
Answer: If it is an acoustic guitar then I would suggest that you weave a shoelace or something similar around the strings near the bridge. This should reduce the sound significantly. Another idea is to use a piece of thick paper to strum and pick instead of a plastic pick.
Answer:
Use a toothbrush ... particularly the Oral-B CrossAction All In One Toothbrush as the tip of a bristles are longer. You can use that little part or strum hard with the entire head.

(And if you want LOUD and a different tone the Oral-B Indicator is the only toothbrush I've ever found in which the back of the head has a rounded, smooth, surface which makes is pretty comfortable for strumming ... and it's far louder and brighter because it's hard plastic.)

Use an electric with a acoustic pedal ... through an amp with headphones.
Answer: I realize this is quite an old question, but it has activity today so I'll chime in.
Any soft object placed under the area just in front of the bridge will greatly reduce sound of an acoustic guitar. Socks, cloth, foam padding, etc. If you look up bridge mute you can find devices especially made for this.
The real answer to this question is to find a practice space where you can play acoustic guitar un-muted. Muting the strings means you cannot hear yourself as well, and you need to hear yourself when practicing.

Practicing acoustic guitar silently


Add a new aspx page to a published website

Question: I have a .Net website which is published. Now I need to add a new page to the website but I do not have the source code which means that I cannot recompile and republish the website. I know that I can add an HTML page for this as the content for the new page is just plain HTML but that would show .html extension in the browser which I don't want. Is there any way to add an aspx page or html page is the only option I have ?
Comment: Yes you can add new pages without recompiling. I think you just need to not reference a code behind file.
Comment: Thanks your advice worked for me. Post is as an answer so that I can accept it.
Answer: alternatively, you can add a create an application and then add it as an application under the original website. As in, in IIS, right click on the original site, then Add Application; and put your new application into it.  Your new application will have it's own application pools and is an application by its own right without needing the original site's data.
Answer: Yes you can add pages without recompiling, just ensure the pages don't reference a code-behind file. You'll still be able to use code in the actual page itself, as well as reference controls (<code>.ascx</code> files).


How to filter content in views based on user id

Question: Is there a way to for a normal user (without admin power) to set permissions for a specific piece of content (not a content type) so that it is only visible to a specific user? I want it so that said specific user can see content that has been specifically assigned to them in a table in a view.
Comment: I tried making using a select list with names of users so that a name could be selected and assigned for a certain content type. I then edited the view for the specific user so that it would filter content based on what name was assigned, but I realized that since the view was for everyone in a certain role, I couldn't users see only content that was assigned to them specifically. @keithm
Comment: Welcome  to Drupal Answers! What do you mean by _a specific piece of content_?
Comment: By specific piece of content  mean, for example, Basic Page A, instead of just basic pages in general. @kiamlaluno
Answer: You can do it by using these modules:

If you want to give permissions to node then you can use this module
Node Access

Nodeaccess is a Drupal access control module which provides view, edit
  and delete access to nodes. Users with the 'grant node permissions'
  permission will have a grant tab on node pages which allows them to
  grant access to that node by user or role. Administrators can set
  default access controls per content type, and also define which roles
  are available to grant permissions to on the node grants tab.

If you want to "assign" node to some user, you can use user reference field and then in view add filter for that field and make it filter by current user.

For user reference use this field
References

There were a couple changes in the way 'References' views are handled
  ("referenceable nodes/users defined by a view"), which might require
  double-checking those existing on your site:

The 'label' (node title or user name) is no longer automatically    added if not included in the view. If some of your 'References' views
  currently do not include it, you might want to add it explicitly,
  else it will no longer appear in the widgets.
The HTML generated by the view is no longer stripped out before being    handed to "checkboxes / radios" widgets, thus allowing
  advanced    formatting. You might want to check for Reference views
  having fields    configured to display "as links", since the (probably
  unwanted)     tags generated by Views are not removed anymore.
Answer: have you seen Field Permissions module ?
visit https://www.drupal.org/project/field_permissions
by this module, you can add permissions to fields in order to visible/invisible part of content type.


Efficient way of scaling hundreds of QGraphicItems

Question: I have a zoomable QGraphicsView with scene that contains hundreds (and even thousands) of datapoints. The points are represented by QGraphicsEllipseItems and collected into a QGraphicsItemGroup. When the view is zoomed in to I want datapoints to stay at a constant size (i.e., the distances between neigbouring points increase but the sizes stay the same). Right now I achieve this by running this code every time the user zooms in:

#get all the QGraphicsEllipseItems that make up the QGraphicsItemGroup
children = graphics_item_group.childItems()
for c in children:
    #base_size_x and base_size_y are the sizes of the
    #untrasformed ellipse (on the scene) when zoom factor is 1
    #New width and height are obtained from the original sizes and
    #the new zoom factors (h_scale, v_scale)
    new_width = base_size_x/h_scale
    new_height = base_size_y/v_scale

    #The top-left corner of the new rectangle for the item has to be recalculated
    #when scaling in order to keep the center at a constant position
    #For this, the center of the item has to be stored first
    old_center_x = c.rect().center().x()
    old_center_y = c.rect().center().y()

    #New coordinates of the rectangle top left point are calculated
    new_topleft_x = old_center_x - new_width/2.
    new_topleft_y = old_center_y - new_height/2.

    #Finally a new rectangle is set for the ellipse
    c.setRect(new_topleft_x, new_topleft_y, new_width, new_height)

This code works. The problem is that it is quite slow (without the compensatory scaling zooming in/out works very smoothly). I tried turning off antialiasing for the view but it makes things look pretty ugly. Is there anything else that I can do to make  the processing/redrawing faster?
Answer: In the constructor of the QGraphicsItem:
    setFlag(ItemIgnoresTransformations);

When you zoom, the item will remain the same size, and you won't have to manually scale it.


Putting something in the mailbox that will be picked up on Shabbos or Yom Tov

Question: Are you allowed to put an envelope in your personal mailbox that will be picked up on Shabbos or Yom Tov?
Comment: This question would be much improved if you'd indicate why you think it might be forbidden.
Answer: The Sanctity of Shabbos by Rabbi S. B. Cohen pg. 107 writes: "One is also permitted to place mail in his personal mailbox on Friday. (If one knows, however, that his mailman is Jewish, this is prohibited.)"
Amongst his sources is אגרות משה או"ח ח"ג [סוף] סי' מ"ו.
Comment: Welcome to MiYodeya. Thanks for your answer and source.
Answer: I have never asked a posek, but I have done so since I do not specify a need for it to be picked up on Shabbos, and Sunday works just as well.  The post office chooses their own time to pick up the mail (Its their preference to pick up on Saturday, not Sunday) so they are doing melacha on Shabbos for themselves.
Claiming that placing the mail there or raising the flag is similar to a command would mean I am not allowed to drop off my clothes at a launderer if I know for sure he's going to clean them on Shabbos, yet this restriction is not stipulated in the halachic sources.
I know of one rav who went into the post office on Friday to send an overnight letter (which would be a problem) and tried having a conversation with a confused postal worker about how he didn't want it delivered until Sunday!
Comment: Can you order a pick up for Yom Tov?
Comment: I don't think so and probably not erev yom tov, either. When you place your mail outside, everyone knows you didn't ask the mailman to specifically deliver your mail on Shabbos. When the mailman does a special pick-up, that is similar to Shulchan Aruch 247:3.  In that case, since there was a purchase of service on Fiday and all saw the mail guy start the service on Shabbos, it looks like the sender requested the service for Shabbos, despite his not caring when it gets delivered.


iOS + ArcGIS SDK. `AGSPictureMarkerSymbol*` shows on simulator, but doesn't on device

Question: I can show a AGSPictureMarkerSymbol* on iOS 6.1 simulator, but when running in debug with the device (iPhone 4, iOS 6.1), even though the code is "read" and no warning or exception appears, the marker just doesn't appear. The code is the following:
AGSPictureMarkerSymbol* locker = [[AGSPictureMarkerSymbol alloc] initWithImageNamed:@"locker.png"];
AGSPoint* point = [[AGSPoint alloc] initWithX:coord.x y:coord.y spatialReference:self.mapView.spatialReference];
[self.lockersLayer addGraphic:[[AGSGraphic alloc] initWithGeometry:point symbol:locker attributes:nil infoTemplateDelegate:nil]];

As a reference, this self.lockersLayer has also lots of AGSTextSymbol* and they show up just fine.
Thank you.
Answer: The problem was with the locker.png file. Don't know exactly what the problem was, but after changing it to another image, it started showing up on the device.


Evolution of Life

Question: Since life evolved here on Earth does that mean that life had to have existed before or in the future elsewhere in the Universe or could it be a one time only freak accident ?
Comment: Panspermia: http://en.wikipedia.org/wiki/Panspermia#Lithopanspermia
Comment: It **could** be a freak accident, but with the sheer scale of the universe, this is looking less likely.
Answer: Lets say you put a billion balloons on a dart board.  Now lets say you throw a million darts at that dart board.  If you were to pick a specific balloon and calculate the odds that THIS particular balloon would be hit by a dart, the odds would be astronomically low.  However, if you were to say that at least SOME of the balloons would be popped, the odds are astronomically high.
This is why I get frustrated at those who claim that the number of coincidences that had to happen (and there are many) are too many.  No, we were just one of the lucky planets out of the billions that got hit by a dart.
Answer: A "one time only freak accident" is only going to be considered as a likely possibility when scientists gain a deep understanding how life actually arises and on the basis of that can rule out that life will typically arise on Earth like planets in habitable zones. We haven't arrived at that point yet. Scientists will not invoke "freak accidents" to explain something unless there is a lot of evidence that points to that; clearly such assumptions amount to making the assumption that there is no natural explanation, but that has to be justified by other evidence first.
Answer: It almost surely did, is, and will exist elsewere in the Universe. Despite being an improbable event for a single planet, there are something like $10^{18}$ planets in the observable universe.
We already have found traces of proteins typical of life on Mars and comets coming from outer space. Probably Venus could host life a few billion years ago, when it was much warmer than today.
You can see more here, about the probability of the existence of other (intelligent) creatures in our Galaxy (notice that we're not even talking about the whole Universe!):
http://en.wikipedia.org/wiki/Drake_equation
Comment: Expand a little on the Drake Equation and you've got a good answer here!
Answer: Lacking both observation of ET life and a good understanding of how life originated, this question remains a great mystery. One can never completely disprove the existence of extraterrestrial life.
There are two basic approaches to potentially answer this: one theoretical and one empirical.

If a good theoretical understanding of the origin of life, abiogenesis, is achieved in laboratories, then the frequency of it happening given different observed exoplanetary conditions could be estimated.
Empirically, of course we might be lucky enough to discover some statistics of actually observed living exoplanets.

But there's a third way too, the SETI way. The evolutionary steps to intelligence, to technology, to space travel all seem to benefit the proliferation of life and thus would tend to become more common over time, if they at all occur. Considering the small size of the Milky Way compared to its age and reasonable space traveling and settling speeds, one could put upper limits on how common life is.
If anyone anytime anywhere in the Milky Way developed space travel to its nearest stars, they (their offspring) should be everywhere today! They won't need to travel further than a few light years to "seed" the entire galaxy, because their Sun does the traveling through the galaxy for them. Our Sun makes a revolution every 0.25 billion years, 18 full revolutions since it was formed. We know that dinosaurs lived on the other side of the galactic center. Traveling to the nearest stars over time spreads a space traveling civilization to all over the place. If we don't find any signs of artificiality during the next few decades, given the rapid advancements in telescopy, we can say that space traveling civilizations never happened anywhere (or got too exotic for us to discover even if under our nose). And that might be extrapolated to how frequent biological evolution is overall. And most importantly, what unique event happened here to make us walk on the Moon.
On Earth, life has settled every habitable spot on Earth (everywhere where liquid water is found, life is also found). Maybe life tends to settle on interstellar scales too?
Comment: @Peter U Do you "contact" trees? Since they must be there, and we don't see them, they must be weirder than we can understand.
Comment: Yes, this is the Fermi paradox isn't it ? They should be everywhere by now and yet we see no evidence of extra terrestrial life " where are they " ? SETI's reply is that they haven't been searching long enough and need a few dozen more years but why haven't they made any contact with us over billions of years ?
Comment: " Since they must be there " this has not been established yet with any proof. Different Worlds could be at different stages in development and yet we see no sign of any of them ??? The most obvious answer is that there is no one out there but I am still keeping an open mind and think that we should never give up in the search because nothing has been proven yet one way or other. Also I wanted to add that there are people that do actually try and contact trees but that is another story so we won't go into that, lol
Comment: What is most reasonable: 1) No one anywhere has ever done what we are doing here and now (how can we know what everyone  everywhere has always done?) Then why haven't we discovered what makes us unique? That divine thing is per definition here were we are, still we don't see it, why? Doesn't our unique divinity exist? 2) There was once somewhere space traveling life, and therefor it is eternal and everywhere because the galaxy is so small and old and no event can exterminate interstellar life. We see it already, but we just don't know what to look for so we do not recognize it.
Answer:
Could it be a one time only freak accident?

It's rather dubious, but there's no way to rule this out until we have seen signs of life elsewhere.
Depending on the numbers one plugs into the Drake equation, or variants thereof, the number of intelligent species ranges from hundreds of millions just within the Milky Way galaxy to but one in the entire observable universe. Needless to say, that's a rather sizable range.
If our nearest intelligent neighbor is in the next galaxy cluster, that still leaves room for billions of intelligent species in the observable universe, but it also leaves us essentially all alone. There's essentially no difference between a one-time freak accident where we truly are alone in the universe versus a billion intelligent species in the universe. There would need to be billions upon billions of intelligent species in the universe to have neighbors with whom we can communicate. Are there? The only possible answer science can currently offer is "that's a good question!"
Answer: Life here on earth developed on earth as far as scientists are aware. It is believed that life began in nutrient-rich puddles of a mud-like substance that is known as "primordial soup". This was the primitive ocean of the earth. Heat was also needed to develop life, and it's believed that life developed in the mid regions of Africa due to it being the hottest areas of the earth. I don't know about the formation of the cell under these conditions so that's an area I won't be able to explain. But from there, the theory of evolution took over. Cells start forming, mutating, developing some degree of genetic variation. Eventually, after millions of years, multi-celled organisms formed, like plants and basic animals. It's debated whether it was jellyfish or sea sponges that came first. Personally, I believe it's the sea sponge simply because it seems a more simple creature, it's just a bunch of identical cells working together collectively. Then evolution just continues on, creating more and more complex life.
Comment: I think the first multicellular organisms were simple unicellular organisms being glued together. It was a next step as they've started to differentiate for different tasks. For example, if we have a 2-cell being, where the first cell does only photosynthesis, and the second does the biochemical processes, they can be much more effective as if both should do both tasks. | Another possibility, that multicellular life started by that a cell has eaten another, but it couldn't digest it. Probably so were the mitochondrions evolved.

Evolution of Life


How do I stop my Nikon D40 from blurring when the flash is off?

Question: I hate using the flash when taking photos. I set a fast shutter speed and played with the aperture settings. It's fine with the flash on and takes the photo really quickly, but when I turn it off it always comes out blurred and I don't understand why. Frustration, please help.
Comment: possible duplicate of [How "slow" can I take a picture at a boxing match?](http://photo.stackexchange.com/questions/10439/how-slow-can-i-take-a-picture-at-a-boxing-match)
Comment: If your subject isn't moving you use a tripod.
Comment: While depending on it to have enough light to take an image clearly is a disadvantage of a flash, I find that the creative possibilities one gains when employing it (even just on camera) outweigh that fact by a huge amount (think grain of sand vs. Jupiter). Maybe you hate the flash because something is wrong with it or you have not yet explored all the possibilities, including those that you might actually _love_. As it's indifference that's the opposite of love, not hate, there seems to be something passionate about flash within you. I dare you to exploit it.
Answer: The camera needs a specific amount of light to take a properly exposed picture. How much light hits the sensor is tied to two items: shutter speed and aperture. Shutter speed defines how long light hits the sensor and aperture defines how much light hits per unit of time.
If you want to avoid blurry images you have to set a fast shutter speed as you've done, but that means that to take a properly exposed image, you need to adjust other things to make up for less light hitting the sensor. You can open up the aperture, but a lens has limits, and if you need more light than a wide open aperture can give for a shutter speed, the image won't work. That's physics.
Flash is used to add more light to a low-light situation so that the amount of light that hits the sensor is adequate. If you can't use flash and you can't adjust the shutter speed and aperture to get an adequate amount of light, your options are limited to playing with your ISO.
ISO defines how sensitive the sensor is to that light. If you raise the ISO, then the sensor is more sensitive to light. The side effect of this is that the sensor will generate more noise into the image, especially in the dark areas. If you raise the ISO too high, the noise will make the image unusable -- what that means is a judgement call, so you need to experiment here.
But unfortunately sometimes you simply can't get around the light and you need to decide what compromise to give up on -- do you accept the blur? do you accept the noise? Or do you strap on a flash? Part of figuring out photography is learning how to adjust for these factors to get the image you want.
Comment: To add to this, Image Stabilzation also comes into consideration. You can read about its application to still photography here: http://en.wikipedia.org/wiki/Image_stabilization#Application_in_still_photography


How to configure 2.1 speakers?

Question: I have a 2.1 speakers system that was working fine on Windows 7.
I just installed Ubuntu 14.04 LTS and now just the front-left and front-right speakers are working. The subwoofer is not working.
In the Sound Settings, there is just one option: "Analog Output (Built-in Audio)" where the subwoofer control is disabled and in the "Test sound" window I can only see "Front left" and "Front right" speakers.
I have already tried:
1) /etc/pulse/daemon.conf
enable-lfe-remixing = yes
default-sample-channels = 3
default-channel-map = front-left,front-right,lfe

Result: no changes
2) /etc/pulse/default.pa
load-module module-combine channels=3 channel_map=front-left,front-right,lfe

/etc/pulse/daemon.conf
enable-lfe-remixing = yes

Result: another option appeared in the Sound Settings: "Simultaneous output to Caicos HDMI Audio [Radeon HD 6400 Seris] Digital Stereo (HDMI), Buil-in Audio Analog Stereo". Within it, when I clicked "Test Sound", a new option appeared - "Subwoofer". But the sound was played by the 2 front speakers, and the subwoofer is still not working.
Does anybody have any idea?
Thanks
Answer: Have you tried the following?
resample-method = speex-float-1
enable-remixing = yes

enable-lfe-remixing = yes

Comment: can you please explain your answer a bit?

How to configure 2.1 speakers?


motor hums, light works, fan won't turn

Question: I just hung a ceiling fan with light fixture.  I wired black to black and white to white.  The fan and light are operated by a remote.  The light will go on, motor hums, but the fan won't turn.  I have installed many fans before and never had this problem.
Comment: Can you spin the blades by hand?
Comment: Is it possible for you to send us a picture of the fan and cable?
Thank you
Answer: Could be a mechanical problem.  Try this: with the power OFF, try to rotate the fan with your finger. It should spin freely for awhile after you poke it.  If not, then something is mechanically impeding the travel of the fan blades.
Check for anything touching any part of that rotating fan assembly.  Maybe some left-over protective packaging that you missed?  Or a wire that is bent in and pushing on the blades?
If not the above then good chance this is just a defective fan motor.
Comment: Motor, or just a bad capacitor. Sometimes a motor with a defective capacitor will continue turning if you give it a push start.

motor hums, light works, fan won't turn


How do you load a folder full of png files to construct an AS3 movie clip?

Question: I see plenty of AS3 examples of loading 1 image file into a 1 frame movieclip, but how can you take a folder full of images, load them and treat each image as an individual frame of a single movieclip?
The essential problem I seem to keep running into is how to create a keyframe during runtime...
Answer: I haven really tried it but maybe if you do something like
mc.addChild(image);
mc.nextFrame();
mc.addChild(image2);
mc.nextFrame();
Cant tell you for sure that it works though :)
What are you going to use this movieclip for ?
Answer: You can't do anything like that, because you can't create keyframes at runtime and when add a child to the MovieClip with code, it wont add it to the current frame, it will just add it to the clip's display list, so what you added dynamically will be on every frame.
You should probably try loading your images and storing them in an array or making an array of movie clips or sprites that each have on image. That way you have all the images in a list of clips, and you can still use those clips and display them however you want in your flash movie.
Answer: There is no way to add frames dynamically.
What you can do is what __dominic suggests:
create a class that mimics a movieclip by managing different frames by storing image data in an array ( or similar technique)
A different approach would be to use a sprite sheet. You can find information about sprite sheets in wikipedia and in this SO post
There are also some implementations available online ( i.e. see spritesheet class ).


Adobe Acrobat Reader version 10/11 & Ubuntu 14.04

Question: I'm using Ubuntu 14.04 desktop. I have enabled the partners repo & installed Adobe Reader 9.5.5 OK. Unfortunately, I need Adobe Reader version 10 or 11 for the particular .pdf file I'm using. If anyone is interested, the .pdf file is a file supplied by UK's HMRC for Company Returns which requires certain Trust settings to be made. Can anybody tell me where I can download an appropriate (to Ubuntu 14.04) Adobe Reader 10/11 install file?
PS I've tried Adobe's web site & internet searched.
Comment: Adobe decided that all us Linux users don't amount to anything in the world, and stopped releasing Adobe Reader for linux a while back.
Comment: What about using Evince instead? Anything is better than Acrobat Reader anyway!
Comment: Ask that company to provide you a Windows Licence or something. Tell them that if they provide an encoded (to PDF) file with none or obscure way (in this case) to read it - that means they do not provide you the file at all.
Answer: maybe you can try to install the Adobe Reader with Wine.

the last native version was adobe reader 9, newer versions are only available for Windows and MacOS.
Comment: I tried installing Adobe Reader with latest version of Wine (from Ubuntu Wine Team). It installed OK but didn't work: some dll problem but I forget what it was.
Comment: i would recommend http://pdfreaders.org/ for an overview of the alternatives.
Comment: No point in trying alternatives as it needs special Adobe Reader trust settings.
Comment: as described in the link: you will need wine 1.7 and winetricks.
Comment: it was just a comment to point out some alternatives for other users reading this...
Answer: Only solution was to install Adobe Reader for Windows XP: I have Windows XP running as a VM using VirtualBox. That worked OK. Hopefully, this problem will not be there for next year's company accounts & tax return as HMRC told me that they will not be using Adobe Reader writing to a downloaded (from HMRC) CT600 pdf file but will instead be completing a CT600 form directly on their website. This is the method used for HMRC personal tax returns, which work OK.
Answer: You can try to open it using Adobe on Android Tablet / or mobile. I am doing this in case I would like to use some features like adding comments or highlighting. I hope this works for you.


Did Griphook double-cross Harry and Co.?

Question: I am aware of this question (Why did Griphook betray Harry in Deathly Hallows?) but I am being a bit more specific in what I am asking, and I was unsatisfied with the answers provided on the other question, so this question is not a duplicate. Griphook did not help the trio out of the Lestrange vault, but he left the trio and Bogrod to die in the vault, which makes little sense considering how Bogrod was also a goblin, and he was in debt to Harry, which goblins take very seriously. So why did he leave the trio to die, versus helping them out? Did he know that Harry didn't intend on giving the sword immediately?
(Please no answers from HP wiki/wikia, HP lexicon, or movie quotes/events, but answers based on Pottermore, book quotes/events, JKR tweets/interviews, and canon-based examples or even speculation are more than welcome.)
Comment: This is hard to answer, because Harry is directly warned that Griphook is likely to have an inscrutable and unpredictable take on what he owes and is owed - and other than observing his actions, the reader is given no further insight or any means to use to clarify that inscrutability.
Comment: @tbrookside that is true, of course, but I at least thought
Griphook would try to save one of his own kind
Comment: Bogrod was under the Imperius Curse; if Griphook tried to save him, Harry might have ordered Bogrod to fight Griphook or something
Answer: Well I'd say because after all, he's still a goblin. It is in their blood to protect the treasures of their clients. No matter what the situation, it goes against their nature to break inside of someone else's treasure, someone's treasure they've sworn to protect.
So when he leaves the trio, he not only retrieves the Sword of Gryffindor (which must have been an infamous artefact among the goblin community as a treasure unfairly stolen), but also saves one his client's vaults from being looted. Even if he hates Bellatrix, it's still bad reputation for the bank and the goblin species if they come to know that a goblin helped in a robbery. They don't particularly hate the Death Eaters too, because they were neutral in the war.
Griphook doesn't double cross them as you say in the question. Because the trade was to help them get inside the vault not get them out, or leave them to die inside for that matter.
He left Bogrod, because in Griphook's eyes, it must have been a good deal. Sword of Gryffindor and saving the bank from an embarrassing robbery for the exchange of life of one of plenty of goblins. The reason to the disregard of Bogrod's life could be due to the fact that they all work in a single place, and there might not be need for so many goblins, leading to salary dilution. So he didn't particularly have any love for Bogrod.
Goblins are very cunning. When the trio plot to betray Griphook, he must have found out about it pretty quickly. That's why it's mentioned a few times to never double cross a goblin and how risky it is to trade with them. That is also why people keep their distance from them. So Griphook would have then plotted a plan of his own to get a better deal than the one they were giving.


How can I cool down a hot garage?

Question: My North Carolina garage is extremely hot, does not have a window and a room over top. In 5 years I have lost three freezers, there is no other place to put the freezer.  I have tried to find a fan w ith a damper and a thermostat that could be mounted thru the wall but no luck. What can I do?
Answer: What about an attic vent fan such as this one?

It has a thermostatic control.
Separate shutters are also available such as these.  They open based on the air pressure generated by the fan.

You would need to create "in" vents, preferably placed low on several walls to allow full air flow. These could be either fixed or shuttered, depending on whether you are concerned about infiltration of air in colder weather.
Answer: In addition to ventilation, you can also insulate your garage, especially the roof and east-south-west walls. That will keep some of the heat out in the first place.
Answer: I've have a similar problem with my garage.  Although no freezer inside.
I haven't fixed it yet, but I think the solution is to install a boat cabin vent like these:

http://www.go2marine.com/product/232325F/marinco-4-day-night-plus-vent-solar-light-w-stainless-steel-cover-n20704s.html
I'd install one on the side of the garage up high to exhaust the hot air. And probably provide a low down vent on the cool side of the garage to allow cool air to flow in.
As for shutting it off.  You may need to make your own damper.  A sheet of plywood or metal with some guides that can slide in front of the fan and vent.
There are also some fancy attic based ventilators, that may be a better option.
Comment: I very much doubt that a little fan like that would make any difference in a hot garage. They're designed to vent small boat cabins, not large spaces like garages. The attic fan that @bib linked to circulates 100x more air per hour. If you're going put openings in your walls you might as well do it right.
Comment: Depends if you want it to be draughty or comfortable.  You actually don't need to have a fan, I've seen this work in a cabin that has more solar gain and larger than a 3 car garage work with just passive air movement through 2 x 150mm vents.  You can get larger solar vents.  It was the concept I was alluding to. Not that you'd necessarily use this particular one.

How can I cool down a hot garage?


The number of variables for each split declined significantly once increased the number of trees

Question: For my data set, I was running a random forest regression with a grid search over a number of trees and number of variables available for splitting (mtry).  the optimal model, according to Rsquared was 300 trees with 10 mtry.  However, if I increase the number of trees to 1500, Rsquare declines by 0.001, but mtry is now 1.  Why would this be the case?
Answer: Given some hyperparameters, a random forest is a random model that has a overall random performance. We can divide our uncertainity about this performance into two components: bias and variance. The way it works is this one: every tree has a large amount of bias, and a little, unavoidable, amount of variance; stacking many trees togheter you get rid of the bias, because that bias itself is variable, and averaging it among trees, you cancel it.
More biased trees need bigger forest to get away with their bias, more flexible trees need need more little ensembles, but in any case, adding more trees will never worsen expected results (as the model is random, in practice performance can actually get worse, but its expected value won't, this is just because of random fluctuations). You choose some finite number of trees because more of them just aren't helping anymore.
So, coming to your case:

With a lower mtry, your trees are more biased, so it makes sense that the forest needs more trees to give good results.
If your forests with mtry = 10 perform better with less trees, that's just because of case. You could have grown one lucky forest, or maybe it's just because estimation of R squared is variable itself. Actually, the more trees you have, the more it is reliable.
As for what I wrote until now, best model seems to be the one with many trees and mtry = 1.
Because of all these sources of variability, you just can never be sure about how your model will really generalize, so these tiny differences in measured performance actually are not that important.

At this point, your question should be completely answered, apart maybe from some curiosity you may still have about why a low value of mtry could be good for the algorithm. This is the trickyier part of the question, because noone knows all about why these algorithms work how they work, so the best we can do is to make some hypothesis.
It is possible that some feature that has very little empirical association with the outcome, actually brings some information that can't be found in the other ones. So when mtry is large, that feature never gets to enter the model, when mtry is 1 instead, sometimes it is randomly chosen. But since it is just one (or maybe few) variable, you need a big number of trees to make it work.
This is just an imaginatve hypothesis, the way mtry affects the trained forests is actually very difficult to catch, you may look into importance scores of the two different forests to make your own idea about it.


How to know that a new data is been added to HDFS?

Question: I am implementing a Notification system based on publish subscribe model to notify about the availability of data as it arrives/loaded to HDFS. I did n't find a ways where to look for this. Is there any HDFS API which can be used to do this or what method should I use to get information of new data written to HDFS? I am using Hadoop v2.0.2 and I don't want to use HCatalog, I want to implement my own tool to do this.
Comment: So, I assume the answers and discussions from Quora [1] were not sufficient? Several people incl. myself told you already that HDFS doesn't do it ATM and offered alternatives. Sigh.

[1] http://www.quora.com/Apache-Hadoop/What-are-the-ways-I-can-know-that-a-new-data-is-been-added-to-HDFS
Comment: checkout Apache Flume. Not exactly what you are looking, but might be of help.
Comment: I want to know which java package/classes in HDFS should I look for this to add this feature. As i know when client write data to HDFS, after completion of writing data it updates the namenode to indicate the file is now complete. I basically want to add my code after Namenode receives completion update.
Comment: look at the following 2 answers and I too believe that there isn'y anything available as of now with HDFS SDK: http://stackoverflow.com/questions/14436748/event-notification-of-data-availability-in-hdfs http://stackoverflow.com/questions/14436748/event-notification-of-data-availability-in-hdfs
Answer: What you are looking for is Oozie Coordinator.
HDFS is a file system, so something must be built on top of HDFS to check for file availability. HBase has coprocessor which are triggered procedures . But it is only available for HBase tables. So it cannot be used for detecting data availabilty in HDFS.
Oozie is a workflow scheduler system to manage Hadoop jobs. Oozie Coordinator jobs are recurrent Oozie Workflow jobs triggered by time (frequency) and data availabilty. Also you can execute other programs from it :

Oozie is integrated with the rest of the Hadoop stack supporting
several types of Hadoop jobs out of the box (such as Java map-reduce,
Streaming map-reduce, Pig, Hive, Sqoop and Distcp) as well as system
specific jobs (such as Java programs and shell scripts).

So you can use the file availability trigger for  your notification system too.
Answer: If you use HDFS you might want to check out HBase as it has the functionality you want.  In HBase, you can create a pre-put (or post-put) coprocessor essentially acting equivilant to a MySQL Trigger- running a bit of code for every time data is written to a table.
If HBase doesn't suit your use case and you must use HDFS, AFAIK there aren't similar triggers.  You can try wrapping the HDFS API with your own code to perform the notification whenever data is written to your file system under the appropriate circumstances.  Alternatively, you can poll HDFS for changes (which sounds like an ugly alternative)...
Hope that helps
Comment: could you plz tell me where can I get enough information about HDFS API?
Comment: here is a javadoc for the hadoop java api: http://hadoop.apache.org/docs/current/api/index.html.   Here is a simple tutorial for using the java api: http://linuxjunkies.wordpress.com/2011/11/21/a-hdfsclient-for-hadoop-using-the-native-java-api-a-tutorial/


Difference between a paintmap and wetmap

Question: Can somebody explain to me what is the difference between a paintmap and a wetmap? I'm currently studying dynamic painting and wondering the difference between these two outputs.
Answer: When a brush with a Color and a Wetness moves through a canvas, it lays paint.
As a result, the canvas gets

a color, represented by the (RGBA) Paintmap, and affected, for instance, by the Dissolve effect

(no dissolve in this example)
some wetness, represented by the (greyscale) Wetmap, and affected, for instance, by the Dry effect.

Once the paint dries out (if it does), its color remains while its wetness goes away.
Example shader where the color is the paintmap, the specularity is the wetmap, the roughness is one minus the wetmap (there is also some alpha-based bump here):
Comment: That is cooool. Imagine how that can be in watercolour painting inside Blender.


Form for billing information

Question: How to remove the "Second name" field in the billing form, I can not find the path to reach this form and modify it. Thanks
Answer: Unfortunately you cannot control billing block fields through UI. There is no such settings since this fields are mandatory for some(infact many) payment processors. This fields are hard coded at https://github.com/civicrm/civicrm-core/blob/master/CRM/Core/Payment.php#L869
You can use buildform hook to remove the second name field.

Note: You might get error from some payment processor if second name
  is empty

HTH
Pradeep
Comment: I could uncheck the billing and put the fields chosen by me to ask who to send the invoice...
Comment: I saw that I can uncheck, so the pre-filled form with the billing fields does not appear: in Contributions> Manage Contribution Pages> Configure Page> Amounts> billing address required ... "Check this box later option to provide billing name and address "  -  In this way, I can put a form with fields chosen by me, for billing  -  Thanks Pradeep; for your NOTE: You might get error from some payment processor if second name is empty...
I tried with the empty field "second name", I had no problems, thanks
Answer: You can hide the field with CSS, can't you?
Or comment this out in CRM/Core/BillingBlock.tpl:
<code>  if ($('#middle_name').length)
    input_ids['#middle_name'] = '#billing_middle_name';
</code>

Form for billing information


Is it possible to send the research to a local and international magazine?

Question: I am 21 years old and I sent a scientific research to a local  journal for youth, meaning it helps young people, and because my research in high school mathematics was sent to that journal, but now I study complex mathematics and understand it, and I want to write the same research, but with complex mathematics and complex concepts, and send it to an international journal. Is it possible?  Acceptance of a research paper from an international journal, even though I sent it to a local journal.
Comment: What does "local journal for youth" mean?  Is it just a school publication?  Something peer-reviewed?
Comment: https://academia.stackexchange.com/questions/2893/attitudes-towards-self-plagiarism
Comment: Quite similar question: https://academia.stackexchange.com/questions/17374/how-can-i-withdraw-a-publication-from-a-predatory-fake-journal-and-resubmit-to
Comment: Do you have an advisor? It is them who would typically teach one how publishing works...
Answer: In general, you can't send the same paper to two journals. There would be copyright issues among other things.
But if you write an extension of an older paper you can submit that to a different journal. Just be sure to cite the older work in the newer one and don't just incorporate parts of it. Quote and cite the older work just as you would the work of any other author.
The second journal will make a judgement, however, about whether the new paper is sufficiently advanced over the older one. If not, they would probably not be interested. Each new paper needs to make some "novel" contribution to the literature.


Red Dragon sample return

Question: How will the Red Dragon take off from Mars and get back to earth? All the drawings I've seen just show the capsule on the surface and no rocket to take off again or power the return flight.  Could they really build that all into the Dragon?
Comment: The Red Dragon itself will not take off from Mars, it has far too little delta-V to achieve orbit from Mars.
Answer: At this early stage, it is unclear what SpaceX is really planning.  They have passed up on the 2018 window, and now planning for the 2020 transfer window. This means they will have two more years to change their plans.
Early suggestions have been to treat the inside as a missile silo with a one or two stage booster to launch from inside the Dragon capsule to return a payload. It is still very early in the planning.
Answer: Everything about Red Dragon is in flux, including whether it's doing a sample return at all, as the main purpose is to demonstrate landing. Chances are sample return depends heavily on how SpaceX does in the next few years, and where they focus, as it will be a challenging mission to engineer.
I haven't seen a single proposal to have the capsule itself take off again after landing, only small rockets launched from inside the capsule. This makes sense, as Red Dragon is far more useful staying on the surface than being sacrificed for maybe a few hundred m/s, max. It would also require less re-engineering, as most of the changes would be restricted to the interior and top hatch.
In situ resource utilization (ISRU) to enable lower launch mass and a higher return payload is unlikely, as the Dragon 2 does not use methalox.

Red Dragon sample return


What is the purpose of the Anti-Counterfeiting Trade Agreement (ACTA)?

Question: What are the stated goals of the proponents of ACTA? In what way do these goals diverge from the likely effects of the Agreement claimed by those who oppose it?
Comment: Do you mean other than to protect the profits of an industry that contributes heavily to political campaigns and lobbists?
Comment: @Chad, no. What specifically does the ACTA law protect. What unintended consequences will passage f the law cause? i.e. I have heard that the Fair Use Doctrine protects USA reuse of copyrighted material, but many other nations have no such protections. Will due process be eliminated? Any other objections, etc.
Comment: What does it protect, will due process be eliminated, how does this effect fair use? are good constructive questions.  The rest of this really is not.
Answer: Regarding purpose, from Wikipedia (emphasis is mine):

The Anti-Counterfeiting Trade Agreement (ACTA) was a proposed multinational treaty for the purpose of establishing international standards for intellectual property rights enforcement. The agreement aims to establish an international legal framework for targeting counterfeit goods, generic medicines and copyright infringement on the Internet, and would create a new governing body outside existing forums [...].

Some of the criticism, also from Wikipedia:

Threats to freedom and human rights
An open letter signed by many organizations [...] states that "the current draft of ACTA would profoundly restrict the fundamental rights and freedoms of European citizens, most notably the freedom of expression and communication privacy."

and (from the same Wikipedia link)

Criminalising generic medicine
According to French EP member Kader Arif, "The problem with ACTA is that, by focusing on the fight against violation of intellectual property rights in general, it treats a generic drug just as a counterfeited drug. This means the patent holder can stop the shipping of the drugs to a developing country, seize the cargo and even order the destruction of the drugs as a preventive measure."
Comment: The second part confuses me - generic drugs are when the patent has expired. So why would the patent holder have anything to say?
Comment: @Orangesandlemons that's one of the criticisms of the ACTA as presented by critics. The [Wikipedia page](https://en.m.wikipedia.org/wiki/Anti-Counterfeiting_Trade_Agreement#Criminalising_generic_medicine) may offer some info. It also links to other sources.
Comment: @Orangesandlemons I'd hazard two guesses. First, that that's the point, patent holder gets a say despite having no right to. Second, that brand name is entirely different from patent and does not expire on set date (it has different rules for "expiry" and may never "expire" if maintained properly) yet ACTA deliberately acts to conflate that, and paint any generic at counterfeit as if brand was patent.
Comment: I strongly suspect that the generic drugs are from a country in which the patent has expired, but the holder of the patent in a different member country can act against them as if they still held the patent in all member countries. So, if the patent expires in the US and another country begins manufacturing generics there, the original patent holder, if they still hold a patent in say, the EU, can prevent the American generic drug from shipping to some third world country as if they still owned the patent in America, essentially stifling international trade (and charity work dependent on it).


Calculate the area of intersection of two rotated rectangles in python

Question: I have two 2D rotated rectangles, defined as an (center x,center y, height, width) and an angle of rotation (0-360°). How would I calculate the area of intersection of these two rotated rectangles.
Comment: Possible duplicate of [Area of Intersection of Two Rotated Rectangles](https://stackoverflow.com/questions/11670028/area-of-intersection-of-two-rotated-rectangles)
Comment: Its a mathematical problem for a mathematician. As a software engineer I come across this type of problem in collision detection, ocr, computer vision and other systems for which I need functional code rather than mathematical theory
Comment: This is less a software engineering problem than a mathematical problem
Comment: Project the vertex to the axis and check those points intersection.
Comment: Can we assume that two of the sides will not be collinear?
Comment: There is a nice expalanation of a polygon area computation here: https://www.youtube.com/watch?v=0KjG8Pg6LGk. Together with links and hints from the linked duplicate question (areas: intersection = polygon1 + polygon2 - aggregated polygon) the missing part is to convert your data to (x,y) coordinates of vertices. i.e. some easy sine and cosine calculations.
Answer: Such tasks are solved using computational geometry packages, e.g. Shapely:
import shapely.geometry
import shapely.affinity

class RotatedRect:
    def __init__(self, cx, cy, w, h, angle):
        self.cx = cx
        self.cy = cy
        self.w = w
        self.h = h
        self.angle = angle

    def get_contour(self):
        w = self.w
        h = self.h
        c = shapely.geometry.box(-w/2.0, -h/2.0, w/2.0, h/2.0)
        rc = shapely.affinity.rotate(c, self.angle)
        return shapely.affinity.translate(rc, self.cx, self.cy)

    def intersection(self, other):
        return self.get_contour().intersection(other.get_contour())

r1 = RotatedRect(10, 15, 15, 10, 30)
r2 = RotatedRect(15, 15, 20, 10, 0)

from matplotlib import pyplot
from descartes import PolygonPatch

fig = pyplot.figure(1, figsize=(10, 4))
ax = fig.add_subplot(121)
ax.set_xlim(0, 30)
ax.set_ylim(0, 30)

ax.add_patch(PolygonPatch(r1.get_contour(), fc='#990000', alpha=0.7))
ax.add_patch(PolygonPatch(r2.get_contour(), fc='#000099', alpha=0.7))
ax.add_patch(PolygonPatch(r1.intersection(r2), fc='#009900', alpha=1))

pyplot.show()

Comment: @Bug once you have the shape of the intersection `r1.intersection(r2)` (which is a `Shapely` object) you only need to access its `area` attribute: `r1.intersection(r2).area`.
Comment: Hi, how do you calculate the area of intersection with this?
Comment: `shapely` rules!
Comment: I have installed shapely through pip install shapely, it shows Requirement already satisfied: shapely in /usr/local/lib/python2.7/dist-packages, but when I run the code, it always tell us ImportError: No module named affinity, any clue?
Comment: @user824624 Given the scarce information you've provided about your problem I have no clue as to what may have gone wrong. I think you better post a separate question for that problem and provide enough details.
Comment: how to do that if you have 4 coordinates of each rectangle?
Comment: This is a nice answer! Thanks.
Answer: Here is a solution that does not use any libraries outside of Python's standard library.
Determining the area of the intersection of two rectangles can be divided in two subproblems:

Finding the intersection polygon, if any;
Determine the area of the intersection polygon.

Both problems are relatively easy when you work with the
vertices (corners) of the rectangles. So first you have to determine
these vertices. Assuming the coordinate origin is in the center
of the rectangle, the vertices are,
starting from the lower left in a counter-clockwise direction:
(-w/2, -h/2), (w/2, -h/2), (w/2, h/2), and (-w/2, h/2).
Rotating this over the angle a, and translating them
to the proper position of the rectangle's center, these become:
(cx + (-w/2)cos(a) - (-h/2)sin(a), cy + (-w/2)sin(a) + (-h/2)cos(a)), and similar for the other corner points.
A simple way to determine the intersection polygon is the following:
you start with one rectangle as the candidate intersection polygon.
Then you apply the process of sequential cutting (as described here.
In short: you take each edges of the second rectangle in turn,
and remove all parts from the candidate intersection polygon that are on the "outer" half plane defined by the edge
(extended in both directions).
Doing this for all edges leaves the candidate intersection polygon
with only the parts that are inside the second rectangle or on its boundary.
The area of the resulting polygon (defined by a series of vertices) can be calculated
from the coordinates of the vertices.
You sum the cross products of the vertices
of each edge (again in counter-clockwise order),
and divide that by two. See e.g. www.mathopenref.com/coordpolygonarea.html
Enough theory and explanation. Here is the code:
from math import pi, cos, sin

class Vector:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, v):
        if not isinstance(v, Vector):
            return NotImplemented
        return Vector(self.x + v.x, self.y + v.y)

    def __sub__(self, v):
        if not isinstance(v, Vector):
            return NotImplemented
        return Vector(self.x - v.x, self.y - v.y)

    def cross(self, v):
        if not isinstance(v, Vector):
            return NotImplemented
        return self.x*v.y - self.y*v.x

class Line:
    # ax + by + c = 0
    def __init__(self, v1, v2):
        self.a = v2.y - v1.y
        self.b = v1.x - v2.x
        self.c = v2.cross(v1)

    def __call__(self, p):
        return self.a*p.x + self.b*p.y + self.c

    def intersection(self, other):
        # See e.g.     https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection#Using_homogeneous_coordinates
        if not isinstance(other, Line):
            return NotImplemented
        w = self.a*other.b - self.b*other.a
        return Vector(
            (self.b*other.c - self.c*other.b)/w,
            (self.c*other.a - self.a*other.c)/w
        )

def rectangle_vertices(cx, cy, w, h, r):
    angle = pi*r/180
    dx = w/2
    dy = h/2
    dxcos = dx*cos(angle)
    dxsin = dx*sin(angle)
    dycos = dy*cos(angle)
    dysin = dy*sin(angle)
    return (
        Vector(cx, cy) + Vector(-dxcos - -dysin, -dxsin + -dycos),
        Vector(cx, cy) + Vector( dxcos - -dysin,  dxsin + -dycos),
        Vector(cx, cy) + Vector( dxcos -  dysin,  dxsin +  dycos),
        Vector(cx, cy) + Vector(-dxcos -  dysin, -dxsin +  dycos)
    )

def intersection_area(r1, r2):
    # r1 and r2 are in (center, width, height, rotation) representation
    # First convert these into a sequence of vertices

    rect1 = rectangle_vertices(*r1)
    rect2 = rectangle_vertices(*r2)

    # Use the vertices of the first rectangle as
    # starting vertices of the intersection polygon.
    intersection = rect1

    # Loop over the edges of the second rectangle
    for p, q in zip(rect2, rect2[1:] + rect2[:1]):
        if len(intersection) <= 2:
            break # No intersection

        line = Line(p, q)

        # Any point p with line(p) <= 0 is on the "inside" (or on the boundary),
        # any point p with line(p) > 0 is on the "outside".

        # Loop over the edges of the intersection polygon,
        # and determine which part is inside and which is outside.
        new_intersection = []
        line_values = [line(t) for t in intersection]
        for s, t, s_value, t_value in zip(
            intersection, intersection[1:] + intersection[:1],
            line_values, line_values[1:] + line_values[:1]):
            if s_value <= 0:
                new_intersection.append(s)
            if s_value * t_value < 0:
                # Points are on opposite sides.
                # Add the intersection of the lines to new_intersection.
                intersection_point = line.intersection(Line(s, t))
                new_intersection.append(intersection_point)

        intersection = new_intersection

    # Calculate area
    if len(intersection) <= 2:
        return 0

    return 0.5 * sum(p.x*q.y - p.y*q.x for p, q in
                     zip(intersection, intersection[1:] + intersection[:1]))

if __name__ == '__main__':
    r1 = (10, 15, 15, 10, 30)
    r2 = (15, 15, 20, 10, 0)
    print(intersection_area(r1, r2))

Comment: No wonder you are a compatriot of [the](http://www.win.tue.nl/~mdberg/) [three](http://www.cs.uu.nl/staff/marc.html) [Marks](http://www.cs.uu.nl/staff/markov.html) coauthoring the [Computational Geometry book](http://www.cs.uu.nl/geobook/). I have a feeling that you may know some of them in person.
Comment: BTW, you should note in your answer that it works for computing the intersection of *any* polygon with *any convex* polygon.
Comment: Thank you for this answer, its very clear and useful!
Is there a mathematical name for the operation happening in `Line.__call__()`. It seems like its related to this? https://math.stackexchange.com/questions/274712/calculate-on-which-side-of-a-straight-line-is-a-given-point-located
Answer: intersection, pnt = contourIntersection(rect1, rect2)

After looking at the possible duplicate page for this problem I couldn't find a completed answer for python so here is my solution using masking. This function will work with complex shapes on any angle, not just rectangles
You pass in the 2 contours of your rotated rectangles as parameters and it returns 'None' if no intersection occurs or an image of the intersected area and the left/top position of that image in relation to the original image the contours were taken from
Uses python, cv2 and numpy
import cv2
import math
import numpy as np

def contourIntersection(con1, con2, showContours=False):

    # skip if no bounding rect intersection
    leftmost1 = tuple(con1[con1[:, :, 0].argmin()][0])
    topmost1 = tuple(con1[con1[:, :, 1].argmin()][0])
    leftmost2 = tuple(con2[con2[:, :, 0].argmin()][0])
    topmost2 = tuple(con2[con2[:, :, 1].argmin()][0])

    rightmost1 = tuple(con1[con1[:, :, 0].argmax()][0])
    bottommost1 = tuple(con1[con1[:, :, 1].argmax()][0])
    rightmost2 = tuple(con2[con2[:, :, 0].argmax()][0])
    bottommost2 = tuple(con2[con2[:, :, 1].argmax()][0])

    if rightmost1[0] < leftmost2[0] or rightmost2[0] < leftmost1[0] or bottommost1[1] < topmost2[1] or bottommost2[1] < topmost1[1]:
        return None, None

    # reset top / left to 0
    left = leftmost1[0] if leftmost1[0] < leftmost2[0] else leftmost2[0]
    top = topmost1[1] if topmost1[1] < topmost2[1] else topmost2[1]

    newCon1 = []
    for pnt in con1:

        newLeft = pnt[0][0] - left
        newTop = pnt[0][1] - top

        newCon1.append([newLeft, newTop])
    # next
    con1_new = np.array([newCon1], dtype=np.int32)

    newCon2 = []
    for pnt in con2:

        newLeft = pnt[0][0] - left
        newTop = pnt[0][1] - top

        newCon2.append([newLeft, newTop])
    # next
    con2_new = np.array([newCon2], dtype=np.int32)

    # width / height
    right1 = rightmost1[0] - left
    bottom1 = bottommost1[1] - top
    right2 = rightmost2[0] - left
    bottom2 = bottommost2[1] - top

    width = right1 if right1 > right2 else right2
    height = bottom1 if bottom1 > bottom2 else bottom2

    # create images
    img1 = np.zeros([height, width], np.uint8)
    cv2.drawContours(img1, con1_new, -1, (255, 255, 255), -1)

    img2 = np.zeros([height, width], np.uint8)
    cv2.drawContours(img2, con2_new, -1, (255, 255, 255), -1)

    # mask images together using AND
    imgIntersection = cv2.bitwise_and(img1, img2)

    if showContours:
        img1[img1 > 254] = 128
        img2[img2 > 254] = 100

        imgAll = cv2.bitwise_or(img1, img2)
        cv2.imshow('Merged Images', imgAll)

    # end if

    if not imgIntersection.sum():
        return None, None

    # trim
    while not imgIntersection[0].sum():
        imgIntersection = np.delete(imgIntersection, (0), axis=0)
        top += 1

    while not imgIntersection[-1].sum():
        imgIntersection = np.delete(imgIntersection, (-1), axis=0)

    while not imgIntersection[:, 0].sum():
        imgIntersection = np.delete(imgIntersection, (0), axis=1)
        left += 1

    while not imgIntersection[:, -1].sum():
        imgIntersection = np.delete(imgIntersection, (-1), axis=1)

    return imgIntersection, (left, top)
# end function

To complete the answer so you can use the above function with the values of CenterX, CenterY, Width, Height and Angle of 2 rotated rectangles I have added the below functions. Simple change the Rect1 and Rect2 properties at the bottom of the code to your own
def pixelsBetweenPoints(xy1, xy2):
    X = abs(xy1[0] - xy2[0])
    Y = abs(xy1[1] - xy2[1])

    return int(math.sqrt((X ** 2) + (Y ** 2)))
# end function

def rotatePoint(angle, centerPoint, dist):
    xRatio = math.cos(math.radians(angle))
    yRatio = math.sin(math.radians(angle))
    xPotted = int(centerPoint[0] + (dist * xRatio))
    yPlotted = int(centerPoint[1] + (dist * yRatio))
    newPoint = [xPotted, yPlotted]

    return newPoint
# end function

def angleBetweenPoints(pnt1, pnt2):
    A_B = pixelsBetweenPoints(pnt1, pnt2)

    pnt3 = (pnt1[0] + A_B, pnt1[1])
    C = pixelsBetweenPoints(pnt2, pnt3)

    angle = math.degrees(math.acos((A_B * A_B + A_B * A_B - C * C) / (2.0 * A_B * A_B)))

    # reverse if above horizon
    if pnt2[1] < pnt1[1]:
        angle = angle * -1
    # end if

    return angle
# end function

def rotateRectContour(xCenter, yCenter, height, width, angle):
    # calc positions
    top = int(yCenter - (height / 2))
    left = int(xCenter - (width / 2))
    right = left + width

    rightTop = (right, top)
    centerPoint = (xCenter, yCenter)

    # new right / top point
    rectAngle = angleBetweenPoints(centerPoint, rightTop)
    angleRightTop = angle + rectAngle
    angleRightBottom = angle + 180 - rectAngle
    angleLeftBottom = angle + 180 + rectAngle
    angleLeftTop = angle - rectAngle

    distance = pixelsBetweenPoints(centerPoint, rightTop)
    rightTop_new = rotatePoint(angleRightTop, centerPoint, distance)
    rightBottom_new = rotatePoint(angleRightBottom, centerPoint, distance)
    leftBottom_new = rotatePoint(angleLeftBottom, centerPoint, distance)
    leftTop_new = rotatePoint(angleLeftTop, centerPoint, distance)

    contourList = [[leftTop_new], [rightTop_new], [rightBottom_new], [leftBottom_new]]
    contour = np.array(contourList, dtype=np.int32)

    return contour
# end function

# rect1
xCenter_1 = 40
yCenter_1 = 20
height_1 = 200
width_1 = 80
angle_1 = 45

rect1 = rotateRectContour(xCenter_1, yCenter_1, height_1, width_1, angle_1)

# rect2
xCenter_2 = 80
yCenter_2 = 25
height_2 = 180
width_2 = 50
angle_2 = 123

rect2 = rotateRectContour(xCenter_2, yCenter_2, height_2, width_2, angle_2)

intersection, pnt = contourIntersection(rect1, rect2, True)

if intersection is None:
    print('No intersection')
else:
    print('Area of intersection = ' + str(int(intersection.sum() / 255)))
    cv2.imshow('Intersection', intersection)
# end if

cv2.waitKey(0)

Comment: The drawback of this solution is that it computes the result via [rasterisation](https://en.wikipedia.org/wiki/Rasterisation), which introduces inaccuracy, is slow and the result may not be directly usable (if we need it as a polygon rather than as an image). See [my answer](https://stackoverflow.com/a/45141648/6394138) for a better option.
Comment: Was attempting to calc a value rather than a shape. Also was thinking the contours may be pulled from an image so returned a result which allows the mapping to the individual intersecting pixels. Only single line to turn image into polygon, didnt want to clutter code
Comment: After running time tests on above code using time.time() with all output to screen turned off it ran at < minimum time able to be recorded by time.time(). Also avoids unnecessary processing if no possibility of intersection occurs


Bread bowls verus loaf of bread

Question: I am making bread bowls for soup.  I made extra dough for a loaf, do you think there is a difference making a loaf from a bread bowl recipe?  The Bread Bowl recipe seems like a pretty standard bread recipe.
Answer: It will make a wonderful bread with lots of holes and a tough crust. Whether that's good for you or not is really whatever you like or not.
It bake the bread bagette style or free bread style right on the stone instead of using a loaf pan, but that's just me.

Bread bowls verus loaf of bread


Mac os x ipfw forward from ip:port to ip:port

Question: I want when on my local machine redirect from 192.168.64.88 port 80 to localhost port 9790. How can I do it with ipfw rule?
Comment: Poor man's solution would be to use `http://localhost:9790` in the browser. I assume this is not an option for you?
Comment: It is not an option
Answer: I found the solution:
<code>sudo ifconfig lo0 192.168.64.88 alias
sudo ipfw add fwd 127.0.0.1,9790 tcp from me to 192.168.64.88 dst-port 80
</code>
After a restart you have to run this commands again.
Comment: Unfortunately ipfw has been deprecated. How to achieve the same using pfctl tool?
Comment: You can define a launchd entry to automatically execute these commands on a reboot.
Comment: or you could put it in your `~/.bash_profile` but that would only work if you live in the terminal


DB design for multiple different objects

Question: I'm working on an application where users can write tests using blocks. Blocks are commands (like assign, for, if etc.) so some of the blocks can also contain other blocks.
We're using the composite pattern - there's an abstract block and leaf & composite block classes (also abstract), and the concrete blocks inherit from the relevant class (if block is composite, assign block is a leaf).
We used to serialize the entire test and save it as a blob, but we're considering changing that (to enable search inside the test, for example).
So how should the DB design look like? Should I have a table for each object? In our case, it will mean around 30 tables. Should we include the block's type as a column? This means we'll have a huge if-else switch somewhere.
I'd appreciate your insights and suggestions.
Thanks.
Answer: You should have a table for each kind of object.  Multiple instances of the same kind should be stored in multiple rows of the same table, with different data used to distinguish them from each other.
The question of whether two objects are or are not of the same kind can be subtle one, especially in the case you outline.  Here's my suggestion.  Do an Object Oriented Analysis of all the objects you intend to deal with.  Be careful to distinguish between  Object Oriented Analysis and Object Oriented Design.  Consult a textbook if you need to.  Peter Coad wrote some good books on OOA some twenty years ago.
Convert the OOA model to an ER model,  dropping behavior out of the mix, and keeping only data.  Keep the OOA model around, because it will be useful to have when you go to design the software.  ER models can accomodate a gen-spec pattern, so use this feature if you have classes and subclasses of objects in your model.  In your case, you will.
Then convert your  ER model to a relational model, in preparation for converting the relational model into a series of SQL data definition scripts.  Classes and subclasses get messy at this point, because the relational model doesn't have inheritance built in.  Consult tutorials on what is called "Class Table Inheritance".  There are plenty of answers to CTI questions here in SO.
If you do CTI properly, you won't need the object type  (class) as a separate field, but you can include it (denormalization) if it will speed things up.  I generally don't do that unless it becomes necessary.


"..and however they like each other." Does the meaning change with commas?

Question: Does "and however they like each other" mean "doesn't matter how much or how they like each other?
And if you add commas "and, however, they like each other", then it means as "despite that/although"
Answer: The meaning does change with the addition of commas, although the meaning might be difficult to establish without the context of surrounding sentences.
For example, if the passage was:

Anne and Bob are critical to this team, and however they like each other, they need to work together.

the meaning becomes "doesn't matter how much or how they like each other". In my opinion, the sentence flows a bit better with the addition of "much" after "however", as in "however much they like each other".
If the passage is instead:

Anne and Bob are critical to this team, and, however, they like each other, they need to work together.

it no longer makes grammatical sense. I would say that the combination of "and" and "however" doesn't make sense in most contexts, since "and" and "however" are conjuctions that serve different purposes. Instead, you might say something like:

Anne and Bob need to work together. However, they like each other, so it should be easy for them to do so.


Installing Flamenco software

Question: I am interested to give the Flamenco software a try. The software and documentation can be downloaded here. After reading the Readme I really don't understand how to install this software on my Mac and Windows machines. As this software facilitates a blender render farm I thought I can ask here if anyone can help me to install that software.
Comment: if you do try to install again, perhaps you should make a new question with what part of the installation process you're stuck on. As it is your question is too broad.
Comment: As one of the Flamenco developers: I agree with Luciano, your question is overly broad. We're still writing documentation, so it's not complete yet, and concrete information about what is unclear or simply missing would really help us in that process.
Answer: From the development team:

Flamenco is undergoing some changes right now, so I would recommend
  you wait with testing it out. Please check out the website again in a
  couple of months, or follow what we are doing on cloud.blender.org to
  spot any news in Flamenco development.

Installing Flamenco software


Is it possible to audit the Amazon AWS console?

Question: We had a situation recently where an elastic IP address assigned to a production server mysteriously became disassociated from that server. We have had this same thing happen in the past to other (fortunately, non-production) servers. We have several admins in the console, but no one is owning up to the mistake. Is there some way to audit AWS console activities?
Comment: Have you ever stopped the instances (not restarted)? This will cause the EIP to become disassociated AFAIK.
Answer:
edit: AWS has since released CloudTrail, which satisfies this need.

No. If you need auditing, you'll likely need to wrap your own frontend around the AWS APIs. If you have paid support AWS may be able to look at their internal logs, I don't know.
One thing to note is that a non-VPC EC2 instance that's stopped will lose its EIP. VPC instances retain their association (and their internal IP, too) during stoppages.
Comment: Basically, if you're going to do anything beyond a hobby project on EC2, use a VPC. AWS is actually making this default for new accounts.
Comment: Ah -- I didn't realize that about stopped VPC instances. Good to know.
Answer: I haven't used the service yet, but it looks like there's a service called CloudTrail for logging AWS API activity:
With CloudTrail, you can get a history of AWS API calls for your account, including API calls made via the AWS Management Console, AWS SDKs, command line tools, and higher-level AWS services (such as AWS CloudFormation). The AWS API call history produced by CloudTrail enables security analysis, resource change tracking, and compliance auditing.
Answer: Depending on your region, I agree with forforf and would recommend checking out CloudTrail. You might also want to review your current security posture within AWS as a whole.
We ran into the same issue with more than 20 admins in AWS. There were way too many cooks in the kitchen. We then decided to give SU access to our 2 enterprise architects, and then segmented access in IAM based on the admins role. Dev, Operations, Engineering, Security, etc. That way if there was a change made, we could at least figure out who made the change between 1-2 people, instead of 20..
Also we implemented Chef as well, which helped with audits, etc. Depends on your environment, needs, etc. though.
For your situation-if it was me...I would gather the IPs of all my instances and click on Elastic Network Interfaces in the AWS console. Search for ENIs via those IP addresses. Click on each ENI and change the termination behavior on termination to False. Then go into IAM and deny permissions for EIP attachment and detachment to multiple admins.
I would also enable termination protection for each instance. If your in a VPC environment any EIP associated or internal IP for that matter will not change upon instance stop or restart...if the instance is in ec2 classic it will.


Laptop not waking up from suspend in Ubuntu 16.04

Question: I'm using Ubuntu 16.04 on a Lenovo Z50-70 system. When I choose to go into the suspend mode, it is successfully going into the suspend mode. But when I decide to wake the laptop from suspend, caps lock and num lock keys light up. But the laptop is not waking and screen continues to be off.
This is my first day of using Linux. It will be great if anyone could help me with this issue.
Answer: Ran into the same thing with Ubuntu 17.10 on an Asus X550J laptop. Originally had upgraded from 17.04, tried to a clean install of 17.10. Tried all of the various driver suggestions; updating grub; etc. Finally found the solution -- BIOS settings.
On Asus computers you boot into BIOS settings by holding down the Escape key while the computer powers up. Once in BIOS tab to the Advanced settings and you'll see Wake on Lid Open and Power Off Energy Saving. I disabled both of those, rebooted, and now I can finally shut the lid on the laptop without it just powering off the system or getting frozen.
Your BIOS shortcut key and settings may differ but worth looking for something similar. Hope that helps someone else avoid some hair pulling.
Comment: For me it actually helped to disable NVidia graphics card. So If I need a performance mode, I will enable it in BIOS, but I don't really need it


What software do you use for drawing diagrams?

Question: what type of software do you use for drawing diagrams (user flows) in a faster manner? I tried draw.io as an online tool because I wanted defined shapes in order to make the flow faster. I do not want to use Sketch, Illustrator, Photoshop type of thing because I have to create my own shapes which is time consuming, projects are different from one another.
Comment: Software recommendations are not on-topic for this site. I have linked to an older question (also closed) that may give you some direction, but such questions are no longer suitable for Stack Exchange sites.
Answer: The fastest one I have in mind is powerpoint. I tend to make a lot of process modelling demonstration through it.
We could also use Bizagi, which is way more professional or even Axure with icon package.
Depends on what you're going for.