How should I know if my humidifier work?

Question: I have a Aprilaire 600 Humidifier installed in my basement, as per the manual it should automatically kick off when the lack of humidity is detected.
It didn't seem happening. After I adjusted the dial setting from the default 35 to 40 (it should mean the target humidity is increased to 40% from 35%), the furnace nearby seemed wake up, but only for a short while and it went quiet again.
Another thing I noticed was that the dial setting panel looks different from that I found online or from the manual.
This is how it looks like of mine:

However from online video it looks like and it's more inline with the illustration from the manual:

The bottom one enables users set/reset for diagnosis, which I didn't find in my dial setting.
Another thing I noticed, on the bottom picture, wires go in the setting panel, which I didn't see any attached to my dial setting (on the top).
Comment: I notice that your dial is a Lennox brand. Quite possibly you are trying to trouble shoot using the wrong manual trying to refer to the Aprilaire brand. I suppose it may be that you really do have an Aprilaire unit and some previous occupant tried to change the setting control -- if that is the case you would have no basis to guess that this setup ever worked at all.
Comment: It also looks like your Lennox brand control is from the 70s or 80s based on the design style, while the Aprilaire looks to be from this century. Nothing inherently wrong with an older one, but it does look old.
Comment: The two controls are different.  The top one is calibrated in absolute %humidity, while the bottom is supposed to be coupled with a temperature sensor (outside) to allow it to raise and lower humidity with temperature (to avoid condensation in cold weather).
Answer: How to know if the humidifier is working?
1) Buy a cheap hygrometer and see if it tracks your humidistat setting? You can get one for less than $10 on Amazon.
2) Check: is there water-flow into the humidifier?
I would have to assume that the wiring for your humidistat is inside the duct. You can probably snap the cover off and see wiring on the base plate and where the wires are routed from. I would be curious to know how well these work once you resolve the issue(s).
Answer: Don't be alarmed that the controls look different. The Aprilaire 600 is a simple device and could be controlled by a variety of humidistats. Aprilaire sells that unit with and without their own control, and apparently the optional control they offer changes over the years.
Perhaps the easiest test is to set the humidistat to an unreasonably high level and leave a moisture indicator, ie some kind of paper, in the pan in the humidifier. If the paper is still dry after a several hours or days you'll know the humidifier hasn't operated.


asp.net 5, exclude .js files for typescript files

Question: Is there a way to prevent the generated .js-files from being added to the solution when adding / saving a typescript file? I'm using Visual Studio 2015 CTP6 and ASP.NET 5.
-Thanks!
Answer: There is but it will prevent typescript files from being compiled on save.
Add the following to your .kproj file:
<PropertyGroup>
    <TypeScriptCompileOnSaveEnabled>False</TypeScriptCompileOnSaveEnabled>
</PropertyGroup>

You can use grunt to produce js files from your ts since ts files will no longer be compiled on save.
Add grunt-ts to your package.json file
"grunt-ts": "^3.0.0"

Your gruntfile.js might look something like this:
ts: {
        dev: {
            src: ['app/src/ts/**/*.ts'],
            outDir: 'ts-bin',
            options: {
                fast: 'never',
                sourceRoot: 'js/app',
                verbose: true}
        }
    },

Documentation for grunt-ts is here: https://www.npmjs.com/package/grunt-ts
One last tip: In VS2015, you can specify a grunt task that will trigger after builds using either the Task Runner Explorer in the GUI or by editing your project.json to include something like this:
"scripts": {
    "postrestore": [ "npm install" ],
    "prepare": [ "grunt bower:install" ],
    "postbuild": [ "grunt default" ]
}

Now your TS files will be compiled into JS on every build.


Do Sigils of the Night stack?

Question: If I put a Superior Sigil of the Night on both my main hand weapon and my offhand weapon, will they stack to +20% damage?
The other two static damage bonus sigils, Sigil of Force and Sigil of Accuracy, do not stack. The Sigil page on the official wiki says that

Static bonuses stack with themselves when used on dual-wielded weapons, except for Superior Sigil of Force (only +5% bonus to damage) and Superior Sigil of Accuracy (only +5% bonus to crit chance).

But, Sigil of the Night is only available in PvE and was introduced after launch (in the 2012 Halloween event), which leads me to believe that it simply wasn't tested when the above statement was made.
Answer: As you already pointed out in your question on the official guild wars 2 wiki the answer is: "Yes, they do stack"
The important quote about this is:
<code>Static bonus sigils

    Static bonuses stack with themselves when used on dual-wielded weapons, except for Superior Sigil of Force (only +5% bonus to damage) and Superior Sigil of Accuracy (only +5% bonus to crit chance).
</code>
I've taken this information from here.
I also checked several translations of this wiki, but couldn't find a more detailed explanation there. I then did a lot of internet research (and found your question posted on several other sites :-) ), as well as people claiming they would stack and people they do not (For example, here is some discussion about the stacking of the sigil of the night and people claim it doesn't work, although we don't know if they are right).
To maybe get a more clear view on the different point of views in this discussion (since it doesn't seem like we can find the information through pure google research) I did a small experiment on my own guild wars 2 account. I bought 4 daggers (each was the same "Carrion Glyphic Handblade") and added a Minor Sigil of the Night (+5% damage) on two of them.
I then went outside to a night area (also checked if it's night) and attacked some ogre supplies (on which you can't do conditions), always changing from the two daggers with no sigil at all and the two daggers with the (hopefully) + 10% damage.
In general the result looked like this:
Two same daggers without sigil:

The same daggers as above but with the minor sigil of the night:

So I mostly did around 83 damage on the first attack without sigil and around 91 damage with sigil on. Doing some simple math (10% of 83 is 8.3) this means that I did 10% more damage with the two weapons with the sigil of the night (each adding +5% damage).
So what to learn from this? It appears that using two sigil of the night stack on each other, although it can of course always have other random reasons for damage increasement. So my answer would be that they stack (and after my just done experiment I personally would use two sigil of the night), but I can't guarantee for it. Maybe also asking on the official guild wars 2 forum will make the facts even more clear for you?
I hope I could help you somehow :-)
Comment: Testing on the Ogre Supplies was a good idea. The Redit posts that you linked are all contradicting each other, but most of them seem to think that no damage +% sigils will stack, even if they're different types. I wonder why there's so much contradictory information. Your testing seems solid though. Thanks.
Comment: +1 for empirical testing above subjective "google research". I don't know whether your answer is correct, but until someone comes with a vastly better approach to testing this, I think the +1 is well deserved.

Do Sigils of the Night stack?


creating a form that is present in header of site rails

Question: I have a form in which users can subscribe to a mailing list. I want this form to

be present on every page
to be submitted via ajax

I am currently struggling on the first part. I found this useful stackoverflow question here. However I stil have the same error as before
undefined method `mailing_lists_path' for #<#<Class:0x000001066599b8>:0x000001066589a0>

I dont see why I need a path just to get the form to appear on the page.
_header.html.erb

Join our Mailing List

        <%= form_for MailingList.new, html: { remote: true } do |f| %>
            <%= f.text_field :email %>
        <% end %>

routes.rb
get '/about', to: 'static_pages#about'
  get '/location', to: 'static_pages#location'
  get '/support', to: 'static_pages#support'
  post '/support', to: 'static_pages#create'
  get '/admin_index', to: 'guides#admin_index'

  resources :news
  resources :yearly_guides
  resources :guides
  resources :courses
  resources :galleries do
    resources :exhibition_images
  end

EDIT: with my current understanding, I don't see how a route is completely necesarry in just getting to the form to show. I realise submitting it would require further implementation in my controllers, but just to get it to show, i dont see why.
Comment: You need a route because Rails translates `form_for MailingList.new` into a html form tag with wants to post to mailing_lists_path. If you do not want this Rails magic, do not use Rails but build the html form by yourself.
Comment: @spickermann can you point me to anything that might help?
Comment: The Rails Guides are always a good starting point: http://guides.rubyonrails.org/form_helpers.html
Comment: http://www.railstutorial.org/book
Answer: The form_for helper expects an url, which you can specify manually if the path rails assumes by default is incorrect:
<%= form_for MailingList.new, url: '/sign_up', html: { remote: true } do |f| %>
  <%= f.text_field :email %>
<% end %>

If you really want a form without an url, just write out the tag manually
<form>
  <%= text_field_tag :email %>
</form>

Comment: Thanks @Sharagoz.
this works now, and is sumbitted via ajax.


Refinish or replace an old staircase

Question: I have a staircase from which I ripped up the old carpet. I'm trying to figure out how to refinish, seems I have four options:

Refacing with a veneer tread cover and riser. This was my original plan but will involve a lot of precision cutting to make it work, especially on the turn.
ripping out existing treads and risers and replacing with pine lumber. The existing treads seem to be pine 2 x10's. I would then stain the pine. Not sure if this is a good idea.
sand down existing stairs and paint or stain, maybe carpet down the middle. There are about a thousand nail holes to fill but this would not involve any cutting.
carpet. These are basement stairs so I'd rather not do this
Comment: Why not carpet?  Get some industrial stuff that's synthetic (so no worrying about damp mold) and be done with it.
Comment: Another option is sheet vinyl with anti-slip edges on the front of each tread.  There are some fairly grippy textured vinyls and it's quite easy to lay (and hard wearing, washable etc.)
Answer: Sand and Paint
Veneer or replace treads - that's a lot of work.
Carpet - relatively easy - but you said you don't want that.
Don't try to sand and stain - the level of sanding will be much more than for painting and I suspect in the end you will find so much old paint that staining won't work well.
Which leaves Sand and Paint as the best option.
No matter what you do, if the stairs are older than 1978 then test for lead paint or just assume that there is lead paint and take appropriate precautions.
Comment: +1, don't even think of staining after sanding. Getting a decent uniform stain can easily require sanding 1-2 mm of wood off. That's really hard to do well in place (especially in the corners), so you'd have to take the treads off first (and at that point you can as well just replace them).
Comment: Personally I would do a light sanding just to smooth them out (ie, not sand down to the wood) and then repaint them.  Sanding back to the wood would be a lot of work, and very fiddly around all the internal corners.

Refinish or replace an old staircase


Cython's prange not improving performance

Question: I'm trying to improve the performance of some metric computations with Cython's prange. Here are my codes:
def shausdorff(float64_t[:,::1] XA not None, float64_t[:,:,::1] XB not None):
    cdef:
        Py_ssize_t i
        Py_ssize_t n  = XB.shape[2]
        float64_t[::1] hdist = np.zeros(n)

    #arrangement to fix contiguity
    XB = np.asanyarray([np.ascontiguousarray(XB[:,:,i]) for i in range(n)])

    for i in range(n):
        hdist[i] = _hausdorff(XA, XB[i])
    return hdist

def phausdorff(float64_t[:,::1] XA not None, float64_t[:,:,::1] XB not None):
    cdef:
        Py_ssize_t i
        Py_ssize_t n  = XB.shape[2]
        float64_t[::1] hdist = np.zeros(n)

    #arrangement to fix contiguity (EDITED)
    cdef float64_t[:,:,::1] XC = np.asanyarray([np.ascontiguousarray(XB[:,:,i]) for i in range(n)])

    with nogil, parallel(num_threads=4):
        for i in prange(n, schedule='static', chunksize=1):
            hdist[i] = _hausdorff(XA, XC[i])
    return hdist

Basically, in each iteration the hausdorff metric is computed between XA and each XB[i]. Here is the signature of the _hausdorff function:
cdef inline float64_t _hausdorff(float64_t[:,::1] XA, float64_t[:,::1] XB) nogil:
    ...

my problem is that both the sequential shausdorff and the parallel phausdorff have the same timings. Furthermore, it seems that phausdorff is not creating any thread at all.
So my question is what is wrong with my code, and how can I fix it to get threading working.
Here is my setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
from Cython.Distutils import build_ext

ext_modules=[
    Extension("custom_metric",
              ["custom_metric.pyx"],
              libraries=["m"],
              extra_compile_args = ["-O3", "-ffast-math", "-march=native", "-fopenmp" ],
              extra_link_args=['-fopenmp']
              )
]

setup(
  name = "custom_metric",
  cmdclass = {"build_ext": build_ext},
  ext_modules = ext_modules
)

EDIT 1: Here is a link to the html generated by cython -a: custom_metric.html
EDIT 2: Here is an example on how to call the corresponding functions (you need to compile the Cython file first)
import custom_metric as cm
import numpy as np

XA = np.random.random((9000, 210))
XB = np.random.random((1000, 210, 9))

#timing 'parallel' version
%timeit cm.phausdorff(XA, XB)

#timing sequential version
%timeit cm.shausdorff(XA, XB)

Comment: Could be that `XB` is a Python object? Run `cython -a custom_metric.pyx` with annotation.
Comment: @mavillan, can you provide a small example on how to call `shausdorff` and `phausdorff` ?
Comment: @mavillan Are you using OSX? Since the information I can see on the internet suggests that the version of clang they supply doesn't support OpenMP. See http://stackoverflow.com/questions/33668323/clang-omp-in-xcode-under-el-capitan possibly, but I'm not using OSX myself so can't confirm...
Comment: Have you considered using a greater `chunk_size`?  Depending on the algorithm you can have a very poor data locality using a `chunk_size` of `1`.
Comment: Have you tried printing the equivalent to `omp_get_thread_num()` within the loop-body of the `prange`. See http://cython.readthedocs.io/en/latest/src/userguide/parallelism.html
Comment: Is there any change if `phausdorff` is decorated with `@cython.boundscheck(False)` and `@cython.wraparound(False)`?
Comment: @cgohlke I have changed that, explicity defining it as a memory view and theres is no change. @J.J. Hakala the macros `#cython: boundscheck=False` and `#cython: wraparound=False` are included at the beginning of the file.
Comment: @Harald when I try to run that, Cython says: `Converting to Python object not allowed without gil`
Comment: @DavidW no, I'm using Ubuntu 16.04 with Anaconda environment.
Comment: @Harald I've added an example on how to use the functions.
Answer: I think this the parallelization is working, but the extra overhead of the parallelization is eating up the time it would have saved. If I try with different sized arrays then I do begin to see a speed up in the parallel version
XA = np.random.random((900, 2100))
XB = np.random.random((100, 2100, 90))

Here the parallel version takes ~2/3 of the time of the serial version for me, which certainly isn't the 1/4 you'd expect, but does at least show some benefit.

One improvement I can offer is to replace the code that fixes contiguity:
XB = np.asanyarray([np.ascontiguousarray(XB[:,:,i]) for i in range(n)])

with
XB = np.ascontiguousarray(np.transpose(XB,[2,0,1]))

This speeds up both the parallel and non-parallel functions fairly significantly (a factor of 2 with the arrays you originally gave). It does make it slightly more obvious that you're being slowed down by overhead in the prange - the serial version is actually faster for the arrays in your example.
Comment: (Posted as community wiki since this doesn't present a solution so I wanted to remove it from contention for the bounty)


Do I need a plywood base to install granite countertops?

Question: I will have the following run of cabinets (which will be screwed together and to the back wall) and will install a 20mm (3/4") thick granite countertop over it (with sink and cooktop range).

I've seem people saying that a plywood backer is important, and some other people saying that it is more trouble than it is worth and the cabinets provide enought support as it its. The maximum space between to cabinet walls is about 90cm (3 ft).
Comment: There was good discussion on this topic on this thread yesterday: http://diy.stackexchange.com/questions/107687/will-a-1-thick-granite-countertop-span-22-inches -- though like you mentioned, people seem to be of both opinions.
Answer: The answer to this seems pretty clear when you consider one thing: It takes a substantial amount of force to bend granite, but it only needs to move a few micrometers* to break.
Now you just ask yourself whether a layer of plywood will prevent that miniscule movement. No, it won't. Physics has no interest in the opinion of the masses.
So, you might use a plywood substrate to help replicate a thicker top, or to reinforce poorly-built cabinets, or to help maintain position by adhering the stone to it, or for other practical reasons, but you don't do it to support, stiffen, or strengthen the stone. That would take something much more substantial and rigid, such as the vertical hardwood cabinet rails that typically exist at the front and rear of a cabinet.
* Or a few dozen, or a few hundred. The result is the same.
Comment: Almost *any* cabinet has a rail above the door or drawer. I'm not sure where the confusion lies.
Comment: Sorry, I wasn't thinking of that type of cabinet. My experience is almost exclusive to custom cabinetry with [full overlay faceframes](http://www.barkerdoor.com/v/vspfiles/assets/images/cabinet%20with%20face%20fram%20only%20in%20paint%20grade.jpg).
Comment: What are the hardwood cabinet rails you mentioned? The faceframe?
Comment: Yes. Vertical 1x3 or so.
Comment: Hum? I'm not following. Do you have a link for a cabinet carcass that has the rail you are talking about?
Comment: But in all plywood carcasses those are also plywood usually. My confusion was the due to "vertical hardwood" rails. Those are horizontal and not always hardwood. :)
In my drawing you can see the rails, but the are horizontal and plywood like the rest of the carcass.
Answer: It is normal to glue on stone worktops.
If you don't have a plywood backer (Or MDF etc) then the stone worktop is directly glued onto the cabinets and it is very hard to remove cabinets if you ever need to.
The other practical issue is it is normal to order the stone worktop once the cabinets are installed so a template can be made for cutting the stone.   The plywood backer allows the kitchen to be used before the stone worktop arrives.
Comment: Mine ( 36" X  68") is not glued and has just sat there for 25 years ; I planned to glue it but never got around to it. It is one inch thick so thinner than most, no backer , just the standard cabinet framework.


Charging Irrigation System, Can I Do This Myself?

Question: Every spring some company comes out and "charges" our sprinkler system. Can someone explain what this is and whether or not this is something I can do?
It basically seems like they come out, turn on the water to the system, run each zone, and check if all the heads are operational.
What am I missing?
Comment: One of the counties in my area requires you to use licensed service people to inspect and service sprinkler systems -- I believe the main concern is the back-flow prevention.  You may have a similar setup in your area.
Answer: Does someone come out and "close" your sprinkler system for the winter?  I don't know much about lawn sprinkler systems, but "charging" sounds similar to opening a swimming pool.  Every fall, I drain all the water out of the lines for the pool and plug them so the water doesn't freeze and crack the lines.  In the spring, I then remove the plugs and prime the pump to get water back in the lines.  I would expect a similar procedure for a sprinkler system in a climate where freezing is a probability.
Answer:
is something I can do?

This is absolutely something that you can do!
You will want to find he first / main valve box.  It's usually the largest one and often rectangular.  It's usually adjacent to your house, or to your water meter.
Open the cover, and identify all blowout valves.  They are often quarter-turn ball valves.  There are four brass blow out valves in this example with little black caps on their connections to keep dirt and bugs out:

Check that each of the blow out valves are solidly closed.  It not, close it.  You may need a straight blade screw driver.
Then, open the larger flow shut-off valves of which there are two in the picture above.  The handle should be parallel with the pipe when it's open for every such valve I've come across.  You should hear a brief 'whoosh' of water when you do this, and if you'll stay dry if all of your blow out valves are closed.
Then go to the controller and run each zone one at a time and look at the heads to confirm they're working properly.  Adjust the heads if you want (though you could do that any time of year).  If any are broken, flag them and call your sprinkler guy to fix (or head to his supply warehouse and buy the parts to do so yourself).
Charging someone to 'turn on' their sprinkler system in the spring is the biggest scam in the book.  In my part of the country there's no annual requirement to check backflow on residential, and sprinkler companies don't anyway.  I've helped out neighbors by turning their on, and It doesn't take me 3 minutes, in the dark.
Charging someone to 'turn off' their system is likewise also a huge rip-off, unless they're also going to thoroughly blow the system out to prevent freezing damage in applicable climates.  Even then if you don't watch them do it they can easily do a partial job to save time, so I have never paid someone to blow my system out.
Biggest advantage to paying for sprinkler 'winterization' I can think of is there's an implied responsibility if they do it wrong and your system is damaged, but good luck proving it if they want to argue about it.
Also you need a very good (high flow rate) compressor to blow your system out, or to rent one made for that purpose.


What is the result of $\infty - 1$?

Question: I was wondering after reading "What is the result of infinity minus infinity", is there any logical result for $\infty - 1$ ?
Comment: Without context it's technically ill-defined, but I think it'll be $\infty$ no matter which way you slice it.
Comment: @The Chaz: Use [Markdown](http://daringfireball.net/projects/markdown/basics): write `[link to Wikipedia](http://en.wikipedia.org)` to get a [link to Wikipedia](http://en.wikipedia.org). Right under the "add comment" button there's a help link containing the very basics of Markdown and [a link here](http://math.stackexchange.com/editing-help#comment-formatting) for further info.
Comment: The logical result is $\infty$. Take for example the sequence $n$, then $\lim n=\infty$. Now $\lim (n-1)=\infty$, too, hence $\infty-1=\infty$. This is one possible explanation.
Comment: See http://en.wikipedia.org/wiki/Extended_real_number_line#Arithmetic_operations (and could someone please teach me how to embed links better?!?)
Comment: Thanks, @com ! I'm on the mobile site, but will inform myself next time there's a computer available :)
Comment: @anon then can I challenge you to slice it so that it doesn't come out to $\infty$?
Answer: Most usually, the answer will be "it doesn't make sense to write that down". The operation of subtraction is something defined only for certain classes of numbers. The class you are probably most familiar with are the Real numbers (denoted by $\mathbb{R}$), which you can think of intuitively as numbers that you can point to on a number line. These include things like $2.5$, $\pi$, and $\sqrt{2}$, but it does not include $\infty$. Since subtraction is defined for these numbers only, to then ask "What is $\infty - 1$ ?" is like asking "What is Cat - 1 ?".
In more advanced mathematics (for example, in Measure theory) we do allow $\infty$ to denote a certain object that can interact with the Real numbers. In those situations, it usually follows your intuition and $\infty - 1$ is defined to be $\infty$ again. Another example of when mathematicians consider the idea of "$\infty - 1$" is in introductory calculus, when one first learns about limits. In that case however, the usage of the symbol $\infty$ is purely short hand notational- it doesn't actually denote any type of number. If a function $f$ becomes arbitrarily large as $n$ becomes large, we may write $\displaystyle\lim_{n\to\infty} f(n) = \infty$ and then for shorthand a teacher may write on the board $$\displaystyle\lim_{n\to\infty} f(n)-1 = \infty - 1 = \infty $$ but strictly that equation is invalid. So indeed, the idea does come up in valid forms, but what you should take away from this post is mainly contained in the first paragraph.
Comment: For me personally, Cat - 1 is often well defined.  I invariably used a Cat symbol to represent a constant (instead of, say, `c`) on physics and math tests in college.
Comment: Ah, "Cat - 1" explained it.
Answer: In the real number system there is no item "$\infty$".  Nor is there in the complex number system.  There are some other number systems that DO have such an item.  One is called the "Riemann sphere" ... consisting of the complex numbers with an extra point $\infty$.  Legitimate caluclations defined on the Riemann sphere do, indeed, include the equation $\infty - 1 = \infty$.
Answer: In layman's terms, infinity is something which you cannot count. Take out $1$ from it and you still cannot count it, so the result is infinity.
Comment: This answer just adds to the confusion of the question author. See the answer by @RagibZaman to see a good answer.

What is the result of $\infty - 1$?


$f:U \rightarrow \mathbb{C} $ is continuous on $U$ if and only if {$z \in U| f(z)\in V$} is open for every open set V in $\mathbb{C}$

Question: I want to prove that if $f:U \rightarrow \mathbb{C}  $ is continuous on $U$ if and only if {$z \in U| f(z)\in V$} is open for every open set V in $\mathbb{C}$. This is my rather incomplete approach to solve this and I hope I get some assistance on this.
 $f^{-1}(V)=${$z \in U| f(z)\in V$}. Let $z\in f^{-1}(V)$. Then $f(z)\in V$. Also f is continuous at the point z. Let $\epsilon >0$. Then there exists a $\delta>0$ such that if $$ 0<|w-z|<\delta\implies |f(w)-f(z)|<\epsilon$$.
$$\implies f(w)\in D_{\epsilon}(f(z))$$.
This also can be written as $f(D_{\delta}(z)\subseteq D_{\epsilon}(f(z))$
 I am totally stuck here and need some help. Thanks
Comment: Since $V$ is open, you can choose an $\epsilon > 0$ such that $D_\epsilon(f(z)) \subset V$.
Comment: $V$ is open so the $\epsilon$ can be chosen with $D_{\epsilon}(f(z)\subset V$. Then proved is that $f(D_{\delta}(z))\subset V$.
Comment: Your opening sentence says "if" and then later "if and only if", which makes a bad sentence. Do you need to prove one direction or both?
Comment: sorry that by mistake the first "if" should not be there. ya I need to prove both sides @MarcvanLeeuwen
Answer: Suppose that f is continuous, you need to prove that for any open set $V$ in $\mathbb{C}$, $f^{-1}(V)$ is also an open set for the first implication.
So you can take $V$ an arbitrary open set in $\mathbb{C}$ and $y \in V$ such that $f^{-1}(y)$ it exists, and then prove that $f^{-1}(y)$ is an interior point. Notice that if $f^{-1}(y)$ does not exist for every $y \in V$ then it's inverse is empty, which is an open set and the result holds. Let's call $x=f^{-1}(y)$ (that is, one of its inverse images, since the function not necessarily is injective, it can have more than 1), so $f(x)=y$
Since $V$ is open you can find $\epsilon >0$ such that $D_{\epsilon}(f(x))\subset V$. For that $\epsilon$ you use the definition of a continuous function you said before and with that you found a $D_{\delta}(x) \subset f^{-1}(V)$, and this proves that x is an interior point, and since it was arbitrary,  $f^{-1}(V)=\{z \in U|f(z) \in V\} $ is an open set.
For the other implication, suppose that $f^{-1}(V)=\{z∈U|f(z)∈V\}$ is open for every open set $V$ in $\mathbb{C}$. Take $y\in \mathbb{C}$ such that there exist $x$ such that $f(x)=y$ (once again, if we don't have such $x$ the result is trivial). For $\epsilon >0$ the disk $D_{\epsilon}(f(x))$ is an open set in $\mathbb{C}$, therefore, $f^{-1}(D_{\epsilon}(f(x)))$ is also an open set, so for $x \in f^{-1}(D_{\epsilon}(f(x))) $ there exists $\delta >0$ such that $D_\delta (x) \subset f^{-1}(D_{\epsilon}(f(x)))$, this means that $f(D_\delta (x))\subset D_{\epsilon}(f(x)) $, which means that for every $w,z\in U$, if $0<|w−z|<δ$ then $|f(w)−f(z)|<ϵ$, in other words, f is continuous.
Answer: Take a $z$ in $f^{-1}(V)$. As $V$ is open in $\mathbb{C}$ and $f(z) \in V$, Choose $\epsilon > 0$ so that $D_{\epsilon} (f(z)) \subset V$.
Now by your argument you have a $\delta >0$, so that $f(D_{\delta} (z)) \subset V$ i.e. $D_{\delta} (z) \subset f^{-1}(V)$.
Hence $z$ is an interior point of $f^{-1}(V)$. As $z$ is arbitrary, $f^{-1}(V)$ is open.


Kotlin not waiting for a coroutine to finish?

Question: I'm learning coroutines and am a little confused by something
import kotlinx.coroutines.*

@OptIn(DelicateCoroutinesApi::class)
fun main() {
    println("[${Thread.currentThread().name}] In main thread")

    GlobalScope.launch {
        println("[${Thread.currentThread().name}] In coroutine")
        repeat(4) {
            println("$it")
        }
    }
}

When I run this code, the output is a little unpredictable, sometimes I get output from the couroutines, sometimes I don't..

could someone please explain what is causing this? Thank you!
Answer: I believe there are a few options, but the heart of the matter is the main thread believes your program is done, so it ends the program.  You need to wait for the coroutine to complete. Try the below block.  It waits for the coroutine to complete before proceeding:
val job = GlobalScope.launch {
    println("[${Thread.currentThread().name}] In coroutine")
    repeat(4) {
        println("$it")
    }
}

job.join()

more info can be found here, https://kotlinlang.org/docs/coroutines-basics.html#an-explicit-job


Rocket League PC offline multiplayer?

Question: Is there any mode of playing Rocket League offline Multiplayer in PC like in PS4? If there is, how can it be done? With a mod or an specific game version?
Answer: There was a LAN mode added for PC in the autumn update (September 2017):
https://www.rocketleague.com/news/autumn-update-local-matches-director-mode/
Answer: There is no way. You can only play online multiplayer on PC. You can play against AI, and that's as much offline as it gets.

Rocket League PC offline multiplayer?


Can a broken microwave leak radiation?

Question: Can a microwave malfunction and start leaking radiation? And is there any way to tell?
What happens if you're in the same room or standing next to it?
Comment: If it's not damaged, there's no reason to think it would be leaking. Old age does not make it any more prone to leak. If it were damaged, junk it and buy a new one makes sense - if it's not damaged, use it until it dies.
Comment: In what way is the microwave "broken"? Is there damage to the door or the mating sealing surface? Does the door close and seat fully?
Comment: Non detectable. Old age
Answer: If the metal grid in the door is intact and the outer metal case it should be fine, one way I have seen used was to clip the leads off a neon lamp if the lamp flashes it is getting hit by microwave radiation. Or to buy a detector.  Depending on the amount of energy being released it can be a simple warming effect to burning, the eyes would be at the biggest risk of damage since they are the closest to water and are very delicate. If you have concerns it would be safer to not use it, but if the grid and case are undamaged there is no way for the energy to escape. Microwaves run at approx 2.4Ghz the length of a single wave would be under 6" and the height or amplitude is based on the power level.
Answer: Simply wave a fluorescent tube around the micro when on, any leaks will illuminate the tube. Of course, if you find something, get it replaced ASAP. The radiation is not the cancer-causing ionizing radiation, but it can easily damage the blood vessels in your eyes and cause other minor burns.
EDIT: I should mention that skin burns, even minor ones, raise your lifetime risk of skin cancer.
Answer: I agree with Ed and he is right 100%. However, microwave energy can be dangerous and nothing to take chances with.  If you have any real concerns, please either have it tested by a professional or replace it.  On the side of replacing it,  understand that the magneutron tube, over time, looses efficiency and requires more electricity to produce the same amount of heating energy. P.

Can a broken microwave leak radiation?


How to fields to the User model

Question: I want to be able to save a picture to a user and maybe even a description, these can be optional, but how to you add to a model. I don't want to go into the souce code of django to change it, can I overide a model to add fields, if so how?
how do i access these accounts.UserProfile and accounts.UserProfile.image in my views.py file
I have django-registration installed
Comment: See http://stackoverflow.com/questions/12535157/how-to-fields-to-the-user-model -- you *can* add fields directly to the database table, but it's not recommended. The Django way is to create a profile model, as the answers below explain.
Answer: From the docs:
If you'd like to store additional information related to your users, Django provides a method to specify a site-specific related model -- termed a "user profile" -- for this purpose.
To make use of this feature, define a model with fields for the additional information you'd like to store, or additional methods you'd like to have available, and also add a OneToOneField named user from your model to the User model. This will ensure only one instance of your model can be created for each User. For example:
from django.contrib.auth.models import User

class UserProfile(models.Model):
    # This field is required.
    user = models.OneToOneField(User)

    # Other fields here
    accepted_eula = models.BooleanField()
    favorite_animal = models.CharField(max_length=20, default="Dragons.")

To indicate that this model is the user profile model for a given site, fill in the setting AUTH_PROFILE_MODULE with a string consisting of the following items, separated by a dot:

The name of the application (case sensitive) in which the user profile model is defined (in other words, the name which was passed to manage.py startapp to create the application).

The name of the model (not case sensitive) class.

For example, if the profile model was a class named UserProfile and was defined inside an application named accounts, the appropriate setting would be:
AUTH_PROFILE_MODULE = 'accounts.UserProfile'

Comment: one more question what whould my view look like to access 'accounts.UserProfile.image and description

How to fields to the User model


Client - server integration testing: mock or not?

Question: I'm working on project with two applications: android app (client) and rest service (server). My android app consumes my rest service.
Both applications are tested separately to ensure they're doing their business as expected.
During server tests I prepare requests and check server responses.
During client tests I set up a simple http mock server and test client's requests against different mocked responses.
Now, this technique works pretty well. It gives me a flexibility I like. I can use different test frameworks and continuous integration environments. But there is one weak point. In both (client and server) test cases I specify the same api. I assume that e.g.
<code>GET /foo-list.json
</code>
will return HTTP 200 with json
<code>[{
    id: 1,
    name: foo1,
}, {
    id: 2,
    name: foo2
}]
</code>
So I repeat myself. If I change a response format my client tests won't fail.
My question is about good practices in testing this kind of scenario. How to make true integration tests without sacrificing flexibility of independent tests. Should I test client with mocked server or with a real instance of my rest service?
Please share your professional experience.
Answer: In your scenario you should continue to write unit tests to test individual classes, and integration tests to test the inter-operation between multiple application layers (e.g. business and database layers).
You ask:

"How to make true integration tests without sacrificing flexibility of independent tests"

All of your code should should use abstractions, so that you can use dependency injection to unit test classes in complete isolation using mock dependencies. The use of mocks will ensure that these tests will remain independent i.e. not coupled to any other classes. Hence taking this approach, the integration tests, which would use your final concrete classes, would not affect the unit tests which use the mocked classes.
Also:

"Should I test client with mocked server or with a real instance of my rest service?"

In addition to unit and integration tests you should also perform client-server integration testing; I use automated acceptance testing for doing this. Using a test framework such as Cucumber (also check out calabash-android, which is written specifically to test mobile applications) you can write tests which would test specific features and scenarios which would interact with both the client (your Android application) and server (your RESTful service). These client-server integration tests would start-up and stop concrete instances of the client and server.
Answer: Mocks are for unit testing. Your description of the tests with the mocks describes exactly that. You test the client and server as separate units.
Integration testing tests if the units work well together. Since the interface is a REST interface, mocking makes no sense then, you have to test the real thing over HTTP.
See also What is the difference between integration and unit tests?
Comment: @haroldolivieri you can spin up a test instance for the duration of the test
Comment: So you recommend to test a client with a real instance of rest service. Correct?
Comment: Correct! For integration tests, hook the units up as they will be in production.
Comment: What if my real instance is down and I depend on this to have a green build on my CI pipeline? What are the possible workarounds for this downside?
Answer: If your service is based in Java, I'd strongly recommend looking into the Spock framework, for mocking any sort of calls that might be coming from the client.  Since Spock is just an extension of jUnit, you might also be able to use it for Android (though, to be fair I've never done Android development)
I'd say you want to do two things.  Integration testing and Unit testing.  Integration testing would attempt to bring up the android application and cause it to make service calls, ensuring the contexts interact with each other kindly.
However, in your regular commits, I'd suggest unit testing that mocks away everything but the class under test.  Spock makes this pretty easy to do, and since it's built on top of jUnit all it takes a jar.
Comment: Well, the purpose of integration testing would be to test across boundaries, in some cases.  In our environment, I'd be likely to do something like using the test version of the service for integration testing to make this work.  You might also be able to get something like a standalone test server running as part of your integration testing context.  Short answer - yes, to do integration testing I would recommend finding a way to get the app to make service calls, instead of mocking them away.
Comment: Let me know if you want me to elaborate - I realize this might be a little bit too generic of an answer for you.
Comment: You're right about necessity of both integration and unit testing. My question is about *integration* testing. When I test the integration of client with service, should I mock the service or should I run a real instance of the service?
Answer: There is no reason you can't run automated end to end tests with a real service instance. You can run a real service instance on the same test machine you are using to run the unit tests, perhaps in the same container. You can set up configuration to use a different URL for the server instance for running automated end to end testing.
Why would you want to do the extra work of creating the mock service if you can run them against the real service?
I would only create a mock service, if the service was an external service over which I had no control!


Where can I find computer readable RGB values for brand name paints?

Question: Where can I find computer readable RGB values, or equivalents, for brand name paints such as Benjamin Moore, Sherwin Williams, and Behr paints?
[Edit] My interest was not so much about the specific color model of RGB, I basically needed some kind of quantitative description of available paint colors of big name brands. If RGB is not scientifically appropriate, whatever quantitative description is OK.
Comment: Under what kind of lighting?  Even if you find two paints from different brands with the exact same RGB under one kind of light, they could be different from each other under another kind of light.  This is because there's a whole spectrum to consider, and RGB is just a perspective.
Comment: I ran across http://www.perbang.dk/rgb some time ago; it might be useful.
Comment: We'd need more info to really be able to understand the intent of the question. What do you mean 'quantifiable description'? Are you just looking for a count?
Comment: Locking since this is asking for an external resource that would be off topic for the site today.
Answer: If your looking for the RGB equivalent of a paint swatch, your probably better off looking at Pantone colors.
http://en.wikipedia.org/wiki/Pantone
You can buy Pantone swatches (I think their pretty expensive though) and then use Photoshop or something to find the equivalent RGB value.
If you go into Photoshop and click on the Color Picker in the toolbar, theres a Color Libraries button that'll show you a great many Pantone colors. Click the one that matches the printed swatch and when you go back to the color picker, you'll see the RGB value.
As wikipedia says, Pantone is pretty much an industry standard, used in painting, printing, etc...
I'm sure you can in turn give a Sherwin Williams or whoever and Pantone color code and have them mix paint for you (if thats what you want).
If you want to take photos of the room you want to paint, photoshop it with the color you want from a swatch, some of the websites (we used sherwin williams) have tools to do that also, but won't produce Pantone or RGB values :(
-Mario
Answer: You can't.  RGB is sufficient to describe the colors to be put out by a monitor, but it is not sufficient to describe the reflectivity of a surface.
Comment: Monitors are additive (rgb), Pigments are subtractive (CMYK, Spot)
Answer: Found this site while looking for the RGB values of an Olympic paint. Regardless of all the free guesses given above, for Sherwin Williams you can find the RGB values easily. Here are most if not all of them. https://www.sherwin-williams.com/wcm/idc/groups/public/@swpublic/@sherwin-williams/@content/documents/webcontent/mdaw/mdaz/~edisp/sw-pdf-sherwin-williams-color.pdf
I know it was an old question, hope this helps the next person wandering by.
Answer:
I basically needed some kind of quantitative description of available paint colors of big name brands

Well, we need more info. Are you asking for the 'number of colors offered'? If so, then just call them up.
As for RGB values, RGB is a way to measure projected light--NOT reflected light. RGB is for screens (which create colors via mixing Red, Green and Blue projected light).
Paint is reflected colors. And is much different color space. The range of projected RGB colors overlaps the range of reflective colors, but they don't exactly match. In other words, there are colors that can be rendered via RGB that can't via paint and vice versa.
Pantone, as mentioned, is a good way to 'match' colors with a very particular description, but note that Pantone is typically a print color standard...for printing inks on paper. And their numbers pertain to mixing pantone brand pigments--which a paint company may or may not be using.
You can certainly take a pantone swatch to a paint store, and they can optically match it, of course.
Comment: Then i can relax my request to "CMYK values of brand name paints".  Where to get a list of such values?
Comment: Well, again, paints don't use CMYK either. You can try matching CMYK colors to commercial paint colors, but just like RGB, there will be overlap, but you won't be able to reproduce all paint colors as CMYK colors. It'd be great to understand your end goal a bit better. It might help us formulate the answer for you.
Comment: End goal is to have list of computer readable color values of all paints.
Comment: What do you mean 'computer readable'? For what purpose? Are you trying to display paint colors on a screen?
Comment: At least for displaying colors on screen.
Comment: I see. Well, one thought is to contact the paint manufacturers directly. Most of them have web sites and/or apps and such so they may very well have already attempted at finding the closest RGB value to match their particular paint colors. Do note, however, that they can never truly match--not only because of projected vs. reflected light physics, but also the simple fact that no two monitors have the same color and contrast settings.
Comment: Actually...the answer from Anon may be exactly what you need. Looks like a web site that has already compiled this information.
Answer: Paint colors. You can indeed check the reflective value of a paint--the higher the Light Reflectance Value (LRV%) the lighter the paint, thus it reflects greater light value. RGB colors for many commercial brands and their named paints may be identified at www.encycolorpedia.com Very helpful in judging color from a computer screen. You'll also find the hex color code, and paint undertones--undertone knowledge is crucial. Staff at paint counters will not be able to ID if the paint has green, or pink undertones, for example--these undertones are difficult to work with. They mix formula RGB, CYK percentages. Note the Benjamin Moore stores may have a staff Colorist to help further--BM paints are excellent interior paint--easy application, steadfast colors, easy to spot clean.


How to catch an event when the control is covered by another control?

Question: I have small problem here, at the application runtime, I move a bit a Control over my Panel (with own Paint method). The problem is, how to catch that event, to make my Panel repaint?
EDIT:
but, I can't find the event name which will be raised when a Control covers my Panel, that's all about
I thought it's Panel.Leave but I was wrong
Comment: Please add some more details. The paint event should normally cover this w/o any extra effort.
Answer: You have to catch the event of the control, and then write code to repaint the panel (if I am understanding your question correctly).
Answer: You can also call the Panel's Invalidate() method to cause it to redraw at the end of your painting routine.


Vue: Filter returns an array, how to get the first element

Question: Lets say I have a custom filter cf.js that needs to return multiple values in an array like this:
export default (value) => {
 var a = 5
 var b = 3

 return [a, b]
}

In my vue file, how can I display only the first element? I thought something like below would work but they do not
{{ myvar | cf[0] }} or {{ (myvar | cf)[0] }}

Answer: You're limited by the filter syntax in the Vue template, so what you tried won't work.
A filter doesn't make sense in the example you've given since it doesn't make use of the argument.
But anyway, to answer your question, two options come to mind:
1. Define another filter to get the first element
{{ myvar | cf | first }}

export default function first(value) {
  return value[0]
}

2. Call the filter function manually
This will allow you to do what you want with the filter result since you're just calling it as if it were any other function.
{{ $options.filters.cf(myvar)[0] }}

Comment: I knew the first one, I was looking for the 2nd one.


Is it still possible to play AOE2: The Age of Kings over a LAN?

Question: My friend and I still have copies of Age of Empires: Age of Kings and we have installed it both our laptops.
Is it still playable over LAN?
Comment: I don't see why not... have you tried it? If so and it doesn't work, what happens?
Answer: I played the old version of AOE II with expansion for a long time over lan, including Windows 10. The only problems I ever had starting the game (ranging from Windows XP to Windows 10) was administrative rights for the network tool AOE II uses and fire wall blockage for which you just have to say 'Allow' and be done with it.
Make sure everybody has version 1.0c and maybe check compatibility mode.
To be honest, I have more problems with the steam version than the old version for multiplayer. The old version loads multiplayer save games nicely, but I never got that working for the steam version. I also have more problems with network stability when playing on steam compared to the old version.
Answer: If you mean the old Windows 9x game, then... kind-of....
It uses an older style of LAN networking that is not used these days (I think it is IPX), and you would have difficulty installing and setting up the computers to use it. The setup required for it was picky, and I mean on Windows XP -- back when you could still easily install it! (EDIT: "easily" meaning the drivers, not the extra steps to take)
If you have Linux installed somewhere (or a modern-ish Mac) and have the Windows 9x CD of the game... I don't know how well it will work with PlayOnLinux (free) -- (PlayOnMac for Mac users, also free)
Age of Empires 2: The Conquerors ONLY:

There was a custom 1.0e patcher for AoE2:TC made by a group (that could switch between that version and 1.0c), but I have no idea where it is located, and since what that 1.0e can do (allowing no CD in the drive), I cannot recommend it, and especially not link to a download... ... who knows if there even still exists a download to that patcher which isn't malware!

Alternate solution (chosen by the asker when offered): Buying the Steam remake which they found on sale.
Comment: That means no? Right?
Comment: Depends on if you can find valid IPX drivers for your OS... yet there may exist a wrapper for IPX over TCP/IP
Comment: ... or is it over UDP? (dang phone sent reply before I could finish typing)
Comment: I don't understand what's that ipx whatever thing. Anyway thanks, I think we will satisfy our things on AOE3 but will miss aoe2. See if there's any other way thanks!
Comment: IPX is an old networking protocol. It is pretty much the format of how the data crosses the wire... http actually uses TCP (TCP and UDP are pretty much standard these days).
Comment: Umm ok anyway we Gonna play aoe3 lan so hope some one know about aoe2 thanks
Comment: If you two have Steam, getting AoE2 that way may be better to play it.... although I can look up that one free game similar to it, but it is slightly different.
Comment: AOE2 HD edition umm I'll think about it, its on sale too. The free game umm don't know but if it is very similar to aoe2 then go ahead and tell me!
Comment: I found it... I think... Also, not reading enough, I don't know if it is Linux-only or not (requires both base game & expansion for 9x version, or HD version on Steam) https://github.com/SFTtech/openage
Comment: So ... actually.... same thing with remade engine (and like I said, I don't know if Linux-only or not)
Comment: Its Linux only ouch
Comment: And required AoE2:TC, which you never stated you had.
Comment: Nope I have only age of kings
Comment: But the HD version... Fun Fact: they actually had to remake the graphics from scratch since they didn't have the original models they based the pixels off of in the 9x version.... and.... HD!
Comment: All add that the Steam version is an alternative to my answer (if I can now). Thank you for accepting it. :)
Answer: download gameranger and then you can play both aoe and aoe2 easily online.


Returning Errors in Web API

Question: I'm developing a brand new REST API using ASP.NET Web API. Coming from a WCF background, I feel drawn to creating "error contracts" for my API.
In this case, I'm not talking about unhandled exceptions being returned to the client. Instead, I'm focusing on errors such as the API being used improperly by the client - especially those where the client can automatically create these errors and resubmit the requests.
Most examples I've found just have a string being returned, usually by throwing an HttpResponseException, or at least doing some stuff to make the process of building up an informative error string more automated: Return custom error objects in Web API
I'm thinking about instead creating an HttpResponseException, passing in an HttpResponseMessage whose content is set to my specific error contract type.
My API is also making heavy use of automatic model validation, though, and those model validation errors come back as a totally different structure.
So should I force my "errors" into the same format as the model validation responses? What are the best practices here?
Lastly, my API will expose formatting options of json, xml, and protocol buffers. As a result, I really need to make sure that my strategy is formatter-independent.
Answer: I wrote this blog post a while back about how Web API does error handling:
http://blogs.msdn.com/b/youssefm/archive/2012/06/28/error-handling-in-asp-net-webapi.aspx
It should help answer your questions. Essentially, you have two options:

Define your own class for error responses. In this case, you want to ensure your class can be serialized as XML, JSON, etc. Then you can use Request.CreateResponse(statusCode, myErrorInstance) to send back your custom errors. You probably also want a way to turn invalid model states into your particular error type.
Use Web API's error response type: HttpError. HttpError is essentially a Dictionary<string, object> where you add your own keys and values to the HttpError. The advantages are many - your errors will look like Web API errors, you know it works with all formatters, and you can avoid the work of having to define transformations from exceptions and invalid model states. The easiest way to use HttpError is calling Request.CreateErrorResponse().
Comment: can you provide any more info on HttpError & the best way to return it? Is it still the standard way to return errors - I can find little about it - thx. It also doesn't appear to work with IHttpActionResult.
Comment: Link is broken.
Answer: You can do anything you want in these situations.  The best experience for the consumer of your web api would be to make sure that you use friendly error messages, in which case you'll want to serialize your errors into well formatted json objects.  The following blog post provides some use cases and a solution that I have come up with: Web Api, HttpError and the Behavior of Exceptions

Returning Errors in Web API


Upgrade fail 12.04 to 14.04

Question: I made a horrible mistake and upgraded from 12.04 (dual boot Win7) to 14.04 DIRECTLY, and it failed and I am left with a scrambled screen which does not respond to anything.
Any way I can recover my system?
Comment: Create backup first, in every attempt to do crucial thing to system. And just do reinstall, don't do upgrade if you want to change your Ubuntu version. This is my suggestion for you.
Answer: Open Terminal(Ctrl+ALt+T) and write the following command,
sudo update-manager -d

Press Enter enter your user password when it asks you.
Things to Note
If you're following this guide on April 17, 2014 then be aware that the whole process could take some time. Ubuntu 14.04 has only just been released and you won't be the only person upgrading, so be prepared for the upgrade to take longer than usual to complete.
Also, while an LTS-to-LTS upgrade should preserve all your files it would be prudent to make a backup of any important documents, folders and photos before you begin. It's rare for 'direct upgrades' to go wrong, but never say never.
Source Link.

Upgrade fail 12.04 to 14.04


PHP/FORM problem

Question: I'm new to programming so please bear with me...I'm using MySQL/PHP to create an application where part of it allows users to select a location and room from two drop down menus.  There are three tables, room, location and room_location.  I have created forms that allow user to add a room to room table and a form to allow them to add a location to location table - these both work fine as the input is just a text field and the user can submit any text they like.  My problem is with the third form/table (dropdown_form.php)- this table has three fields, id | room_name | location_name.
What I am trying to achieve with the room_location table is this:
The user will get a webpage that has a dropdown menu for selecting a location_name (which is derived from the location table) and another dropdown menu for selecting the room_name (which is derived from the room table). After selecting from both dropdowns the user will submit this combination of room and location and a new entry will be added to the room_location table in the database.
example of room_location table
ID  |  location_name  | room_name
1   |  Hospital1      | room1
2   |  Hospital1      | room2
3   |  Hospital1      | room3
4   |  Hospital2      | room1
5   |  Hospital2      | room2
etc
So far I've got the form for this to display both of the dropdown menus but when I select and submit I get an error saying "Error: Duplicate entry '' for key 'PRIMARY' " I included some echo statements for testing purposes to see what is happening, I'm now getting:
Location and Room name entered was
Array ( [select_location] => [select_room] => )
Error: Duplicate entry '' for key 'PRIMARY'
(duplicate entry appears to be NULL? so don't think anything is actually being passed to process.php)
It appears that there is something wrong (I think) with the selects that are supposed to be passing the data to process.php which is handling the $_POST statements.  I've included a copy of my code, any help at all with this would be greatly appreciated.
dropdown_form.php

    <title>Testing Dropdown form</title>

<?php
        //make connection to the database
        mysql_connect ("localhost", "root", "password") or die ('Database connection ERROR: ' . mysql_error());
        mysql_select_db ("my_database");
?>

<fieldset style="width:30%" align="center"><legend>Add New Location/Room Combination</legend>

         Location Name:

         Room Name:

        <form name="room_location_form" action="process.php" method="post">
        <select name="select_location">

        <?php
        //create and run a query that selects all the locations to create an options list
        $loc_query = "SELECT location_name FROM location ORDER BY location_name";
        $loc_result = mysql_query($loc_query);

        while ($row = mysql_fetch_array($loc_result, MYSQL_ASSOC))
        {
        echo "<option value=$row[id]>$row[location_name]</option>";
        }
        ?>
        </select>

        <?php
        //create and run a query that selects all the rooms to create an options list
        $room_query = "SELECT room_name FROM room_name ORDER BY room_name";
        $room_result = mysql_query($room_query);
        ?>

        <select name="select_room">

        <?php
            while ($row = mysql_fetch_array($room_result, MYSQL_ASSOC))
            {
            echo "<option value=$row[id]>$row[room_name]</option>";
            }
        ?>
        </select>

        <input type="submit" value="Add Location/Room">

</form>

</fieldset>

        Location Name
        Room Name

<?php

//build query to display a list of all current locations and rooms
 $query = mysql_query("select * from room_location ORDER BY location_name, room_name");

  //return the array and loop through each row
  while ($row = mysql_fetch_array($query)) {
  $location_name = $row['location_name'];
  $room_name = $row['room_name'];

 ?>

        <?php echo $location_name;?>
        <?php echo $room_name;?>

<?php }  //this ends the loop
?>

process.php
<?php
//make connection
$conn = mysql_connect ("localhost", "root", "password");
if (!$conn)
    {
    die ('Database connection ERROR: ' . mysql_error());
    }
$db = mysql_select_db ("my_database");

//Add new Location and Room Name combination - sent from form
$sql="INSERT INTO room_location (location_name, room_name) VALUES (('$_POST[select_location]'), ('$_POST[select_room]'))";
    echo "Location and Room name entered was ", $_POST['select_location'], " & ", $_POST['select_room'];
?>

<?php
print_r($_POST);  //added for testing purposes to see what is being POSTed
?>

<?php
if (!mysql_query($sql,$conn))
    {
    die ('Error: ' . mysql_error());
    }
    echo "Location and Room name entered was ", $_POST['select_location'], " & ", $_POST['select_room'];

mysql_close($conn)
 ?>

***UPDATES MADE AS SUGGESTED**
Thanks for the suggestions so far, I;ve made some progess thanks to you all. Using code below I now get select_location outputting as location_id and select_room outputting as room_name_id instead of the location_name and room_name - any ideas what I'm doing wrong guys?
dropdown_form.php
    <?php
    //make connection to the database
            mysql_connect ("localhost", "root", "password") or die ('Database connection ERROR: ' . mysql_error());
            mysql_select_db ("my_database");
    ?>

    <fieldset style="width:30%" align="center"><legend>Add New Location/Room Combination</legend>

             Location Name:

             Room Name:

            <form name="room_location_form" action="process.php" method="post">
            <select name="select_location">

            <?php
            //create and run a query that selects all the locations to create an options list
            $loc_query = "SELECT location_id,location_name FROM location ORDER BY location_name";
            $loc_result = mysql_query($loc_query);

            while ($row = mysql_fetch_array($loc_result, MYSQL_ASSOC))
            {
            echo "<option value=\"".$row['location_id']."\">".$row['location_name']."</option>\n";
            }
            ?>
            </select>

            <?php
            //create and run a query that selects all the rooms to create an options list
            $room_query = "SELECT room_name_id,room_name FROM room_name ORDER BY room_name";
            $room_result = mysql_query($room_query);
            ?>

            <select name="select_room">

            <?php
                while ($row = mysql_fetch_array($room_result, MYSQL_ASSOC))
                {
                echo "<option value=\"".$row['room_name_id']."\">".$row['room_name']."</option>\n";
                        }
            ?>
            </select>

            <input type="submit" value="Add Location/Room">

    </form>

    </fieldset>

            Location Name
            Room Name

    <?php

    //build query to display a list of all current locations and rooms
     $query = mysql_query("select * from room_location ORDER BY location_name, room_name");

      //return the array and loop through each row
      while ($row = mysql_fetch_array($query)) {
      $location_name = $row['location_name'];
      $room_name = $row['room_name'];

     ?>

            <?php echo $location_name;?>
            <?php echo $room_name;?>

    <?php }  //this ends the loop
    ?>

process.php
    <?php
    //make connection
    $conn = mysql_connect ("localhost", "root", "password");
    if (!$conn)
        {
        die ('Database connection ERROR: ' . mysql_error());
        }
    $db = mysql_select_db ("my_database");

        //Add new Location and Room Name combination - sent from form
        $sql="INSERT INTO room_location (location_name, room_name) VALUES (('".$_POST['select_location']."'), ('".$_POST['select_room']."'))";

    ?>

    <?php
    print_r($_POST);  //added for testing purposes to see what is being POSTed
    ?>

    <?php
    if (!mysql_query($sql,$conn))
        {
        die ('Error: ' . mysql_error());
        }
    echo "Location and Room name entered was ", [$_POST['select_location']], " & ", $_POST['select_room'];

    mysql_close($conn)
     ?>

Answer: besides what others have said,
in dropdown_form.php on your SELECTS, to get the dropdowns your not retrieving an id for the id value in the form.
SELECT location_name FROM location ORDER BY location
make it
SELECT id,location_name FROM location ORDER BY location desc

then you can access it like:
echo "<option value=\"".$row['id']."\">".$row['location_name']."</option>\n";

notice i also formatted it correctly
do the same with the second select...
On inserting the new row into the database make sure that the id is the primary key and auto increments.
the query:
$sql='INSERT INTO room_location (`id`,`location_name`, `room_name`) VALUES ("","'.mysql_real_escape_string($_POST['select_location']).'", "'.mysql_real_escape_string($_POST['select_room']).'")';

Comment: Thank you all for your help so far.
You were absolutely correct that the main issue was I wasn't SELECTing any id values, I've added that but unfortunately the query didn't work it threw a sytax error on that line - using a combination of your SELECT statement and @Lamoni Lamonis query I am now able to get a bit further, I get a value returned for select_room and select_location but it is its id number rather than the name which is what I need (insert statement fails since it needs the name not the id) - hope this makes sense.  I'll post my full updated code again as a seperate comment.
Answer: Just making note because I'm assuming you removed the sanitizing for quick purposes on this post, but make sure you are sanitizing your $_POST variables against SQL Injection.
With that said, try replacing your query with this:
$sql="INSERT INTO room_location (location_name, room_name) VALUES (('".$_POST['select_location']."'), ('".$_POST['select_room']."'))";

EDIT:
Seems I am a bit late on this, as Blender has already noted it.
Answer: Try setting auto increment to your id field in database
Comment: Hi, yes the location_room_id is auto increment and is the primary key.
Answer: Finally cracked this myself...not the most elegant solution but it works :D Thanks for the pointers.
*UPDATE to process.php ***
<?php
    //This section retrieves the room name selected on dropdown_form.php page
    $room_id = $_POST['select_room']; //temp variable to hold room_name_id
    $query = mysql_query("SELECT room_name FROM room_name WHERE room_name_id = $room_id");
      while ($row = mysql_fetch_array($query))
      {
       $room_name = $row['room_name'];
      }

    //This section retrieves the location name selected on add_room_location_form.php page
    $location_id = $_POST['select_location']; //temp variable to hold location_name_id
    $query = mysql_query("SELECT location_name FROM location WHERE location_id = $location_id");
      while ($row = mysql_fetch_array($query))
      {
      $location_name = $row['location_name'];
          }

    //Insert room & location data held in $location_name & $room_name into room_location table
    $sql="INSERT INTO room_location (location_name, room_name) VALUES (('$location_name'), ('$room_name'))";
    echo "Location and Room name entered was ", $location_name, " & ", $room_name;

    //I tried using this INSERT below but it inserts the array indexes instead of elements to location_name, room_name.
    //$sql="INSERT INTO room_location (location_name, room_name) VALUES (('".$_POST['select_location']."'), ('".$_POST['select_room']."'))";
?>

PHP/FORM problem


What year did Skyrim begin?

Question: I am currently in the year 4E 202 the 26th of some month?  What was the beginning year, and how much "game time" has passed?
Answer: The game of Skyrim starts on Sundas, the 17th of Last Seed, 4E201, at approximately 9:30.

If you don't know what Morndas or Last Seed are, I suggest you look at the answer to this question.
Comment: It's only Morndas because [it was Morndas on your other save](http://www.uesp.net/wiki/Skyrim:Unbound#Notes).  For a brand-new game, it will be Sundas.
Answer: Skyrim starts at 4E 201, 200 years after the Third Era ended along with the Septim bloodline.
If you're playing on PC, you can type help gamedayspassed in the console to see how much time has passed in-game.
Comment: @desaivv The games do not determine the era, no. Consider that Oblivion was the fourth Elder Scrolls game, yet it was set in the *third* era! Rather, the game world has its own history, with numerous events well outside the scope of any game (e.g. the 200 years that have passed since Oblivion), and even events during the games happening elsewhere in the world. http://uesp.net/wiki/Lore:History
Comment: Yeah, @desaivv, the death(?) of Martin marked the end of the Third Era.
Answer: Skyrim starts at 7.10 am, on the 17th of Last Seed (the 8th month out of 12) on a Sundas (equivalent to Sunday).
Comment: This directly contradicts the other answers on both the time and the day of the week. Considering the other answers are supported by references, this answer appears to be wrong.

What year did Skyrim begin?


CakePHP v2 model local variables

Question: I'm working on moving to CakePHP v2 from v1.3.
In my old 1.3 model I had some local variables which a loadData() function set, and then I could retrieve using a get function.
In v2 I get:
<code>Indirect modification of overloaded property [...] has no effect
</code>
I've searched but it isn't related to the data/request->data changes.
Any ideas on how to set these local variables?
Thanks in advance!
Comment: you should post the relevant code here, as wel. also, which 2.x version you are using.
Comment: it should be "public $acntarr = array()"
Comment: You should post the code of `loadData()` here
Comment: Edit your question instead of posting code into comments!
Comment: You're right, my bad.

After the model properties (hasOne etc), I've got:
  var $acntarr = array();

And in the one function I:
  $this->acntarr[$ww]['global']['total'] = $rescnt;
Comment: Thanks for the effort, but it still gives the:
Indirect modification of overloaded property ::$acntarr has no effect

Should I change the way I access it in the function?
Comment: It's just a simple find(...) and I load the data into some local arrays, there are a few more similar functions that populate these arrays and I wanted to be able to migrate the whole model over and still use these "local" variables.
Comment: "Indirect modification of overloaded property **>what's this<** has no effect" where's the code where you manipulate **>what's this<** - your question is missing all info to help you.
Answer: Are you sure you updated any code that you are trying to assign values to the $this->data array
to $this->request->data ?
You can no longer assign manually $this->data['newthing']['here'] any more in 2.0
It must be $this->request->data['newthing']['here'] or unset $this->request->data['currentthing']['here'] etc etc
https://groups.google.com/forum/?fromgroups=#!topic/cake-php/Sa-2m95CezM
Like the others said, however, some code would be nice if you have the time.  Thanks.

CakePHP v2 model local variables


Eror libraries fpdf

Question: I have an error fpdf
A PHP Error was encountered
Severity: Warning
Message: include_once(/home/u7639860/public_html/application/third_party/Fpdf/Pdf.php): failed to open stream: No such file or directory
Filename: libraries/Pdf.php
Line Number: 7
Backtrace:
File: /home/u7639860/public_html/application/libraries/Pdf.php
Line: 7
Function: _error_handler
File: /home/u7639860/public_html/application/libraries/Pdf.php
Line: 7
Function: include_once
File: /home/u7639860/public_html/application/controllers/Tb_permohonan.php
Line: 15
Function: library
File: /home/u7639860/public_html/index.php
Line: 316
Function: require_once
this my libraries
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Pdf {

    public function __construct() {

        include_once APPPATH.'third_party/Fpdf/Pdf.php';

        $pdf = new FPDF();
        $pdf->AddPage();

        $CI =& get_instance();
        $CI->Pdf = $pdf;

    }

}

?>

help me..
Answer: it's very simple because you only need to call one of the libraries

$this->load->library('Pdf');

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Pdf {

    public function __construct() {

        // include_once APPPATH.'third_party/Fpdf/Pdf.php';

        $pdf = new FPDF();
        $pdf->AddPage();

        $CI =& get_instance();
        $CI->Pdf = $pdf;

    }

}

?>

Function include_once is deleted, it's run

Eror libraries fpdf


How to execute different sass files based on a css class?

Question: I am wondering how can I can include a different sass file (theme) based on a certain class?
Now we got 3 apps which all have an unique css class for its styling (.app1 {.background-color: red;})
Now i want to include sass framework and seperate all the css/sass per app label. In order to achieve this we define a base.scss. In this scss we want to reach this:
if .app1 then execute app1.scss
else if .app2 then execute app2.scss
else if .app3 then executr app3.scss
else empty
Anyone an idea?
Comment: Not sure if this will answer your question so I'll put this as a comment. I'm not sure how your app has been architected but the only way that I can think of that you can conditionally load items is to use something like Webpack, which would enable you to load certain features for certain files.
Comment: Since Sass is precompiled, it won't be possible to dynamically choose which CSS it will output based on the HTML that the browser is seeing. Or, another way to say it: by the time you're looking at which `.app` class is on your page, Sass will have been compiled to CSS & linked on your page a long time ago.

If your goal is to limit file size by including only what's necessary, a JavaScript solution could look at your HTML contents & dynamically include CSS. But if you're not concerned with file size, you can actually import Sass files *within* a Sass class (like `.app`).
Comment: You can use if statements in SASS to choose between themes. This might help you get started. https://www.youtube.com/watch?v=AaVxSc11t3Y
Answer: Use a namespace and apply it as a class to the root element. Wrap SASS statements in the appropriate namespaces. You can separate them into different files (partials) and combine them when they get compiled.
// in file _app1.scss
.app1 {
    // rules you want applied in the "app1" case
}

// in file _app2.scss
.app2 {
    // rules you want applied in the "app2" case
}

...

If you separate files into _app1.scss, _app2.scss, etc. then base.scss will include:
@import 'app1';
@import 'app2';
...

This combines the partial files into one when you compile. (You don't have to separate them, but it might be cleaner to do so.) Then, you do something like ... to use the app1 namespace, and only rules from _app1.scss will apply.


all possible permutations of "aabcd"

Question: Is it the correct solution to the problem: in how many ways can we permute the string "aabcd" such that every permutation is only 5 characters long and only the set of ${a,b,c,d}$ characters can be used (each character has to be used). So "aabdc", "abbcd" are valid permutations. My solution is the following:
$$4*\binom{5}{2}*3!$$
because we can place the duplicate character in the string in $\binom{5}{2}$ ways and then we just need to permute the remaining 3 characters. Lastly, there're 4 possible duplicate characters.
Comment: There is a contradiction in your problem statement. Either you count the permutations of $aabcd$ ($60$ of them), either you count the combinations of $5$ characters drawn from $abcd$ with repetitions allowed. Please disambiguate.
Comment: Is $aaaaa$ valid ? This is $5$ characters long, with characters from $abcd$ only.
Comment: no, I edited the question to clarify
Comment: I'm not sure to understand. Is the string you want to permute "aabcd"? If so, the duplicate character is a, and there are no other possible duplicate character. Otherwise, you're good.
Comment: The letters of the string "aabcd". In other words you have two a's to work with, and only one of each of b, c, d, e
Comment: any character out of a,b,c,d can be duplicate.
Comment: @amWhy But the OP said that "abbcd" is a valid permutation. I'm not sure I understand the question either.
Comment: So you want to count 5 letter strings made of $a,b,c,d$ with no restrictions?
Comment: I believe your logic is sound.
Comment: You're right in the sense that it's not strictly a permutation but I believe I explained the additional requirement in the question as well as gave examples. If you have suggestions on how to rephrase the question let me know.
Answer: The number of ways to arrange 5 elements, two of which are identical is $\frac{5!}{2!}$. For example there are $60$ arrangements of $aabcd$.  Then there are 4 different characters that can be the repeated character. So I believe the answer is $4*\frac{5!}{2!}=240$, which is the same answer you got using your method.
Comment: you're right, it's simpler to solve it the way you described. Thank you!
Answer: In response to the title question (as originally posted):
$$\text{ All possible permutations of "aabcd"}$$
This is an example in which multinomials will work.
$$\binom{5}{2,1,1,1} = \frac {5!}{2!1!1!1!}=\frac {5!}{2!} =\frac{120}2 = 60$$
You have a total of five letters to work with, in which the there are 2 of one letter, and only 1 of the remaining three letters available.
This strategy works well, for example, determining the number of different string  existing, for example, when permuting the letters of **MISSISSIPPI"
EDIT AFTER OP's edit:
There is a contradiction in the OP's problem statement. I answered the question in the title, when in fact the OP is not counting permutations.
If allowed to duplicate any one of a, b, c, d, to construct a string of five letters, with each of a, b, c, d must appear, then, since there are four distinct letters that could be duplicated, we simply multiply our previous answer by $4$ to get $$60\times 4 = 240$$ possible 5-letter strings, given these additional constraints.
Comment: I think you are mistaking the question which is actually asking for the number of permutations of the string. "aabcd".  That gives you two a's to work with, and only single letters B,C,D.
Comment: @turkeyhundt  Thanks for noticing and letting me know! :-)
Answer: There are $120$ distinct permutations of $abcde$. You can replace $e$ by any of $a',b',c',d'$, giving $480$ substitutes. Then drop the quote, resulting in every configuration represented twice. There are $240$ unique ones.

Alternatively, you can scramble $aabcd$ in $5!$ ways, but each is repeated twice, hence $60$ distinct permutations. Same with $abbcd,abccd$ and $abcdd$.

all possible permutations of "aabcd"


How to check if object property exists with a variable holding the property name?

Question: I am checking for the existence of an object property with a variable holding the property name in question.
var myObj;
myObj.prop = "exists";
var myProp = "p"+"r"+"o"+"p";

if(myObj.myProp){
    alert("yes, i have that property");
};

This is undefined because it's looking for myObj.myProp but I want it to check for myObj.prop
Comment: is https://stackoverflow.com/questions/4244896/dynamically-access-object-property-using-variable a duplicate of this question? how is that? 'checking existence' and 'accessing value' are different things? Please correct me if I am wrong ....
Comment: Possibly useful: From a comment by Pablo Cabrera at [NCZOnline](http://www.nczonline.net/blog/2010/07/27/determining-if-an-object-property-exists/): "I think it's worth to note that if the `hasOwnProperty` method is overwritten, you can rely on the `Object.prototype.hasOwnProperty.call(object, property)`."
Comment: this is not a duplicate.
Comment: @HumanInDisguise comments should not be used to provide resolving advice.  Your comment would have been better placed as an answer which contains static quoted advice and a link to its source.  Now that @ adnan2d has posted this advice, your comment can be safely deleted.
Answer: var myProp = 'prop';
if(myObj.hasOwnProperty(myProp)){
    alert("yes, i have that property");
}

Or
var myProp = 'prop';
if(myProp in myObj){
    alert("yes, i have that property");
}

Or
if('prop' in myObj){
    alert("yes, i have that property");
}

Note that hasOwnProperty doesn't check for inherited properties, whereas in does.  For example 'constructor' in myObj is true, but myObj.hasOwnProperty('constructor') is not.
Comment: `hasOwnProperty()` is better then `myObj[myProp]` (from other answers) as it works even if the value of `myProp` is 0
Comment: The "in" operator does not work with strings. e.g. 'length' in 'qqq' will produce an exception. So if you want a general purpose check you need to use hasOwnProperty.
Comment: To avoid breaking eslint `no-prototype-builtins` rule you should use `Object.prototype.hasOwnProperty.call(myObj, myProp)` instead of `myObj.hasOwnProperty(myProp)`
Comment: @Jacob what do you mean when you say 'The "in" operator does not work with strings'? with "in"' operator the left expression must be a string or value that can converts into a string. Yes, you cannot write 'length' in 'qqq' but you cannot write 'qqq'.hasOwnProperty('length') either
Comment: @Wachburn: `'qqq'.hasOwnProperty('length')` is `true`, you can do that.
Comment: @gaurav5430 I believe what I am referring to is that if `myProp` is 0, the if statement would look like `if (myObj[0])` which if `myObj` has any properties at all, the expresssion would evaluate to `true`. And `myObj[0]` may not be the property you are looking for.
Comment: @MattR what do you mean by "it works even if the value of myProp is 0" ?
Comment: @RocketHazmat while you *can* indeed do 'qqq'.hasOwn... that does not check if the object qqq has anything. It checks that the anonymous string with value "qqq" has that property, which seems useless since you know at compile time if that is true or not so why would you check that at runtime? I mean you're technically correct but... not sure it holds as an argument against using `in` unless I'm missing something here.
Comment: @AnorZaken I think it refers to when you pass a variable whose value is a string. For example `var s = 'foo'; if ('prop' in s) {} /* vs */ if (s.hasOwnProperty('prop')) {}`, the first will throw an error but the second will check correctly.
Answer: You can use hasOwnProperty, but based on the reference you need quotes when using this method:
if (myObj.hasOwnProperty('myProp')) {
    // do something
}

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
Another way is to use in operator, but you need quotes here as well:
if ('myProp' in myObj) {
    // do something
}

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in
Comment: This is incorrect. By putting quotes around the name myProp, you are no longer referencing the value of myProp, rather you are declaring a new String() of 'myProp' and there is no such property of 'myProp' in myObj.
Comment: That is [**not**](http://jsfiddle.net/s8eegdry/1) how `hasOwnProperty()` is implemented.
Comment: TriumpST: from MDN linked above, "prop - A string or symbol representing a property name or array index (non-symbols will be coerced to strings)."
Comment: 'hasOwnProperty' is not equivalent to using the 'in' operator, as Rocket Hazmat's answer explains.
Comment: This is correct. If you don't want to use a variable, but just if a specific 'myProp' is present, you need the quotes.
Comment: @KatinkaHesselink: Your comment is misleading. The question was "How to check if object property exists with a variable holding the property name?"
Comment: just used in in Chrome 80 with double quotes, worked for me. :/
Answer: Thank you for everyone's assistance and pushing to get rid of the eval statement.
Variables needed to be in brackets, not dot notation. This works and is clean, proper code.
Each of these are variables: appChoice, underI, underObstr.
if(typeof tData.tonicdata[appChoice][underI][underObstr] !== "undefined"){
    //enter code here
}

Comment: Despite your intentions with your initial post, you actually asked a different question than the one for which you provided this answer. You wanted to check the existence of a property, you don't mention anything about how to access it. Which makes this answer unrelated to the actual question.
Comment: This looks like a problem to me. If `tData.tonicdata[appChoice]` results in a value that doesn't have a property/index that matches `underI`, then this will result in an `TypeError` being thrown.
Answer: For own property :
var loan = { amount: 150 };
if(Object.prototype.hasOwnProperty.call(loan, "amount"))
{
   //will execute
}

Note: using Object.prototype.hasOwnProperty is better than loan.hasOwnProperty(..), in case a custom hasOwnProperty is defined in the prototype chain (which is not the case here), like
var foo = {
      hasOwnProperty: function() {
        return false;
      },
      bar: 'Here be dragons'
    };

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty
To include inherited properties in the finding use the in operator: (but you must place an object at the right side of 'in', primitive values will throw error, e.g.  'length' in 'home' will throw error, but 'length' in new String('home') won't)
const yoshi = { skulk: true };
const hattori = { sneak: true };
const kuma = { creep: true };
if ("skulk" in yoshi)
    console.log("Yoshi can skulk");

if (!("sneak" in yoshi))
    console.log("Yoshi cannot sneak");

if (!("creep" in yoshi))
    console.log("Yoshi cannot creep");

Object.setPrototypeOf(yoshi, hattori);

if ("sneak" in yoshi)
    console.log("Yoshi can now sneak");
if (!("creep" in hattori))
    console.log("Hattori cannot creep");

Object.setPrototypeOf(hattori, kuma);

if ("creep" in hattori)
    console.log("Hattori can now creep");
if ("creep" in yoshi)
    console.log("Yoshi can also creep");

// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in
Note: One may be tempted to use typeof and [ ] property accessor as the following code which doesn't work always ...
var loan = { amount: 150 };

loan.installment = undefined;

if("installment" in loan) // correct
{
    // will execute
}

if(typeof loan["installment"] !== "undefined") // incorrect
{
    // will not execute
}

Answer: A much more secure way to check if property exists on the object is to use empty object or object prototype to call hasOwnProperty()
var foo = {
  hasOwnProperty: function() {
    return false;
  },
  bar: 'Here be dragons'
};

foo.hasOwnProperty('bar'); // always returns false

// Use another Object's hasOwnProperty and call it with 'this' set to foo
({}).hasOwnProperty.call(foo, 'bar'); // true

// It's also possible to use the hasOwnProperty property from the Object
// prototype for this purpose
Object.prototype.hasOwnProperty.call(foo, 'bar'); // true

Reference from MDN Web Docs - Object.prototype.hasOwnProperty()
Comment: If you are incorporating JavaScript that might do something evil like override `hasOwnProperty`, no amount of guards like this will make your code safe or secure.
Comment: @meustrus I know where you coming from, but from business perspective it is highly possible to receive that an inexperienced developer would use this property name, which not necessarily mean their are doing something evil intentionally.
Answer: there are much simpler solutions and I don't see any answer to your actual question:

"it's looking for myObj.myProp but I want it to check for myObj.prop"

to obtain a property value from a variable, use bracket notation.
to test that property for truthy values, use optional
chaining
to return a boolean, use double-not / bang-bang / (!!)
use the in operator if you are certain you have an object and only want to check for the existence of the property (true even if prop value is undefined).  or perhaps combine with nullish coalescing operator ?? to avoid errors being thrown.

var nothing = undefined;
var obj = {prop:"hello world"}
var myProp = "prop";

consolelog( 1,()=> obj.myProp); // obj does not have a "myProp"
consolelog( 2,()=> obj[myProp]); // brackets works
consolelog( 3,()=> nothing[myProp]); // throws if not an object
consolelog( 4,()=> obj?.[myProp]); // optional chaining very nice ⭐⭐⭐⭐⭐
consolelog( 5,()=> nothing?.[myProp]); // optional chaining avoids throwing
consolelog( 6,()=> nothing?.[nothing]); // even here it is error-safe
consolelog( 7,()=> !!obj?.[myProp]); // double-not yields true
consolelog( 8,()=> !!nothing?.[myProp]); // false because undefined
consolelog( 9,()=> myProp in obj); // in operator works
consolelog(10,()=> myProp in nothing); // throws if not an object
consolelog(11,()=> myProp in (nothing ?? {})); // safe from throwing
consolelog(12,()=> myProp in {prop:undefined}); // true (prop key exists even though its value undefined)

// beware of 'hasOwnProperty' pitfalls
// it can't detect inherited properties and 'hasOwnProperty' is itself inherited
// also comparatively verbose
consolelog(13,()=> obj.hasOwnProperty("hasOwnProperty")); // DANGER: it yields false
consolelog(14,()=> nothing.hasOwnProperty("hasOwnProperty")); // throws when undefined
obj.hasOwnProperty = ()=>true; // someone could overwrite it
consolelog(15,()=> obj.hasOwnProperty(nothing)); // DANGER: the foolish overwrite will now always return true
consolelog(16,()=> Object.prototype.hasOwnProperty.call(obj,"hasOwnProperty")); // explain?!
consolelog(17,()=> Object.hasOwn(obj,"hasOwnProperty")); // explain?!

function consolelog(num,myTest){
    try{
    console.log(num,myTest());
    }
    catch(e){
    console.log(num,'throws',e.message);
    }
}
Answer: You can use hasOwnProperty() as well as in operator.
Comment: All of this ^ is why I hate javascript
Comment: @pwaterz don't hate the [player](https://giphy.com/search/javascript)
Comment: 'hasOwnProperty' is not equivalent to using the 'in' operator, as Rocket Hazmat's answer explains.
Comment: maybe you could try to explain when does using either option don't really matters, but accepted answer is pretty clear
Answer: Using the new Object.hasOwn method is another alternative and it's intention is to replace the Object.hasOwnProperty method.
This static method returns true if the specified object has the indicated property as its own property or false if the property is inherited or does not exist on that object.
Please not that you must check the Browser compatibility table carefully before using this in production since it's still considered an  experimental technology and is not fully supported yet by all browsers (soon to be though)

var myObj = {};
myObj.myProp = "exists";

if (Object.hasOwn(myObj, 'myProp')) {
  alert("yes, i have that property");
}

More about Object.hasOwn - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn
Object.hasOwn browser compatibility - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn#browser_compatibility
Answer: Several ways to check if an object property exists.
const dog = { name: "Spot" }

if (dog.name) console.log("Yay 1"); // Prints.
if (dog.sex) console.log("Yay 2"); // Doesn't print.

if ("name" in dog) console.log("Yay 3"); // Prints.
if ("sex" in dog) console.log("Yay 4"); // Doesn't print.

if (dog.hasOwnProperty("name")) console.log("Yay 5"); // Prints.
if (dog.hasOwnProperty("sex")) console.log("Yay 6"); // Doesn't print, but prints undefined.

Answer: Working for me.
if (typeof receviedData?.d?.heartbeat_interval != "undefined") {
}

Answer: In the answers I didn't see the !! truthiness check.
if (!!myObj.myProp) //Do something

Comment: This is just a double negation pattern. https://stackoverflow.com/questions/10467475/double-negation-in-javascript-what-is-the-purpose
Comment: You didn't see it here because it's wrong. This is not a property-existence check, but a truthiness check.
Comment: Can you please link me to some documentation on this `!!` operator? I have searched google high and low and I cannot find it anywhere, I can only find the `!` operator